Commit 467c0736 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Extract a get_store function to let a chance to client cube to hack store creation

For instance in SAEM, we need a store with custom metadata generator that will
generate ark for imported concepts.
parent c74d8dd017ce
...@@ -106,18 +106,30 @@ def lcsv_check(cnx, store, fname, scheme_uri): ...@@ -106,18 +106,30 @@ def lcsv_check(cnx, store, fname, scheme_uri):
def init_seda_scheme(cnx, title): def init_seda_scheme(cnx, title):
"""Create a scheme to hold SEDA concepts with the given title.
Separated function to be monkey-patched if one need to customize the store (eg saem).
"""
description = u'edition 2009' if title.startswith('SEDA :') else None description = u'edition 2009' if title.startswith('SEDA :') else None
return cnx.create_entity('ConceptScheme', title=title, description=description) return cnx.create_entity('ConceptScheme', title=title, description=description)
def import_seda_schemes(cnx, lcsv_import=lcsv_import): def get_store(cnx):
"""Import all LCSV data files defined in LCSV_FILES""" """Return the store to be used to import LCSV data files.
Separated function to be monkey-patched if one needs to customize the store (eg saem).
"""
if cnx.repo.system_source.dbdriver == 'postgres': if cnx.repo.system_source.dbdriver == 'postgres':
from cubicweb.dataimport.massive_store import MassiveObjectStore from cubicweb.dataimport.massive_store import MassiveObjectStore
store = MassiveObjectStore(cnx, eids_seq_range=1000) return MassiveObjectStore(cnx, eids_seq_range=1000)
else: else:
from cubicweb.dataimport.stores import NoHookRQLObjectStore from cubicweb.dataimport.stores import NoHookRQLObjectStore
store = NoHookRQLObjectStore(cnx) return NoHookRQLObjectStore(cnx)
def import_seda_schemes(cnx, lcsv_import=lcsv_import):
"""Import all LCSV data files defined in LCSV_FILES."""
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): if not cnx.find('ConceptScheme', title=title):
print('importing', title.encode('utf-8')) print('importing', title.encode('utf-8'))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment