diff --git a/2-metadata-processor.py b/2-metadata-processor.py index 49a9ad0aa250bba92e8753546c8027e785d41daa..a015aa77e82a67b00b95aecbf3c04bce8022bac8 100644 --- a/2-metadata-processor.py +++ b/2-metadata-processor.py @@ -88,21 +88,23 @@ def list_to_dictlist( the_input, the_context=None ): # In the following, we arrange things differently... if the_context == 'responsibleParty': + # try: + # # the following applies to legacy metadata + # parent_organisation, child_organisation = out_item['organisationName'].split('/') + # parent_organisation = parent_organisation.strip() + # child_organisation = child_organisation.strip() + # except: + # pass + try: - # the following applies to legacy metadata - parent_organisation, child_organisation = out_item['organisationName'].split('/') - parent_organisation = parent_organisation.strip() - child_organisation = child_organisation.strip() + # the following applies to Dublin Core metadata + my_re = re.compile(r"(?P<organisationName>[^\(\)]+)(\((?P<individualName>.*)\))") + parent_organisation = my_re.match(out_item['organisationName']).groupdict()['organisationName'].strip() + child_organisation = my_re.match(out_item['organisationName']).groupdict()['individualName'].strip() except: - try: - # the following applies to Dublin Core metadata - my_re = re.compile(r"(?P<organisationName>[^\(\)]+)(\((?P<individualName>.*)\))") - parent_organisation = my_re.match(out_item['organisationName']).groupdict()['organisationName'].strip() - child_organisation = my_re.match(out_item['organisationName']).groupdict()['individualName'].strip() - except: - parent_organisation, child_organisation = out_item['organisationName'], None - parent_organisation = parent_organisation.strip() - child_organisation = None + parent_organisation, child_organisation = out_item['organisationName'], None + parent_organisation = parent_organisation.strip() + child_organisation = None out_item['organisationName'] = parent_organisation