2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
* src/RelLib.py (Transaction.__len__): Redefine length.
* src/ChooseParents.py, src/EditPerson.py, src/EditSource.py,
src/EventEdit.py, src/FamilyView.py, src/gramps_main.py,
src/ImageSelect.py, src/Marriage.py, src/MediaView.py,
src/PedView.py, src/PeopleModel.py, src/PlaceView.py,
src/SelectChild.py, src/SelectObject.py, src/Sources.py,
src/SourceView.py, src/Utils.py, src/Witness.py,
src/WriteXML.py: Switch from find_* to try_to_find_* methods.
svn: r3193
2004-05-26 08:56:18 +05:30
|
|
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
2003-11-24 02:25:14 +05:30
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
Contains the interface to allow a database to get written using
|
|
|
|
GRAMPS' XML file format.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# load standard python libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import string
|
|
|
|
import time
|
|
|
|
import shutil
|
|
|
|
import os
|
2003-04-20 09:22:54 +05:30
|
|
|
import codecs
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-01 09:39:55 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# load gtk libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# load GRAMPS libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2003-02-24 10:21:57 +05:30
|
|
|
import RelLib
|
2004-09-17 09:00:04 +05:30
|
|
|
import Date
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-21 06:48:07 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Attempt to load the GZIP library. Some version of python do not seem
|
|
|
|
# to be compiled with this available.
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
try:
|
|
|
|
import gzip
|
|
|
|
_gzip_ok = 1
|
|
|
|
except:
|
|
|
|
_gzip_ok = 0
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-11 11:38:35 +05:30
|
|
|
def exportData(database, filename, person, callback=None):
|
2004-07-09 23:49:47 +05:30
|
|
|
ret = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
if os.path.isfile(filename):
|
2003-06-04 02:48:23 +05:30
|
|
|
try:
|
2004-02-01 08:46:23 +05:30
|
|
|
shutil.copyfile(filename, filename + ".bak")
|
2003-06-04 02:48:23 +05:30
|
|
|
shutil.copystat(filename, filename + ".bak")
|
|
|
|
except:
|
|
|
|
pass
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-01 09:39:55 +05:30
|
|
|
compress = _gzip_ok == 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
try:
|
|
|
|
g = XmlWriter(database,callback,0,compress)
|
2004-07-09 23:49:47 +05:30
|
|
|
ret = g.write(filename)
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
|
2003-02-24 10:21:57 +05:30
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
ErrorDialog(_("Failure writing %s") % filename,
|
2003-06-02 18:53:54 +05:30
|
|
|
_("An attempt is being made to recover the original file"))
|
2003-06-04 02:48:23 +05:30
|
|
|
shutil.copyfile(filename + ".bak", filename)
|
|
|
|
try:
|
|
|
|
shutil.copystat(filename + ".bak", filename)
|
|
|
|
except:
|
|
|
|
pass
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
return ret
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def quick_write(database, filename,callback=None):
|
|
|
|
g = XmlWriter(database,callback,0,1)
|
|
|
|
g.write(filename)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class XmlWriter:
|
|
|
|
"""
|
|
|
|
Writes a database to the XML file.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,db,callback,strip_photos,compress=1):
|
|
|
|
"""
|
2003-04-20 09:22:54 +05:30
|
|
|
Initializes, but does not write, an XML file.
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
db - database to write
|
|
|
|
callback - function to provide progress indication
|
|
|
|
strip_photos - remove full paths off of media object paths
|
|
|
|
compress - attempt to compress the database
|
|
|
|
"""
|
|
|
|
self.compress = compress
|
|
|
|
self.db = db
|
|
|
|
self.callback = callback
|
|
|
|
self.strip_photos = strip_photos
|
|
|
|
|
|
|
|
def write(self,filename):
|
|
|
|
"""
|
2003-04-20 09:22:54 +05:30
|
|
|
Write the database to the specified file.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2004-02-01 08:46:23 +05:30
|
|
|
base = os.path.dirname(filename)
|
|
|
|
if os.path.isdir(base):
|
|
|
|
if not os.access(base,os.W_OK) or not os.access(base,os.R_OK):
|
|
|
|
ErrorDialog(_('Failure writing %s') % filename,
|
|
|
|
_("The database cannot be saved because you do not "
|
|
|
|
"have permission to write to the directory. "
|
|
|
|
"Please make sure you have write access to the "
|
|
|
|
"directory and try again."))
|
2004-07-09 23:49:47 +05:30
|
|
|
return 0
|
2004-02-01 08:46:23 +05:30
|
|
|
|
|
|
|
if os.path.exists(filename):
|
|
|
|
if not os.access(filename,os.W_OK):
|
|
|
|
ErrorDialog(_('Failure writing %s') % filename,
|
|
|
|
_("The database cannot be saved because you do not "
|
|
|
|
"have permission to write to the file. "
|
|
|
|
"Please make sure you have write access to the "
|
|
|
|
"file and try again."))
|
2004-07-09 23:49:47 +05:30
|
|
|
return 0
|
2004-02-01 08:46:23 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.fileroot = os.path.dirname(filename)
|
2004-02-01 08:46:23 +05:30
|
|
|
try:
|
|
|
|
if self.compress:
|
|
|
|
try:
|
|
|
|
g = gzip.open(filename,"wb")
|
|
|
|
except:
|
|
|
|
g = open(filename,"w")
|
|
|
|
else:
|
2003-04-20 09:22:54 +05:30
|
|
|
g = open(filename,"w")
|
2004-02-01 08:46:23 +05:30
|
|
|
except IOError,msg:
|
|
|
|
ErrorDialog(_('Failure writing %s') % filename,msg)
|
2004-07-09 23:49:47 +05:30
|
|
|
return 0
|
2004-02-01 08:46:23 +05:30
|
|
|
|
2003-04-20 09:22:54 +05:30
|
|
|
self.g = codecs.getwriter("utf8")(g)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.write_xml_data()
|
2003-04-20 09:22:54 +05:30
|
|
|
g.close()
|
2004-07-09 23:49:47 +05:30
|
|
|
return 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_handle(self,handle):
|
|
|
|
"""
|
2003-04-20 09:22:54 +05:30
|
|
|
Write the database to the specified file handle.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
if self.compress:
|
|
|
|
try:
|
2003-04-20 09:22:54 +05:30
|
|
|
g = gzip.GzipFile(mode="wb",fileobj=handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
2003-04-20 09:22:54 +05:30
|
|
|
g = handle
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-04-20 09:22:54 +05:30
|
|
|
g = handle
|
|
|
|
|
|
|
|
self.g = codecs.getwriter("utf8")(g)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.write_xml_data()
|
2004-07-09 23:49:47 +05:30
|
|
|
g.close()
|
2003-04-20 09:22:54 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_xml_data(self):
|
|
|
|
|
|
|
|
date = string.split(time.ctime(time.time()))
|
2004-02-14 11:10:30 +05:30
|
|
|
owner = self.db.get_researcher()
|
|
|
|
person_len = self.db.get_number_of_people()
|
2004-08-22 18:15:47 +05:30
|
|
|
family_len = len(self.db.get_family_handles())
|
2004-08-13 10:04:07 +05:30
|
|
|
source_len = len(self.db.get_source_handles())
|
|
|
|
place_len = len(self.db.get_place_handles())
|
|
|
|
objList = self.db.get_media_object_handles()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
total = person_len + family_len + place_len + source_len
|
|
|
|
|
2003-10-14 08:43:52 +05:30
|
|
|
self.g.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('<!DOCTYPE database SYSTEM "gramps.dtd" []>\n')
|
2003-10-14 08:43:52 +05:30
|
|
|
self.g.write("<database xmlns=\"http://gramps.sourceforge.net/database\">\n")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" <header>\n")
|
2004-08-04 10:23:29 +05:30
|
|
|
self.g.write(" <created date=\"%s %s %s\"" % \
|
|
|
|
(date[2],string.upper(date[1]),date[4]))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" version=\"" + const.version + "\"")
|
|
|
|
self.g.write(" people=\"%d\"" % person_len)
|
|
|
|
self.g.write(" families=\"%d\"" % family_len)
|
|
|
|
self.g.write(" sources=\"%d\"" % source_len)
|
|
|
|
self.g.write(" places=\"%d\"/>\n" % place_len)
|
|
|
|
self.g.write(" <researcher>\n")
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_line("resname",owner.get_name(),3)
|
|
|
|
self.write_line("resaddr",owner.get_address(),3)
|
|
|
|
self.write_line("rescity",owner.get_city(),3)
|
|
|
|
self.write_line("resstate",owner.get_state(),3)
|
|
|
|
self.write_line("rescountry",owner.get_country(),3)
|
|
|
|
self.write_line("respostal",owner.get_postal_code(),3)
|
|
|
|
self.write_line("resphone",owner.get_phone(),3)
|
|
|
|
self.write_line("resemail",owner.get_email(),3)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" </researcher>\n")
|
|
|
|
self.g.write(" </header>\n")
|
|
|
|
|
|
|
|
count = 0
|
|
|
|
delta = max(int(total/50),1)
|
|
|
|
|
|
|
|
if person_len > 0:
|
|
|
|
self.g.write(" <people")
|
2004-02-14 11:10:30 +05:30
|
|
|
person = self.db.get_default_person()
|
2002-10-20 19:55:16 +05:30
|
|
|
if person:
|
2004-08-24 15:54:17 +05:30
|
|
|
self.g.write(' default="%s" home="%s"' %
|
|
|
|
(person.get_gramps_id (),
|
|
|
|
person.get_handle()))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(">\n")
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
keys = self.db.get_person_handles(sort_handles=False)
|
2004-08-22 17:51:01 +05:30
|
|
|
sorted_keys = []
|
2003-11-12 18:30:58 +05:30
|
|
|
for key in keys:
|
2004-08-22 17:51:01 +05:30
|
|
|
person = self.db.get_person_from_handle (key)
|
2004-10-06 09:12:54 +05:30
|
|
|
value = (person.get_gramps_id (), person)
|
|
|
|
sorted_keys.append (value)
|
2004-08-22 17:51:01 +05:30
|
|
|
|
|
|
|
sorted_keys.sort ()
|
|
|
|
for (gramps_id, person) in sorted_keys:
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.callback and count % delta == 0:
|
|
|
|
self.callback(float(count)/float(total))
|
2004-08-13 10:04:07 +05:30
|
|
|
count += 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.write_id("person",person,2)
|
2005-02-01 09:16:29 +05:30
|
|
|
if person.get_gender() == RelLib.Person.MALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_line("gender","M",3)
|
2005-02-01 09:16:29 +05:30
|
|
|
elif person.get_gender() == RelLib.Person.FEMALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_line("gender","F",3)
|
|
|
|
else:
|
|
|
|
self.write_line("gender","U",3)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.dump_name("name",person.get_primary_name(),3)
|
|
|
|
for name in person.get_alternate_names():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_name("aka",name,3)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_line("nick",person.get_nick_name(),3)
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
birth = self.db.get_event_from_handle(person.get_birth_handle())
|
|
|
|
death = self.db.get_event_from_handle(person.get_death_handle())
|
2004-02-19 10:35:43 +05:30
|
|
|
self.dump_my_event("Birth",birth,3)
|
|
|
|
self.dump_my_event("Death",death,3)
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in person.get_event_list():
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_event(event,3)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.dump_ordinance("baptism",person.get_lds_baptism(),3)
|
|
|
|
self.dump_ordinance("endowment",person.get_lds_endowment(),3)
|
|
|
|
self.dump_ordinance("sealed_to_parents",person.get_lds_sealing(),3)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
self.write_media_list(person.get_media_list())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if len(person.get_address_list()) > 0:
|
|
|
|
for address in person.get_address_list():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(' <address%s>\n' % conf_priv(address))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_date(address.get_date_object(),4)
|
|
|
|
self.write_line("street",address.get_street(),4)
|
|
|
|
self.write_line("city",address.get_city(),4)
|
|
|
|
self.write_line("state",address.get_state(),4)
|
|
|
|
self.write_line("country",address.get_country(),4)
|
|
|
|
self.write_line("postal",address.get_postal_code(),4)
|
|
|
|
self.write_line("phone",address.get_phone(),4)
|
|
|
|
if address.get_note() != "":
|
|
|
|
self.write_note("note",address.get_note_object(),4)
|
|
|
|
for s in address.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_source_ref(s,4)
|
|
|
|
self.g.write(' </address>\n')
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_attribute_list(person.get_attribute_list())
|
|
|
|
self.write_url_list(person.get_url_list())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for alt in person.get_parent_family_handle_list():
|
2002-10-20 19:55:16 +05:30
|
|
|
if alt[1] != "Birth":
|
|
|
|
mrel=' mrel="%s"' % alt[1]
|
|
|
|
else:
|
|
|
|
mrel=''
|
|
|
|
if alt[2] != "Birth":
|
|
|
|
frel=' frel="%s"' % alt[2]
|
|
|
|
else:
|
|
|
|
frel=''
|
2004-08-22 18:07:44 +05:30
|
|
|
parent_family = self.db.get_family_from_handle (alt[0])
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write(" <childof hlink=\"%s\"%s%s/>\n" % \
|
|
|
|
(parent_family.get_handle(), mrel, frel))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-22 18:07:44 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle (family_handle)
|
2004-08-24 09:18:15 +05:30
|
|
|
self.write_ref("parentin",family.get_handle(),3)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_note("note",person.get_note_object(),3)
|
|
|
|
for s in person.get_source_references():
|
2003-10-29 10:34:43 +05:30
|
|
|
self.dump_source_ref(s,4)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.g.write(" </person>\n")
|
|
|
|
self.g.write(" </people>\n")
|
|
|
|
|
|
|
|
if family_len > 0:
|
|
|
|
self.g.write(" <families>\n")
|
2003-06-19 15:19:43 +05:30
|
|
|
|
2004-08-22 18:15:47 +05:30
|
|
|
keys = self.db.get_family_handles()
|
|
|
|
sorted_keys = []
|
|
|
|
for key in keys:
|
|
|
|
family = self.db.get_family_from_handle(key)
|
2004-10-06 09:12:54 +05:30
|
|
|
value = (family.get_gramps_id (), family)
|
|
|
|
sorted_keys.append (value)
|
2004-08-22 18:15:47 +05:30
|
|
|
|
|
|
|
sorted_keys.sort ()
|
|
|
|
for (gramps_id, family) in sorted_keys:
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.callback and count % delta == 0:
|
|
|
|
self.callback(float(count)/float(total))
|
|
|
|
count = count + 1
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
self.write_family_handle(family,2)
|
2004-08-23 04:46:57 +05:30
|
|
|
fhandle = family.get_father_handle()
|
|
|
|
mhandle = family.get_mother_handle()
|
|
|
|
if fhandle:
|
2004-08-24 09:18:15 +05:30
|
|
|
fid = self.db.get_person_from_handle (fhandle).get_handle()
|
2004-08-22 18:22:33 +05:30
|
|
|
self.write_ref("father",fid,3)
|
2004-08-23 04:46:57 +05:30
|
|
|
if mhandle:
|
2004-08-24 09:18:15 +05:30
|
|
|
mid = self.db.get_person_from_handle (mhandle).get_handle()
|
2004-08-22 18:22:33 +05:30
|
|
|
self.write_ref("mother",mid,3)
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in family.get_event_list():
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_event(event,3)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.dump_ordinance("sealed_to_spouse",family.get_lds_sealing(),3)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
self.write_media_list(family.get_media_list())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if len(family.get_child_handle_list()) > 0:
|
2004-08-22 18:22:33 +05:30
|
|
|
for person_handle in family.get_child_handle_list():
|
|
|
|
person = self.db.get_person_from_handle (person_handle)
|
2004-08-24 09:18:15 +05:30
|
|
|
self.write_ref("child",person.get_handle(),3)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_attribute_list(family.get_attribute_list())
|
|
|
|
self.write_note("note",family.get_note_object(),3)
|
|
|
|
for s in family.get_source_references():
|
2003-10-29 10:34:43 +05:30
|
|
|
self.dump_source_ref(s,3)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" </family>\n")
|
|
|
|
self.g.write(" </families>\n")
|
|
|
|
|
|
|
|
if source_len > 0:
|
|
|
|
self.g.write(" <sources>\n")
|
2004-08-13 10:04:07 +05:30
|
|
|
keys = self.db.get_source_handles ()
|
2003-06-19 15:19:43 +05:30
|
|
|
keys.sort ()
|
|
|
|
for key in keys:
|
2004-08-07 10:46:57 +05:30
|
|
|
source = self.db.get_source_from_handle(key)
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.callback and count % delta == 0:
|
|
|
|
self.callback(float(count)/float(total))
|
|
|
|
count = count + 1
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write(" <source id=\"%s\" handle=\"%s\" change=\"%d\">\n" %
|
2004-11-23 10:45:37 +05:30
|
|
|
(source.get_gramps_id(), source.get_handle(),
|
|
|
|
source.get_change_time()))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_force_line("stitle",source.get_title(),3)
|
|
|
|
self.write_line("sauthor",source.get_author(),3)
|
|
|
|
self.write_line("spubinfo",source.get_publication_info(),3)
|
|
|
|
self.write_line("sabbrev",source.get_abbreviation(),3)
|
|
|
|
if source.get_note() != "":
|
|
|
|
self.write_note("note",source.get_note_object(),3)
|
2004-02-21 11:41:59 +05:30
|
|
|
self.write_media_list(source.get_media_list())
|
2004-11-23 10:45:37 +05:30
|
|
|
self.write_data_map(source.get_data_map())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" </source>\n")
|
|
|
|
self.g.write(" </sources>\n")
|
|
|
|
|
|
|
|
if place_len > 0:
|
|
|
|
self.g.write(" <places>\n")
|
2004-08-13 10:04:07 +05:30
|
|
|
keys = self.db.get_place_handles()
|
2003-06-19 15:19:43 +05:30
|
|
|
keys.sort ()
|
|
|
|
for key in keys:
|
2002-10-20 19:55:16 +05:30
|
|
|
try:
|
2004-08-22 17:36:19 +05:30
|
|
|
place = self.db.get_place_from_handle(key)
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.callback and count % delta == 0:
|
|
|
|
self.callback(float(count)/float(total))
|
|
|
|
self.write_place_obj(place)
|
|
|
|
except:
|
|
|
|
print "Could not find place %s" % key
|
|
|
|
count = count + 1
|
|
|
|
|
|
|
|
self.g.write(" </places>\n")
|
|
|
|
|
|
|
|
if len(objList) > 0:
|
|
|
|
self.g.write(" <objects>\n")
|
2004-08-22 21:49:45 +05:30
|
|
|
keys = self.db.get_media_object_handles()
|
|
|
|
sorted_keys = []
|
|
|
|
for key in keys:
|
2004-08-23 04:46:57 +05:30
|
|
|
obj = self.db.get_object_from_handle (key)
|
2004-10-06 09:12:54 +05:30
|
|
|
value = (obj.get_gramps_id (), obj)
|
|
|
|
sorted_keys.append (value)
|
2004-08-22 21:49:45 +05:30
|
|
|
|
|
|
|
sorted_keys.sort ()
|
2004-08-23 04:46:57 +05:30
|
|
|
for (gramps_id, obj) in sorted_keys:
|
|
|
|
self.write_object(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" </objects>\n")
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if len(self.db.get_bookmarks()) > 0:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" <bookmarks>\n")
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in self.db.get_bookmarks():
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write(' <bookmark hlink="%s"/>\n' % person_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" </bookmarks>\n")
|
|
|
|
|
2004-10-04 09:58:58 +05:30
|
|
|
if len(self.db.name_group) > 0:
|
|
|
|
self.g.write(' <groups>\n')
|
|
|
|
for key in self.db.name_group.keys():
|
|
|
|
self.g.write(' <group_map name="%s" group="%s"/>\n' %
|
|
|
|
(key,self.db.name_group[key]))
|
|
|
|
self.g.write(' </groups>\n')
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write("</database>\n")
|
|
|
|
|
|
|
|
def fix(self,line):
|
2003-10-14 08:43:52 +05:30
|
|
|
l = line.strip()
|
|
|
|
l = l.replace('&','&')
|
|
|
|
l = l.replace('>','>')
|
|
|
|
l = l.replace('<','<')
|
|
|
|
return l.replace('"','"')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-10 09:19:53 +05:30
|
|
|
def write_note(self,val,noteobj,indent=0):
|
|
|
|
if not noteobj:
|
|
|
|
return
|
|
|
|
text = noteobj.get()
|
|
|
|
if not text:
|
|
|
|
return
|
|
|
|
if indent != 0:
|
|
|
|
self.g.write(" " * indent)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
format = noteobj.get_format()
|
2003-12-29 21:25:08 +05:30
|
|
|
if format:
|
|
|
|
self.g.write('<%s format="%d">' % (val,format))
|
|
|
|
else:
|
|
|
|
self.g.write('<%s>' % val)
|
2003-12-10 09:19:53 +05:30
|
|
|
self.g.write(self.fix(string.rstrip(text)))
|
|
|
|
self.g.write("</%s>\n" % val)
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2003-12-10 09:19:53 +05:30
|
|
|
def write_text(self,val,text,indent=0):
|
|
|
|
if not text:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
if indent != 0:
|
|
|
|
self.g.write(" " * indent)
|
|
|
|
|
2003-12-10 09:19:53 +05:30
|
|
|
self.g.write('<%s>' % val)
|
|
|
|
self.g.write(self.fix(string.rstrip(text)))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write("</%s>\n" % val)
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def dump_event(self,event,index=1):
|
|
|
|
if event:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.dump_my_event(event.get_name(),event,index)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-02-24 10:21:57 +05:30
|
|
|
def write_witness(self,witness_list,index):
|
|
|
|
if not witness_list:
|
|
|
|
return
|
|
|
|
for w in witness_list:
|
|
|
|
sp = " "*index
|
|
|
|
com = self.fix(w.get_comment())
|
|
|
|
if w.get_type() == RelLib.Event.ID:
|
2003-10-14 08:43:52 +05:30
|
|
|
self.g.write('%s<witness>\n' % sp)
|
2005-01-16 09:30:35 +05:30
|
|
|
self.g.write(' %s<hlink>%s</hlink>\n' % (sp,w.get_value()))
|
2003-10-14 08:43:52 +05:30
|
|
|
if com:
|
|
|
|
self.g.write(' %s<comment>%s</comment>\n' % (sp,com))
|
|
|
|
self.g.write('%s</witness>\n' % sp)
|
2003-02-24 10:21:57 +05:30
|
|
|
else:
|
2003-11-24 02:23:20 +05:30
|
|
|
nm = self.fix(w.get_value())
|
2003-10-14 08:43:52 +05:30
|
|
|
self.g.write('%s<witness>\n' % sp)
|
2003-11-24 02:23:20 +05:30
|
|
|
self.g.write(' %s<name>%s</name>\n' % (sp,nm))
|
2003-10-14 08:43:52 +05:30
|
|
|
if com:
|
|
|
|
self.g.write(' %s<comment>%s</comment>\n' % (sp,com))
|
|
|
|
self.g.write('%s</witness>\n' % sp)
|
2003-02-24 10:21:57 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def dump_my_event(self,name,event,index=1):
|
|
|
|
if not event or event.is_empty():
|
|
|
|
return
|
|
|
|
|
|
|
|
sp = " " * index
|
2003-08-07 09:24:10 +05:30
|
|
|
name = const.save_event(name)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('%s<event type="%s"%s>\n' % (sp,self.fix(name),conf_priv(event)))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_date(event.get_date_object(),index+1)
|
2003-02-24 10:21:57 +05:30
|
|
|
|
|
|
|
self.write_witness(event.get_witness_list(),index+1)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.write_ref("place",event.get_place_handle(),index+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_line("cause",event.get_cause(),index+1)
|
|
|
|
self.write_line("description",event.get_description(),index+1)
|
|
|
|
if event.get_note():
|
|
|
|
self.write_note("note",event.get_note_object(),index+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for s in event.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_source_ref(s,index+1)
|
2004-06-03 11:05:30 +05:30
|
|
|
self.write_media_list(event.get_media_list(),index+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write("%s</event>\n" % sp)
|
|
|
|
|
|
|
|
def dump_ordinance(self,name,ord,index=1):
|
|
|
|
if not ord:
|
|
|
|
return
|
|
|
|
|
|
|
|
sp = " " * index
|
|
|
|
sp2 = " " * (index+1)
|
|
|
|
self.g.write('%s<lds_ord type="%s">\n' % (sp,self.fix(name)))
|
2004-02-14 11:10:30 +05:30
|
|
|
dateobj = ord.get_date_object()
|
2005-01-16 09:30:35 +05:30
|
|
|
if dateobj and not dateobj.is_empty():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_date(dateobj,index+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
if ord.get_temple():
|
|
|
|
self.g.write('%s<temple val="%s"/>\n' % (sp2,self.fix(ord.get_temple())))
|
2004-07-28 07:59:07 +05:30
|
|
|
self.write_ref("place",ord.get_place_handle(),index+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
if ord.get_status() != 0:
|
|
|
|
self.g.write('%s<status val="%d"/>\n' % (sp2,ord.get_status()))
|
2004-07-28 07:59:07 +05:30
|
|
|
if ord.get_family_handle():
|
2005-01-16 09:30:35 +05:30
|
|
|
self.g.write('%s<sealed_to hlink="%s"/>\n' %
|
|
|
|
(sp2,self.fix(ord.get_family_handle())))
|
2004-02-14 11:10:30 +05:30
|
|
|
if ord.get_note() != "":
|
|
|
|
self.write_note("note",ord.get_note_object(),index+1)
|
|
|
|
for s in ord.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_source_ref(s,index+1)
|
|
|
|
self.g.write('%s</lds_ord>\n' % sp)
|
|
|
|
|
|
|
|
def dump_source_ref(self,source_ref,index=1):
|
2004-08-07 10:46:57 +05:30
|
|
|
source = self.db.get_source_from_handle(source_ref.get_base_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
if source:
|
2004-02-14 11:10:30 +05:30
|
|
|
p = source_ref.get_page()
|
|
|
|
c = source_ref.get_comments()
|
|
|
|
t = source_ref.get_text()
|
|
|
|
d = source_ref.get_date()
|
|
|
|
q = source_ref.get_confidence_level()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(" " * index)
|
2004-02-14 11:10:30 +05:30
|
|
|
if p == "" and c == "" and t == "" and d.is_empty() and q == 2:
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('<sourceref hlink="%s"/>\n' % source.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
if q == 2:
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('<sourceref hlink="%s">\n' % source.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('<sourceref hlink="%s" conf="%d">\n' % (source.get_handle(),q))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_line("spage",p,index+1)
|
2003-12-10 09:19:53 +05:30
|
|
|
self.write_text("scomments",c,index+1)
|
|
|
|
self.write_text("stext",t,index+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_date(d,index+1)
|
|
|
|
self.g.write("%s</sourceref>\n" % (" " * index))
|
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
def write_ref(self,label,gid,index=1):
|
|
|
|
if gid:
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('%s<%s hlink="%s"/>\n' % (" "*index,label,gid))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_id(self,label,person,index=1):
|
|
|
|
if person:
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('%s<%s id="%s" handle="%s" change="%d"' %
|
|
|
|
(" "*index,label,person.get_gramps_id(),person.get_handle(),
|
|
|
|
person.get_change_time()))
|
2004-08-13 10:04:07 +05:30
|
|
|
comp = person.get_complete_flag()
|
2003-12-03 09:19:39 +05:30
|
|
|
if comp:
|
|
|
|
self.g.write(' complete="1"')
|
|
|
|
self.g.write('>\n')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def write_family_handle(self,family,index=1):
|
2002-10-20 19:55:16 +05:30
|
|
|
if family:
|
2004-02-14 11:10:30 +05:30
|
|
|
rel = family.get_relationship()
|
2004-08-13 10:04:07 +05:30
|
|
|
comp = family.get_complete_flag()
|
2002-10-20 19:55:16 +05:30
|
|
|
sp = " " * index
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('%s<family id="%s" handle="%s" change="%d"' %
|
|
|
|
(sp,family.get_gramps_id(),family.get_handle(),family.get_change_time()))
|
2003-10-29 10:34:43 +05:30
|
|
|
if comp:
|
|
|
|
self.g.write(' complete="1"')
|
2002-10-20 19:55:16 +05:30
|
|
|
if rel != "":
|
2003-08-07 09:24:10 +05:30
|
|
|
self.g.write(' type="%s">\n' % const.save_frel(rel))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.g.write('>\n')
|
|
|
|
|
2002-12-04 10:28:07 +05:30
|
|
|
def write_last(self,name,indent=1):
|
2004-02-19 10:35:43 +05:30
|
|
|
p = name.get_surname_prefix()
|
|
|
|
n = name.get_surname()
|
2004-10-04 09:58:58 +05:30
|
|
|
g = name.get_group_as()
|
|
|
|
self.g.write('%s<last' % (' '*indent))
|
2002-12-04 10:28:07 +05:30
|
|
|
if p:
|
2004-10-04 09:58:58 +05:30
|
|
|
self.g.write(' prefix="%s"' % p)
|
|
|
|
if g:
|
|
|
|
self.g.write(' group="%s"' % g)
|
|
|
|
self.g.write('>%s</last>\n' % self.fix(n))
|
2002-12-04 10:28:07 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_line(self,label,value,indent=1):
|
|
|
|
if value:
|
|
|
|
self.g.write('%s<%s>%s</%s>\n' % (' '*indent,label,self.fix(value),label))
|
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
def get_iso_date(self,date):
|
|
|
|
if date[2] == 0:
|
|
|
|
y = "????"
|
|
|
|
else:
|
|
|
|
y = "%04d" % date[2]
|
|
|
|
|
|
|
|
if date[1] == 0:
|
|
|
|
if date[0] == 0:
|
|
|
|
m = ""
|
|
|
|
else:
|
|
|
|
m = "-??"
|
|
|
|
else:
|
|
|
|
m = "-%02d" % (date[1])
|
|
|
|
if date[0] == 0:
|
|
|
|
d = ''
|
|
|
|
else:
|
|
|
|
d = "-%02d" % date[0]
|
|
|
|
return "%s%s%s" % (y,m,d)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_date(self,date,indent=1):
|
|
|
|
sp = ' '*indent
|
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
cal= date.get_calendar()
|
|
|
|
if cal != Date.CAL_GREGORIAN:
|
|
|
|
calstr = ' cformat="%s"' % Date.Date.calendar_names[cal]
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
calstr = ''
|
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
mode = date.get_modifier()
|
|
|
|
|
|
|
|
if date.is_compound():
|
|
|
|
d1 = self.get_iso_date(date.get_start_date())
|
|
|
|
d2 = self.get_iso_date(date.get_stop_date())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('%s<daterange start="%s" stop="%s"%s/>\n' % (sp,d1,d2,calstr))
|
2004-09-17 09:00:04 +05:30
|
|
|
elif mode != Date.MOD_TEXTONLY:
|
|
|
|
dstr = self.get_iso_date(date.get_start_date())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
if mode == Date.MOD_BEFORE:
|
2002-10-20 19:55:16 +05:30
|
|
|
pref = ' type="before"'
|
2004-09-17 09:00:04 +05:30
|
|
|
elif mode == Date.MOD_AFTER:
|
2002-10-20 19:55:16 +05:30
|
|
|
pref = ' type="after"'
|
2004-09-17 09:00:04 +05:30
|
|
|
elif mode == Date.MOD_ABOUT:
|
2002-10-20 19:55:16 +05:30
|
|
|
pref = ' type="about"'
|
|
|
|
else:
|
|
|
|
pref = ""
|
|
|
|
|
|
|
|
self.g.write('%s<dateval val="%s"%s%s/>\n' % (sp,dstr,pref,calstr))
|
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.g.write('%s<datestr val="%s"/>\n' %(sp,self.fix(date.get_text())))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_force_line(self,label,value,indent=1):
|
|
|
|
if value != None:
|
|
|
|
self.g.write('%s<%s>%s</%s>\n' % (' '*indent,label,self.fix(value),label))
|
|
|
|
|
|
|
|
def dump_name(self,label,name,index=1):
|
|
|
|
sp = " "*index
|
2004-08-23 04:46:57 +05:30
|
|
|
name_type = name.get_type()
|
2004-10-04 09:58:58 +05:30
|
|
|
self.g.write('%s<%s' % (sp,label))
|
2004-08-23 04:46:57 +05:30
|
|
|
if name_type:
|
2004-10-04 09:58:58 +05:30
|
|
|
self.g.write(' type="%s"' % name_type)
|
|
|
|
if name.get_privacy() != 0:
|
|
|
|
self.g.write(' priv="%d"' % name.get_privacy())
|
|
|
|
if name.get_sort_as() != 0:
|
|
|
|
self.g.write(' sort="%d"' % name.get_sort_as())
|
|
|
|
if name.get_display_as() != 0:
|
|
|
|
self.g.write(' display="%d"' % name.get_display_as())
|
|
|
|
self.g.write('>\n')
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_line("first",name.get_first_name(),index+1)
|
2002-12-04 10:28:07 +05:30
|
|
|
self.write_last(name,index+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_line("suffix",name.get_suffix(),index+1)
|
2004-10-04 09:58:58 +05:30
|
|
|
self.write_line("patronymic",name.get_patronymic(),index+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_line("title",name.get_title(),index+1)
|
|
|
|
if name.get_note() != "":
|
|
|
|
self.write_note("note",name.get_note_object(),index+1)
|
|
|
|
for s in name.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_source_ref(s,index+1)
|
|
|
|
|
|
|
|
self.g.write('%s</%s>\n' % (sp,label))
|
|
|
|
|
|
|
|
def append_value(self,orig,val):
|
|
|
|
if orig:
|
|
|
|
return "%s, %s" % (orig,val)
|
|
|
|
else:
|
|
|
|
return val
|
|
|
|
|
|
|
|
def build_place_title(self,loc):
|
|
|
|
"Builds a title from a location"
|
|
|
|
city = self.fix(loc.get_city())
|
|
|
|
parish = self.fix(loc.get_parish())
|
|
|
|
state = self.fix(loc.get_state())
|
|
|
|
country = self.fix(loc.get_country())
|
|
|
|
county = self.fix(loc.get_county())
|
|
|
|
|
|
|
|
value = ""
|
|
|
|
|
|
|
|
if city:
|
|
|
|
value = city
|
|
|
|
if parish:
|
|
|
|
value = self.append_value(value,parish)
|
|
|
|
if county:
|
|
|
|
value = self.append_value(value,county)
|
|
|
|
if state:
|
|
|
|
value = self.append_value(value,state)
|
|
|
|
if country:
|
|
|
|
value = self.append_value(value,country)
|
|
|
|
return value
|
|
|
|
|
|
|
|
def dump_location(self,loc):
|
|
|
|
"Writes the location information to the output file"
|
|
|
|
city = self.fix(loc.get_city())
|
|
|
|
parish = self.fix(loc.get_parish())
|
|
|
|
state = self.fix(loc.get_state())
|
|
|
|
country = self.fix(loc.get_country())
|
|
|
|
county = self.fix(loc.get_county())
|
2004-10-06 09:12:54 +05:30
|
|
|
zip_code = self.fix(loc.get_postal_code())
|
2003-12-09 11:32:36 +05:30
|
|
|
phone = self.fix(loc.get_phone())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.g.write(' <location')
|
|
|
|
if city:
|
|
|
|
self.g.write(' city="%s"' % city)
|
|
|
|
if parish:
|
|
|
|
self.g.write(' parish="%s"' % parish)
|
|
|
|
if county:
|
|
|
|
self.g.write(' county="%s"' % county)
|
|
|
|
if state:
|
|
|
|
self.g.write(' state="%s"' % state)
|
|
|
|
if country:
|
|
|
|
self.g.write(' country="%s"' % country)
|
2004-10-06 09:12:54 +05:30
|
|
|
if zip_code:
|
|
|
|
self.g.write(' postal="%s"' % zip_code)
|
2003-12-09 11:32:36 +05:30
|
|
|
if phone:
|
|
|
|
self.g.write(' phone="%s"' % phone)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('/>\n')
|
|
|
|
|
|
|
|
def write_attribute_list(self, list, indent=3):
|
|
|
|
sp = ' ' * indent
|
|
|
|
for attr in list:
|
|
|
|
self.g.write('%s<attribute%s type="%s" value="%s"' % \
|
2004-02-14 11:10:30 +05:30
|
|
|
(sp,conf_priv(attr),const.save_attr(attr.get_type()),
|
|
|
|
self.fix(attr.get_value())))
|
|
|
|
slist = attr.get_source_references()
|
|
|
|
note = attr.get_note()
|
2002-10-20 19:55:16 +05:30
|
|
|
if note == "" and len(slist) == 0:
|
|
|
|
self.g.write('/>\n')
|
|
|
|
else:
|
|
|
|
self.g.write('>\n')
|
2004-02-14 11:10:30 +05:30
|
|
|
for s in attr.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_source_ref(s,indent+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_note("note",attr.get_note_object(),4)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('%s</attribute>\n' % sp)
|
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
def write_media_list(self,list,indent=3):
|
2002-10-20 19:55:16 +05:30
|
|
|
sp = ' '*indent
|
|
|
|
for photo in list:
|
2004-07-28 07:59:07 +05:30
|
|
|
mobj_id = photo.get_reference_handle()
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write('%s<objref hlink="%s"' % (sp,mobj_id))
|
2004-02-14 11:10:30 +05:30
|
|
|
if photo.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write(' priv="1"')
|
2004-02-14 11:10:30 +05:30
|
|
|
proplist = photo.get_attribute_list()
|
2004-06-03 11:05:30 +05:30
|
|
|
refslist = photo.get_source_references()
|
|
|
|
if len(proplist) == 0 and len(refslist) == 0 \
|
|
|
|
and photo.get_note() == "":
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write("/>\n")
|
|
|
|
else:
|
|
|
|
self.g.write(">\n")
|
|
|
|
self.write_attribute_list(proplist,indent+1)
|
2004-06-03 11:05:30 +05:30
|
|
|
for ref in refslist:
|
|
|
|
self.dump_source_ref(ref,indent+1)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_note("note",photo.get_note_object(),indent+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('%s</objref>\n' % sp)
|
|
|
|
|
2004-11-23 10:45:37 +05:30
|
|
|
def write_data_map(self,datamap,indent=3):
|
|
|
|
if len(datamap) == 0:
|
|
|
|
return
|
|
|
|
|
|
|
|
sp = ' '*indent
|
|
|
|
for key in datamap.keys():
|
|
|
|
self.g.write('%s<data_item key="%s" value="%s"/>' %
|
|
|
|
(sp,key,datamap[key]))
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_url_list(self,list):
|
|
|
|
for url in list:
|
|
|
|
self.g.write(' <url priv="%d" href="%s"' % \
|
2004-02-14 11:10:30 +05:30
|
|
|
(url.get_privacy(),self.fix(url.get_path())))
|
2002-10-20 19:55:16 +05:30
|
|
|
if url.get_description() != "":
|
|
|
|
self.g.write(' description="%s"' % self.fix(url.get_description()))
|
|
|
|
self.g.write('/>\n')
|
|
|
|
|
|
|
|
def write_place_obj(self,place):
|
|
|
|
title = self.fix(place.get_title())
|
2004-10-06 09:12:54 +05:30
|
|
|
longitude = self.fix(place.get_longitude())
|
2002-10-20 19:55:16 +05:30
|
|
|
lat = self.fix(place.get_latitude())
|
2004-10-06 09:12:54 +05:30
|
|
|
handle = place.get_gramps_id()
|
2002-10-20 19:55:16 +05:30
|
|
|
main_loc = place.get_main_location()
|
2004-02-14 11:10:30 +05:30
|
|
|
llen = len(place.get_alternate_locations()) + len(place.get_url_list()) + \
|
2004-02-21 11:41:59 +05:30
|
|
|
len(place.get_media_list()) + len(place.get_source_references())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
ml_empty = main_loc.is_empty()
|
2004-02-14 11:10:30 +05:30
|
|
|
note = place.get_note()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if title == "":
|
|
|
|
title = self.fix(self.build_place_title(place.get_main_location()))
|
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write(' <placeobj id="%s" handle="%s" change="%d" title="%s"' %
|
2004-10-06 09:12:54 +05:30
|
|
|
(handle,place.get_handle(),place.get_change_time(),title))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-06 09:12:54 +05:30
|
|
|
if longitude or lat or not ml_empty or llen > 0 or note:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('>\n')
|
|
|
|
else:
|
|
|
|
self.g.write('/>\n')
|
|
|
|
return
|
|
|
|
|
2004-10-06 09:12:54 +05:30
|
|
|
if longitude or lat:
|
|
|
|
self.g.write(' <coord long="%s" lat="%s"/>\n' % (longitude,lat))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.dump_location(main_loc)
|
|
|
|
for loc in place.get_alternate_locations():
|
|
|
|
self.dump_location(loc)
|
2004-02-21 11:41:59 +05:30
|
|
|
self.write_media_list(place.get_media_list())
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_url_list(place.get_url_list())
|
2002-10-20 19:55:16 +05:30
|
|
|
if note != "":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_note("note",place.get_note_object(),3)
|
|
|
|
for s in place.get_source_references():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_source_ref(s,3)
|
|
|
|
self.g.write(" </placeobj>\n")
|
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
def write_object(self,obj):
|
2004-10-06 09:12:54 +05:30
|
|
|
handle = obj.get_gramps_id()
|
2004-08-23 04:46:57 +05:30
|
|
|
mime_type = obj.get_mime_type()
|
|
|
|
path = obj.get_path()
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.strip_photos:
|
|
|
|
path = os.path.basename(path)
|
|
|
|
else:
|
|
|
|
l = len(self.fileroot)
|
|
|
|
if len(path) >= l:
|
|
|
|
if self.fileroot == path[0:l]:
|
|
|
|
path = path[l+1:]
|
2004-08-24 09:18:15 +05:30
|
|
|
self.g.write(' <object id="%s" handle="%s" change="%d" src="%s" mime="%s"' %
|
2004-10-06 09:12:54 +05:30
|
|
|
(handle,obj.get_handle(),obj.get_change_time(),path,mime_type))
|
2004-08-23 04:46:57 +05:30
|
|
|
self.g.write(' description="%s"' % self.fix(obj.get_description()))
|
|
|
|
alist = obj.get_attribute_list()
|
|
|
|
note = obj.get_note()
|
2004-11-06 09:01:34 +05:30
|
|
|
phandle = obj.get_place_handle()
|
|
|
|
dval = obj.get_date_object()
|
2004-08-23 04:46:57 +05:30
|
|
|
slist = obj.get_source_references()
|
2004-11-06 09:01:34 +05:30
|
|
|
if len(alist) == 0 and len(slist) == 0 and note == "" and \
|
|
|
|
phandle == "" and not dval.is_empty():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.g.write('/>\n')
|
|
|
|
else:
|
|
|
|
self.g.write('>\n')
|
|
|
|
self.write_attribute_list(alist)
|
|
|
|
if note != "":
|
2004-08-23 04:46:57 +05:30
|
|
|
self.write_note("note",obj.get_note_object(),3)
|
2004-11-06 09:01:34 +05:30
|
|
|
if phandle:
|
|
|
|
self.g.write(' <place ref="%s"/>\n' % phandle)
|
|
|
|
if not dval.is_empty():
|
|
|
|
self.write_date(dval,3)
|
2002-10-20 19:55:16 +05:30
|
|
|
for s in slist:
|
|
|
|
self.dump_source_ref(s,3)
|
|
|
|
self.g.write(" </object>\n")
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def sortById(first,second):
|
2004-08-01 09:51:31 +05:30
|
|
|
fid = first.get_gramps_id()
|
|
|
|
sid = second.get_gramps_id()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if fid < sid:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return fid != sid
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def conf_priv(obj):
|
2004-02-14 11:10:30 +05:30
|
|
|
if obj.get_privacy() != 0:
|
|
|
|
return ' priv="%d"' % obj.get_privacy()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
return ''
|
2004-07-01 09:39:55 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-09 23:49:47 +05:30
|
|
|
_title = _('GRAMPS _XML database')
|
|
|
|
_description = _('The GRAMPS XML database is a format used by older '
|
|
|
|
'versions of GRAMPS. It is read-write compatible with '
|
|
|
|
'the present GRAMPS database format.')
|
|
|
|
_config = None
|
|
|
|
_filename = 'gramps'
|
2004-07-01 09:39:55 +05:30
|
|
|
|
2005-01-05 10:32:19 +05:30
|
|
|
from PluginMgr import register_export
|
2004-07-09 23:49:47 +05:30
|
|
|
register_export(exportData,_title,_description,_config,_filename)
|