From 1d4291c24ea89e8a43bbc3674332eb21b4a6b9ae Mon Sep 17 00:00:00 2001
From: Alessandro Cerioni <acerioni@grandlyon.com>
Date: Tue, 16 Apr 2019 12:02:57 +0200
Subject: [PATCH] Fixed the splitting of organisationName and individualName.

---
 2-metadata-processor.py | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/2-metadata-processor.py b/2-metadata-processor.py
index 49a9ad0..a015aa7 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
 
-- 
GitLab