svn: r1023
This commit is contained in:
Don Allingham 2002-06-10 04:53:53 +00:00
parent bef3d944bf
commit fb1052623d
32 changed files with 392 additions and 325 deletions

View File

@ -88,7 +88,6 @@ class AddSpouse:
self.spouse_list.set_column_visibility(2,0)
self.spouse_list.set_column_visibility(3,0)
self.sorter = Sorter.Sorter(self.spouse_list,arrow_map,'spouse',self.top)
self.name_list = self.db.getPersonKeys()
self.rel_combo.set_popdown_strings(const.familyRelations)
title = _("Choose Spouse/Partner of %s") % GrampsCfg.nameof(person)
self.glade.get_widget("spouseTitle").set_text(title)
@ -132,7 +131,6 @@ class AddSpouse:
QuickAdd.QuickAdd(self.db,gen,self.update_list)
def update_list(self,person):
self.name_list.append(person.getId())
self.addperson(person)
self.relation_type_changed(self.relation_type)
row = self.spouse_list.find_row_from_data(person)
@ -186,18 +184,23 @@ class AddSpouse:
gender = self.person.getGender()
if text == _("Partners"):
if gender == RelLib.Person.male:
gender = RelLib.Person.female
sgender = const.female
else:
gender = RelLib.Person.male
sgender = const.male
else:
if gender == RelLib.Person.male:
sgender = const.male
else:
sgender = const.female
index = 0
self.spouse_list.clear()
self.spouse_list.freeze()
for key in self.name_list:
person = self.db.getPerson(key)
if person.getGender() == gender:
for key in self.db.getPersonKeys():
data = self.db.getPersonDisplay(key)
if data[2] == sgender:
continue
data = person.getDisplayInfo()
self.spouse_list.append([data[0],data[3],data[5],data[6]])
self.spouse_list.set_row_data(index,key)
index = index + 1
@ -238,8 +241,6 @@ class SetSpouse:
self.relation_def = self.glade.get_widget("reldef")
self.top = self.glade.get_widget("spouseDialog")
self.name_list = self.db.getPersonMap().values()
self.name_list.sort(sort.by_last_name)
self.rel_combo.set_popdown_strings(const.familyRelations)
title = _("Choose Spouse/Partner of %s") % GrampsCfg.nameof(person)
self.glade.get_widget("spouseTitle").set_text(title)
@ -274,8 +275,6 @@ class SetSpouse:
QuickAdd.QuickAdd(self.db,gen,self.update_list)
def update_list(self,person):
self.name_list.append(person)
self.name_list.sort(sort.by_last_name)
self.addperson(person)
self.relation_type_changed(self.relation_type)
@ -322,18 +321,24 @@ class SetSpouse:
gender = self.person.getGender()
if text == _("Partners"):
if gender == RelLib.Person.male:
gender = RelLib.Person.female
sgender = const.female
else:
gender = RelLib.Person.male
sgender = const.male
else:
if gender == RelLib.Person.male:
sgender = const.male
else:
sgender = const.female
index = 0
self.spouse_list.clear()
self.spouse_list.freeze()
for person in self.name_list:
if person.getGender() == gender:
for key in self.db.getPersonKeys():
data = self.db.getPersonDisplay(key)
if data[2] == sgender:
continue
name = person.getPrimaryName().getName()
self.spouse_list.append([name,Utils.birthday(person)])
self.spouse_list.set_row_data(index,person)
self.spouse_list.append([data[0],data[3],data[5],data[6]])
self.spouse_list.set_row_data(index,key)
index = index + 1
self.spouse_list.thaw()

View File

@ -217,15 +217,15 @@ class FindSource(FindBase):
class FindMedia(FindBase):
"""Opens a Find Media Object dialog for GRAMPS"""
def __init__(self,clist,task,plist):
def __init__(self,clist,task,db):
"""Opens a dialog box instance that allows users to
search for a place.
clist - GtkCList containing the people information
task - function to call to change the active person"""
FindBase.__init__(self,clist,task,_("Find Media Object"))
for n in plist:
FindBase.__init__(self,clist,task,_("Find Media Object"),db)
for n in self.db.getObjectMap().values():
self.nlist.append(n.getDescription())
self.enable_autocomp()

View File

