[PATCH 5 of 9 seda] [dataimport] Turn path from relative to absolute in the LCSV_FILES structure

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Oct 12 16:59:50 CEST 2017

# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1507728534 -7200
#      Wed Oct 11 15:28:54 2017 +0200
# Node ID e562b3d62a0d0a6e19764327d82b48e508ae494c
# Parent  1ef4f5936c15d72393a0938e680f58e05912d5ca
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r e562b3d62a0d
[dataimport] Turn path from relative to absolute in the LCSV_FILES structure

rather than later, so one may still use the `import_seda_schemes` high-level
function to import files which are not in the migration/data directory (but
rather in test/data).

Related to #36331831

diff --git a/cubicweb_seda/dataimport.py b/cubicweb_seda/dataimport.py
--- a/cubicweb_seda/dataimport.py
+++ b/cubicweb_seda/dataimport.py
@@ -17,22 +17,24 @@
 """cubicweb-seda data import tools"""
 from __future__ import print_function
 from itertools import count
-from os.path import join, dirname
+from os.path import abspath, dirname, join
 from six import text_type
 from cubicweb.server.checkintegrity import reindex_entities
 from cubicweb.dataimport.stores import NoHookRQLObjectStore
 from cubicweb.dataimport.importer import SimpleImportLog
 from cubes.skos import lcsv, sobjects as skos
+LCSV_FILES = [(title, rtype, etype,
+               join(abspath(dirname(__file__)), 'migration', 'data', fname))
+              for title, rtype, etype, fname in (
     # schemes extracted from SEDA 2 XSD
     (u'SEDA 2 : Actions',
      'seda_final_action', 'SEDAStorageRule',
     (u'SEDA 2 : Unités de mesure',
@@ -92,16 +94,16 @@ LCSV_FILES = (
     (u'Catégories de fichier',
      'file_category', (),
 def lcsv_import(cnx, store, fname, scheme_uri):
     """Actually import LCSV data file."""
-    with open(join(dirname(__file__), 'migration', 'data', fname)) as stream:
+    with open(fname) as stream:
         extentities = skos.lcsv_extentities(stream, scheme_uri, ';', 'utf-8')
         import_log = SimpleImportLog(fname)
         skos.store_skos_extentities(cnx, store, extentities, import_log,
                                     raise_on_error=True, extid_as_cwuri=False)

More information about the saem-devel mailing list