[PATCH 1 of 3 eac] [dataimport] Avoid considering external uris with empty uri

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Apr 14 15:31:06 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1492162297 -7200
#      Fri Apr 14 11:31:37 2017 +0200
# Node ID a07698e9d41359c8cb9b9b38e1dc0d75bcffc6e7
# Parent  718258f07cfc572f5e80727ae8dcae101648e368
[dataimport] Avoid considering external uris with empty uri

this may occurs if attribute is defined with an empty value. Fix this by
using truth value instead of None identity.

diff --git a/cubicweb_eac/dataimport.py b/cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py
+++ b/cubicweb_eac/dataimport.py
@@ -227,11 +227,11 @@ def equivalent_concept(tagname, etype):
         @wraps(func)
         def wrapped(self, elem, *args, **kwargs):
             subelem = self._elem_find(elem, tagname)
             if subelem is not None:
                 extid = subelem.attrib.get('vocabularySource')
-                if extid is not None:
+                if extid:
                     yield external_uri(extid)
             else:
                 extid = None
 
             def update_extentity(extentity):
@@ -774,11 +774,11 @@ class EACCPFImporter(object):
                 'unsupported cpfRelationType %s in element %s, skipping')
                 % (relationship, etree.tostring(elem)),
                 line=elem.sourceline)
             return
         obj_uri = elem.attrib.get('{%(xlink)s}href' % self.namespaces)
-        if obj_uri is None:
+        if not obj_uri:
             self.import_log.record_warning(self._('found a cpfRelation without any object (no '
                                                   'xlink attribute), skipping'),
                                            line=elem.sourceline)
             return
         yield external_uri(obj_uri)


More information about the saem-devel mailing list