[PATCH eac V3] Add support for <languageDeclaration>

gvandevelde guillaume.vandevelde at logilab.fr
Tue Aug 6 11:54:11 CEST 2019


Changement de plan !

Au final ce changeset ne sera pas intégré !

Relecture annulée. Désolé pour le bruit inutile sur la liste.

On 8/6/19 11:10 AM, Guillaume Vandevelde wrote:
> # HG changeset patch
> # User Guillaume Vandevelde <gvandevelde at logilab.fr>
> # Date 1564500696 -7200
> #      Tue Jul 30 17:31:36 2019 +0200
> # Node ID 5424f9badb314cd69742053ffe793f892a15bf7d
> # Parent  29a224db521a3644469c44173b2973bb398e0f12
> # Available At http://hg.logilab.org/review/cubes/eac
> #              hg pull http://hg.logilab.org/review/cubes/eac -r 5424f9badb31
> Add support for <languageDeclaration>
>
> Add a new entity `LanguageDeclaration` representing the tag <languageDeclaration>.
>
> diff -r 29a224db521a -r 5424f9badb31 cubicweb_eac/dataimport.py
> --- a/cubicweb_eac/dataimport.py	Fri Aug 02 10:20:36 2019 +0200
> +++ b/cubicweb_eac/dataimport.py	Tue Jul 30 17:31:36 2019 +0200
> @@ -40,7 +40,7 @@
>   TYPE_MAPPING['human'] = u'person'
>   
>   ETYPES_ORDER_HINT = ('AgentKind', 'PhoneNumber', 'PostalAddress', 'AuthorityRecord',
> -                     'Convention', 'AgentPlace', 'Mandate', 'LegalStatus',
> +                     'Convention', 'LanguageDeclaration', 'AgentPlace', 'Mandate', 'LegalStatus',
>                        'History', 'HistoricalEvent', 'Structure', 'AgentFunction', 'Occupation',
>                        'GeneralContext', 'AssociationRelation', 'ChronologicalRelation',
>                        'HierarchicalRelation', 'EACResourceRelation', 'ExternalUri',
> @@ -889,11 +889,29 @@
>                                     namespaces=self.namespaces):
>               for extentity in self.build_maintenance_event(elem):
>                   yield extentity
> +        for elem in control.xpath('eac:languageDeclaration',
> +                                  namespaces=self.namespaces):
> +            for extentity in self.build_language_declaration(elem):
> +                yield extentity
>           for elem in control.xpath('eac:conventionDeclaration',
>                                     namespaces=self.namespaces):
>               for extentity in self.build_convention(elem):
>                   yield extentity
>   
> +    @relate_to_record_through('LanguageDeclaration', 'language_declaration_of')
> +    @filter_empty
> +    @elem_maybe_none
> +    def build_language_declaration(self, elem):
> +        """Build a `LanguageDeclaration` external entity"""
> +        values = self.parse_tag_description(elem)
> +        language = self._elem_find(elem, 'eac:language')
> +        script = self._elem_find(elem, 'eac:script')
> +        if language is not None and language.text:
> +            values['language'] = set([text_type(etree.tostring(language).strip())])
> +        if script is not None and script.text:
> +            values['script'] = set([text_type(etree.tostring(script).strip())])
> +        yield ExtEntity('LanguageDeclaration', self._gen_extid(), values)
> +
>       def build_maintenance_event(self, elem):
>           """Parse a `maintenanceEvent` tag, yielding a prov:Activity external
>           entity along with necessary Records.
> diff -r 29a224db521a -r 5424f9badb31 cubicweb_eac/i18n/en.po
> --- a/cubicweb_eac/i18n/en.po	Fri Aug 02 10:20:36 2019 +0200
> +++ b/cubicweb_eac/i18n/en.po	Tue Jul 30 17:31:36 2019 +0200
> @@ -1599,3 +1599,47 @@
>   msgctxt "HierarchicalRelation"
>   msgid "xml_wrap"
>   msgstr ""
> +
> +msgid "LanguageDeclaration"
> +msgstr "language declaration"
> +
> +msgid "LanguageDeclaration_plural"
> +msgstr "language declarations"
> +
> +msgid "New LanguageDeclaration"
> +msgstr "new language declaration"
> +
> +msgid "This LanguageDeclaration"
> +msgstr "this language declaration"
> +
> +msgid "This LanguageDeclaration:"
> +msgstr "this language declaration :"
> +
> +msgid "language"
> +msgstr ""
> +
> +msgid "add a LanguageDeclaration"
> +msgstr "add a language declaration"
> +
> +msgid "language_declaration_of"
> +msgstr ""
> +
> +msgctxt "LanguageDeclaration"
> +msgid "language_declaration_of"
> +msgstr ""
> +
> +msgid "language_declaration_of_object"
> +msgstr ""
> +
> +msgctxt "AuthorityRecord"
> +msgid "language_declaration_of_object"
> +msgstr ""
> +
> +msgid ""
> +"creating LanguageDeclaration (LanguageDeclaration language_declaration_of AuthorityRecord %(linkto)s)"
> +msgstr ""
> +
> +msgctxt "LanguageDeclaration"
> +msgid "description"
> +msgstr ""
> +
> diff -r 29a224db521a -r 5424f9badb31 cubicweb_eac/i18n/fr.po
> --- a/cubicweb_eac/i18n/fr.po	Fri Aug 02 10:20:36 2019 +0200
> +++ b/cubicweb_eac/i18n/fr.po	Tue Jul 30 17:31:36 2019 +0200
> @@ -1610,3 +1610,47 @@
>   msgctxt "HierarchicalRelation"
>   msgid "xml_wrap"
>   msgstr ""
> +
> +msgid "LanguageDeclaration"
> +msgstr "langue déclarée"
> +
> +msgid "LanguageDeclaration_plural"
> +msgstr "langues déclarées"
> +
> +msgid "New LanguageDeclaration"
> +msgstr "nouvelle langue déclarée"
> +
> +msgid "This LanguageDeclaration"
> +msgstr "cette langue déclarée"
> +
> +msgid "This LanguageDeclaration:"
> +msgstr "cette langue déclarée :"
> +
> +msgid "language"
> +msgstr "langue"
> +
> +msgid "add a LanguageDeclaration"
> +msgstr "ajouter une langue"
> +
> +msgid "language_declaration_of"
> +msgstr "langue déclarée de"
> +
> +msgctxt "LanguageDeclaration"
> +msgid "language_declaration_of"
> +msgstr "langue déclarée de"
> +
> +msgid "language_declaration_of_object"
> +msgstr "language déclaré de cet objet"
> +
> +msgctxt "AuthorityRecord"
> +msgid "language_declaration_of_object"
> +msgstr "langue déclarée de cette notice"
> +
> +msgid ""
> +"creating LanguageDeclaration (LanguageDeclaration language_declaration_of AuthorityRecord %(linkto)s)"
> +msgstr ""
> +
> +msgctxt "LanguageDeclaration"
> +msgid "description"
> +msgstr ""
> +
> diff -r 29a224db521a -r 5424f9badb31 cubicweb_eac/migration/0.9.0_Any.py
> --- a/cubicweb_eac/migration/0.9.0_Any.py	Fri Aug 02 10:20:36 2019 +0200
> +++ b/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 30 17:31:36 2019 +0200
> @@ -1,3 +1,4 @@
>   add_attribute('History', 'abstract')
>   add_entity_type('HistoricalEvent')
>   add_entity_type('Convention')
> +add_entity_type('LanguageDeclaration')
> diff -r 29a224db521a -r 5424f9badb31 cubicweb_eac/schema.py
> --- a/cubicweb_eac/schema.py	Fri Aug 02 10:20:36 2019 +0200
> +++ b/cubicweb_eac/schema.py	Tue Jul 30 17:31:36 2019 +0200
> @@ -186,6 +186,13 @@
>       composite = 'object'
>   
>   
> +class language_declaration_of(RelationDefinition):
> +    subject = 'LanguageDeclaration'
> +    object = 'AuthorityRecord'
> +    cardinality = '1*'
> +    composite = 'object'
> +
> +
>   class _agent_relation(RelationDefinition):
>       """Abstract relation between authority record"""
>       subject = None
> @@ -266,6 +273,12 @@
>       description = RichString(fulltextindexed=True)
>   
>   
> +class LanguageDeclaration(EntityType):
> +    language = String(fulltextindexed=True)
> +    script = String(fulltextindexed=True)
> +    description = RichString(fulltextindexed=True)
> +
> +
>   class Convention(EntityType):
>       "Rules or conventions applied in creating the EAC-CPF instance"
>       abbrev = String(fulltextindexed=True)
> diff -r 29a224db521a -r 5424f9badb31 test/test_dataimport.py
> --- a/test/test_dataimport.py	Fri Aug 02 10:20:36 2019 +0200
> +++ b/test/test_dataimport.py	Tue Jul 30 17:31:36 2019 +0200
> @@ -124,10 +124,21 @@
>                 'agent': set([u'Delphine Jamet'])
>                },
>               ),
> +            ('LanguageDeclaration', _gen_extid(),
> +             {'language_declaration_of': ['FRAD033_EAC_00001'],
> +              'language': set([u'<language xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="'
> +                               u'http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http:/'
> +                               u'/www.w3.org/1999/xlink" languageCode="fre">français</language'
> +                               u'>']),
> +              'script': set([u'<script xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org'
> +                             u'/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/'
> +                             u'xlink" scriptCode="Latn">latin</script>'])
> +             },
> +            ),
>               ('Convention', _gen_extid(),
>                {'convention_of': ['FRAD033_EAC_00001'],
>                 'abbrev': set([u'ISAAR(CPF)']),
> -              'has_citation': ['8'],
> +              'has_citation': ['9'],
>                 'description_format': set([u'text/html']),
>                 'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" '
>                                     u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
> @@ -188,7 +199,7 @@
>                {'name': set([u'Bordeaux (Gironde, France)']),
>                 'role': set([u'siege']),
>                 'place_agent': set(['FRAD033_EAC_00001']),
> -              'place_address': set(['13']),
> +              'place_address': set(['14']),
>                 'equivalent_concept': set(['http://catalogue.bnf.fr/ark:/12148/cb152418385']),
>                },
>               ),
> @@ -231,8 +242,8 @@
>                 ]),
>                 'text_format': set([u'text/html']),
>                 'history_agent': set(['FRAD033_EAC_00001']),
> -              'has_citation': set(['20', '21']),
> -              'has_event': set(['22', '23']),
> +              'has_citation': set(['21', '22']),
> +              'has_event': set(['24', '23']),
>                },
>               ),
>               ('Citation', _gen_extid(),
> @@ -300,7 +311,7 @@
>                 'description': set([u'Organisation des réunions ...']),
>                 'description_format': set([u'text/plain']),
>                 'occupation_agent': set(['FRAD033_EAC_00001']),
> -              'has_citation': set(['29']),
> +              'has_citation': set(['30']),
>                 'equivalent_concept': set(['http://pifgadget.com']),
>                },
>               ),
> @@ -313,7 +324,7 @@
>                                 u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
>                                 u'xmlns:xlink="http://www.w3.org/1999/xlink">very famous</p>']),
>                 'content_format': set([u'text/html']),
> -              'has_citation': set(['31']),
> +              'has_citation': set(['32']),
>                 'general_context_of': set(['FRAD033_EAC_00001']),
>                 }
>               ),
> @@ -424,7 +435,6 @@
>                            {'maintenanceStatus': set([12]),
>                             'publicationStatus': set([14]),
>                             'maintenanceAgency': set([16]),
> -                          'languageDeclaration': set([21]),
>                             'localControl': set([54]),
>                             'source': set([76]),  # empty.
>                             'structureOrGenealogy': set([189]),  # empty.
> @@ -526,7 +536,7 @@
>                                  cwuri=u'http://data.culture.fr/thesaurus/page/ark:/67717/T1-1074')
>               cnx.commit()
>               created, updated = testutils.eac_import(cnx, fpath)
> -            self.assertEqual(len(created), 45)
> +            self.assertEqual(len(created), 46)
>               self.assertEqual(updated, set())
>               rset = cnx.find('AuthorityRecord', isni=u'22330001300016')
>               self.assertEqual(len(rset), 1)
> @@ -549,7 +559,8 @@
>               self.assertEqual(len(record.reverse_function_agent), 3)
>               for related in ('structure', 'history', 'mandate', 'occupation',
>                               'generalcontext', 'legal_status', 'eac_relations',
> -                            'equivalent_concept', 'control', 'convention'):
> +                            'equivalent_concept', 'control', 'convention',
> +                            'language_declaration'):
>                   with self.subTest(related=related):
>                       checker = getattr(self, '_check_' + related)
>                       checker(cnx, record)
> @@ -569,6 +580,19 @@
>                            u'Norme ISAAR(CPF) du Conseil international des archives, '
>                            u'2e \xe9dition, 1996.')
>   
> +    def _check_language_declaration(self, cnx, record):
> +        rset = cnx.find('LanguageDeclaration', language_declaration_of=record)
> +        self.assertEqual(len(rset), 1)
> +        entity = rset.one()
> +        self.assertEqual(entity.printable_value('language', format=u'text/plain').strip(),
> +                         u'<language xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3'
> +                         u'.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999'
> +                         u'/xlink" languageCode="fre">français</language>')
> +        self.assertEqual(entity.printable_value('script', format=u'text/plain').strip(),
> +                         u'<script xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org'
> +                         u'/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink"'
> +                         u' scriptCode="Latn">latin</script>')
> +
>       def _check_history(self, cnx, record):
>           rset = cnx.find('History', history_agent=record)
>           self.assertEqual(len(rset), 1)
> diff -r 29a224db521a -r 5424f9badb31 test/test_schema.py
> --- a/test/test_schema.py	Fri Aug 02 10:20:36 2019 +0200
> +++ b/test/test_schema.py	Tue Jul 30 17:31:36 2019 +0200
> @@ -108,6 +108,8 @@
>               'EACResourceRelation': {('resource_relation_agent', 'subject'):
>                                       set(['AuthorityRecord'])},
>               'Convention': {('convention_of', 'subject'): set(['AuthorityRecord'])},
> +            'LanguageDeclaration': {
> +                ('language_declaration_of', 'subject'): set(['AuthorityRecord'])},
>               'EACSource': {('source_agent', 'subject'): set(['AuthorityRecord'])},
>               'HistoricalEvent': {('has_event', 'object'): set(['History'])},
>               'GeneralContext': {('general_context_of', 'subject'): set(['AuthorityRecord'])},
>



More information about the saem-devel mailing list