* src/ArgHandler.py: Get rid of obsolete self.parent.
svn: r6302
This commit is contained in:
parent
e37110ba5b
commit
edfe00dd54
@ -1,3 +1,6 @@
|
|||||||
|
2006-04-10 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/ArgHandler.py: Get rid of obsolete self.parent.
|
||||||
|
|
||||||
2006-04-10 Don Allingham <don@gramps-project.org>
|
2006-04-10 Don Allingham <don@gramps-project.org>
|
||||||
* src/Editors/_EditFamily.py: Fix adding of spouse after family
|
* src/Editors/_EditFamily.py: Fix adding of spouse after family
|
||||||
has been created
|
has been created
|
||||||
|
@ -272,8 +272,8 @@ class ArgHandler:
|
|||||||
"when opening non-native formats. The "
|
"when opening non-native formats. The "
|
||||||
"following dialog will let you select "
|
"following dialog will let you select "
|
||||||
"the new database."),
|
"the new database."),
|
||||||
self.parent.topWindow)
|
self.vm.window)
|
||||||
prompter = NewNativeDbPrompter(self.parent)
|
prompter = NewNativeDbPrompter(self.vm,self.state)
|
||||||
if not prompter.chooser():
|
if not prompter.chooser():
|
||||||
QuestionDialog.ErrorDialog(
|
QuestionDialog.ErrorDialog(
|
||||||
_("New GRAMPS database was not set up"),
|
_("New GRAMPS database was not set up"),
|
||||||
@ -283,7 +283,7 @@ class ArgHandler:
|
|||||||
os._exit(1)
|
os._exit(1)
|
||||||
elif filetype == const.app_gramps_package:
|
elif filetype == const.app_gramps_package:
|
||||||
print "Type: GRAMPS package"
|
print "Type: GRAMPS package"
|
||||||
self.parent.read_pkg(filename)
|
self.read_pkg(filename)
|
||||||
success = True
|
success = True
|
||||||
else:
|
else:
|
||||||
print "Unknown file type: %s" % filetype
|
print "Unknown file type: %s" % filetype
|
||||||
@ -297,7 +297,6 @@ class ArgHandler:
|
|||||||
if success:
|
if success:
|
||||||
# Add the file to the recent items
|
# Add the file to the recent items
|
||||||
RecentFiles.recent_files(filename,filetype)
|
RecentFiles.recent_files(filename,filetype)
|
||||||
self.parent.build_recent_menu()
|
|
||||||
else:
|
else:
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
return
|
return
|
||||||
@ -307,7 +306,7 @@ class ArgHandler:
|
|||||||
# the InMem formats, without setting up a new database. Then
|
# the InMem formats, without setting up a new database. Then
|
||||||
# go on and process the rest of the command line arguments.
|
# go on and process the rest of the command line arguments.
|
||||||
|
|
||||||
#self.parent.cl = bool(self.exports or self.actions)
|
self.cl = bool(self.exports or self.actions)
|
||||||
|
|
||||||
name,format = self.open
|
name,format = self.open
|
||||||
success = False
|
success = False
|
||||||
@ -333,11 +332,11 @@ class ArgHandler:
|
|||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
if self.imports:
|
if self.imports:
|
||||||
#self.parent.cl = bool(self.exports or self.actions or self.parent.cl)
|
self.cl = bool(self.exports or self.actions or self.cl)
|
||||||
|
|
||||||
# Create dir for imported database(s)
|
# Create dir for imported database(s)
|
||||||
self.impdir_path = os.path.join(const.home_dir,"import" )
|
self.impdir_path = os.path.join(const.home_dir,"import")
|
||||||
self.imp_db_path = os.path.join(self.impdir_path, "import_db.grdb" )
|
self.imp_db_path = os.path.join(self.impdir_path,"import_db.grdb")
|
||||||
if not os.path.isdir(self.impdir_path):
|
if not os.path.isdir(self.impdir_path):
|
||||||
try:
|
try:
|
||||||
os.mkdir(self.impdir_path,0700)
|
os.mkdir(self.impdir_path,0700)
|
||||||
@ -355,7 +354,7 @@ class ArgHandler:
|
|||||||
if os.path.isfile(os.path.join(self.impdir_path,fn)):
|
if os.path.isfile(os.path.join(self.impdir_path,fn)):
|
||||||
os.remove(os.path.join(self.impdir_path,fn))
|
os.remove(os.path.join(self.impdir_path,fn))
|
||||||
|
|
||||||
self.parent.load_database(self.imp_db_path)
|
self.vm.load_database(self.imp_db_path)
|
||||||
|
|
||||||
for imp in self.imports:
|
for imp in self.imports:
|
||||||
print "Importing: file %s, format %s." % imp
|
print "Importing: file %s, format %s." % imp
|
||||||
@ -367,27 +366,27 @@ class ArgHandler:
|
|||||||
"supply at least one input file to process."
|
"supply at least one input file to process."
|
||||||
print "Launching interactive session..."
|
print "Launching interactive session..."
|
||||||
|
|
||||||
# if self.parent.cl:
|
if self.cl:
|
||||||
# for (action,options_str) in self.actions:
|
for (action,options_str) in self.actions:
|
||||||
# print "Performing action: %s." % action
|
print "Performing action: %s." % action
|
||||||
# if options_str:
|
if options_str:
|
||||||
# print "Using options string: %s" % options_str
|
print "Using options string: %s" % options_str
|
||||||
# self.cl_action(action,options_str)
|
self.cl_action(action,options_str)
|
||||||
|
|
||||||
# for expt in self.exports:
|
for expt in self.exports:
|
||||||
# print "Exporting: file %s, format %s." % expt
|
print "Exporting: file %s, format %s." % expt
|
||||||
# self.cl_export(expt[0],expt[1])
|
self.cl_export(expt[0],expt[1])
|
||||||
|
|
||||||
# print "Cleaning up."
|
|
||||||
# # remove import db after use
|
|
||||||
# self.parent.db.close()
|
|
||||||
# if self.imports:
|
|
||||||
# os.remove(self.imp_db_path)
|
|
||||||
# print "Exiting."
|
|
||||||
# os._exit(0)
|
|
||||||
|
|
||||||
|
print "Cleaning up."
|
||||||
|
# remove import db after use
|
||||||
|
self.state.db.close()
|
||||||
if self.imports:
|
if self.imports:
|
||||||
self.parent.import_tool_callback()
|
os.remove(self.imp_db_path)
|
||||||
|
print "Exiting."
|
||||||
|
os._exit(0)
|
||||||
|
|
||||||
|
## if self.imports:
|
||||||
|
## self.parent.import_tool_callback()
|
||||||
elif Config.get_lastfile() and Config.get_autoload():
|
elif Config.get_lastfile() and Config.get_autoload():
|
||||||
self.auto_save_load(Config.get_lastfile())
|
self.auto_save_load(Config.get_lastfile())
|
||||||
|
|
||||||
@ -404,7 +403,8 @@ class ArgHandler:
|
|||||||
if format == 'grdb':
|
if format == 'grdb':
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
try:
|
try:
|
||||||
GrampsDb.gramps_db_reader_factory(const.app_gramps)(self.parent.db,filename,None)
|
GrampsDb.gramps_db_reader_factory(const.app_gramps)(
|
||||||
|
self.state.db,filename,None)
|
||||||
except:
|
except:
|
||||||
print "Error importing %s" % filename
|
print "Error importing %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
@ -412,7 +412,7 @@ class ArgHandler:
|
|||||||
from GrampsDb import GedcomParser
|
from GrampsDb import GedcomParser
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
try:
|
try:
|
||||||
g = GedcomParser(self.parent.db,filename,None)
|
g = GedcomParser(self.state.db,filename,None)
|
||||||
g.parse_gedcom_file()
|
g.parse_gedcom_file()
|
||||||
g.resolve_refns()
|
g.resolve_refns()
|
||||||
del g
|
del g
|
||||||
@ -421,7 +421,8 @@ class ArgHandler:
|
|||||||
os._exit(1)
|
os._exit(1)
|
||||||
elif format == 'gramps-xml':
|
elif format == 'gramps-xml':
|
||||||
try:
|
try:
|
||||||
GrampsDb.gramps_db_reader_factory(const.app_gramps_xml)(self.parent.db,filename,None,self.parent.cl)
|
GrampsDb.gramps_db_reader_factory(const.app_gramps_xml)(
|
||||||
|
self.state.db,filename,None,self.cl)
|
||||||
except:
|
except:
|
||||||
print "Error importing %s" % filename
|
print "Error importing %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
@ -429,7 +430,7 @@ class ArgHandler:
|
|||||||
import ImportGeneWeb
|
import ImportGeneWeb
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
try:
|
try:
|
||||||
ImportGeneWeb.importData(self.parent.db,filename,None)
|
ImportGeneWeb.importData(self.state.db,filename,None)
|
||||||
except:
|
except:
|
||||||
print "Error importing %s" % filename
|
print "Error importing %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
@ -470,7 +471,8 @@ class ArgHandler:
|
|||||||
dbname = os.path.join(tmpdir_path,const.xmlFile)
|
dbname = os.path.join(tmpdir_path,const.xmlFile)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
GrampsDb.gramps_db_reader_factory(const.app_gramps_xml)(self.parent.db,dbname,None)
|
GrampsDb.gramps_db_reader_factory(const.app_gramps_xml)(
|
||||||
|
self.state.db,dbname,None)
|
||||||
except:
|
except:
|
||||||
print "Error importing %s" % filename
|
print "Error importing %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
@ -482,8 +484,8 @@ class ArgHandler:
|
|||||||
else:
|
else:
|
||||||
print "Invalid format: %s" % format
|
print "Invalid format: %s" % format
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
if not self.parent.cl:
|
if not self.cl:
|
||||||
return self.parent.post_load(self.imp_db_path)
|
return self.vm.post_load(self.imp_db_path)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -498,13 +500,14 @@ class ArgHandler:
|
|||||||
"""
|
"""
|
||||||
if format == 'grdb':
|
if format == 'grdb':
|
||||||
try:
|
try:
|
||||||
GrampsDb.gramps_db_writer_factory(const.app_gramps)(self.parent.db,filename)
|
GrampsDb.gramps_db_writer_factory(const.app_gramps)(
|
||||||
|
self.state.db,filename)
|
||||||
except:
|
except:
|
||||||
print "Error exporting %s" % filename
|
print "Error exporting %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
elif format == 'gedcom':
|
elif format == 'gedcom':
|
||||||
try:
|
try:
|
||||||
gw = GrampsDb.GedcomWriter(self.parent.db,None,1,filename)
|
gw = GrampsDb.GedcomWriter(self.state.db,None,1,filename)
|
||||||
ret = gw.export_data(filename)
|
ret = gw.export_data(filename)
|
||||||
except:
|
except:
|
||||||
print "Error exporting %s" % filename
|
print "Error exporting %s" % filename
|
||||||
@ -513,7 +516,7 @@ class ArgHandler:
|
|||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
if filename:
|
if filename:
|
||||||
try:
|
try:
|
||||||
g = GrampsDb.XmlWriter(self.parent.db,None,0,1)
|
g = GrampsDb.XmlWriter(self.state.db,None,0,1)
|
||||||
ret = g.write(filename)
|
ret = g.write(filename)
|
||||||
except:
|
except:
|
||||||
print "Error exporting %s" % filename
|
print "Error exporting %s" % filename
|
||||||
@ -521,7 +524,7 @@ class ArgHandler:
|
|||||||
elif format == 'gramps-pkg':
|
elif format == 'gramps-pkg':
|
||||||
try:
|
try:
|
||||||
import WritePkg
|
import WritePkg
|
||||||
writer = WritePkg.PackageWriter(self.parent.db,filename)
|
writer = WritePkg.PackageWriter(self.state.db,filename)
|
||||||
ret = writer.export()
|
ret = writer.export()
|
||||||
except:
|
except:
|
||||||
print "Error creating %s" % filename
|
print "Error creating %s" % filename
|
||||||
@ -529,7 +532,7 @@ class ArgHandler:
|
|||||||
elif format == 'iso':
|
elif format == 'iso':
|
||||||
import WriteCD
|
import WriteCD
|
||||||
try:
|
try:
|
||||||
writer = WriteCD.PackageWriter(self.parent.db,filename,1)
|
writer = WriteCD.PackageWriter(self.state.db,filename,1)
|
||||||
ret = writer.export()
|
ret = writer.export()
|
||||||
except:
|
except:
|
||||||
print "Error exporting %s" % filename
|
print "Error exporting %s" % filename
|
||||||
@ -537,7 +540,7 @@ class ArgHandler:
|
|||||||
elif format == 'wft':
|
elif format == 'wft':
|
||||||
import WriteFtree
|
import WriteFtree
|
||||||
try:
|
try:
|
||||||
writer = WriteFtree.FtreeWriter(self.parent.db,None,1,filename)
|
writer = WriteFtree.FtreeWriter(self.state.db,None,1,filename)
|
||||||
ret = writer.export_data()
|
ret = writer.export_data()
|
||||||
except:
|
except:
|
||||||
print "Error exporting %s" % filename
|
print "Error exporting %s" % filename
|
||||||
@ -545,7 +548,7 @@ class ArgHandler:
|
|||||||
elif format == 'geneweb':
|
elif format == 'geneweb':
|
||||||
import WriteGeneWeb
|
import WriteGeneWeb
|
||||||
try:
|
try:
|
||||||
writer = WriteGeneWeb.GeneWebWriter(self.parent.db,
|
writer = WriteGeneWeb.GeneWebWriter(self.state.db,
|
||||||
None,1,filename)
|
None,1,filename)
|
||||||
ret = writer.export_data()
|
ret = writer.export_data()
|
||||||
except:
|
except:
|
||||||
@ -567,7 +570,7 @@ class ArgHandler:
|
|||||||
"""
|
"""
|
||||||
if action == 'check':
|
if action == 'check':
|
||||||
import Check
|
import Check
|
||||||
checker = Check.CheckIntegrity(self.parent.db,None,None)
|
checker = Check.CheckIntegrity(self.state.db,None,None)
|
||||||
checker.check_for_broken_family_links()
|
checker.check_for_broken_family_links()
|
||||||
checker.cleanup_missing_photos(1)
|
checker.cleanup_missing_photos(1)
|
||||||
checker.check_parent_relationships()
|
checker.check_parent_relationships()
|
||||||
@ -577,7 +580,7 @@ class ArgHandler:
|
|||||||
checker.report(1)
|
checker.report(1)
|
||||||
elif action == 'summary':
|
elif action == 'summary':
|
||||||
import Summary
|
import Summary
|
||||||
text = Summary.build_report(self.parent.db,None)
|
text = Summary.build_report(self.state.db,None)
|
||||||
print text
|
print text
|
||||||
elif action == "report":
|
elif action == "report":
|
||||||
try:
|
try:
|
||||||
@ -599,10 +602,10 @@ class ArgHandler:
|
|||||||
options_class = item[3]
|
options_class = item[3]
|
||||||
if category in (Report.CATEGORY_BOOK,Report.CATEGORY_CODE,
|
if category in (Report.CATEGORY_BOOK,Report.CATEGORY_CODE,
|
||||||
Report.CATEGORY_WEB):
|
Report.CATEGORY_WEB):
|
||||||
options_class(self.parent.db,name,
|
options_class(self.state.db,name,
|
||||||
category,options_str_dict)
|
category,options_str_dict)
|
||||||
else:
|
else:
|
||||||
Report.cl_report(self.parent.db,name,category,
|
Report.cl_report(self.state.db,name,category,
|
||||||
report_class,options_class,
|
report_class,options_class,
|
||||||
options_str_dict)
|
options_str_dict)
|
||||||
return
|
return
|
||||||
@ -628,7 +631,7 @@ class ArgHandler:
|
|||||||
category = item[1]
|
category = item[1]
|
||||||
tool_class = item[2]
|
tool_class = item[2]
|
||||||
options_class = item[3]
|
options_class = item[3]
|
||||||
Tool.cli_tool(self.parent.db,name,category,
|
Tool.cli_tool(self.state.db,name,category,
|
||||||
tool_class,options_class,options_str_dict)
|
tool_class,options_class,options_str_dict)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -651,9 +654,9 @@ class NewNativeDbPrompter:
|
|||||||
it is appended.
|
it is appended.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,parent,parent_window=None):
|
def __init__(self,vm,state):
|
||||||
self.parent = parent
|
self.vm = vm
|
||||||
self.parent_window = parent_window
|
self.state = state
|
||||||
|
|
||||||
def chooser(self):
|
def chooser(self):
|
||||||
"""
|
"""
|
||||||
@ -661,13 +664,13 @@ class NewNativeDbPrompter:
|
|||||||
Return 1 when selection is made and 0 otherwise.
|
Return 1 when selection is made and 0 otherwise.
|
||||||
"""
|
"""
|
||||||
choose = gtk.FileChooserDialog(_('GRAMPS: Create GRAMPS database'),
|
choose = gtk.FileChooserDialog(_('GRAMPS: Create GRAMPS database'),
|
||||||
self.parent_window,
|
self.vm.window,
|
||||||
gtk.FILE_CHOOSER_ACTION_SAVE,
|
gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||||
(gtk.STOCK_CANCEL,
|
(gtk.STOCK_CANCEL,
|
||||||
gtk.RESPONSE_CANCEL,
|
gtk.RESPONSE_CANCEL,
|
||||||
gtk.STOCK_OPEN,
|
gtk.STOCK_OPEN,
|
||||||
gtk.RESPONSE_OK))
|
gtk.RESPONSE_OK))
|
||||||
self.parent.clear_database()
|
self.state.db.close()
|
||||||
|
|
||||||
# Always add automatic (macth all files) filter
|
# Always add automatic (macth all files) filter
|
||||||
add_all_files_filter(choose)
|
add_all_files_filter(choose)
|
||||||
@ -697,11 +700,12 @@ class NewNativeDbPrompter:
|
|||||||
if os.path.splitext(filename)[1] != ".grdb":
|
if os.path.splitext(filename)[1] != ".grdb":
|
||||||
filename = filename + ".grdb"
|
filename = filename + ".grdb"
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
self.parent.db = GrampsDb.gramps_db_factory(const.app_gramps)()
|
self.state.db = GrampsDb.gramps_db_factory(const.app_gramps)()
|
||||||
self.parent.read_file(filename)
|
self.vm.read_file(filename)
|
||||||
|
self.state.signal_change()
|
||||||
|
self.change_page(None, None)
|
||||||
# Add the file to the recent items
|
# Add the file to the recent items
|
||||||
RecentFiles.recent_files(filename,const.app_gramps)
|
RecentFiles.recent_files(filename,const.app_gramps)
|
||||||
self.parent.build_recent_menu()
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
@ -726,3 +730,6 @@ def add_grdb_filter(chooser):
|
|||||||
mime_filter.set_name(_('GRAMPS databases'))
|
mime_filter.set_name(_('GRAMPS databases'))
|
||||||
mime_filter.add_mime_type(const.app_gramps)
|
mime_filter.add_mime_type(const.app_gramps)
|
||||||
chooser.add_filter(mime_filter)
|
chooser.add_filter(mime_filter)
|
||||||
|
|
||||||
|
def read_pkg(filename):
|
||||||
|
print "FIXME: This is not re-implemented yet."
|
||||||
|
@ -958,7 +958,7 @@ class ViewManager:
|
|||||||
add_xml_filter(choose)
|
add_xml_filter(choose)
|
||||||
add_gedcom_filter(choose)
|
add_gedcom_filter(choose)
|
||||||
|
|
||||||
format_list = [const.app_gramps, const.app_gramps_xml, const.app_gedcom]
|
format_list = [const.app_gramps,const.app_gramps_xml,const.app_gedcom]
|
||||||
|
|
||||||
# Add more data type selections if opening existing db
|
# Add more data type selections if opening existing db
|
||||||
for data in import_list:
|
for data in import_list:
|
||||||
|
Loading…
Reference in New Issue
Block a user