2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-02-22 10:38:40 +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-12-03 09:19:39 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-08-11 06:29:16 +05:30
|
|
|
import const
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
|
|
|
import Date
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
import string
|
2003-01-02 10:01:52 +05:30
|
|
|
import Calendar
|
2002-10-20 19:55:16 +05:30
|
|
|
import Utils
|
|
|
|
import xml.parsers.expat
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Remove extraneous spaces
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def rs(text):
|
|
|
|
return string.join(string.split(text))
|
|
|
|
|
|
|
|
def fix_spaces(text_list):
|
|
|
|
return string.join(map(rs,text_list),'\n')
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps database parsing class. Derived from SAX XML parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class GrampsParser:
|
|
|
|
|
|
|
|
def __init__(self,database,callback,base):
|
|
|
|
self.stext_list = []
|
|
|
|
self.scomments_list = []
|
|
|
|
self.note_list = []
|
|
|
|
self.tlist = []
|
|
|
|
self.conf = 2
|
|
|
|
|
|
|
|
self.ord = None
|
|
|
|
self.objref = None
|
|
|
|
self.object = None
|
|
|
|
self.pref = None
|
|
|
|
self.use_p = 0
|
|
|
|
self.in_note = 0
|
|
|
|
self.in_stext = 0
|
|
|
|
self.in_scomments = 0
|
2003-10-14 08:43:52 +05:30
|
|
|
self.in_witness = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = database
|
|
|
|
self.base = base
|
|
|
|
self.photo = None
|
|
|
|
self.person = None
|
|
|
|
self.family = None
|
|
|
|
self.address = None
|
|
|
|
self.source = None
|
|
|
|
self.source_ref = None
|
|
|
|
self.attribute = None
|
|
|
|
self.placeobj = None
|
|
|
|
self.locations = 0
|
|
|
|
self.place_map = {}
|
|
|
|
|
|
|
|
self.resname = ""
|
|
|
|
self.resaddr = ""
|
|
|
|
self.rescity = ""
|
|
|
|
self.resstate = ""
|
|
|
|
self.rescon = ""
|
|
|
|
self.respos = ""
|
|
|
|
self.resphone = ""
|
|
|
|
self.resemail = ""
|
|
|
|
|
|
|
|
self.pmap = {}
|
|
|
|
self.fmap = {}
|
|
|
|
self.smap = {}
|
2003-05-05 07:06:21 +05:30
|
|
|
self.lmap = {}
|
2004-02-29 05:34:45 +05:30
|
|
|
self.media_file_map = {}
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.callback = callback
|
|
|
|
self.entries = 0
|
|
|
|
self.count = 0
|
|
|
|
self.increment = 100
|
|
|
|
self.event = None
|
|
|
|
self.name = None
|
|
|
|
self.tempDefault = None
|
2003-01-10 10:51:32 +05:30
|
|
|
self.owner = RelLib.Researcher()
|
2004-02-29 05:34:45 +05:30
|
|
|
self.func_list = [None]*50
|
|
|
|
self.func_index = 0
|
|
|
|
self.func = None
|
2003-10-14 08:43:52 +05:30
|
|
|
self.witness_comment = ""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-05-05 07:06:21 +05:30
|
|
|
self.func_map = {
|
|
|
|
"address" : (self.start_address, self.stop_address),
|
|
|
|
"addresses" : (None,None),
|
|
|
|
"childlist" : (None,None),
|
|
|
|
"aka" : (self.start_name, self.stop_aka),
|
|
|
|
"attribute" : (self.start_attribute, self.stop_attribute),
|
|
|
|
"attr_type" : (None,self.stop_attr_type),
|
|
|
|
"attr_value" : (None,self.stop_attr_value),
|
|
|
|
"bookmark" : (self.start_bmark, None),
|
|
|
|
"witness" : (self.start_witness,self.stop_witness),
|
|
|
|
"bookmarks" : (None, None),
|
|
|
|
"child" : (self.start_child,None),
|
|
|
|
"childof" : (self.start_childof,None),
|
|
|
|
"city" : (None, self.stop_city),
|
|
|
|
"country" : (None, self.stop_country),
|
2003-10-14 08:43:52 +05:30
|
|
|
"comment" : (None, self.stop_comment),
|
2003-05-05 07:06:21 +05:30
|
|
|
"created" : (self.start_created, None),
|
2003-10-14 08:43:52 +05:30
|
|
|
"ref" : (None, self.stop_ref),
|
2003-05-05 07:06:21 +05:30
|
|
|
"database" : (None, None),
|
2003-12-09 11:32:36 +05:30
|
|
|
"phone" : (None, self.stop_phone),
|
2003-05-05 07:06:21 +05:30
|
|
|
"date" : (None, self.stop_date),
|
|
|
|
"cause" : (None, self.stop_cause),
|
|
|
|
"description": (None, self.stop_description),
|
|
|
|
"event" : (self.start_event, self.stop_event),
|
|
|
|
"families" : (None, self.stop_families),
|
2003-10-29 10:34:43 +05:30
|
|
|
"family" : (self.start_family, self.stop_family),
|
2003-05-05 07:06:21 +05:30
|
|
|
"father" : (self.start_father, None),
|
|
|
|
"first" : (None, self.stop_first),
|
|
|
|
"gender" : (None, self.stop_gender),
|
|
|
|
"header" : (None, None),
|
|
|
|
"last" : (self.start_last, self.stop_last),
|
|
|
|
"mother" : (self.start_mother,None),
|
|
|
|
"name" : (self.start_name, self.stop_name),
|
|
|
|
"nick" : (None, self.stop_nick),
|
|
|
|
"note" : (self.start_note, self.stop_note),
|
|
|
|
"p" : (None, self.stop_ptag),
|
|
|
|
"parentin" : (self.start_parentin,None),
|
2004-02-21 11:41:59 +05:30
|
|
|
"people" : (self.start_people, self.stop_people),
|
2003-05-05 07:06:21 +05:30
|
|
|
"person" : (self.start_person, self.stop_person),
|
|
|
|
"img" : (self.start_photo, self.stop_photo),
|
|
|
|
"objref" : (self.start_objref, self.stop_objref),
|
|
|
|
"object" : (self.start_object, self.stop_object),
|
|
|
|
"place" : (self.start_place, self.stop_place),
|
|
|
|
"dateval" : (self.start_dateval, None),
|
|
|
|
"daterange" : (self.start_daterange, None),
|
|
|
|
"datestr" : (self.start_datestr, None),
|
|
|
|
"places" : (None, self.stop_places),
|
|
|
|
"placeobj" : (self.start_placeobj,self.stop_placeobj),
|
|
|
|
"location" : (self.start_location,None),
|
|
|
|
"lds_ord" : (self.start_lds_ord, self.stop_lds_ord),
|
|
|
|
"temple" : (self.start_temple, None),
|
|
|
|
"status" : (self.start_status, None),
|
|
|
|
"sealed_to" : (self.start_sealed_to, None),
|
|
|
|
"coord" : (self.start_coord,None),
|
|
|
|
"pos" : (self.start_pos, None),
|
|
|
|
"postal" : (None, self.stop_postal),
|
|
|
|
"researcher" : (None, self.stop_research),
|
|
|
|
"resname" : (None, self.stop_resname ),
|
|
|
|
"resaddr" : (None, self.stop_resaddr ),
|
|
|
|
"rescity" : (None, self.stop_rescity ),
|
|
|
|
"resstate" : (None, self.stop_resstate ),
|
|
|
|
"rescountry" : (None, self.stop_rescountry),
|
|
|
|
"respostal" : (None, self.stop_respostal),
|
|
|
|
"resphone" : (None, self.stop_resphone),
|
|
|
|
"resemail" : (None, self.stop_resemail),
|
|
|
|
"sauthor" : (None, self.stop_sauthor),
|
2003-12-08 07:53:53 +05:30
|
|
|
"sabbrev" : (None, self.stop_sabbrev),
|
2003-05-05 07:06:21 +05:30
|
|
|
"scomments" : (None, self.stop_scomments),
|
|
|
|
"sdate" : (None,self.stop_sdate),
|
|
|
|
"source" : (self.start_source, self.stop_source),
|
|
|
|
"sourceref" : (self.start_sourceref, self.stop_sourceref),
|
|
|
|
"sources" : (None, None),
|
|
|
|
"spage" : (None, self.stop_spage),
|
|
|
|
"spubinfo" : (None, self.stop_spubinfo),
|
|
|
|
"state" : (None, self.stop_state),
|
|
|
|
"stext" : (None, self.stop_stext),
|
|
|
|
"stitle" : (None, self.stop_stitle),
|
|
|
|
"street" : (None, self.stop_street),
|
|
|
|
"suffix" : (None, self.stop_suffix),
|
|
|
|
"title" : (None, self.stop_title),
|
|
|
|
"url" : (self.start_url, None)
|
|
|
|
}
|
|
|
|
|
2003-05-13 01:09:49 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def parse(self,file):
|
|
|
|
p = xml.parsers.expat.ParserCreate()
|
|
|
|
p.StartElementHandler = self.startElement
|
|
|
|
p.EndElementHandler = self.endElement
|
|
|
|
p.CharacterDataHandler = self.characters
|
|
|
|
p.ParseFile(file)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.db.set_researcher(self.owner)
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.tempDefault != None:
|
|
|
|
id = self.tempDefault
|
2004-02-21 11:41:59 +05:30
|
|
|
if self.db.has_person_id(id) and self.db.get_default_person() == None:
|
2004-03-23 10:31:19 +05:30
|
|
|
self.db.set_default_person_id(id)
|
2003-07-28 00:06:37 +05:30
|
|
|
|
2003-05-13 01:09:49 +05:30
|
|
|
for key in self.func_map.keys():
|
|
|
|
del self.func_map[key]
|
2003-07-28 00:06:37 +05:30
|
|
|
del self.func_map
|
|
|
|
del self.func_list
|
|
|
|
del p
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_lds_ord(self,attrs):
|
|
|
|
type = attrs['type']
|
2003-01-10 10:51:32 +05:30
|
|
|
self.ord = RelLib.LdsOrd()
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.person:
|
|
|
|
if type == "baptism":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_lds_baptism(self.ord)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif type == "endowment":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_lds_endowment(self.ord)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif type == "sealed_to_parents":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_lds_sealing(self.ord)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.family:
|
|
|
|
if type == "sealed_to_spouse":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_lds_sealing(self.ord)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_temple(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.ord.set_temple(attrs['val'])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_status(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.ord.set_status(int(attrs['val']))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_sealed_to(self,attrs):
|
|
|
|
id = attrs['ref']
|
2004-02-14 11:10:30 +05:30
|
|
|
self.ord.set_family_id(self.db.find_family_no_map(id))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_place(self,attrs):
|
|
|
|
if attrs.has_key('ref'):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj = self.db.find_place_from_id(attrs['ref'])
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.placeobj = None
|
|
|
|
|
|
|
|
def start_placeobj(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj = self.db.find_place_from_id(attrs['id'])
|
2002-10-20 19:55:16 +05:30
|
|
|
title = attrs['title']
|
|
|
|
if title == "":
|
|
|
|
title = attrs['id']
|
|
|
|
self.placeobj.set_title(title)
|
|
|
|
self.locations = 0
|
|
|
|
if self.num_places > 0:
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2003-10-29 10:34:43 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def start_location(self,attrs):
|
|
|
|
"""Bypass the function calls for this one, since it appears to
|
|
|
|
take up quite a bit of time"""
|
|
|
|
|
2003-01-10 10:51:32 +05:30
|
|
|
loc = RelLib.Location()
|
2003-12-09 11:32:36 +05:30
|
|
|
if attrs.has_key('phone'):
|
|
|
|
loc.phone = attrs['phone']
|
|
|
|
if attrs.has_key('postal'):
|
|
|
|
loc.postal = attrs['postal']
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key('city'):
|
|
|
|
loc.city = attrs['city']
|
|
|
|
if attrs.has_key('parish'):
|
|
|
|
loc.parish = attrs['parish']
|
|
|
|
if attrs.has_key('state'):
|
|
|
|
loc.state = attrs['state']
|
|
|
|
if attrs.has_key('county'):
|
|
|
|
loc.county =attrs['county']
|
|
|
|
if attrs.has_key('country'):
|
|
|
|
loc.country = attrs['country']
|
|
|
|
if self.locations > 0:
|
|
|
|
self.placeobj.add_alternate_locations(loc)
|
|
|
|
else:
|
|
|
|
self.placeobj.set_main_location(loc)
|
|
|
|
self.locations = self.locations + 1
|
2003-02-24 10:21:57 +05:30
|
|
|
|
|
|
|
def start_witness(self,attrs):
|
2003-10-14 08:43:52 +05:30
|
|
|
self.in_witness = 1
|
2003-02-24 10:21:57 +05:30
|
|
|
if attrs.has_key('ref'):
|
|
|
|
self.witness = RelLib.Witness(RelLib.Event.ID,attrs['ref'])
|
|
|
|
if attrs.has_key('name'):
|
|
|
|
self.witness = RelLib.Witness(RelLib.Event.NAME,attrs['name'])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_coord(self,attrs):
|
|
|
|
if attrs.has_key('lat'):
|
|
|
|
self.placeobj.set_latitude(attrs['lat'])
|
|
|
|
if attrs.has_key('long'):
|
|
|
|
self.placeobj.set_longitude(attrs['long'])
|
|
|
|
|
|
|
|
def start_event(self,attrs):
|
2003-01-10 10:51:32 +05:30
|
|
|
self.event = RelLib.Event()
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.add_event(self.event)
|
2003-08-11 06:29:16 +05:30
|
|
|
self.event_type = const.save_event(attrs["type"])
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
|
|
|
self.event.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.event.conf = 2
|
|
|
|
if attrs.has_key("priv"):
|
|
|
|
self.event.private = int(attrs["priv"])
|
|
|
|
|
|
|
|
def start_attribute(self,attrs):
|
2003-01-10 10:51:32 +05:30
|
|
|
self.attribute = RelLib.Attribute()
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
|
|
|
self.attribute.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.attribute.conf = 2
|
|
|
|
if attrs.has_key("priv"):
|
|
|
|
self.attribute.private = int(attrs["priv"])
|
|
|
|
if attrs.has_key('type'):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.set_type(const.save_attr(attrs["type"]))
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key('value'):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.set_value(attrs["value"])
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.photo:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.add_attribute(self.attribute)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.object:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.add_attribute(self.attribute)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.objref:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.objref.add_attribute(self.attribute)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.person:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_attribute(self.attribute)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.family:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.add_attribute(self.attribute)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_address(self,attrs):
|
2003-01-10 10:51:32 +05:30
|
|
|
self.address = RelLib.Address()
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_address(self.address)
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
|
|
|
self.address.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.address.conf = 2
|
|
|
|
if attrs.has_key("priv"):
|
|
|
|
self.address.private = int(attrs["priv"])
|
|
|
|
|
|
|
|
def start_bmark(self,attrs):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.bookmarks.append(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_person(self,attrs):
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person = self.db.find_person_from_id(attrs["id"])
|
2003-12-03 09:19:39 +05:30
|
|
|
if attrs.has_key("complete"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_complete(int(attrs['complete']))
|
2003-12-03 09:19:39 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_complete(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_people(self,attrs):
|
|
|
|
if attrs.has_key("default"):
|
|
|
|
self.tempDefault = attrs["default"]
|
|
|
|
|
|
|
|
def start_father(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_father_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_mother(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_mother_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_child(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.add_child_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_url(self,attrs):
|
|
|
|
|
|
|
|
if not attrs.has_key("href"):
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
desc = attrs["description"]
|
|
|
|
except KeyError:
|
|
|
|
desc = ""
|
|
|
|
|
|
|
|
try:
|
2003-01-10 10:51:32 +05:30
|
|
|
url = RelLib.Url()
|
2002-10-20 19:55:16 +05:30
|
|
|
url.set_path(attrs["href"])
|
|
|
|
url.set_description(desc)
|
|
|
|
if attrs.has_key("priv"):
|
2004-02-14 11:10:30 +05:30
|
|
|
url.set_privacy(int(attrs['priv']))
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.person:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_url(url)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.placeobj:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj.add_url(url)
|
2002-10-20 19:55:16 +05:30
|
|
|
except KeyError:
|
|
|
|
return
|
|
|
|
|
|
|
|
def start_family(self,attrs):
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family = self.db.find_family_no_map(attrs["id"])
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("type"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_relationship(const.save_frel(attrs["type"]))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_relationship("")
|
2003-10-29 10:34:43 +05:30
|
|
|
if attrs.has_key("complete"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_complete(int(attrs['complete']))
|
2003-10-29 10:34:43 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_complete(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_childof(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
family = self.db.find_family_no_map(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("mrel"):
|
|
|
|
mrel = attrs["mrel"]
|
|
|
|
else:
|
|
|
|
mrel = "Birth"
|
|
|
|
if attrs.has_key("frel"):
|
|
|
|
frel = attrs["frel"]
|
|
|
|
else:
|
|
|
|
frel = "Birth"
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_parent_family_id(family.get_id(),mrel,frel)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_parentin(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_family_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_name(self,attrs):
|
2003-10-14 08:43:52 +05:30
|
|
|
if not self.in_witness:
|
|
|
|
self.name = RelLib.Name()
|
|
|
|
if attrs.has_key("type"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_type(attrs["type"])
|
2003-10-14 08:43:52 +05:30
|
|
|
if attrs.has_key("conf"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_confidence(int(attrs["conf"]))
|
2003-10-14 08:43:52 +05:30
|
|
|
else:
|
|
|
|
self.name.conf = 2
|
|
|
|
if attrs.has_key("priv"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_privacy(int(attrs["priv"]))
|
2002-12-04 10:28:07 +05:30
|
|
|
|
|
|
|
def start_last(self,attrs):
|
|
|
|
if attrs.has_key('prefix'):
|
2004-02-22 10:38:40 +05:30
|
|
|
self.name.set_surname_prefix(attrs['prefix'])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_note(self,attrs):
|
|
|
|
self.in_note = 1
|
2003-12-10 09:19:53 +05:30
|
|
|
self.note = RelLib.Note()
|
|
|
|
if attrs.has_key("format"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.note.set_format(int(attrs['format']))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_sourceref(self,attrs):
|
2003-01-10 10:51:32 +05:30
|
|
|
self.source_ref = RelLib.SourceRef()
|
2004-02-14 11:10:30 +05:30
|
|
|
source = self.db.find_source_from_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
|
|
|
self.source_ref.confidence = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.source_ref.confidence = self.conf
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_base_id(source.get_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.photo:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.ord:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.ord.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.object:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.event:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.name:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.attribute:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.placeobj:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj.add_source_reference(self.source_ref)
|
2003-10-29 10:34:43 +05:30
|
|
|
elif self.family:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.add_source_reference(self.source_ref)
|
2003-10-29 10:34:43 +05:30
|
|
|
elif self.person:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_source_reference(self.source_ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_source(self,attrs):
|
|
|
|
if self.num_srcs > 0:
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source = self.db.find_source_from_id(attrs["id"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_objref(self,attrs):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.objref = RelLib.MediaRef()
|
2004-02-25 09:38:51 +05:30
|
|
|
self.objref.set_reference_id(attrs['ref'])
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key('priv'):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.objref.set_privacy(int(attrs['priv']))
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.family:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.family.add_media_reference(self.objref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.source:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.source.add_media_reference(self.objref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.person:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.person.add_media_reference(self.objref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.placeobj:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.placeobj.add_media_reference(self.objref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_object(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object = self.db.find_object_from_id(attrs['id'])
|
|
|
|
self.object.set_mime_type(attrs['mime'])
|
|
|
|
self.object.set_description(attrs['description'])
|
2002-10-20 19:55:16 +05:30
|
|
|
src = attrs["src"]
|
|
|
|
if src:
|
|
|
|
if src[0] != '/':
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.set_path("%s/%s" % (self.base,src))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.set_path(src)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
def stop_people(self,tag):
|
|
|
|
pass
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def stop_object(self,tag):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.commit_media_object(self.object)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.object = None
|
|
|
|
|
|
|
|
def stop_objref(self,tag):
|
|
|
|
self.objref = None
|
|
|
|
|
|
|
|
def start_photo(self,attrs):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.photo = RelLib.MediaObject()
|
|
|
|
self.pref = RelLib.MediaRef()
|
2004-02-25 09:38:51 +05:30
|
|
|
self.pref.set_reference_id(self.photo.get_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
for key in attrs.keys():
|
|
|
|
if key == "descrip" or key == "description":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.set_description(attrs[key])
|
2002-10-20 19:55:16 +05:30
|
|
|
elif key == "priv":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.pref.set_privacy(int(attrs[key]))
|
2002-10-20 19:55:16 +05:30
|
|
|
elif key == "src":
|
|
|
|
src = attrs["src"]
|
|
|
|
if src[0] != '/':
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.set_path("%s/%s" % (self.base,src))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.set_path(src)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-01-10 10:51:32 +05:30
|
|
|
a = RelLib.Attribute()
|
2004-02-14 11:10:30 +05:30
|
|
|
a.set_type(key)
|
|
|
|
a.set_value(attrs[key])
|
|
|
|
self.photo.add_attribute(a)
|
|
|
|
self.photo.set_mime_type(Utils.get_mime_type(self.photo.get_path()))
|
|
|
|
self.db.add_object(self.photo)
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.family:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.family.add_media_reference(self.pref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.source:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.source.add_media_reference(self.pref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.person:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.person.add_media_reference(self.pref)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.placeobj:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.placeobj.add_media_reference(self.pref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_daterange(self,attrs):
|
|
|
|
if self.source_ref:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.source_ref.get_date()
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.ord:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.ord.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.address.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.event.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if attrs.has_key("calendar"):
|
2003-01-02 10:01:52 +05:30
|
|
|
d.set_calendar_val(int(attrs['calendar']))
|
|
|
|
|
|
|
|
if attrs.has_key("cformat"):
|
|
|
|
d.set_calendar(Calendar.find_calendar(attrs['calendar']))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
d.get_start_date().set_iso_date(attrs['start'])
|
|
|
|
d.get_stop_date().set_iso_date(attrs['stop'])
|
2002-10-20 19:55:16 +05:30
|
|
|
d.range = 1
|
|
|
|
|
|
|
|
def start_dateval(self,attrs):
|
|
|
|
if self.source_ref:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.source_ref.get_date()
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.ord:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.ord.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.address.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.event.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if attrs.has_key("calendar"):
|
2003-01-02 10:01:52 +05:30
|
|
|
d.set_calendar_val(int(attrs['calendar']))
|
|
|
|
|
|
|
|
if attrs.has_key("cformat"):
|
2003-01-06 10:44:49 +05:30
|
|
|
d.set_calendar(Calendar.find_calendar(attrs['cformat']))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
d.get_start_date().set_iso_date(attrs['val'])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if attrs.has_key("type"):
|
2004-03-23 10:31:19 +05:30
|
|
|
d.get_start_date().set_mode(attrs['type'])
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-03-23 10:31:19 +05:30
|
|
|
d.get_start_date().set_mode(None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_datestr(self,attrs):
|
|
|
|
if self.source_ref:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.source_ref.get_date()
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.ord:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.ord.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.address.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = self.event.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
d.set(attrs['val'])
|
|
|
|
|
|
|
|
def start_created(self,attrs):
|
|
|
|
if attrs.has_key('sources'):
|
|
|
|
self.num_srcs = int(attrs['sources'])
|
|
|
|
else:
|
|
|
|
self.num_srcs = 0
|
|
|
|
if attrs.has_key('places'):
|
|
|
|
self.num_places = int(attrs['places'])
|
|
|
|
else:
|
|
|
|
self.num_places = 0
|
|
|
|
self.entries = int(attrs["people"]) + int(attrs["families"]) + \
|
|
|
|
self.num_places + self.num_srcs
|
|
|
|
|
|
|
|
def start_pos(self,attrs):
|
|
|
|
self.person.position = (int(attrs["x"]), int(attrs["y"]))
|
|
|
|
|
|
|
|
def stop_attribute(self,tag):
|
|
|
|
self.attribute = None
|
|
|
|
|
2003-10-14 08:43:52 +05:30
|
|
|
def stop_comment(self,tag):
|
|
|
|
if tag.strip():
|
|
|
|
self.witness_comment = tag
|
|
|
|
else:
|
|
|
|
self.witness_comment = ""
|
|
|
|
|
2003-02-24 10:21:57 +05:30
|
|
|
def stop_witness(self,tag):
|
2003-10-14 08:43:52 +05:30
|
|
|
if self.witness_comment:
|
|
|
|
self.witness.set_comment(self.witness_comment)
|
|
|
|
elif tag.strip():
|
|
|
|
self.witness.set_comment(tag)
|
|
|
|
else:
|
|
|
|
self.witness.set_comment("")
|
2003-02-24 10:21:57 +05:30
|
|
|
self.event.add_witness(self.witness)
|
2003-10-14 08:43:52 +05:30
|
|
|
self.in_witness = 0
|
2003-02-24 10:21:57 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def stop_attr_type(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.set_type(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_attr_value(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.set_value(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_address(self,tag):
|
|
|
|
self.address = None
|
|
|
|
|
|
|
|
def stop_places(self,tag):
|
|
|
|
self.placeobj = None
|
|
|
|
|
|
|
|
def stop_photo(self,tag):
|
|
|
|
self.photo = None
|
|
|
|
|
|
|
|
def stop_placeobj(self,tag):
|
|
|
|
if self.placeobj.get_title() == "":
|
|
|
|
loc = self.placeobj.get_main_location()
|
|
|
|
self.placeobj.set_title(build_place_title(loc))
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.commit_place(self.placeobj)
|
2003-10-29 10:34:43 +05:30
|
|
|
self.placeobj = None
|
|
|
|
|
|
|
|
def stop_family(self,tag):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.commit_family(self.family)
|
2003-10-29 10:34:43 +05:30
|
|
|
self.family = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_event(self,tag):
|
|
|
|
self.event.name = self.event_type
|
|
|
|
|
|
|
|
if self.family:
|
2004-02-19 10:35:43 +05:30
|
|
|
self.family.add_event_id(self.event.get_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
if self.event_type == "Birth":
|
2004-02-19 10:35:43 +05:30
|
|
|
self.person.set_birth_id(self.event.get_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.event_type == "Death":
|
2004-02-19 10:35:43 +05:30
|
|
|
self.person.set_death_id(self.event.get_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-19 10:35:43 +05:30
|
|
|
self.person.add_event_id(self.event.get_id())
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.commit_event(self.event)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.event = None
|
|
|
|
|
|
|
|
def stop_name(self,tag):
|
2003-10-14 08:43:52 +05:30
|
|
|
if self.in_witness:
|
|
|
|
self.witness = RelLib.Witness(RelLib.Event.NAME,tag)
|
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.name.get_type() == "":
|
|
|
|
self.name.set_type("Birth Name")
|
|
|
|
self.person.set_primary_name (self.name)
|
|
|
|
self.person.get_primary_name().build_sort_name()
|
2003-10-14 08:43:52 +05:30
|
|
|
self.name = None
|
|
|
|
|
|
|
|
def stop_ref(self,tag):
|
|
|
|
self.witness = RelLib.Witness(RelLib.Event.ID,tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_place(self,tag):
|
|
|
|
if self.placeobj == None:
|
|
|
|
if self.place_map.has_key(tag):
|
|
|
|
self.placeobj = self.place_map[tag]
|
|
|
|
else:
|
2003-01-10 10:51:32 +05:30
|
|
|
self.placeobj = RelLib.Place()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.placeobj.set_title(tag)
|
|
|
|
if self.ord:
|
2004-02-21 11:41:59 +05:30
|
|
|
self.ord.set_place_id(self.placeobj.get_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-21 11:41:59 +05:30
|
|
|
self.event.set_place_id(self.placeobj.get_id())
|
|
|
|
self.db.commit_place(self.placeobj)
|
2003-10-29 10:34:43 +05:30
|
|
|
self.placeobj = None
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def stop_date(self,tag):
|
|
|
|
if tag:
|
|
|
|
if self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_date(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_date(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_first(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_first_name(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_families(self,tag):
|
|
|
|
self.family = None
|
|
|
|
|
|
|
|
def stop_person(self,tag):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.commit_person(self.person)
|
2003-10-29 10:34:43 +05:30
|
|
|
self.person = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_description(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_description(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_cause(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_cause(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_gender(self,tag):
|
|
|
|
t = tag
|
|
|
|
if t == "M":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_gender (RelLib.Person.male)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif t == "F":
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_gender (RelLib.Person.female)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_gender (RelLib.Person.unknown)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_stitle(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source.set_title(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_sourceref(self,tag):
|
|
|
|
self.source_ref = None
|
|
|
|
|
|
|
|
def stop_source(self,tag):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.db.commit_source(self.source)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.source = None
|
|
|
|
|
|
|
|
def stop_sauthor(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source.set_author(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_sdate(self,tag):
|
2003-01-10 10:51:32 +05:30
|
|
|
date = Date.Date()
|
2002-10-20 19:55:16 +05:30
|
|
|
date.set(tag)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_date(date)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-09 11:32:36 +05:30
|
|
|
def stop_phone(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_phone(tag)
|
2003-12-09 11:32:36 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def stop_street(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_street(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_city(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_city(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_state(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_state(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_country(self,tag):
|
|
|
|
self.address.setCountry(tag)
|
|
|
|
|
|
|
|
def stop_postal(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_postal_code(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_spage(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_page(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_lds_ord(self,tag):
|
|
|
|
self.ord = None
|
|
|
|
|
|
|
|
def stop_spubinfo(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source.set_publication_info(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-08 07:53:53 +05:30
|
|
|
def stop_sabbrev(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source.set_abbreviation(tag)
|
2003-12-08 07:53:53 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def stop_stext(self,tag):
|
|
|
|
if self.use_p:
|
|
|
|
self.use_p = 0
|
|
|
|
note = fix_spaces(self.stext_list)
|
|
|
|
else:
|
|
|
|
note = tag
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_text(note)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_scomments(self,tag):
|
|
|
|
if self.use_p:
|
|
|
|
self.use_p = 0
|
|
|
|
note = fix_spaces(self.scomments_list)
|
|
|
|
else:
|
|
|
|
note = tag
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_comments(note)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_last(self,tag):
|
|
|
|
if self.name:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_surname(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_suffix(self,tag):
|
|
|
|
if self.name:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_suffix(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_title(self,tag):
|
|
|
|
if self.name:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_title(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_nick(self,tag):
|
|
|
|
if self.person:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_nick_name(tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_note(self,tag):
|
|
|
|
self.in_note = 0
|
|
|
|
if self.use_p:
|
|
|
|
self.use_p = 0
|
2003-12-10 09:19:53 +05:30
|
|
|
text = fix_spaces(self.note_list)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-12-10 09:19:53 +05:30
|
|
|
text = tag
|
|
|
|
self.note.set(text)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.ord:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.ord.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.attribute:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.object:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.objref:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.objref.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.photo:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.name:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.source:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.event:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.person:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.family:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.placeobj:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj.set_note_object(self.note)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def stop_research(self,tag):
|
|
|
|
self.owner.set(self.resname, self.resaddr, self.rescity, self.resstate,
|
|
|
|
self.rescon, self.respos, self.resphone, self.resemail)
|
|
|
|
|
|
|
|
def stop_resname(self,tag):
|
|
|
|
self.resname = tag
|
|
|
|
|
|
|
|
def stop_resaddr(self,tag):
|
|
|
|
self.resaddr = tag
|
|
|
|
|
|
|
|
def stop_rescity(self,tag):
|
|
|
|
self.rescity = tag
|
|
|
|
|
|
|
|
def stop_resstate(self,tag):
|
|
|
|
self.resstate = tag
|
|
|
|
|
|
|
|
def stop_rescountry(self,tag):
|
|
|
|
self.rescon = tag
|
|
|
|
|
|
|
|
def stop_respostal(self,tag):
|
|
|
|
self.respos = tag
|
|
|
|
|
|
|
|
def stop_resphone(self,tag):
|
|
|
|
self.resphone = tag
|
|
|
|
|
|
|
|
def stop_resemail(self,tag):
|
|
|
|
self.resemail = tag
|
|
|
|
|
|
|
|
def stop_ptag(self,tag):
|
|
|
|
self.use_p = 1
|
|
|
|
if self.in_note:
|
|
|
|
self.note_list.append(tag)
|
|
|
|
elif self.in_stext:
|
|
|
|
self.stext_list.append(tag)
|
|
|
|
elif self.in_scomments:
|
|
|
|
self.scomments_list.append(tag)
|
|
|
|
|
|
|
|
def stop_aka(self,tag):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_alternate_name(self.name)
|
|
|
|
if self.name.get_type() == "":
|
|
|
|
self.name.set_type("Also Known As")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.name = None
|
|
|
|
|
|
|
|
def startElement(self,tag,attrs):
|
|
|
|
|
|
|
|
self.func_list[self.func_index] = (self.func,self.tlist)
|
|
|
|
self.func_index = self.func_index + 1
|
|
|
|
self.tlist = []
|
|
|
|
|
|
|
|
try:
|
2003-05-05 07:06:21 +05:30
|
|
|
f,self.func = self.func_map[tag]
|
2002-10-20 19:55:16 +05:30
|
|
|
if f:
|
2003-05-05 07:06:21 +05:30
|
|
|
f(attrs)
|
2002-10-20 19:55:16 +05:30
|
|
|
except KeyError:
|
2003-05-05 07:06:21 +05:30
|
|
|
self.func_map[tag] = (None,None)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.func = None
|
|
|
|
|
|
|
|
def endElement(self,tag):
|
|
|
|
|
|
|
|
if self.func:
|
2003-05-05 07:06:21 +05:30
|
|
|
self.func(string.join(self.tlist,''))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.func_index = self.func_index - 1
|
|
|
|
self.func,self.tlist = self.func_list[self.func_index]
|
|
|
|
|
|
|
|
def characters(self, data):
|
|
|
|
if self.func:
|
|
|
|
self.tlist.append(data)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps database parsing class. Derived from SAX XML parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class GrampsImportParser(GrampsParser):
|
|
|
|
|
2003-05-05 07:06:21 +05:30
|
|
|
def __init__(self,database,callback,base):
|
|
|
|
GrampsParser.__init__(self,database,callback,base)
|
|
|
|
|
2003-05-07 09:06:28 +05:30
|
|
|
def start_childof(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
family = self.db.find_family_no_conflicts(attrs["ref"],self.fmap)
|
2003-05-07 09:06:28 +05:30
|
|
|
if attrs.has_key("mrel"):
|
|
|
|
mrel = attrs["mrel"]
|
|
|
|
else:
|
|
|
|
mrel = "Birth"
|
|
|
|
if attrs.has_key("frel"):
|
|
|
|
frel = attrs["frel"]
|
|
|
|
else:
|
|
|
|
frel = "Birth"
|
2004-02-29 01:04:29 +05:30
|
|
|
self.person.add_parent_family_id(family.get_id(),mrel,frel)
|
2003-05-07 09:06:28 +05:30
|
|
|
|
|
|
|
def start_parentin(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.add_family_id(attrs["ref"])
|
2003-05-05 07:06:21 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def start_bmark(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
person = self.db.find_person_no_conflicts(attrs["ref"],self.pmap)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db.bookmarks.append(person)
|
|
|
|
|
|
|
|
def start_person(self,attrs):
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person = self.db.find_person_no_conflicts(attrs["id"],self.pmap)
|
2003-12-03 09:19:39 +05:30
|
|
|
if attrs.has_key("complete"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_complete(int(attrs['complete']))
|
2003-12-03 09:19:39 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_complete(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_father(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_father_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_mother(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_mother_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_child(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.add_child_id(attrs["ref"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_family(self,attrs):
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family = self.db.find_family_no_conflicts(attrs["id"],self.fmap)
|
2002-10-20 19:55:16 +05:30
|
|
|
if attrs.has_key("type"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_relationship(const.save_frel(attrs["type"]))
|
2003-12-03 09:19:39 +05:30
|
|
|
if attrs.has_key("complete"):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_complete(int(attrs['complete']))
|
2003-12-03 09:19:39 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_complete(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def start_source(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source = self.db.find_source_no_conflicts(attrs["id"],self.smap)
|
2003-05-05 07:06:21 +05:30
|
|
|
|
|
|
|
def start_sourceref(self,attrs):
|
|
|
|
self.source_ref = RelLib.SourceRef()
|
2004-02-14 11:10:30 +05:30
|
|
|
source = self.db.find_source_no_conflicts(attrs["ref"],self.smap)
|
2003-05-05 07:06:21 +05:30
|
|
|
if attrs.has_key("conf"):
|
|
|
|
self.source_ref.confidence = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.source_ref.confidence = self.conf
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_base_id(source.get_id())
|
2003-05-05 07:06:21 +05:30
|
|
|
if self.photo:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.ord:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.ord.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.object:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.event:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.address:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.address.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.name:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.name.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.attribute:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attribute.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.placeobj:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj.add_source_reference(self.source_ref)
|
2003-10-29 10:34:43 +05:30
|
|
|
elif self.family:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.add_source_reference(self.source_ref)
|
2003-05-05 07:06:21 +05:30
|
|
|
|
|
|
|
def start_place(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj = self.db.find_place_no_conflicts(attrs['ref'],self.lmap)
|
2003-05-05 07:06:21 +05:30
|
|
|
|
|
|
|
def start_placeobj(self,attrs):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.placeobj = self.db.find_place_no_conflicts(attrs['id'],self.lmap)
|
2003-05-05 07:06:21 +05:30
|
|
|
title = attrs['title']
|
|
|
|
if title == "":
|
|
|
|
title = attrs['id']
|
|
|
|
self.placeobj.set_title(title)
|
|
|
|
self.locations = 0
|
|
|
|
if self.num_places > 0:
|
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
|
|
|
|
|
|
|
def start_objref(self,attrs):
|
2004-02-21 11:41:59 +05:30
|
|
|
self.objref = RelLib.MediaRef()
|
2004-02-29 05:34:45 +05:30
|
|
|
id = self.db.find_object_no_conflicts(attrs['ref'],self.media_file_map).get_id()
|
2004-02-25 09:38:51 +05:30
|
|
|
self.objref.set_reference_id(id)
|
2003-05-05 07:06:21 +05:30
|
|
|
if attrs.has_key('priv'):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.objref.set_privacy(int(attrs['priv']))
|
2003-05-05 07:06:21 +05:30
|
|
|
if self.family:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.family.add_media_reference(self.objref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.source:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.source.add_media_reference(self.objref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.person:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.person.add_media_reference(self.objref)
|
2003-05-05 07:06:21 +05:30
|
|
|
elif self.placeobj:
|
2004-02-22 10:27:06 +05:30
|
|
|
self.placeobj.add_media_reference(self.objref)
|
2003-05-05 07:06:21 +05:30
|
|
|
|
|
|
|
def start_object(self,attrs):
|
2004-02-29 05:34:45 +05:30
|
|
|
self.object = self.db.find_object_no_conflicts(attrs['id'],self.media_file_map)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.set_mime_type(attrs['mime'])
|
|
|
|
self.object.set_description(attrs['description'])
|
2003-05-05 07:06:21 +05:30
|
|
|
src = attrs["src"]
|
|
|
|
if src:
|
|
|
|
if src[0] != '/':
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.set_path("%s/%s" % (self.db.get_save_path(),src))
|
2003-05-05 07:06:21 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.object.set_path(src)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def append_value(orig,val):
|
|
|
|
if orig:
|
|
|
|
return "%s, %s" % (orig,val)
|
|
|
|
else:
|
|
|
|
return val
|
|
|
|
|
|
|
|
def build_place_title(loc):
|
|
|
|
"Builds a title from a location"
|
|
|
|
city = loc.get_city()
|
|
|
|
state = loc.get_state()
|
|
|
|
country = loc.get_country()
|
|
|
|
county = loc.get_county()
|
|
|
|
parish = loc.get_parish()
|
|
|
|
|
|
|
|
value = ""
|
|
|
|
|
|
|
|
if parish:
|
|
|
|
value = parish
|
|
|
|
if city:
|
|
|
|
value = append_value(value,city)
|
|
|
|
if county:
|
|
|
|
value = append_value(value,county)
|
|
|
|
if state:
|
|
|
|
value = append_value(value,state)
|
|
|
|
if country:
|
|
|
|
value = append_value(value,country)
|
|
|
|
return value
|