fix: leverage import handler method to determine command/subcommand

just moved previous logic to rattail/handler
This commit is contained in:
Lance Edgar 2024-07-04 20:33:34 -05:00
parent 89d7009a18
commit ddec77c37f

View file

@ -34,7 +34,6 @@ import time
import sqlalchemy as sa import sqlalchemy as sa
from rattail.exceptions import ConfigurationError
from rattail.threads import Thread from rattail.threads import Thread
import colander import colander
@ -458,22 +457,7 @@ And here is the output:
return HTML.tag('div', class_='tailbone-markdown', c=[notes]) return HTML.tag('div', class_='tailbone-markdown', c=[notes])
def get_cmd_for_handler(self, handler, ignore_errors=False): def get_cmd_for_handler(self, handler, ignore_errors=False):
handler_key = handler.get_key() return handler.get_cmd(ignore_errors=ignore_errors)
cmd = self.rattail_config.getlist('rattail.importing',
'{}.cmd'.format(handler_key))
if not cmd or len(cmd) != 2:
cmd = self.rattail_config.getlist('rattail.importing',
'{}.default_cmd'.format(handler_key))
if not cmd or len(cmd) != 2:
msg = ("Missing or invalid config; please set '{}.default_cmd' in the "
"[rattail.importing] section of your config file".format(handler_key))
if ignore_errors:
return
raise ConfigurationError(msg)
return cmd
def get_runas_for_handler(self, handler): def get_runas_for_handler(self, handler):
handler_key = handler.get_key() handler_key = handler.get_key()