@ -208,7 +208,7 @@ class Marriage:
ord = self.family.getLdsSeal()
if ord == None:
ord = LdsOrd()
self.person.setLdsSeal(ord)
self.family.setLdsSeal(ord)
Sources.SourceSelector(ord.getSourceRefList(),self,src_changed)
def lds_note_clicked(self,obj):
@ -216,7 +216,7 @@ class Marriage:
ord = self.family.getLdsSeal()
if ord == None:
ord = LdsOrd()
self.person.setLdsSeal(ord)
self.family.setLdsSeal(ord)
NoteEdit.NoteEditor(ord)
def on_up_clicked(self,obj):

View File

@ -254,8 +254,6 @@ class PluginStatus:
window.show_string(info.read())
self.top.run_and_close()
#-------------------------------------------------------------------------
#
# load_plugins

View File

@ -21,7 +21,6 @@
from TextDoc import *
from latin_utf8 import latin_to_utf8
import Utils
import time
import StringIO
import os

View File

@ -19,7 +19,6 @@
#
import os
import tempfile
import string
import Plugins
import intl

View File

@ -22,7 +22,6 @@
import Filter
import Date
import RelLib
import intl
_ = intl.gettext

View File

@ -22,7 +22,6 @@
import Filter
import Date
import RelLib
import intl
_ = intl.gettext

View File

@ -21,7 +21,6 @@
"Disconnected individuals"
import Filter
import RelLib
import intl
_ = intl.gettext

View File

@ -22,7 +22,6 @@
import Filter
import re
import RelLib
import intl
_ = intl.gettext
@ -38,7 +37,6 @@ class EventPlace(Filter.Filter):
Filter.Filter.__init__(self,text)
def match(self,person):
val = 0
list = person.getEventList()[:]
list.append(person.getBirth())
list.append(person.getDeath())

View File

@ -22,7 +22,6 @@
import Filter
import soundex
import RelLib
import intl
_ = intl.gettext

View File

@ -22,7 +22,6 @@
import Filter
import soundex
import RelLib
import intl
_ = intl.gettext

View File

@ -23,7 +23,6 @@ locale.setlocale(locale.LC_NUMERIC,"C")
# Standard python modules
#
#-------------------------------------------------------------------------
import traceback
import sys
#-------------------------------------------------------------------------
@ -56,12 +55,8 @@ try:
else:
gramps_main.Gramps(arg)
except:
traceback.print_exc()
import DisplayTrace
DisplayTrace.DisplayTrace()
fname = os.path.expanduser("~/gramps.err")
errfile = open(fname,"w")
traceback.print_exc(file=errfile)
errfile.close()
gtk.mainloop()

View File

@ -67,7 +67,6 @@ import sort
import Utils
import Bookmarks
import Sorter
import ListColors
import GrampsCfg
import EditPerson
import Marriage
@ -334,8 +333,7 @@ class Gramps:
elif self.notebook.get_current_page() == 3:
Find.FindSource(self.source_view.source_list,self.find_goto_source,self.db)
elif self.notebook.get_current_page() == 5:
Find.FindMedia(self.media_view.media_list,self.find_goto_media,
self.db.getObjectMap().values())
Find.FindMedia(self.media_view.media_list,self.find_goto_media,self.db)
else:
Find.FindPerson(self.person_list,self.find_goto_to,self.db)
@ -593,7 +591,7 @@ class Gramps:
def new_database_response(self):
import DbPrompter
self.clear_database()
self.clear_database(2)
DbPrompter.DbPrompter(self,1)
def clear_database(self,zodb=1):
@ -604,8 +602,10 @@ class Gramps:
const.familyAttributes = const.init_family_attribute_list()
const.familyRelations = const.init_family_relation_list()
if zodb:
if zodb == 1:
self.db = GrampsZODB()
elif zodb == 2:
self.db = GrampsDB()
else:
self.db = GrampsXML()
self.db.set_iprefix(GrampsCfg.iprefix)
@ -696,7 +696,7 @@ class Gramps:
if filename == "" or filename == None:
return
self.clear_database()
self.clear_database(0)
if getoldrev.get_active():
vc = VersionControl.RcsVersionControl(filename)
@ -1269,8 +1269,7 @@ class Gramps:
self.update_display(0)
def update_after_merge(self,person,old_id):
if epo:
print person,old_id
if person:
self.remove_from_person_list(person,old_id)
self.redisplay_person_list(person)
self.update_display(0)
@ -1710,7 +1709,7 @@ class Gramps:
self.statusbar.set_status(_("%s has been bookmarked") % name)
gtk.timeout_add(5000,self.modify_statusbar)
else:
GnomeWarningDialog(_("Bookmark could not be set because no one was selected"))
gramps.ui.GnomeWarningDialog(_("Bookmark could not be set because no one was selected"))
def on_edit_bookmarks_activate(self,obj):
self.bookmarks.edit()

