Add core-office import-csv command; deprecate crepes import-csv

This commit is contained in:
Lance Edgar 2023-06-09 19:53:47 -05:00
parent 6267205966
commit 2cf865d879
5 changed files with 46 additions and 31 deletions

View file

@ -96,6 +96,32 @@ class GetConfigValue(commands.Subcommand):
self.stdout.write(f"{value}\n")
class ImportCSV(commands.ImportFileSubcommand):
"""
Import data from CSV to CORE Office "op" DB
"""
name = 'import-csv'
description = __doc__.strip()
handler_key = 'to_corepos_db_office_op.from_csv.import'
def add_parser_args(self, parser):
super().add_parser_args(parser)
parser.add_argument('--dbkey', metavar='KEY', default='default',
help="Config key for database engine to be used as the \"target\" "
"CORE DB, i.e. where data will be imported *to*. This key must be "
"defined in the [corepos.db.office_op] section of your config file.")
def get_handler_kwargs(self, **kwargs):
kwargs = super().get_handler_kwargs(**kwargs)
if 'args' in kwargs:
args = kwargs['args']
kwargs['dbkey'] = args.dbkey
return kwargs
class ImportSelf(commands.ImportSubcommand):
"""
Import data from CORE Office ("op" DB) to "self"

View file

@ -28,8 +28,7 @@ from corepos.db.office_op import model as corepos, Session as CoreSession
from rattail.importing.handlers import FromFileHandler
from rattail.importing.csv import FromCSVToSQLAlchemyMixin
from rattail_corepos.corepos.office.importing.db.model import ToCore
from rattail_corepos.corepos.office.importing.db.corepos import ToCoreHandler
from rattail_corepos.corepos.office.importing.db.model import ToCoreHandler, ToCore
class FromCSVToCore(FromCSVToSQLAlchemyMixin, FromFileHandler, ToCoreHandler):
@ -39,10 +38,6 @@ class FromCSVToCore(FromCSVToSQLAlchemyMixin, FromFileHandler, ToCoreHandler):
host_title = "CSV"
ToParent = ToCore
@property
def local_title(self):
return "CORE ({})".format(self.dbkey)
def get_model(self):
return corepos