Skip to content

Commit

Permalink
feat(generic): add logging to GenericModelImporter
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 9, 2024
1 parent ba14ace commit 8d282cd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apis_core/generic/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from apis_core.utils.normalize import clean_uri
from apis_core.utils.rdf import get_definition_and_attributes_from_uri

import logging

logger = logging.getLogger(__name__)


@cache
class GenericModelImporter:
Expand Down Expand Up @@ -39,14 +43,15 @@ def request(self, uri):
try:
defn, data = get_definition_and_attributes_from_uri(uri, self.model)
return data
except Exception:
pass
except Exception as e:
logging.debug(e)
# if everything else fails, try parsing json
# if even that does not help, return an empty dict
try:
return json.loads(urllib.request.urlopen(uri).read())
except Exception:
return {}
except Exception as e:
logging.debug(e)
return {}

def mangle_data(self, data):
return data
Expand Down

0 comments on commit 8d282cd

Please sign in to comment.