Skip to content

Commit

Permalink
Add fallback for namespaces not in map
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Sep 6, 2022
1 parent 31b83e7 commit 90d73ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion metsrw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())
__version__ = "0.3.21"
__version__ = "0.3.22"

__all__ = [
"Agent",
Expand Down
10 changes: 8 additions & 2 deletions metsrw/plugins/premisrw/premis.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,14 @@ def _data_to_lxml_el(data, ns, nsmap, element_maker=None, snake=True):
if snake:
attr = utils.snake_to_camel(attr)
if ns:
attr = "{" + nsmap[ns] + "}" + attr
ret.attrib[attr] = val
try:
attr = "{" + nsmap[ns] + "}" + attr
ret.attrib[attr] = val
except (KeyError, ValueError):
# If namespace is not in map (e.g. from characterization tool
# output), fall back to using ns as it exists prior to colon.
attr = "{" + ns + "}" + attr
ret.attrib[attr] = val
else:
ret.attrib[attr] = val
return ret
Expand Down

0 comments on commit 90d73ff

Please sign in to comment.