5598: implement User() class for tools

refactoring in progress - convert calling the tools' classes
using positional syntax

svn: r23032
This commit is contained in:
Vassilii Khachaturov 2013-09-04 14:44:19 +00:00
parent 4cf8c95170
commit acdf385509
4 changed files with 28 additions and 14 deletions

View File

@ -650,8 +650,13 @@ class ArgHandler(object):
category = pdata.category category = pdata.category
tool_class = eval('mod.' + pdata.toolclass) tool_class = eval('mod.' + pdata.toolclass)
options_class = eval('mod.' + pdata.optionclass) options_class = eval('mod.' + pdata.optionclass)
tool.cli_tool(self.dbstate, name, category, tool_class, tool.cli_tool(
options_class, options_str_dict) dbstate=self.dbstate,
name=name,
category=category,
tool_class=tool_class,
options_class=options_class,
options_str_dict=options_str_dict)
return return
msg = _("Unknown tool name.") msg = _("Unknown tool name.")
else: else:

View File

@ -248,11 +248,15 @@ class PluginDialog(ManagedWindow):
pdata.name, pdata.id, pdata.name, pdata.id,
pdata.category, pdata.require_active) pdata.category, pdata.require_active)
else: else:
tool.gui_tool(self.state, self.uistate, tool.gui_tool(
eval('mod.' + pdata.toolclass), dbstate = self.state,
eval('mod.' + pdata.optionclass), uistate = self.uistate,
pdata.name, pdata.id, pdata.category, tool_class = eval('mod.' + pdata.toolclass),
self.state.db.request_rebuild) options_class = eval('mod.' + pdata.optionclass),
translated_name = pdata.name,
name = pdata.id,
category = pdata.category,
callback = self.state.db.request_rebuild)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -253,7 +253,9 @@ def gui_tool(dbstate, uistate, tool_class, options_class, translated_name,
""" """
try: try:
tool_class(dbstate, uistate, options_class, name, callback) tool_class(dbstate = dbstate, uistate = uistate,
options_class = options_class, name = name,
callback = callback)
except WindowActiveError: except WindowActiveError:
pass pass
except: except:
@ -272,7 +274,8 @@ def cli_tool(dbstate, name, category, tool_class, options_class, options_str_dic
# run tool # run tool
try: try:
tool_class(dbstate, None, clt.option_class, name, None) tool_class(dbstate = dbstate, uistate = None,
options_class = clt.option_class, name = name, callback = None)
except: except:
log.error("Failed to start tool.", exc_info=True) log.error("Failed to start tool.", exc_info=True)

View File

@ -1628,11 +1628,13 @@ def run_plugin(pdata, dbstate, uistate):
pdata.category, pdata.require_active, pdata.category, pdata.require_active,
) )
else: else:
tool.gui_tool(dbstate, uistate, tool.gui_tool(dbstate = dbstate, uistate = uistate,
getattr(mod, pdata.toolclass), tool_class = getattr(mod, pdata.toolclass),
getattr(mod, pdata.optionclass), options_class = getattr(mod, pdata.optionclass),
pdata.name, pdata.id, pdata.category, translated_name = pdata.name,
dbstate.db.request_rebuild) name = pdata.id,
category = pdata.category,
callback = dbstate.db.request_rebuild)
def make_plugin_callback(pdata, dbstate, uistate): def make_plugin_callback(pdata, dbstate, uistate):
""" """