From 9dc7014f3da3068b9872c9ed2713061845de0d20 Mon Sep 17 00:00:00 2001 From: etj Date: Wed, 28 Apr 2021 13:37:15 +0200 Subject: [PATCH] #58 fix parser --- rndt/layers/metadata.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rndt/layers/metadata.py b/rndt/layers/metadata.py index 752f19c..621bf14 100644 --- a/rndt/layers/metadata.py +++ b/rndt/layers/metadata.py @@ -108,14 +108,19 @@ def get_use_costraints(self, vals, acc_constr): use_constr = item.find(util.nspath_eval("gmd:otherConstraints/gmx:Anchor", self.namespaces)) if use_constr is not None: url = use_constr.attrib.get('{http://www.w3.org/1999/xlink}href') - t = ThesaurusKeyword.objects.filter(about=url).filter(thesaurus__identifier='ConditionsApplyingToAccessAndUse') + t = ThesaurusKeyword.objects\ + .filter(about=url)\ + .filter(thesaurus__identifier='ConditionsApplyingToAccessAndUse') if t.exists(): vals['constraints_other'] = url else: vals['constraints_other'] = f"{use_constr.text} {acc_constr}" else: - use_constrs = item.find(util.nspath_eval("gmd:otherConstraints/gco:CharacterString", self.namespaces)).text - vals['constraints_other'] = f"{use_constr.text} {acc_constr}" + use_constr = item.find(util.nspath_eval("gmd:otherConstraints/gco:CharacterString", self.namespaces)) + if use_constr is not None: + vals['constraints_other'] = f"{use_constr.text} {acc_constr}" + else: + vals['constraints_other'] = acc_constr return vals def get_resolutions(self, custom):