fix(py3): we still have some unicode() arround

authorLaurent Peuch <cortex@worlddomination.be>
changesetef0787d6b03b
branchdefault
phasedraft
hiddenno
parent revision#a4d465a3e77d fix(ci): manually remove the .tox/doc directory
child revision<not specified>
files modified by this revision
cubicweb/devtools/fix_po_encoding
doc/tutorials/dataimport/diseasome_parser.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1611758307 -3600
# Wed Jan 27 15:38:27 2021 +0100
# Node ID ef0787d6b03ba15f323bfbd9303c59b20931a32a
# Parent a4d465a3e77d07cf6a79c121c10b2d6484cd7468
fix(py3): we still have some unicode() arround

diff --git a/cubicweb/devtools/fix_po_encoding b/cubicweb/devtools/fix_po_encoding
@@ -13,11 +13,11 @@
1      fdesc.close()
2      encoding = find_encoding(data)
3      if encoding == target:
4          return
5      data = fix_encoding(data, target)
6 -    data = unicode(data, encoding)
7 +    data = str(data, encoding)
8      fdesc = codecs.open(filename, 'wb', encoding=target)
9      fdesc.write(data)
10      fdesc.close()
11 
12  def find_encoding(data):
diff --git a/doc/tutorials/dataimport/diseasome_parser.py b/doc/tutorials/dataimport/diseasome_parser.py
@@ -87,14 +87,14 @@
13      entities = {}
14      for subj, rel, obj in _retrieve_structure(filename, etypes):
15          entities.setdefault(subj, {})
16          entities[subj].setdefault('attributes', {})
17          entities[subj].setdefault('relations', {})
18 -        entities[subj]['attributes'].setdefault('cwuri', unicode(subj))
19 +        entities[subj]['attributes'].setdefault('cwuri', str(subj))
20          if rel in MAPPING_ATTS:
21              entities[subj]['attributes'].setdefault(MAPPING_ATTS[rel], 
22 -                                                    unicode(obj))
23 +                                                    str(obj))
24          if rel in MAPPING_RELS:
25              entities[subj]['relations'].setdefault(MAPPING_RELS[rel], set())
26 -            entities[subj]['relations'][MAPPING_RELS[rel]].add(unicode(obj))
27 +            entities[subj]['relations'][MAPPING_RELS[rel]].add(str(obj))
28      return ((ent.get('attributes'), ent.get('relations')) 
29              for ent in entities.values())