View File

@ -301,11 +301,14 @@ class AncestorChartDialog(DrawReportDialog):
"""Create the object that will produce the Ancestor Chart.
All user dialog has already been handled and the output file
opened."""
MyReport = AncestorChart(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.report_text)
MyReport.write_report()
try:
MyReport = AncestorChart(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.report_text)
MyReport.write_report()
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#

View File

@ -35,16 +35,11 @@ import libglade
#------------------------------------------------------------------------
#
#
# AncestorReport
#
#------------------------------------------------------------------------
class AncestorReport(Report):
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def __init__(self,database,person,output,max,doc,pgbrk):
self.map = {}
self.database = database
@ -58,11 +53,6 @@ class AncestorReport(Report):
except IOError,msg:
gnome.ui.GnomeErrorDialog(_("Could not open %s") % output + "\n" + msg)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def filter(self,person,index):
if person == None or index >= (1 << 31):
return
@ -73,11 +63,6 @@ class AncestorReport(Report):
self.filter(family.getFather(),index*2)
self.filter(family.getMother(),(index*2)+1)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def write_report(self):
self.filter(self.start,1)
@ -215,7 +200,6 @@ class AncestorReport(Report):
self.doc.write_text(".")
self.doc.end_paragraph()
self.doc.close()
@ -250,11 +234,6 @@ class AncestorReportDialog(TextReportDialog):
"""Where to save styles for this report."""
return "ancestor_report.xml"
#------------------------------------------------------------------------
#
# Create output styles appropriate to this report.
#
#------------------------------------------------------------------------
def make_default_style(self):
"""Make the default output style for the Ahnentafel report."""
font = FontStyle()
@ -277,18 +256,17 @@ class AncestorReportDialog(TextReportDialog):
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
self.default_style.add_style("Entry",para)
#------------------------------------------------------------------------
#
# Create the contents of the report.
#
#------------------------------------------------------------------------
def make_report(self):
"""Create the object that will produce the Ahnentafel Report.
All user dialog has already been handled and the output file
opened."""
MyReport = AncestorReport(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.pg_brk)
MyReport.write_report()
try:
MyReport = AncestorReport(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.pg_brk)
MyReport.write_report()
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------

View File

@ -37,7 +37,11 @@ _ = intl.gettext
#
#-------------------------------------------------------------------------
def runTool(database,person,callback):
ChangeTypes(database,person)
try:
ChangeTypes(database,person)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
class ChangeTypes:
def __init__(self,db,person):

View File

@ -37,12 +37,16 @@ import libglade
#-------------------------------------------------------------------------
def runTool(database,active_person,callback):
checker = CheckIntegrity(database)
checker.check_for_broken_family_links()
checker.cleanup_missing_photos()
checker.check_parent_relationships()
checker.cleanup_empty_families(0)
checker.report()
try:
checker = CheckIntegrity(database)
checker.check_for_broken_family_links()
checker.cleanup_missing_photos()
checker.check_parent_relationships()
checker.cleanup_empty_families(0)
checker.report()
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#-------------------------------------------------------------------------
#

View File

