diff --git a/MODS_Scripts/process_xml.py b/MODS_Scripts/process_xml.py index c9b5ad2..a6f719f 100644 --- a/MODS_Scripts/process_xml.py +++ b/MODS_Scripts/process_xml.py @@ -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] @@ -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() @@ -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