diff --git a/gramps/cli/arghandler.py b/gramps/cli/arghandler.py index 275053d14..490548170 100644 --- a/gramps/cli/arghandler.py +++ b/gramps/cli/arghandler.py @@ -652,7 +652,8 @@ class ArgHandler(object): category=category, tool_class=tool_class, options_class=options_class, - options_str_dict=options_str_dict) + options_str_dict=options_str_dict, + user=self.user) return msg = _("Unknown tool name.") else: diff --git a/gramps/cli/grampscli.py b/gramps/cli/grampscli.py index 03cfe04ef..99b41e7e3 100644 --- a/gramps/cli/grampscli.py +++ b/gramps/cli/grampscli.py @@ -339,8 +339,7 @@ def startcli(errors, argparser): #we need a manager for the CLI session from .user import User - user=User(error=self.__error, - auto_accept=argparser.auto_accept, + user=User(auto_accept=argparser.auto_accept, quiet=argparser.quiet) climanager = CLIManager(dbstate, setloader=True, user=user) diff --git a/gramps/gen/user.py b/gramps/gen/user.py index cb6975bb1..a634983cf 100644 --- a/gramps/gen/user.py +++ b/gramps/gen/user.py @@ -36,6 +36,7 @@ class User(): self.callback_function = callback self.error_function = error self._fileout = sys.stderr # redirected to mocks by unit tests + self.uistate = None def begin_progress(self, title, message, steps): """ diff --git a/gramps/gui/plug/_dialogs.py b/gramps/gui/plug/_dialogs.py index 12a9a07fa..7ea933517 100644 --- a/gramps/gui/plug/_dialogs.py +++ b/gramps/gui/plug/_dialogs.py @@ -248,9 +248,10 @@ class PluginDialog(ManagedWindow): pdata.name, pdata.id, pdata.category, pdata.require_active) else: + from ..user import User tool.gui_tool( dbstate = self.state, - uistate = self.uistate, + user = User(uistate=self.uistate), tool_class = eval('mod.' + pdata.toolclass), options_class = eval('mod.' + pdata.optionclass), translated_name = pdata.name, diff --git a/gramps/gui/plug/_windows.py b/gramps/gui/plug/_windows.py index 8409d9513..71996c00a 100644 --- a/gramps/gui/plug/_windows.py +++ b/gramps/gui/plug/_windows.py @@ -1046,7 +1046,8 @@ class ToolManagedWindowBase(ManagedWindow): class ToolManagedWindowBatch(tool.BatchTool, ToolManagedWindowBase): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate # This constructor will ask a question, set self.fail: self.dbstate = dbstate self.uistate = uistate diff --git a/gramps/gui/plug/tool.py b/gramps/gui/plug/tool.py index 62f9e1ccf..4b5a132a5 100644 --- a/gramps/gui/plug/tool.py +++ b/gramps/gui/plug/tool.py @@ -244,7 +244,7 @@ class CommandLineTool(object): #------------------------------------------------------------------------ # Standard GUI tool generic task -def gui_tool(dbstate, uistate, tool_class, options_class, translated_name, +def gui_tool(dbstate, user, tool_class, options_class, translated_name, name, category, callback): """ tool - task starts the report. The plugin system requires that the @@ -253,7 +253,7 @@ def gui_tool(dbstate, uistate, tool_class, options_class, translated_name, """ try: - tool_class(dbstate = dbstate, uistate = uistate, + tool_class(dbstate = dbstate, user = user, options_class = options_class, name = name, callback = callback) except WindowActiveError: @@ -262,7 +262,7 @@ def gui_tool(dbstate, uistate, tool_class, options_class, translated_name, log.error("Failed to start tool.", exc_info=True) # Command-line generic task -def cli_tool(dbstate, name, category, tool_class, options_class, options_str_dict): +def cli_tool(dbstate, name, category, tool_class, options_class, options_str_dict, user = None): clt = CommandLineTool(dbstate.db, name, category, options_class, options_str_dict) @@ -272,9 +272,12 @@ def cli_tool(dbstate, name, category, tool_class, options_class, options_str_dic if clt.show: return + if user is None: + from ...cli.user import User + user = User() # run tool try: - tool_class(dbstate = dbstate, uistate = None, + tool_class(dbstate = dbstate, user = user, options_class = clt.option_class, name = name, callback = None) except: log.error("Failed to start tool.", exc_info=True) diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index c9846d02f..952869dda 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -1626,7 +1626,7 @@ def run_plugin(pdata, dbstate, uistate): pdata.category, pdata.require_active, ) else: - tool.gui_tool(dbstate = dbstate, uistate = uistate, + tool.gui_tool(dbstate = dbstate, user = User(uistate = uistate), tool_class = getattr(mod, pdata.toolclass), options_class = getattr(mod, pdata.optionclass), translated_name = pdata.name, diff --git a/gramps/plugins/tool/changenames.py b/gramps/plugins/tool/changenames.py index b420f68b0..fd6dcecaa 100644 --- a/gramps/plugins/tool/changenames.py +++ b/gramps/plugins/tool/changenames.py @@ -72,7 +72,8 @@ WIKI_HELP_SEC = _('manual|Fix_Capitalization_of_Family_Names...') #------------------------------------------------------------------------- class ChangeNames(tool.BatchTool, ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = _('Capitalization changes') self.cb = callback diff --git a/gramps/plugins/tool/changetypes.py b/gramps/plugins/tool/changetypes.py index 93a19797d..af4955cd9 100644 --- a/gramps/plugins/tool/changetypes.py +++ b/gramps/plugins/tool/changetypes.py @@ -54,7 +54,8 @@ from gramps.gui.glade import Glade #------------------------------------------------------------------------- class ChangeTypes(tool.BatchTool, ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.BatchTool.__init__(self, dbstate, uistate, options_class, name) if self.fail: diff --git a/gramps/plugins/tool/check.py b/gramps/plugins/tool/check.py index 00643aa83..ffa27d5df 100644 --- a/gramps/plugins/tool/check.py +++ b/gramps/plugins/tool/check.py @@ -135,7 +135,8 @@ def cross_table_duplicates(db): # #------------------------------------------------------------------------- class Check(tool.BatchTool): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.BatchTool.__init__(self, dbstate, uistate, options_class, name) if self.fail: diff --git a/gramps/plugins/tool/dateparserdisplaytest.py b/gramps/plugins/tool/dateparserdisplaytest.py index 1244e9757..3d7a3031d 100644 --- a/gramps/plugins/tool/dateparserdisplaytest.py +++ b/gramps/plugins/tool/dateparserdisplaytest.py @@ -59,7 +59,8 @@ from gramps.gen.datehandler import displayer as _dd #------------------------------------------------------------------------- class DateParserDisplayTest(tool.Tool): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) if uistate: diff --git a/gramps/plugins/tool/desbrowser.py b/gramps/plugins/tool/desbrowser.py index 0b543ec01..ded1da3fe 100644 --- a/gramps/plugins/tool/desbrowser.py +++ b/gramps/plugins/tool/desbrowser.py @@ -57,7 +57,8 @@ WIKI_HELP_SEC = _('manual|Interactive_Descendant_Browser...') class DesBrowse(tool.ActivePersonTool, ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.ActivePersonTool.__init__(self, dbstate, uistate, options_class, name) diff --git a/gramps/plugins/tool/dumpgenderstats.py b/gramps/plugins/tool/dumpgenderstats.py index 010186d14..80931f06e 100644 --- a/gramps/plugins/tool/dumpgenderstats.py +++ b/gramps/plugins/tool/dumpgenderstats.py @@ -45,7 +45,8 @@ _GENDER = [ _('female'), _('male'), _('unknown') ] #------------------------------------------------------------------------- class DumpGenderStats(tool.Tool, ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = _("Gender Statistics tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: diff --git a/gramps/plugins/tool/eval.py b/gramps/plugins/tool/eval.py index e4cfbfc2e..3489968bc 100644 --- a/gramps/plugins/tool/eval.py +++ b/gramps/plugins/tool/eval.py @@ -55,7 +55,8 @@ from gramps.gen.constfunc import cuni # #------------------------------------------------------------------------- class Eval(tool.Tool,ManagedWindow): - def __init__(self,dbstate, uistate, options_class, name, callback=None): + def __init__(self,dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.title = _("Python evaluation window") tool.Tool.__init__(self,dbstate, options_class, name) diff --git a/gramps/plugins/tool/eventcmp.py b/gramps/plugins/tool/eventcmp.py index 6c3d1e5b9..d9fa9ff26 100644 --- a/gramps/plugins/tool/eventcmp.py +++ b/gramps/plugins/tool/eventcmp.py @@ -117,7 +117,8 @@ class TableReport(object): # #------------------------------------------------------------------------ class EventComparison(tool.Tool,ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.dbstate = dbstate self.uistate = uistate diff --git a/gramps/plugins/tool/eventnames.py b/gramps/plugins/tool/eventnames.py index 5ece3fe03..9c05bb5ca 100644 --- a/gramps/plugins/tool/eventnames.py +++ b/gramps/plugins/tool/eventnames.py @@ -68,7 +68,8 @@ class EventNames(tool.BatchTool, ManagedWindow): """ - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.BatchTool.__init__(self, dbstate, uistate, options_class, name) if not self.fail: diff --git a/gramps/plugins/tool/extractcity.py b/gramps/plugins/tool/extractcity.py index 27d100a52..188c2a6e0 100644 --- a/gramps/plugins/tool/extractcity.py +++ b/gramps/plugins/tool/extractcity.py @@ -413,7 +413,8 @@ class ExtractCity(tool.BatchTool, ManagedWindow): or Paris, ILE DE FRANCE 75000, FRA """ - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = _('Extract Place data') ManagedWindow.__init__(self, uistate, [], self.__class__) diff --git a/gramps/plugins/tool/finddupes.py b/gramps/plugins/tool/finddupes.py index b2771a5c5..8a853758c 100644 --- a/gramps/plugins/tool/finddupes.py +++ b/gramps/plugins/tool/finddupes.py @@ -88,7 +88,8 @@ def is_initial(name): #------------------------------------------------------------------------- class Merge(tool.Tool,ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, uistate, [], diff --git a/gramps/plugins/tool/leak.py b/gramps/plugins/tool/leak.py index 648c108eb..bf7c26794 100644 --- a/gramps/plugins/tool/leak.py +++ b/gramps/plugins/tool/leak.py @@ -67,7 +67,8 @@ from gramps.gui.utils import is_right_click # #------------------------------------------------------------------------- class Leak(tool.Tool, ManagedWindow): - def __init__(self,dbstate, uistate, options_class, name, callback=None): + def __init__(self,dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.title = _('Uncollected Objects Tool') tool.Tool.__init__(self,dbstate, options_class, name) diff --git a/gramps/plugins/tool/mediamanager.py b/gramps/plugins/tool/mediamanager.py index 4a57c18d2..a27c7f3e3 100644 --- a/gramps/plugins/tool/mediamanager.py +++ b/gramps/plugins/tool/mediamanager.py @@ -78,7 +78,8 @@ WIKI_HELP_SEC = _('manual|Media_Manager...') #------------------------------------------------------------------------- class MediaMan(tool.Tool): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) self.uistate = uistate diff --git a/gramps/plugins/tool/mergecitations.py b/gramps/plugins/tool/mergecitations.py index bd6826d89..08c3dbb10 100644 --- a/gramps/plugins/tool/mergecitations.py +++ b/gramps/plugins/tool/mergecitations.py @@ -92,7 +92,8 @@ WIKI_HELP_SEC = _('manual|Merge citations...') #------------------------------------------------------------------------- class MergeCitations(tool.BatchTool,ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate diff --git a/gramps/plugins/tool/notrelated.py b/gramps/plugins/tool/notrelated.py index cdcd3c04e..05534e1a6 100644 --- a/gramps/plugins/tool/notrelated.py +++ b/gramps/plugins/tool/notrelated.py @@ -68,7 +68,8 @@ WIKI_HELP_SEC = _('manual|Not_Related...') #------------------------------------------------------------------------ class NotRelated(tool.ActivePersonTool, ManagedWindow) : - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.ActivePersonTool.__init__(self, dbstate, uistate, options_class, name) diff --git a/gramps/plugins/tool/ownereditor.py b/gramps/plugins/tool/ownereditor.py index dfa7f91f8..faa10326e 100644 --- a/gramps/plugins/tool/ownereditor.py +++ b/gramps/plugins/tool/ownereditor.py @@ -86,7 +86,8 @@ class OwnerEditor(tool.Tool, ManagedWindow): Provides a possibility to direcly verify and edit the owner data of the current database. It also allows copying data from/to the preferences. """ - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate ManagedWindow.__init__(self, uistate, [], self.__class__) tool.Tool.__init__(self, dbstate, options_class, name) diff --git a/gramps/plugins/tool/patchnames.py b/gramps/plugins/tool/patchnames.py index ffedd6e2d..bf81bc8b7 100644 --- a/gramps/plugins/tool/patchnames.py +++ b/gramps/plugins/tool/patchnames.py @@ -103,7 +103,8 @@ class PatchNames(tool.BatchTool, ManagedWindow): pref1id = 3 compid = 4 - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = _('Name and title extraction tool') ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') diff --git a/gramps/plugins/tool/populatesources.py b/gramps/plugins/tool/populatesources.py index 2a95a30fd..cf18c4457 100644 --- a/gramps/plugins/tool/populatesources.py +++ b/gramps/plugins/tool/populatesources.py @@ -54,7 +54,8 @@ class PopulateSources(tool.Tool, ManagedWindow): Gramplet that populates the database with sources and citations. """ - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = 'Populate sources and citations tool' ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') diff --git a/gramps/plugins/tool/rebuild.py b/gramps/plugins/tool/rebuild.py index ba79199ab..9965134cb 100644 --- a/gramps/plugins/tool/rebuild.py +++ b/gramps/plugins/tool/rebuild.py @@ -64,7 +64,8 @@ from gramps.gen.updatecallback import UpdateCallback #------------------------------------------------------------------------- class Rebuild(tool.Tool, UpdateCallback): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) diff --git a/gramps/plugins/tool/rebuildgenderstat.py b/gramps/plugins/tool/rebuildgenderstat.py index c96645f20..0087ff54c 100644 --- a/gramps/plugins/tool/rebuildgenderstat.py +++ b/gramps/plugins/tool/rebuildgenderstat.py @@ -70,7 +70,8 @@ COLUMN_ALTNAMES = 4 class RebuildGenderStat(tool.Tool, UpdateCallback): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) diff --git a/gramps/plugins/tool/rebuildrefmap.py b/gramps/plugins/tool/rebuildrefmap.py index ed194d41b..2d3a76a44 100644 --- a/gramps/plugins/tool/rebuildrefmap.py +++ b/gramps/plugins/tool/rebuildrefmap.py @@ -66,7 +66,8 @@ from gramps.gen.updatecallback import UpdateCallback #------------------------------------------------------------------------- class RebuildRefMap(tool.Tool, UpdateCallback): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) diff --git a/gramps/plugins/tool/relcalc.py b/gramps/plugins/tool/relcalc.py index ae5a1e4dd..d0b91c833 100644 --- a/gramps/plugins/tool/relcalc.py +++ b/gramps/plugins/tool/relcalc.py @@ -71,7 +71,8 @@ column_names = [column[0] for column in BasePersonView.COLUMNS] #------------------------------------------------------------------------- class RelCalc(tool.Tool, ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate """ Relationship calculator class. """ diff --git a/gramps/plugins/tool/removeunused.py b/gramps/plugins/tool/removeunused.py index e57af8455..9096c24a9 100644 --- a/gramps/plugins/tool/removeunused.py +++ b/gramps/plugins/tool/removeunused.py @@ -77,7 +77,8 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback): OBJ_TYPE_COL = 3 OBJ_HANDLE_COL = 4 - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.title = _('Unused Objects') tool.Tool.__init__(self, dbstate, options_class, name) diff --git a/gramps/plugins/tool/reorderids.py b/gramps/plugins/tool/reorderids.py index 4ec040be0..55b7e915e 100644 --- a/gramps/plugins/tool/reorderids.py +++ b/gramps/plugins/tool/reorderids.py @@ -59,7 +59,8 @@ _parseformat = re.compile('.*%(\d+)[^\d]+') # #------------------------------------------------------------------------- class ReorderIds(tool.BatchTool): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate tool.BatchTool.__init__(self, dbstate, uistate, options_class, name) if self.fail: return diff --git a/gramps/plugins/tool/soundgen.py b/gramps/plugins/tool/soundgen.py index e000f6d06..73a931623 100644 --- a/gramps/plugins/tool/soundgen.py +++ b/gramps/plugins/tool/soundgen.py @@ -56,7 +56,8 @@ WIKI_HELP_SEC = _('manual|Generate_SoundEx_codes') class SoundGen(tool.Tool, ManagedWindow): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = _('SoundEx code generator') tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self,uistate,[],self.__class__) diff --git a/gramps/plugins/tool/testcasegenerator.py b/gramps/plugins/tool/testcasegenerator.py index deaa6e86a..0d9a404ab 100644 --- a/gramps/plugins/tool/testcasegenerator.py +++ b/gramps/plugins/tool/testcasegenerator.py @@ -116,7 +116,8 @@ class TestcaseGenerator(tool.BatchTool): EventType.MARR_SETTL, EventType.CUSTOM ]) - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.person = None if dbstate.db.readonly: return diff --git a/gramps/plugins/tool/verify.py b/gramps/plugins/tool/verify.py index 19063155e..aa794c802 100644 --- a/gramps/plugins/tool/verify.py +++ b/gramps/plugins/tool/verify.py @@ -254,7 +254,8 @@ def get_marriage_date(db, family): #------------------------------------------------------------------------- class Verify(tool.Tool, ManagedWindow, UpdateCallback): - def __init__(self, dbstate, uistate, options_class, name, callback=None): + def __init__(self, dbstate, user, options_class, name, callback=None): + uistate = user.uistate self.label = _('Data Verify tool') self.vr = None tool.Tool.__init__(self, dbstate, options_class, name)