Skip to content

Commit

Permalink
Fix bug with relatedItem types + no copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt3 committed Sep 12, 2024
1 parent 38e4bc5 commit 4325413
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MODS_Scripts/process_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def get_name_value(name=ET.Element):
def get_copyright_data(accessCondition=ET.Element):
copyright = accessCondition.find(
'copyrightMD:copyright', namespaces['copyright_ns'])
if copyright is None:
return []
data = [('publication_status', copyright.attrib.get('publication.status')),
('copyright_status', copyright.attrib.get('copyright.status'))]
return [(key, value) for key, value in data if value]
Expand Down Expand Up @@ -211,7 +213,6 @@ def get_name_data(name=ET.Element):
return data



# Add type attribute value for name element to XPath
def add_name_type(element=ET.Element, xpath=str):
name = element.getparent()
Expand Down Expand Up @@ -293,7 +294,7 @@ def process_xml(file):
if tag in ['namePart', 'roleTerm']:
field = add_name_type(element, xpath)
if 'relatedItem/' in field:
field = add_relatedItem_type(element, xpath)
field = add_relatedItem_type(element, field)
# Update xpath to corresponding column name, if one exists
field = columns[field] if field in columns else field
# Add data to record
Expand Down

0 comments on commit 4325413

Please sign in to comment.