[PATCH 2 of 2 saem_ref] Add a "naa-what" option to "skos-import" command

Denis Laxalde denis.laxalde at logilab.fr
Mon Jan 8 12:34:57 CET 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1515410428 -3600
#      Mon Jan 08 12:20:28 2018 +0100
# Node ID d80a9d2304a9820a515d0019f4272785e7f9134b
# Parent  0140f2679535d889a3919194ba9253962cf83648
# EXP-Topic lcsv-skos-import
Add a "naa-what" option to "skos-import" command

This should be used in LCSV import format in particular to allow
imported concepts to be assigned an ARK.

Closes Extranet #44146518.

diff --git a/cubicweb_saem_ref/__init__.py b/cubicweb_saem_ref/__init__.py
--- a/cubicweb_saem_ref/__init__.py
+++ b/cubicweb_saem_ref/__init__.py
@@ -66,13 +66,15 @@ def includeme(config):
     config.include('.pviews')
 
 
-def _massive_store_factory(cnx, **kwargs):
+def _massive_store_factory(cnx, config):
     from cubicweb.dataimport.massive_store import MassiveObjectStore
     from .sobjects import SAEMMetadataGenerator
-    return MassiveObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx), **kwargs)
+    naa_what = config.naa_what
+    return MassiveObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx, naa_what=naa_what))
 
 
-def _nohook_store_factory(cnx):
+def _nohook_store_factory(cnx, config):
     from cubicweb.dataimport.stores import NoHookRQLObjectStore
     from .sobjects import SAEMMetadataGenerator
-    return NoHookRQLObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx))
+    naa_what = config.naa_what
+    return NoHookRQLObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx, naa_what=naa_what))
diff --git a/cubicweb_saem_ref/ccplugin.py b/cubicweb_saem_ref/ccplugin.py
--- a/cubicweb_saem_ref/ccplugin.py
+++ b/cubicweb_saem_ref/ccplugin.py
@@ -42,6 +42,15 @@ eac.ImportEacData.options = (
 )
 
 
+skos.ImportSkosData.options = skos.ImportSkosData.options + (
+    ("naa-what", {
+        'type': 'string',
+        'help': ('"what" number of the Name Assigning Authority to import '
+                 'concept through (only relevant for LSCV import format)'),
+    }),
+)
+
+
 def _skos_drop_rql_store():
     """Remove "rql" store from ImportSkosData command.
 
diff --git a/dev-requirements.txt b/dev-requirements.txt
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,3 +1,4 @@
 mock
 pytest
 webtest
+http://hg.logilab.org/review/cubes/skos/archive/tip.tar.bz2#egg=cubicweb-skos



More information about the saem-devel mailing list