[PATCH 06 of 17 seda] [py3] Open files in binary mode in dataimport

Denis Laxalde denis.laxalde at logilab.fr
Wed Oct 2 16:06:34 CEST 2019


diff --git a/cubicweb_seda/dataimport.py b/cubicweb_seda/dataimport.py
index 54c0084..1a8be77 100644
--- a/cubicweb_seda/dataimport.py
+++ b/cubicweb_seda/dataimport.py
@@ -18,6 +18,7 @@
 
 from __future__ import print_function
 
+import io
 from itertools import count
 from os.path import abspath, dirname, join
 
@@ -110,7 +111,7 @@ LCSV_FILES = [(title, rtype, etype,
 
 def lcsv_import(cnx, store, fname, scheme_uri, **kwargs):
     """Actually import LCSV data file."""
-    with open(fname) as stream:
+    with io.open(fname, 'rb') as stream:
         extentities = skos.lcsv_extentities(stream, scheme_uri, ';', 'utf-8')
         import_log = SimpleImportLog(fname)
         skos.store_skos_extentities(cnx, store, extentities, import_log,
@@ -124,7 +125,7 @@ def lcsv_check(cnx, store, fname, scheme
     def uri_generator(val):
         return text_type(next(counter)) + val
 
-    with open(join(dirname(__file__), 'migration', 'data', fname)) as stream:
+    with io.open(join(dirname(__file__), 'migration', 'data', fname), 'rb') as stream:
         lcsv2rdf = lcsv.LCSV2RDF(stream, separator, 'utf-8',
                                  # XXX drop once skos is released
                                  uri_generator=uri_generator, uri_cls=text_type)



More information about the saem-devel mailing list