--- a/dataimport/importer.py Fri Oct 16 17:04:30 2015 +0200
+++ b/dataimport/importer.py Fri Oct 16 17:06:12 2015 +0200
@@ -69,7 +69,7 @@
def use_extid_as_cwuri_filter(extentities):
for extentity in extentities:
if extentity.extid not in extid2eid:
- extentity.values.setdefault('cwuri', set([unicode(extentity.extid)]))
+ extentity.values.setdefault('cwuri', set([extentity.extid.decode('utf-8')]))
yield extentity
return use_extid_as_cwuri_filter
--- a/dataimport/stores.py Fri Oct 16 17:04:30 2015 +0200
+++ b/dataimport/stores.py Fri Oct 16 17:06:12 2015 +0200
@@ -61,6 +61,8 @@
from datetime import datetime
from copy import copy
+from six import text_type
+
from logilab.common.deprecation import deprecated
from logilab.common.decorators import cached
@@ -298,7 +300,7 @@
genfunc = self.generate(attr)
if genfunc:
entity.cw_edited.edited_attribute(attr, genfunc(entity))
- if isinstance(extid, unicode):
+ if isinstance(extid, text_type):
extid = extid.encode('utf-8')
return self.source, extid
--- a/dataimport/test/unittest_importer.py Fri Oct 16 17:04:30 2015 +0200
+++ b/dataimport/test/unittest_importer.py Fri Oct 16 17:06:12 2015 +0200
@@ -152,14 +152,14 @@
class UseExtidAsCwuriTC(TestCase):
def test(self):
- personne = ExtEntity('Personne', 1, {'nom': set([u'de la lune']),
- 'prenom': set([u'Jean'])})
+ personne = ExtEntity('Personne', b'1', {'nom': set([u'de la lune']),
+ 'prenom': set([u'Jean'])})
mapping = {}
set_cwuri = use_extid_as_cwuri(mapping)
list(set_cwuri((personne,)))
self.assertIn('cwuri', personne.values)
- self.assertEqual(personne.values['cwuri'], set(['1']))
- mapping[1] = 'whatever'
+ self.assertEqual(personne.values['cwuri'], set([u'1']))
+ mapping[b'1'] = 'whatever'
personne.values.pop('cwuri')
list(set_cwuri((personne,)))
self.assertNotIn('cwuri', personne.values)