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
tool_class = eval('mod.' + pdata.toolclass)
options_class = eval('mod.' + pdata.optionclass)
tool.cli_tool(self.dbstate, name, category, tool_class,
options_class, options_str_dict)
tool.cli_tool(
dbstate=self.dbstate,
name=name,
category=category,
tool_class=tool_class,
options_class=options_class,
options_str_dict=options_str_dict)
return
msg = _("Unknown tool name.")
else:

View File

@ -248,11 +248,15 @@ class PluginDialog(ManagedWindow):
pdata.name, pdata.id,
pdata.category, pdata.require_active)
else:
tool.gui_tool(self.state, self.uistate,
eval('mod.' + pdata.toolclass),
eval('mod.' + pdata.optionclass),
pdata.name, pdata.id, pdata.category,
self.state.db.request_rebuild)
tool.gui_tool(
dbstate = self.state,
uistate = self.uistate,
tool_class = eval('mod.' + pdata.toolclass),
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:
tool_class(dbstate, uistate, options_class, name, callback)
tool_class(dbstate = dbstate, uistate = uistate,
options_class = options_class, name = name,
callback = callback)
except WindowActiveError:
pass
except:
@ -272,7 +274,8 @@ def cli_tool(dbstate, name, category, tool_class, options_class, options_str_dic
# run tool
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:
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,
)
else:
tool.gui_tool(dbstate, uistate,
getattr(mod, pdata.toolclass),
getattr(mod, pdata.optionclass),
pdata.name, pdata.id, pdata.category,
dbstate.db.request_rebuild)
tool.gui_tool(dbstate = dbstate, uistate = uistate,
tool_class = getattr(mod, pdata.toolclass),
options_class = getattr(mod, pdata.optionclass),
translated_name = pdata.name,
name = pdata.id,
category = pdata.category,
callback = dbstate.db.request_rebuild)
def make_plugin_callback(pdata, dbstate, uistate):
"""