From d15a49c4b8206618040c707f5243cf0776df4804 Mon Sep 17 00:00:00 2001 From: "Morten W. Hansen" Date: Fri, 30 Oct 2020 11:08:36 +0100 Subject: [PATCH] #35: this should solve the issue in python2.7 --- pythesint/cf_vocabulary.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pythesint/cf_vocabulary.py b/pythesint/cf_vocabulary.py index 8e462ed..132e94e 100644 --- a/pythesint/cf_vocabulary.py +++ b/pythesint/cf_vocabulary.py @@ -20,13 +20,21 @@ def _fetch_online_data(self): details = {} metadata_details = node.getElementsByTagName('owl:Ontology')[0] for detail in metadata_details.childNodes: - if type(detail)==xml.dom.minidom.Element: + # This does not work in python2.7 because type(detail)=instance + #if type(detail)==xml.dom.minidom.Element: + try: details[detail.nodeName] = detail.childNodes[0].data + except (AttributeError, IndexError): + continue cf_list = [details] for cnode in node.getElementsByTagName('Standard_Name')[0].childNodes: - if type(cnode)==xml.dom.minidom.Element: + #if type(cnode)==xml.dom.minidom.Element: + try: entry = cnode.getElementsByTagName('Standard_Name')[0] + except (AttributeError, IndexError): + continue + else: standard_name = entry.getAttribute('rdf:about') units = '' if entry.getElementsByTagName('canonical_units'):