[PATCH 01 of 11 seda] [dataimport] Allow to specify files to import to import_seda_schemes

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 3 10:43:13 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1488475256 -3600
#      Thu Mar 02 18:20:56 2017 +0100
# Node ID f9ce0269a69b8a93200296edbe19c8266d02242b
# Parent  08ff736126f14654fc1d1282ac998964dcb7ddcd
[dataimport] Allow to specify files to import to import_seda_schemes

Will ease later migration to import specific vocabularies.

diff --git a/cubicweb_seda/dataimport.py b/cubicweb_seda/dataimport.py
--- a/cubicweb_seda/dataimport.py
+++ b/cubicweb_seda/dataimport.py
@@ -126,24 +126,24 @@ def get_store(cnx):
         return MassiveObjectStore(cnx, eids_seq_range=1000)
     else:
         return NoHookRQLObjectStore(cnx)
 
 
-def import_seda_schemes(cnx, lcsv_import=lcsv_import):
+def import_seda_schemes(cnx, lcsv_import=lcsv_import, lcsv_files=LCSV_FILES):
     """Import all LCSV data files defined in LCSV_FILES."""
     orig_cwuri2eid = post321_import.cwuri2eid
     try:
-        _import_seda_schemes(cnx, lcsv_import)
+        _import_seda_schemes(cnx, lcsv_import, lcsv_files)
     finally:
         post321_import.cwuri2eid = orig_cwuri2eid
 
 
-def _import_seda_schemes(cnx, lcsv_import=lcsv_import):
+def _import_seda_schemes(cnx, lcsv_import=lcsv_import, lcsv_files=LCSV_FILES):
     """Import all LCSV data files defined in LCSV_FILES."""
     feed_extid2eid_cache(cnx)
     store = get_store(cnx)
-    for title, rtypes, etypes, fname in LCSV_FILES:
+    for title, rtypes, etypes, fname in lcsv_files:
         if not cnx.find('ConceptScheme', title=title):
             print('importing', title.encode('utf-8'))
             scheme = init_seda_scheme(cnx, title)
             lcsv_import(cnx, store, fname, scheme.cwuri)
             if not isinstance(rtypes, tuple):


More information about the saem-devel mailing list