OMG a ridiculous commit to overhaul import handler config etc.
- register all import/export handlers via setup.py and config - use "handler key" lookup for all import/export commands - fix logic bugs w/ CORE -> Trainwreck importer
This commit is contained in:
parent
0e28a6ee2b
commit
3140245857
9 changed files with 122 additions and 97 deletions
|
@ -34,15 +34,7 @@ class ExportCore(commands.ImportSubcommand):
|
|||
"""
|
||||
name = 'export-corepos'
|
||||
description = __doc__.strip()
|
||||
default_handler_spec = 'rattail_corepos.corepos.importing.rattail:FromRattailToCore'
|
||||
|
||||
def get_handler_factory(self, **kwargs):
|
||||
if self.config:
|
||||
spec = self.config.get('rattail.exporting', 'corepos.handler',
|
||||
default=self.default_handler_spec)
|
||||
else:
|
||||
spec = self.default_handler_spec
|
||||
return load_object(spec)
|
||||
handler_key = 'to_corepos_api.from_rattail.export'
|
||||
|
||||
|
||||
class ImportCOREPOSAPI(commands.ImportSubcommand):
|
||||
|
@ -51,15 +43,7 @@ class ImportCOREPOSAPI(commands.ImportSubcommand):
|
|||
"""
|
||||
name = 'import-corepos-api'
|
||||
description = __doc__.strip()
|
||||
default_handler_spec = 'rattail_corepos.importing.corepos.api:FromCOREPOSToRattail'
|
||||
|
||||
def get_handler_factory(self, **kwargs):
|
||||
if self.config:
|
||||
spec = self.config.get('rattail.importing', 'corepos_api.handler',
|
||||
default=self.default_handler_spec)
|
||||
else:
|
||||
spec = self.default_handler_spec
|
||||
return load_object(spec)
|
||||
handler_key = 'to_rattail.from_corepos_api.import'
|
||||
|
||||
|
||||
class ImportCOREPOSDB(commands.ImportSubcommand):
|
||||
|
@ -68,6 +52,7 @@ class ImportCOREPOSDB(commands.ImportSubcommand):
|
|||
"""
|
||||
name = 'import-corepos-db'
|
||||
description = __doc__.strip()
|
||||
handler_key = 'to_rattail.from_corepos_db_office_op.import'
|
||||
|
||||
def add_parser_args(self, parser):
|
||||
super(ImportCOREPOSDB, self).add_parser_args(parser)
|
||||
|
@ -77,14 +62,6 @@ class ImportCOREPOSDB(commands.ImportSubcommand):
|
|||
"defined in the [rattail_corepos.db] section of your config file. "
|
||||
"Defaults to 'default'.")
|
||||
|
||||
def get_handler_factory(self, **kwargs):
|
||||
if self.config:
|
||||
spec = self.config.get('rattail.importing', 'corepos.handler',
|
||||
default='rattail_corepos.importing.corepos:FromCOREPOSToRattail')
|
||||
else:
|
||||
spec = 'rattail_corepos.importing.corepos:FromCOREPOSToRattail'
|
||||
return load_object(spec)
|
||||
|
||||
def get_handler_kwargs(self, **kwargs):
|
||||
if 'args' in kwargs:
|
||||
kwargs['corepos_dbkey'] = kwargs['args'].corepos_dbkey
|
||||
|
@ -97,4 +74,4 @@ class CoreImportSquare(commands.ImportFromCSV):
|
|||
"""
|
||||
name = 'corepos-import-square'
|
||||
description = __doc__.strip()
|
||||
handler_spec = 'rattail_corepos.corepos.importing.square:FromSquareToCoreTrans'
|
||||
handler_key = 'to_corepos_db_office_trans.from_square_csv.import'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue