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

Denis Laxalde denis.laxalde at logilab.fr
Mon Aug 12 15:14:13 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 7f368a4aff38e7c176c27d808a51d8be2d3b4c0b
> # Parent  8abcfe4e3ba441a6d5d5e5666b413961b8c22246
> # Available At http://hg.logilab.org/review/cubes/eac
> #              hg pull http://hg.logilab.org/review/cubes/eac -r 7f368a4aff38
> Add support for <functionRelation> in <cpfRelation>
> 
> Create a new entity EACFunctionRelation similar to EACRessourceRelation.

Tests fail, see:

  https://jenkins.logilab.org/job/cubicweb-eac/168/TOXENV=py27,distributions=debian_stretch/console

> diff -r 8abcfe4e3ba4 -r 7f368a4aff38 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)

I think this can simply be:

  relationship = elem.attrib.pop('functionRelationType', None)
  obj_uri = elem.attrib.pop('{%(xlink)s}href' % self.namespaces, None)

without ifs.

> +        # 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 = {k: v for (k, v) in 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