Skip to content

Commit

Permalink
add url fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
vvmruder committed Jun 16, 2023
1 parent 22cbfb3 commit d48c657
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setup(
name='geolink2oereb',
version='0.1.8',
version='0.1.9',
description='Transforms a geolink to OeREBKRMtrsfr_V2_0 document entities',
license='BSD',
long_description='{readme}\n\n{changelog}'.format(readme=readme, changelog=changelog),
Expand Down
2 changes: 1 addition & 1 deletion src/geolink2oereb/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.8'
__version__ = '0.1.9'
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes import (
OeREBKRM_V2_0_Dokumente_Dokument,
LocalisationCH_V1_MultilingualText,
Expand All @@ -12,6 +13,16 @@
OeREBKRM_V2_0_MultilingualUri
)

logging.basicConfig(level="DEBUG", format="%(asctime)s [%(levelname)s] %(message)s")


def fix_url(url):
if not url.startswith('http'):
new_url = 'https://{}'.format(url)
logging.info(f"Fixing url from {url} to {new_url}")
return new_url
return url


def multilingual_text_from_dict(multilingual_dict):
if multilingual_dict is None:
Expand All @@ -30,7 +41,7 @@ def multilingual_uri_from_dict(multilingual_dict):
localized_texts = LocalisedTextType86()
for language in multilingual_dict:
localized_texts.OeREBKRM_V2_0_LocalisedUri.append(
OeREBKRM_V2_0_LocalisedUri(language, multilingual_dict[language])
OeREBKRM_V2_0_LocalisedUri(language, fix_url(multilingual_dict[language]))
)
return TextImWebType(OeREBKRM_V2_0_MultilingualUri(localized_texts))

Expand Down

0 comments on commit d48c657

Please sign in to comment.