From 74b0322e4bef8b15e5972085cbe71d81345520eb Mon Sep 17 00:00:00 2001 From: Franz Steinmetz Date: Wed, 21 Oct 2020 10:18:26 +0200 Subject: [PATCH 1/2] fix(util/attr2rdf): split attr_name from right To support prefixes with underscores (e.g. iWGS84_POS), the attr_name must be split at the _last_ underscore. --- surf/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surf/util.py b/surf/util.py index c6b3226..d32a036 100644 --- a/surf/util.py +++ b/surf/util.py @@ -164,7 +164,7 @@ def attr2rdf(attr_name): """ def to_rdf(attr_name): - prefix, predicate = attr_name.split('_', 1) + prefix, predicate = attr_name.rsplit('_', 1) ns = get_namespace_url(prefix) try: return ns[predicate] From 75f5d144ab475944db48e7b6dc23c94b24ffe1cb Mon Sep 17 00:00:00 2001 From: Franz Steinmetz Date: Mon, 12 Apr 2021 12:03:47 +0200 Subject: [PATCH 2/2] fix(util): do not use replace for attr2rdf Replacing "_to" also changes attribute names that contain "_to" as part of their name --- surf/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surf/util.py b/surf/util.py index d32a036..4c0639b 100644 --- a/surf/util.py +++ b/surf/util.py @@ -172,7 +172,7 @@ def to_rdf(attr_name): return None if pattern_inverse.match(attr_name): - return to_rdf(attr_name.replace('is_', '').replace('_of', '')), False + return to_rdf(attr_name[3:-3]), False elif pattern_direct.match(attr_name): return to_rdf(attr_name), True return None, None