From 82aac3836f90f3ff8a3c8a4594e93e8309f413e4 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Wed, 15 Apr 2009 19:27:17 +0000 Subject: [PATCH] plugins/tools: make file path build logic conform to Python standards svn: r12450 --- src/plugins/tool/ChangeTypes.py | 13 +++++++++++-- src/plugins/tool/Check.py | 13 +++++++++++-- src/plugins/tool/Desbrowser.py | 11 +++++------ src/plugins/tool/Eval.py | 14 +++++++++++--- src/plugins/tool/FindDupes.py | 9 ++++++--- src/plugins/tool/Leak.py | 12 +++++++++++- src/plugins/tool/NotRelated.py | 7 +++++-- src/plugins/tool/RelCalc.py | 13 +++++++++++-- src/plugins/tool/RemoveUnused.py | 16 +++++++++++++--- src/plugins/tool/SoundGen.py | 7 +++++-- src/plugins/tool/Verify.py | 17 ++++++++++------- 11 files changed, 99 insertions(+), 33 deletions(-) diff --git a/src/plugins/tool/ChangeTypes.py b/src/plugins/tool/ChangeTypes.py index 08bca0782..676e53102 100644 --- a/src/plugins/tool/ChangeTypes.py +++ b/src/plugins/tool/ChangeTypes.py @@ -53,6 +53,13 @@ from QuestionDialog import OkDialog from PluginUtils import Tool from gen.plug import PluginManager +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "changetype.glade" + #------------------------------------------------------------------------- # # @@ -77,8 +84,10 @@ class ChangeTypes(Tool.BatchTool, ManagedWindow.ManagedWindow): def init_gui(self): # Draw dialog and make it handle everything - base = os.path.dirname(__file__) - glade_file = base + os.sep + "changetype.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.glade = gtk.Builder() self.glade.add_from_file(glade_file) diff --git a/src/plugins/tool/Check.py b/src/plugins/tool/Check.py index 65516579c..e4f0eba36 100644 --- a/src/plugins/tool/Check.py +++ b/src/plugins/tool/Check.py @@ -65,6 +65,13 @@ from gen.plug import PluginManager from QuestionDialog import OkDialog, MissingMediaDialog from BasicUtils import name_displayer as _nd +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "summary.glade" + #------------------------------------------------------------------------- # # Low Level repair @@ -1621,8 +1628,10 @@ class Report(ManagedWindow.ManagedWindow): ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) - base = os.path.dirname(__file__) - glade_file = base + os.sep + "summary.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + topDialog = gtk.Builder() topDialog.add_from_file(glade_file) topDialog.get_object("close").connect('clicked',self.close) diff --git a/src/plugins/tool/Desbrowser.py b/src/plugins/tool/Desbrowser.py index bd259d114..ded77bdf7 100644 --- a/src/plugins/tool/Desbrowser.py +++ b/src/plugins/tool/Desbrowser.py @@ -56,10 +56,7 @@ from TransUtils import sgettext as _ #------------------------------------------------------------------------ WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Interactive_Descendant_Browser...') - - - - +_GLADE_FILE = "desbrowse.glade" class DesBrowse(Tool.ActivePersonTool, ManagedWindow.ManagedWindow): @@ -77,8 +74,10 @@ class DesBrowse(Tool.ActivePersonTool, ManagedWindow.ManagedWindow): ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) - base = os.path.dirname(__file__) - glade_file = base + os.sep + "desbrowse.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.glade = gtk.Builder() self.glade.add_from_file(glade_file) self.glade.connect_signals({ diff --git a/src/plugins/tool/Eval.py b/src/plugins/tool/Eval.py index 3685fe00f..78edef1ad 100644 --- a/src/plugins/tool/Eval.py +++ b/src/plugins/tool/Eval.py @@ -50,6 +50,13 @@ from PluginUtils import Tool from gen.plug import PluginManager import ManagedWindow +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "eval.glade" + #------------------------------------------------------------------------- # # Actual tool @@ -62,9 +69,10 @@ class Eval(Tool.Tool,ManagedWindow.ManagedWindow): Tool.Tool.__init__(self,dbstate, options_class, name) ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__) - base = os.path.dirname(__file__) - glade_file = base + os.sep + "eval.glade" - glade_file = '/tmp/eval.glade' + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.glade = gtk.Builder() self.glade.add_from_file(glade_file) diff --git a/src/plugins/tool/FindDupes.py b/src/plugins/tool/FindDupes.py index 4cf5501fe..698e3d45d 100644 --- a/src/plugins/tool/FindDupes.py +++ b/src/plugins/tool/FindDupes.py @@ -71,6 +71,7 @@ _val2label = { WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Find_Possible_Duplicate_People...') +_GLADE_FILE = "merge.glade" #------------------------------------------------------------------------- # # @@ -108,9 +109,11 @@ class Merge(Tool.Tool,ManagedWindow.ManagedWindow): self.update = callback self.use_soundex = 1 - base = os.path.dirname(__file__) - self.glade_file = base + os.sep + "merge.glade" - top = glade.XML(self.glade_file,"dialog","gramps") + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + + top = glade.XML(glade_file,"dialog","gramps") # retrieve options threshold = self.options.handler.options_dict['threshold'] diff --git a/src/plugins/tool/Leak.py b/src/plugins/tool/Leak.py index 83f38a847..390114c38 100644 --- a/src/plugins/tool/Leak.py +++ b/src/plugins/tool/Leak.py @@ -53,6 +53,13 @@ from gen.plug import PluginManager import ManagedWindow from QuestionDialog import InfoDialog +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "leak.glade" + #------------------------------------------------------------------------- # # Actual tool @@ -65,7 +72,10 @@ class Leak(Tool.Tool,ManagedWindow.ManagedWindow): Tool.Tool.__init__(self,dbstate, options_class, name) ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__) - glade_file = os.path.dirname(__file__) + os.sep + "leak.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.glade = gtk.Builder() self.glade.add_from_file(glade_file) diff --git a/src/plugins/tool/NotRelated.py b/src/plugins/tool/NotRelated.py index 88e4fbe09..4d474432e 100644 --- a/src/plugins/tool/NotRelated.py +++ b/src/plugins/tool/NotRelated.py @@ -61,6 +61,7 @@ from TransUtils import sgettext as _ #------------------------------------------------------------------------- WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Not_Related...') +_GLADE_FILE = "NotRelated.glade" #------------------------------------------------------------------------ # # @@ -82,8 +83,10 @@ class NotRelated(Tool.ActivePersonTool, ManagedWindow.ManagedWindow) : self.uistate = uistate self.db = dbstate.db - base = os.path.dirname(__file__) - glade_file = base + os.sep + "NotRelated.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + topDialog = gtk.Builder() topDialog.add_from_file(glade_file) diff --git a/src/plugins/tool/RelCalc.py b/src/plugins/tool/RelCalc.py index 80edd5a1e..541d23403 100644 --- a/src/plugins/tool/RelCalc.py +++ b/src/plugins/tool/RelCalc.py @@ -51,6 +51,13 @@ from QuestionDialog import ErrorDialog from PluginUtils import Tool from gen.plug import PluginManager +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "relcalc.glade" + column_names = [ _('Name'), _('ID') , @@ -84,8 +91,10 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow): self.relationship = pmgr.get_relationship_calculator() self.relationship.connect_db_signals(dbstate) - base = os.path.dirname(__file__) - glade_file = base + os.sep + "relcalc.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.glade = gtk.Builder() self.glade.add_from_file(glade_file) diff --git a/src/plugins/tool/RemoveUnused.py b/src/plugins/tool/RemoveUnused.py index 418c402f5..b56f06f44 100644 --- a/src/plugins/tool/RemoveUnused.py +++ b/src/plugins/tool/RemoveUnused.py @@ -61,6 +61,14 @@ from BasicUtils import UpdateCallback from PluginUtils import Tool from gen.plug import PluginManager +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +_GLADE_FILE = "unused.glade" + + #------------------------------------------------------------------------- # # runTool @@ -129,11 +137,13 @@ class RemoveUnused(Tool.Tool,ManagedWindow.ManagedWindow,UpdateCallback): self.init_gui() def init_gui(self): - base = os.path.dirname(__file__) - self.glade_file = base + os.sep + "unused.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.top = gtk.Builder() - self.top.add_from_file(self.glade_file) + self.top.add_from_file(glade_file) window = self.top.get_object("unused") self.set_window(window,self.top.get_object('title'),self.title) diff --git a/src/plugins/tool/SoundGen.py b/src/plugins/tool/SoundGen.py index 2659a2e81..b00e6077f 100644 --- a/src/plugins/tool/SoundGen.py +++ b/src/plugins/tool/SoundGen.py @@ -58,6 +58,8 @@ from gen.plug import PluginManager #------------------------------------------------------------------------- WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Generate_SoundEx_codes') +_GLADE_FILE = "soundex.glade" + #------------------------------------------------------------------------- # # SoundGen.py @@ -71,8 +73,9 @@ class SoundGen(Tool.Tool, ManagedWindow.ManagedWindow): Tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__) - base = os.path.dirname(__file__) - glade_file = base + os.sep + "soundex.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) self.glade = gtk.Builder() self.glade.add_from_file(glade_file) diff --git a/src/plugins/tool/Verify.py b/src/plugins/tool/Verify.py index 72e4e2312..953989e12 100644 --- a/src/plugins/tool/Verify.py +++ b/src/plugins/tool/Verify.py @@ -68,6 +68,7 @@ from TransUtils import sgettext as _ #------------------------------------------------------------------------- WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Verify_the_Data...') +_GLADE_FILE = "verify.glade" #------------------------------------------------------------------------- # @@ -245,13 +246,13 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback): def init_gui(self): # Draw dialog and make it handle everything - base = os.path.dirname(__file__) - self.glade_file = base + os.sep + "verify.glade" self.vr = None + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) self.top = gtk.Builder() -# self.add_from_file(self.glade_file),"verify_settings","gramps") - self.top.add_from_file(self.glade_file) + self.top.add_from_file(glade_file) self.top.connect_signals({ "destroy_passed_object" : self.close, "on_help_clicked" : self.on_help_clicked, @@ -413,10 +414,12 @@ class VerifyResults(ManagedWindow): self.dbstate = dbstate - base = os.path.dirname(__file__) - self.glade_file = base + os.sep + "verify.glade" + glade_file = os.path.join( + os.path.split(__file__)[0], + _GLADE_FILE) + self.top = gtk.Builder() - self.top.add_from_file(self.glade_file) + self.top.add_from_file(glade_file) window = self.top.get_object("verify_result") self.set_window(window,self.top.get_object('title'),self.title)