@ -20,17 +20,32 @@
"Generate files/Descendant Report"
import GraphLayout
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import string
#------------------------------------------------------------------------
#
# GTK/GNOME modules
#
#------------------------------------------------------------------------
import libglade
import gtk
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
import GraphLayout
from FontScale import string_width
from DrawDoc import *
from Report import *
from TextDoc import *
import libglade
import gtk
import string
import intl
_ = intl.gettext
@ -44,13 +59,13 @@ _sep = 0.5
def pt2cm(pt):
return (float(pt)/72.0)*2.54
#------------------------------------------------------------------------
#
# DescendantReport
#
#------------------------------------------------------------------------
class DescendantReport:
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def __init__(self,database,display,person,output,doc):
self.doc = doc
self.doc.creator(database.getResearcher().getName())
@ -98,7 +113,6 @@ class DescendantReport:
self.lines = max(self.lines,len(self.text[p]))
def write_report(self):
self.calc()
@ -214,14 +228,10 @@ class DescendantReport:
except:
print "Document close failure"
#--------------------------------------------------------------------
#
# calc - calculate the maximum width that a box needs to be. From
# that and the page dimensions, calculate the proper place to put
# the elements on a page.
#
#--------------------------------------------------------------------
def calc(self):
"""calc - calculate the maximum width that a box needs to be. From
that and the page dimensions, calculate the proper place to put
the elements on a page."""
self.height = self.lines*pt2cm(1.25*self.font.get_size())
self.box_width = pt2cm(self.box_width+20)
@ -238,11 +248,6 @@ class DescendantReport:
g = GraphicsStyle()
self.doc.add_draw_style("line",g)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def print_page(self, plist,elist,r,c):
self.doc.start_page()
@ -299,6 +304,11 @@ class DescendantReport:
self.doc.end_page()
#------------------------------------------------------------------------
#
# DescendantReportDialog
#
#------------------------------------------------------------------------
class DescendantReportDialog(DrawReportDialog):
def __init__(self,database,person):
DrawReportDialog.__init__(self,database,person)
@ -337,10 +347,14 @@ class DescendantReportDialog(DrawReportDialog):
"""Create the object that will produce the Descendant Graph.
All user dialog has already been handled and the output file
opened."""
MyReport = DescendantReport(self.db,self.report_text,
self.person, self.target_path, self.doc)
MyReport.write_report()
try:
MyReport = DescendantReport(self.db,self.report_text,
self.person, self.target_path, self.doc)
MyReport.write_report()
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#
#

View File

@ -20,14 +20,30 @@
"Analysis and Exploration/Interactive descendant browser"
from RelLib import *
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import os
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
from RelLib import *
import Utils
import intl
import GrampsCfg
_ = intl.gettext
#------------------------------------------------------------------------
#
# GTK/GNOME modules
#
#------------------------------------------------------------------------
import GDK
import gtk
import libglade
@ -38,7 +54,11 @@ import libglade
#
#------------------------------------------------------------------------
def runTool(database,person,callback):
DesBrowse(database,person,callback)
try:
DesBrowse(database,person,callback)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
class DesBrowse:
def __init__(self,database,person,callback):

View File

@ -20,30 +20,40 @@
"Generate files/Descendant Report"
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import os
import sort
import string
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
from Report import *
import intl
_ = intl.gettext
from Report import *
#------------------------------------------------------------------------
#
# GTK/GNOME modules
#
#------------------------------------------------------------------------
import gtk
import libglade
#------------------------------------------------------------------------
#
#
# DescendantReport
#
#------------------------------------------------------------------------
class DescendantReport:
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def __init__(self,db,person,name,max,doc):
self.creator = db.getResearcher().getName()
self.name = name
@ -51,27 +61,12 @@ class DescendantReport:
self.max_generations = max
self.doc = doc
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def setup(self):
self.doc.open(self.name)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def end(self):
self.doc.close()
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def dump_dates(self, person):
birth = person.getBirth().getDateObj().get_start_date()
death = person.getDeath().getDateObj().get_start_date()
@ -85,11 +80,6 @@ class DescendantReport:
self.doc.write_text('d. ' + str(death.getYear()))
self.doc.write_text(')')
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def report(self):
self.doc.start_paragraph("Title")
name = self.person.getPrimaryName().getRegularName()
@ -98,11 +88,6 @@ class DescendantReport:
self.doc.end_paragraph()
self.dump(0,self.person)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def dump(self,level,person):
if level != 0:
@ -155,11 +140,6 @@ class DescendantReportDialog(TextReportDialog):
"""Where to save styles for this report."""
return "descend_report.xml"
#------------------------------------------------------------------------
#
# Create output styles appropriate to this report.
#
#------------------------------------------------------------------------
def make_default_style(self):
"""Make the default output style for the Descendant Report."""
f = FontStyle()
@ -178,20 +158,19 @@ class DescendantReportDialog(TextReportDialog):
p.set_left_margin(max(10.0,float(i-1)))
self.default_style.add_style("Level%d" % i,p)
#------------------------------------------------------------------------
#
# Create the contents of the report.
#
#------------------------------------------------------------------------
def make_report(self):
"""Create the object that will produce the Descendant Report.
All user dialog has already been handled and the output file
opened."""
MyReport = DescendantReport(self.db, self.person, self.target_path,
self.max_gen, self.doc)
MyReport.setup()
MyReport.report()
MyReport.end()
try:
MyReport = DescendantReport(self.db, self.person, self.target_path,
self.max_gen, self.doc)
MyReport.setup()
MyReport.report()
MyReport.end()
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#

View File

