Skip to content

Commit

Permalink
Fix missing thesaurus keyword bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vjf committed Jan 3, 2024
1 parent 350dc3b commit 804c45f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 6 additions & 8 deletions owslib/iso_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,28 +465,27 @@ def __init__(self, namespaces, md=None):
val = md.find(util.nspath_eval('mri:type/mri:MD_KeywordTypeCode', self.namespaces))
self.type = util.testXMLAttribute(val, 'codeListValue')

val = md.find(util.nspath_eval('mri:thesaurusName/gco:CharacterString', self.namespaces))
if val is not None:
cit = md.find(util.nspath_eval('mri:thesaurusName/cit:CI_Citation', self.namespaces))
if cit is not None:
self.thesaurus = {}

title = val.find(util.nspath_eval('cit:title/gco:CharacterString', self.namespaces))
title = cit.find(util.nspath_eval('cit:title/gco:CharacterString', self.namespaces))
self.thesaurus['title'] = util.testXMLValue(title)
self.thesaurus['url'] = None

if self.thesaurus['title'] is None: # try gmx:Anchor
t = val.find(util.nspath_eval('cit:title/gcx:Anchor', self.namespaces))
t = cit.find(util.nspath_eval('cit:title/gcx:Anchor', self.namespaces))
if t is not None:
self.thesaurus['title'] = util.testXMLValue(t)
self.thesaurus['url'] = t.attrib.get(util.nspath_eval('xlink:href', self.namespaces))

date_ = val.find(util.nspath_eval('cit:date/cit:CI_Date/cit:date/gco:Date', self.namespaces))
date_ = cit.find(util.nspath_eval('cit:date/cit:CI_Date/cit:date/gco:Date', self.namespaces))
self.thesaurus['date'] = util.testXMLValue(date_)

datetype = val.find(
datetype = cit.find(
util.nspath_eval('cit:date/cit:CI_Date/cit:dateType/cit:CI_DateTypeCode', self.namespaces))
self.thesaurus['datetype'] = util.testXMLAttribute(datetype, 'codeListValue')


class MD_DataIdentification(printable):
""" Process MD_DataIdentification
"""
Expand Down Expand Up @@ -849,7 +848,6 @@ def __init__(self, namespaces, md=None):
for confdatetype in md.xpath(
'mdq:report/*/mdq:evaluationMethod/mdq:DQ_EvaluationMethod/mdq:evaluationProcedure/cit:CI_Citation/cit:date/cit:CI_Date/cit:dateType/cit:CI_DateTypeCode',
namespaces=self.namespaces):
print(f"{confdatetype=}")
self.conformancedatetype.append(util.testXMLValue(confdatetype))

for confdegree in md.xpath(
Expand Down
5 changes: 4 additions & 1 deletion tests/test_iso3_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ def test_identification_keywords(bmd):
keyw = bmd.identification[0].keywords
assert keyw[0].keywords[0].name == 'Sol et sous-sol'
assert keyw[0].keywords[0].url == 'https://metawal.wallonie.be/thesaurus/theme-geoportail-wallon#SubThemesGeoportailWallon/1030'
assert keyw[0].thesaurus['date'] == '2014-01-01'
assert keyw[0].thesaurus['datetype'] =='publication'
assert keyw[0].thesaurus['title'] == 'Thèmes du géoportail wallon'
assert keyw[0].thesaurus['url'] == 'https://metawal.wallonie.be/thesaurus/theme-geoportail-wallon'
assert keyw[0].type == 'theme'
assert len(keyw[0].keywords) == 2
assert len(keyw) == 5
Expand Down Expand Up @@ -564,7 +568,6 @@ def test_md_reference_system(emd):
assert emd.referencesystem.code == 'Resource > Spatial Reference > Reference System > Code'
assert emd.referencesystem.codeSpace == 'Resource > Spatial Reference > Reference System > Code Space'
assert emd.referencesystem.version == 'Resource > Spatial Reference > Reference System > Version'
print(emd.format_me())

def test_service2(emd):
""" Tests SV_ServiceIdentification fields not present in other sources
Expand Down

0 comments on commit 804c45f

Please sign in to comment.