[PATCH 01 of 10 eac] * add support for the <abstract> tag under <bioghist>

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Thu Jun 27 10:12:07 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1560340913 -7200
#      Wed Jun 12 14:01:53 2019 +0200
# Node ID 6ca3ee58f6b11cea36033a54391810b9a0e9a4c2
# Parent  1ff1b25a10195b1663fbf4fc2a3aeb9d3305d0c5
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 6ca3ee58f6b1
* add support for the <abstract> tag under <bioghist>
* add better testing for the <abstract> tag

Differential Revision: https://phab.logilab.fr/D3367

diff -r 1ff1b25a1019 -r 6ca3ee58f6b1 cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Wed Oct 31 16:14:06 2018 +0100
+++ b/cubicweb_eac/dataimport.py	Wed Jun 12 14:01:53 2019 +0200
@@ -587,10 +587,13 @@
     @elem_maybe_none
     def build_history(self, elem):
         """Build a `History` external entity."""
+        abstract = self._elem_find(elem, 'eac:abstract')
         desc, desc_format = self.parse_tag_content(elem)
         if desc:
             values = {'text': set([desc]),
                       'text_format': set([desc_format])}
+            if abstract is not None and abstract.text:
+                values['abstract'] = set([text_type(abstract.text)])
             yield ExtEntity('History', self._gen_extid(), values)
 
     @elem_maybe_none
diff -r 1ff1b25a1019 -r 6ca3ee58f6b1 cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Wed Oct 31 16:14:06 2018 +0100
+++ b/cubicweb_eac/schema.py	Wed Jun 12 14:01:53 2019 +0200
@@ -261,6 +261,7 @@
 
 class History(EntityType):
     """Biographical or historical information"""
+    abstract = RichString(fulltextindexed=True)
     text = RichString(fulltextindexed=True)
 
 
diff -r 1ff1b25a1019 -r 6ca3ee58f6b1 doc/supported.rst
--- a/doc/supported.rst	Wed Oct 31 16:14:06 2018 +0100
+++ b/doc/supported.rst	Wed Jun 12 14:01:53 2019 +0200
@@ -9,11 +9,12 @@
 
 .. _`balises XML du format EAC-CPF`: http://eac.staatsbibliothek-berlin.de/fileadmin/user_upload/schema/cpfTagLibrary.html
 
+
 ===== ==========================
 Sup.       Éléments EAC-CPF     
 ===== ==========================
   x          abbreviation       
-  x            abstract         
+  .            abstract         
   .            address          
   .          addressLine        
   x           agencyCode        
diff -r 1ff1b25a1019 -r 6ca3ee58f6b1 test/data/FRAD033_EAC_00001_simplified.xml
--- a/test/data/FRAD033_EAC_00001_simplified.xml	Wed Oct 31 16:14:06 2018 +0100
+++ b/test/data/FRAD033_EAC_00001_simplified.xml	Wed Jun 12 14:01:53 2019 +0200
@@ -194,6 +194,7 @@
       </generalContext>
 
       <biogHist>
+	  <abstract>Test of an abstract element</abstract>
           <p>La loi du 22 décembre 1789, en divisant ...</p>
           <p>L'inspecteur Canardo</p>
           <citation xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.assemblee-nationale.fr/histoire/images-decentralisation/decentralisation/loi-du-22-decembre-1789-.pdf" xlink:type="simple"></citation>
@@ -203,6 +204,9 @@
       <!--empty biogHist-->
       <biogHist></biogHist>
 
+      <!--empty bioghist with empty abstract-->
+      <biogHist><abstract></abstract></biogHist>
+
     </description>
 
     <relations>
diff -r 1ff1b25a1019 -r 6ca3ee58f6b1 test/test_dataimport.py
--- a/test/test_dataimport.py	Wed Oct 31 16:14:06 2018 +0100
+++ b/test/test_dataimport.py	Wed Jun 12 14:01:53 2019 +0200
@@ -192,6 +192,7 @@
               'text_format': set([u'text/html']),
               'history_agent': set(['FRAD033_EAC_00001']),
               'has_citation': set(['16', '17']),
+              'abstract': set([u'Test of an abstract element']),
              },
             ),
             ('Citation', _gen_extid(),
@@ -366,7 +367,7 @@
                           'localControl': set([54]),
                           'source': set([76]),  # empty.
                           'structureOrGenealogy': set([189]),  # empty.
-                          'biogHist': set([204]),  # empty.
+                          'biogHist': set([205, 208]),  # empty.
                           })
 
     def test_mandate_under_mandates(self):
@@ -501,6 +502,8 @@
 
     def _check_history(self, cnx, record):
         rset = cnx.find('History', history_agent=record)
+        self.assertEqual(rset.one().printable_value('abstract', format=u'text/plain').strip(),
+                         u'Test of an abstract element')
         self.assertEqual(len(rset), 1)
         self.assertEqual(rset.one().printable_value('text',
                                                     format=u'text/plain').strip(),


More information about the saem-devel mailing list