@ -27,9 +27,6 @@ _ = intl.gettext
from Report import *
import gtk
import libglade
#------------------------------------------------------------------------
#
#
@ -365,9 +362,9 @@ class FamilyGroupDialog(TextReportDialog):
will return a placebo label and disable the OK button."""
mapping = {}
family_list = self.person.getFamilyList()
if not family_list:
mapping[_("No known marriages")] = None
self.topDialog.get_widget("OK").set_sensitive(0)
# if not family_list:
# mapping[_("No known marriages")] = None
# self.topDialog.get_widget("OK").set_sensitive(0)
for family in family_list:
if self.person == family.getFather():
spouse = family.getMother()

View File

@ -501,7 +501,11 @@ def get_name_obj(person):
#
#-------------------------------------------------------------------------
def runTool(database,active_person,callback):
Merge(database,callback)
try:
Merge(database,callback)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#-------------------------------------------------------------------------
#

View File

@ -43,7 +43,11 @@ _nick_re = re.compile(r"(.+)[(\"](.*)[)\"]")
#
#-------------------------------------------------------------------------
def runTool(database,active_person,callback):
PatchNames(database,callback)
try:
PatchNames(database,callback)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
class PatchNames:

View File

@ -1705,7 +1705,11 @@ def on_ok_clicked(obj):
if name == "":
return
Utils.destroy_passed_object(obj)
importData(db,name)
try:
importData(db,name)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#-------------------------------------------------------------------------
#

View File

@ -20,7 +20,6 @@
"Import from Gramps"
import libglade
from ReadXML import *
import Utils
import intl
@ -69,7 +68,11 @@ class ReadNative:
name = "%s/%s" % (name,const.xmlFile)
Utils.destroy_passed_object(self.top)
importData(self.db,name,progress)
try:
importData(self.db,name,progress)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
self.callback(1)
#------------------------------------------------------------------------

View File

@ -33,7 +33,11 @@ _findint = re.compile('^[^\d]*(\d+)[^\d]*')
def runTool(db,active_person,callback):
"""Changed person, family, object, source, and place ids"""
ReorderIds(db,callback)
try:
ReorderIds(db,callback)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
class ReorderIds:

View File

@ -20,15 +20,29 @@
"View/Summary of the database"
from RelLib import *
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import os
import posixpath
import re
import string
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
from RelLib import *
import Utils
import intl
_ = intl.gettext
#------------------------------------------------------------------------
#
# GNOME/GTK modules
#
#------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
from libglade import *

View File

@ -20,19 +20,33 @@
"View/Verify"
from RelLib import *
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import os
import posixpath
import re
import sort
import string
#------------------------------------------------------------------------
#
# GNOME/GTK modules
#
#------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
from libglade import *
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
from RelLib import *
import Utils
import intl
_ = intl.gettext
from gtk import *
from gnome.ui import *
from libglade import *
db = None
glade_file = None

View File

@ -283,7 +283,11 @@ def ged_subdate(date):
#
#-------------------------------------------------------------------------
def writeData(database,person):
GedcomWriter(database,person)
try:
GedcomWriter(database,person)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#-------------------------------------------------------------------------
#

View File

@ -20,113 +20,132 @@
"Export to GRAMPS package"
#-------------------------------------------------------------------------
#
# standard python modules
#
#-------------------------------------------------------------------------
import time
import os
from cStringIO import StringIO
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
#
#-------------------------------------------------------------------------
import libglade
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from RelLib import *
import WriteXML
import time
import os
import TarFile
import Utils
import libglade
from cStringIO import StringIO
import intl
_ = intl.gettext
#-------------------------------------------------------------------------
#
# writeData
#
#-------------------------------------------------------------------------
def writeData(database,person):
global db
global topDialog
global active_person
try:
PackageWriter(database)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
db = database
active_person = person
base = os.path.dirname(__file__)
glade_file = base + os.sep + "pkgexport.glade"
#-------------------------------------------------------------------------
#
# PackageWriter
#
#-------------------------------------------------------------------------
class PackageWriter:
def __init__(self,database):
self.db = database
dic = {
"destroy_passed_object" : Utils.destroy_passed_object,
"on_ok_clicked" : on_ok_clicked
}
base = os.path.dirname(__file__)
glade_file = "%s/%s" % (base,"pkgexport.glade")
dic = {
"destroy_passed_object" : Utils.destroy_passed_object,
"on_ok_clicked" : self.on_ok_clicked
}
self.top = libglade.GladeXML(glade_file,"packageExport")
self.top.signal_autoconnect(dic)
self.top.get_widget("packageExport").show()
topDialog = libglade.GladeXML(glade_file,"packageExport")
topDialog.signal_autoconnect(dic)
def on_ok_clicked(self,obj):
name = self.top.get_widget("filename").get_text()
Utils.destroy_passed_object(obj)
self.export(name)
topDialog.get_widget("packageExport").show()
def export(self, filename):
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_ok_clicked(obj):
global db
global topDialog
name = topDialog.get_widget("filename").get_text()
Utils.destroy_passed_object(obj)
exportData(db,name)
t = TarFile.TarFile(filename)
g = StringIO()
gfile = WriteXML.XmlWriter(self.db,None,1)
gfile.write_handle(g)
mtime = time.time()
t.add_file("data.gramps",mtime,g)
g.close()
def callback(a):
pass
def exportData(database, filename):
t = TarFile.TarFile(filename)
g = StringIO()
gfile = WriteXML.XmlWriter(database,None,1)
gfile.write_handle(g)
mtime = time.time()
t.add_file("data.gramps",mtime,g)
g.close()
for f in database.getPersonMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
for f in database.getFamilyMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
for f in database.getSourceMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
for f in database.getPlaceMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
t.close()
for f in self.db.getPersonMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
for f in self.db.getFamilyMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
for f in self.db.getSourceMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
for f in self.db.getPlaceMap().values():
for p in f.getPhotoList():
object = p.getReference()
base = os.path.basename(object.getPath())
try:
g = open(object.getPath(),"rb")
t.add_file(base,mtime,g)
g.close()
except:
pass
t.close()
#-------------------------------------------------------------------------
#
#
# Register the plugin
#
#-------------------------------------------------------------------------
from Plugins import register_export

View File

@ -31,49 +31,59 @@ from gnome.ui import *
from libglade import *
def report(database,person):
text = ""
base = os.path.dirname(__file__)
glade_file = base + os.sep + "summary.glade"
topDialog = GladeXML(glade_file,"summary")
topDialog.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
})
thisgen = []
allgen = []
thisgen.append(person)
title = _("Number of ancestors of \"%s\" by generation") % person.getPrimaryName().getName()
text = text + title + ':\n'
thisgensize=1
gen=1
while thisgensize>0:
thisgensize=0
if len(thisgen) >0:
thisgensize=len(thisgen)
gen= gen-1
if thisgensize == 1 :
text = text + _("Generation %d has 1 individual.\n") % (gen)
else:
text = text + _("Generation %d has %d individuals.\n") % (gen, thisgensize)
temp = thisgen
thisgen = []
for person in temp:
family = person.getMainParents()
if family != None:
father = family.getFather()
mother = family.getMother()
if father != None:
thisgen.append(father)
if mother != None:
thisgen.append(mother)
allgen = allgen + thisgen
text = text + _("Total ancestors in generations %d to -1 is %d .\n") % (gen, len(allgen))
try:
CountAncestors(database,person)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
top = topDialog.get_widget("summary")
textwindow = topDialog.get_widget("textwindow")
topDialog.get_widget("summaryTitle").set_text(title)
textwindow.show_string(text)
top.show()
class CountAncestors:
def __init__(self,database,person):
text = ""
base = os.path.dirname(__file__)
glade_file = base + os.sep + "summary.glade"
topDialog = GladeXML(glade_file,"summary")
topDialog.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
})
thisgen = []
allgen = []
thisgen.append(person)
title = _("Number of ancestors of \"%s\" by generation") % person.getPrimaryName().getName()
text = text + title + ':\n'
thisgensize=1
gen=1
while thisgensize>0:
thisgensize=0
if len(thisgen) >0:
thisgensize=len(thisgen)
gen= gen-1
if thisgensize == 1 :
text = text + _("Generation %d has 1 individual.\n") % (gen)
else:
text = text + _("Generation %d has %d individuals.\n") % (gen, thisgensize)
temp = thisgen
thisgen = []
for person in temp:
family = person.getMainParents()
if family != None:
father = family.getFather()
mother = family.getMother()
if father != None:
thisgen.append(father)
if mother != None:
thisgen.append(mother)
allgen = allgen + thisgen
text = text + _("Total ancestors in generations %d to -1 is %d .\n") % (gen, len(allgen))
top = topDialog.get_widget("summary")
textwindow = topDialog.get_widget("textwindow")
topDialog.get_widget("summaryTitle").set_text(title)
textwindow.show_string(text)
top.show()
#-------------------------------------------------------------------------
#