From d48c6578b36f139c00ac8e580b06910e4312bb89 Mon Sep 17 00:00:00 2001 From: Clemens Rudert Date: Fri, 16 Jun 2023 18:00:31 +0200 Subject: [PATCH] add url fixing --- setup.py | 2 +- src/geolink2oereb/__init__.py | 2 +- .../lib/interfaces/oerebkrmtrsfr/v2_0/generators.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 35c36b0..02cd4ce 100644 --- a/setup.py +++ b/setup.py @@ -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), diff --git a/src/geolink2oereb/__init__.py b/src/geolink2oereb/__init__.py index c3bb296..1c98a23 100644 --- a/src/geolink2oereb/__init__.py +++ b/src/geolink2oereb/__init__.py @@ -1 +1 @@ -__version__ = '0.1.8' +__version__ = '0.1.9' diff --git a/src/geolink2oereb/lib/interfaces/oerebkrmtrsfr/v2_0/generators.py b/src/geolink2oereb/lib/interfaces/oerebkrmtrsfr/v2_0/generators.py index 01d691d..d6134fa 100644 --- a/src/geolink2oereb/lib/interfaces/oerebkrmtrsfr/v2_0/generators.py +++ b/src/geolink2oereb/lib/interfaces/oerebkrmtrsfr/v2_0/generators.py @@ -1,3 +1,4 @@ +import logging from geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes import ( OeREBKRM_V2_0_Dokumente_Dokument, LocalisationCH_V1_MultilingualText, @@ -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: @@ -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))