[PATCH eac V6] Add support for <functionRelation> in <cpfRelation>

Denis Laxalde denis.laxalde at logilab.fr
Mon Aug 12 17:52:15 CEST 2019


Guillaume Vandevelde a ├ęcrit :
> # HG changeset patch
> # User Guillaume Vandevelde <gvandevelde at logilab.fr>
> # Date 1564500697 -7200
> #      Tue Jul 30 17:31:37 2019 +0200
> # Node ID 0b61fbb4f0a7995c7dcc5adeb80d497a67099b05
> # Parent  8abcfe4e3ba441a6d5d5e5666b413961b8c22246
> # Available At http://hg.logilab.org/review/cubes/eac
> #              hg pull http://hg.logilab.org/review/cubes/eac -r 0b61fbb4f0a7
> Add support for <functionRelation> in <cpfRelation>
> 
> Create a new entity EACFunctionRelation similar to EACRessourceRelation.
> 
> diff -r 8abcfe4e3ba4 -r 0b61fbb4f0a7 cubicweb_eac/dataimport.py
> --- a/cubicweb_eac/dataimport.py	Tue Jul 30 17:31:36 2019 +0200
> +++ b/cubicweb_eac/dataimport.py	Tue Jul 30 17:31:37 2019 +0200

> @@ -836,6 +837,43 @@
>          values.update(self.parse_tag_description(elem))
>          yield ExtEntity(etype, self._gen_extid(), values)
>  
> +    @add_xml_wrap_for('EACFunctionRelation')
> +    def build_function_relation(self, elem):
> +        """Build a relation between function entities
> +
> +        yield an ExternalUri object, and an EACFunctionRelation
> +        object that make the link between the ExternalUri and
> +        the AuthorityRecord object"""
> +        obj_uri = None
> +        relationship = None
> +        values = self.parse_tag_description(elem)
> +        if elem.attrib.get('functionRelationType'):
> +            relationship = elem.attrib.pop('functionRelationType')
> +        if elem.attrib.get('{%(xlink)s}href' % self.namespaces):
> +            obj_uri = elem.attrib.pop('{%(xlink)s}href' % self.namespaces)

Still useless (I think) .get() and .pop().

> +        # Yield the ExternalUri object
> +        if obj_uri:
> +            yield external_uri(obj_uri)
> +            values.update(
> +                {'function_relation_function': set([text_type(obj_uri)])})
> +        dates = self.parse_daterange(
> +            self._elem_find(elem, 'eac:dateRange'))
> +        if dates:
> +            values.update(dates)
> +        if relationship:
> +            values.update({'r_type': set([text_type(relationship)])})
> +        values.update({
> +            'function_relation_agent': set([text_type(self.record.extid)]),
> +        })
> +        values.update(self.values_from_xpaths(
> +            elem,
> +            (('place_entry', 'eac:placeEntry'),
> +             ('relation_entry', 'eac:relationEntry'))))
> +        attrib = sorted(dict(elem.attrib).items())
> +        if attrib:
> +            values.update({'attributes': set([text_type(attrib)])})
> +        yield ExtEntity('EACFunctionRelation', self._gen_extid(), values)
> +
>      @add_xml_wrap_for('EACResourceRelation')
>      def build_resource_relation(self, elem):
>          """Build a `EACResourceRelation` external entity (along with



More information about the saem-devel mailing list