[PATCH eac] add `languages` attribute on AuthorityRecord

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Thu Aug 29 10:47:17 CEST 2019


# HG changeset patch
# User Katia Saurfelt <katia.saurfelt at logilab.fr>
# Date 1564507231 -7200
#      Tue Jul 30 19:20:31 2019 +0200
# Node ID b6eaf5a685ea2aa838626115baf6ff9c350220fe
# Parent  ddc2ddcb51fc5e3f6c49d7e7e3497014e0c6d0fd
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r b6eaf5a685ea
add `languages` attribute on AuthorityRecord

diff -r ddc2ddcb51fc -r b6eaf5a685ea cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Tue Jul 23 17:32:01 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Tue Jul 30 19:20:31 2019 +0200
@@ -500,6 +500,16 @@
             values['parts'] = {u', '.join(text_type(p.text) for p in parts)}
             yield ExtEntity('NameEntry', self._gen_extid(), values)
 
+    def parse_languages(self, elems):
+        """Add a `languages` on AuthorityRecord"""
+        languages = []
+        for elem in elems:
+            language = self._elem_find(elem, 'eac:language')
+            if language is not None and language.text.strip():
+                languages.append(language.text.strip())
+        if languages:
+            self.record.values['languages'] = set([u', '.join(languages)])
+
     @filter_none
     def parse_description(self, description):
         """Parse the `description` tag and yield external entities, possibly
@@ -527,6 +537,10 @@
         for mandate in self.find_nested(description, 'eac:mandate', 'eac:mandates'):
             for extentity in self.build_mandate(mandate):
                 yield extentity
+        # languagesUsed
+        languages = self.find_nested(description, 'eac:languageUsed', 'eac:languagesUsed')
+        if languages:
+            self.parse_languages(languages)
         # history
         for history in self._elem_findall(description, 'eac:biogHist'):
             for extentity in self.build_history(history):
diff -r ddc2ddcb51fc -r b6eaf5a685ea cubicweb_eac/migration/0.9.0_Any.py
--- a/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 23 17:32:01 2019 +0200
+++ b/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 30 19:20:31 2019 +0200
@@ -53,3 +53,5 @@
 add_relation_type('place_entry_relation')
 
 add_attribute('Activity', 'agent_type')
+
+add_attribute('AuthorityRecord', 'languages')
diff -r ddc2ddcb51fc -r b6eaf5a685ea cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Tue Jul 23 17:32:01 2019 +0200
+++ b/cubicweb_eac/schema.py	Tue Jul 30 19:20:31 2019 +0200
@@ -60,6 +60,7 @@
     record_id = String(indexed=True)
     isni = String(unique=True,
                   description=_('International Standard Name Identifier'))
+    languages = String()
 
 
 class NameEntry(EntityType):
diff -r ddc2ddcb51fc -r b6eaf5a685ea test/data/FRAD033_EAC_00001_simplified.xml
--- a/test/data/FRAD033_EAC_00001_simplified.xml	Tue Jul 23 17:32:01 2019 +0200
+++ b/test/data/FRAD033_EAC_00001_simplified.xml	Tue Jul 30 19:20:31 2019 +0200
@@ -169,6 +169,20 @@
     <description>
       <existDates><dateRange><fromDate>1800</fromDate><toDate>2099</toDate></dateRange>
       </existDates>
+	<languageUsed>
+	  <language
+	      languageCode="eng">English
+	  </language>
+	  <script scriptCode="Latn">Latin
+	  </script>
+	</languageUsed>
+	<languageUsed>
+	  <language
+	      languageCode="spa">Spanish
+	  </language>
+	  <script scriptCode="Latn">Latin
+	  </script>
+	</languageUsed>
       <place>
           <placeRole>siege</placeRole>
           <placeEntry vocabularySource="http://catalogue.bnf.fr/ark:/12148/cb152418385">Bordeaux (Gironde, France)</placeEntry>
diff -r ddc2ddcb51fc -r b6eaf5a685ea test/test_dataimport.py
--- a/test/test_dataimport.py	Tue Jul 23 17:32:01 2019 +0200
+++ b/test/test_dataimport.py	Tue Jul 30 19:20:31 2019 +0200
@@ -616,6 +616,7 @@
              ),
             ('AuthorityRecord', 'authorityrecord-FRAD033_EAC_00001',
              {'isni': set([u'22330001300016']),
+              'languages': [u'English, Spanish'],
               'start_date': set([datetime.date(1800, 1, 1)]),
               'end_date': set([datetime.date(2099, 1, 1)]),
               'agent_kind': set(['agentkind/authority']),
@@ -647,10 +648,11 @@
                           'publicationStatus': set([14]),
                           'maintenanceAgency': set([16]),
                           'languageDeclaration': set([21]),
+                          'languageUsed': set([172, 179]),
                           'localControl': set([54]),
                           'source': set([76]),  # empty.
-                          'structureOrGenealogy': set([233]),  # empty.
-                          'biogHist': set([293, 296]),  # empty.
+                          'structureOrGenealogy': set([247]),  # empty.
+                          'biogHist': set([307, 310]),  # empty.
                           })
 
     def check_order_entities(self, entities, expected):



More information about the saem-devel mailing list