Minor refactoring of initial schemes import code to ease overriding
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 14 Oct 2016 17:48:49 +0200
changeset 1843 4cec18e07edf
parent 1842 ece22f65f9e5
child 1844 f5490600f552
Minor refactoring of initial schemes import code to ease overriding by e.g. saem_ref which want to assign ark to created schemes.
dataimport.py
--- a/dataimport.py	Fri Oct 14 18:10:07 2016 +0200
+++ b/dataimport.py	Fri Oct 14 17:48:49 2016 +0200
@@ -105,6 +105,11 @@
         list(lcsv2rdf.triples())
 
 
+def init_seda_scheme(cnx, title):
+    description = u'edition 2009' if title.startswith('SEDA :') else None
+    return cnx.create_entity('ConceptScheme', title=title, description=description)
+
+
 def import_seda_schemes(cnx, lcsv_import=lcsv_import):
     """Import all LCSV data files defined in LCSV_FILES"""
     if cnx.repo.system_source.dbdriver == 'postgres':
@@ -116,9 +121,7 @@
     for title, rtypes, etypes, fname in LCSV_FILES:
         if not cnx.find('ConceptScheme', title=title):
             print('importing', title.encode('utf-8'))
-            description = u'edition 2009' if title.startswith('SEDA :') else None
-            scheme = cnx.create_entity('ConceptScheme', title=title,
-                                       description=description)
+            scheme = init_seda_scheme(cnx, title)
             lcsv_import(cnx, store, fname, scheme.cwuri)
             if not isinstance(rtypes, tuple):
                 rtypes = (rtypes,)