2001-05-13 07:26:57 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
|
|
|
from RelLib import *
|
|
|
|
|
|
|
|
import string
|
|
|
|
import os
|
2001-06-13 04:54:46 +05:30
|
|
|
import sys
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-05-18 04:38:27 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Try to abstract SAX1 from SAX2
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2001-06-13 04:54:46 +05:30
|
|
|
if sys.version[0] != '1':
|
2001-06-22 04:44:01 +05:30
|
|
|
try:
|
|
|
|
from _xmlplus.sax import handler
|
2001-06-28 20:53:16 +05:30
|
|
|
from _xmlplus.sax import make_parser
|
2001-06-22 05:28:44 +05:30
|
|
|
except:
|
2001-06-22 04:44:01 +05:30
|
|
|
from xml.sax import handler
|
2001-06-28 20:53:16 +05:30
|
|
|
from xml.sax import make_parser
|
2001-06-13 04:54:46 +05:30
|
|
|
else:
|
2001-06-28 20:53:16 +05:30
|
|
|
from xml.sax import handler
|
|
|
|
from xml.sax import make_parser
|
2001-05-18 04:38:27 +05:30
|
|
|
|
2001-06-20 02:18:35 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Unicode to latin conversion
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2001-05-18 04:38:27 +05:30
|
|
|
from latin_utf8 import utf8_to_latin
|
2001-06-20 02:18:35 +05:30
|
|
|
u2l = utf8_to_latin
|
2001-05-18 04:38:27 +05:30
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Remove extraneous spaces
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def fix_spaces(text_list):
|
|
|
|
val = ""
|
|
|
|
for text in text_list:
|
|
|
|
val = val + string.join(string.split(text),' ') + "\n"
|
|
|
|
return val
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps database parsing class. Derived from SAX XML parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class GrampsParser(handler.ContentHandler):
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
2001-06-17 19:10:57 +05:30
|
|
|
def __init__(self,database,callback,base):
|
2001-05-13 07:26:57 +05:30
|
|
|
self.stext_list = []
|
|
|
|
self.scomments_list = []
|
|
|
|
self.note_list = []
|
2001-09-28 08:04:58 +05:30
|
|
|
self.tlist = []
|
2001-10-04 09:52:41 +05:30
|
|
|
self.conf = 2
|
2001-09-28 08:04:58 +05:30
|
|
|
|
2001-05-31 23:27:14 +05:30
|
|
|
self.use_p = 0
|
2001-05-13 07:26:57 +05:30
|
|
|
self.in_note = 0
|
2001-05-30 09:54:27 +05:30
|
|
|
self.in_old_attr = 0
|
2001-05-13 07:26:57 +05:30
|
|
|
self.in_stext = 0
|
|
|
|
self.in_scomments = 0
|
2001-05-19 08:28:18 +05:30
|
|
|
self.db = database
|
2001-05-13 07:26:57 +05:30
|
|
|
self.base = base
|
|
|
|
self.person = None
|
|
|
|
self.family = None
|
2001-05-30 09:54:27 +05:30
|
|
|
self.address = None
|
2001-05-13 07:26:57 +05:30
|
|
|
self.source = None
|
2001-05-30 09:54:27 +05:30
|
|
|
self.source_ref = None
|
2001-06-17 19:10:57 +05:30
|
|
|
self.attribute = None
|
2001-08-17 04:54:53 +05:30
|
|
|
self.placeobj = None
|
2001-09-14 09:14:26 +05:30
|
|
|
self.locations = 0
|
2001-08-17 04:54:53 +05:30
|
|
|
self.place_map = {}
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-05-19 08:28:18 +05:30
|
|
|
self.resname = ""
|
|
|
|
self.resaddr = ""
|
|
|
|
self.rescity = ""
|
|
|
|
self.resstate = ""
|
|
|
|
self.rescon = ""
|
|
|
|
self.respos = ""
|
|
|
|
self.resphone = ""
|
|
|
|
self.resemail = ""
|
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
self.pmap = {}
|
|
|
|
self.fmap = {}
|
|
|
|
self.smap = {}
|
|
|
|
|
|
|
|
self.callback = callback
|
|
|
|
self.entries = 0
|
|
|
|
self.count = 0
|
2001-06-20 02:18:35 +05:30
|
|
|
self.increment = 100
|
2001-05-13 07:26:57 +05:30
|
|
|
self.event = None
|
|
|
|
self.name = None
|
|
|
|
self.tempDefault = None
|
|
|
|
self.owner = Researcher()
|
2001-05-19 08:28:18 +05:30
|
|
|
self.func_list = [None]*50
|
|
|
|
self.func_index = 0
|
|
|
|
self.func = None
|
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
handler.ContentHandler.__init__(self)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def setDocumentLocator(self,locator):
|
|
|
|
self.locator = locator
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def endDocument(self):
|
2001-05-19 08:28:18 +05:30
|
|
|
self.db.setResearcher(self.owner)
|
2001-05-13 07:26:57 +05:30
|
|
|
if self.tempDefault != None:
|
|
|
|
id = self.tempDefault
|
2001-05-19 08:28:18 +05:30
|
|
|
if self.db.personMap.has_key(id):
|
|
|
|
person = self.db.personMap[id]
|
|
|
|
self.db.setDefaultPerson(person)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-08-17 04:54:53 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_place(self,attrs):
|
|
|
|
if attrs.has_key('ref'):
|
|
|
|
self.placeobj = self.db.findPlaceNoMap(u2l(attrs['ref']))
|
|
|
|
else:
|
|
|
|
self.placeobj = None
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_placeobj(self,attrs):
|
|
|
|
self.placeobj = self.db.findPlaceNoMap(u2l(attrs['id']))
|
|
|
|
self.placeobj.set_title(u2l(attrs['title']))
|
2001-09-14 09:14:26 +05:30
|
|
|
self.locations = 0
|
2001-08-17 04:54:53 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_location(self,attrs):
|
|
|
|
loc = Location()
|
|
|
|
if attrs.has_key('city'):
|
2001-08-19 01:05:30 +05:30
|
|
|
loc.set_city(u2l(attrs['city']))
|
2001-08-17 04:54:53 +05:30
|
|
|
if attrs.has_key('state'):
|
2001-08-19 01:03:46 +05:30
|
|
|
loc.set_state(u2l(attrs['state']))
|
2001-08-17 04:54:53 +05:30
|
|
|
if attrs.has_key('county'):
|
2001-08-19 01:07:03 +05:30
|
|
|
loc.set_county(u2l(attrs['county']))
|
2001-08-17 04:54:53 +05:30
|
|
|
if attrs.has_key('country'):
|
2001-08-19 01:07:03 +05:30
|
|
|
loc.set_country(u2l(attrs['country']))
|
2001-09-14 09:14:26 +05:30
|
|
|
if self.locations > 0:
|
2001-08-17 04:54:53 +05:30
|
|
|
self.placeobj.add_alternate_locations(loc)
|
|
|
|
else:
|
|
|
|
self.placeobj.set_main_location(loc)
|
2001-09-14 09:14:26 +05:30
|
|
|
self.locations = self.locations + 1
|
|
|
|
|
2001-08-17 04:54:53 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
2001-09-01 22:43:15 +05:30
|
|
|
def start_coord(self,attrs):
|
2001-08-17 04:54:53 +05:30
|
|
|
if attrs.has_key('lat'):
|
2001-08-19 01:03:46 +05:30
|
|
|
self.placeobj.set_latitude(u2l(attrs['lat']))
|
2001-08-17 04:54:53 +05:30
|
|
|
if attrs.has_key('long'):
|
2001-08-19 01:03:46 +05:30
|
|
|
self.placeobj.set_longitude(u2l(attrs['long']))
|
2001-08-17 04:54:53 +05:30
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_event(self,attrs):
|
|
|
|
self.event = Event()
|
2001-08-24 03:43:56 +05:30
|
|
|
self.event_type = u2l(attrs["type"])
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
2001-10-04 09:52:41 +05:30
|
|
|
self.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.conf = 2
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("priv"):
|
2001-08-24 03:43:56 +05:30
|
|
|
self.event.private = int(attrs["priv"])
|
2001-05-30 09:54:27 +05:30
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_attribute(self,attrs):
|
|
|
|
self.attribute = Attribute()
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
2001-10-04 09:52:41 +05:30
|
|
|
self.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.conf = 2
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("priv"):
|
2001-08-24 03:43:56 +05:30
|
|
|
self.attribute.privacy = int(attrs["priv"])
|
2001-05-30 09:54:27 +05:30
|
|
|
if attrs.has_key('type'):
|
|
|
|
self.in_old_attr = 1
|
2001-08-24 03:43:56 +05:30
|
|
|
self.attribute.setType(u2l(attrs["type"]))
|
2001-05-30 09:54:27 +05:30
|
|
|
else:
|
|
|
|
self.in_old_attr = 0
|
2001-06-17 19:10:57 +05:30
|
|
|
if self.person:
|
2001-06-03 04:26:04 +05:30
|
|
|
self.person.addAttribute(self.attribute)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.family:
|
2001-06-03 04:26:04 +05:30
|
|
|
self.family.addAttribute(self.attribute)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_address(self,attrs):
|
|
|
|
self.address = Address()
|
|
|
|
self.person.addAddress(self.address)
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
2001-10-04 09:52:41 +05:30
|
|
|
self.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.conf = 2
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("priv"):
|
2001-08-24 03:43:56 +05:30
|
|
|
self.address.private = int(attrs["priv"])
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_bmark(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
person = self.db.findPersonNoMap(u2l(attrs["ref"]))
|
2001-05-19 08:28:18 +05:30
|
|
|
self.db.bookmarks.append(person)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_person(self,attrs):
|
2001-08-24 03:43:56 +05:30
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
2001-05-13 07:26:57 +05:30
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2001-06-22 01:01:12 +05:30
|
|
|
self.person = self.db.findPersonNoMap(u2l(attrs["id"]))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_people(self,attrs):
|
2001-06-17 19:10:57 +05:30
|
|
|
if attrs.has_key("default"):
|
2001-09-28 18:23:05 +05:30
|
|
|
self.tempDefault = u2l(attrs["default"])
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_father(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family.Father = self.db.findPersonNoMap(u2l(attrs["ref"]))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_mother(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family.Mother = self.db.findPersonNoMap(u2l(attrs["ref"]))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_child(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family.Children.append(self.db.findPersonNoMap(u2l(attrs["ref"])))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_url(self,attrs):
|
|
|
|
|
|
|
|
if not attrs.has_key("href"):
|
|
|
|
return
|
2001-05-18 04:38:27 +05:30
|
|
|
try:
|
2001-06-22 01:01:12 +05:30
|
|
|
desc = u2l(attrs["description"])
|
2001-05-18 04:38:27 +05:30
|
|
|
except KeyError:
|
2001-05-13 07:26:57 +05:30
|
|
|
desc = ""
|
2001-05-18 04:38:27 +05:30
|
|
|
|
|
|
|
try:
|
2001-07-29 11:36:16 +05:30
|
|
|
url = Url()
|
|
|
|
url.set_path(u2l(attrs["href"]))
|
|
|
|
url.set_description(desc)
|
|
|
|
if attrs.has_key("priv"):
|
2001-08-24 03:43:56 +05:30
|
|
|
url.setPrivacy(int(attrs['priv']))
|
2001-08-17 04:54:53 +05:30
|
|
|
if self.person:
|
|
|
|
self.person.addUrl(url)
|
|
|
|
elif self.placeobj:
|
|
|
|
self.placeobj.addUrl(url)
|
2001-05-18 04:38:27 +05:30
|
|
|
except KeyError:
|
|
|
|
return
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_family(self,attrs):
|
2001-08-24 03:43:56 +05:30
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
2001-05-13 07:26:57 +05:30
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family = self.db.findFamilyNoMap(u2l(attrs["id"]))
|
2001-05-25 08:07:40 +05:30
|
|
|
if attrs.has_key("type"):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family.setRelationship(u2l(attrs["type"]))
|
2001-08-08 08:05:17 +05:30
|
|
|
else:
|
|
|
|
self.family.setRelationship("")
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_childof(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
family = self.db.findFamilyNoMap(u2l(attrs["ref"]))
|
2001-09-28 18:23:05 +05:30
|
|
|
if len(attrs) == 1:
|
|
|
|
self.person.MainFamily = family
|
|
|
|
else:
|
|
|
|
mrel = ""
|
|
|
|
frel = ""
|
2001-08-08 06:52:59 +05:30
|
|
|
if attrs.has_key("mrel"):
|
2001-09-28 18:23:05 +05:30
|
|
|
mrel = attrs["mrel"]
|
2001-08-08 06:52:59 +05:30
|
|
|
if attrs.has_key("frel"):
|
2001-09-28 18:23:05 +05:30
|
|
|
frel = attrs["frel"]
|
2001-08-07 05:28:09 +05:30
|
|
|
if mrel=="Birth" and frel=="Birth":
|
|
|
|
self.person.MainFamily = family
|
|
|
|
else:
|
2001-09-28 18:23:05 +05:30
|
|
|
if mrel or frel:
|
|
|
|
self.person.AltFamilyList.append((family,mrel,frel))
|
|
|
|
else:
|
|
|
|
type = u2l(attrs["type"])
|
|
|
|
self.person.AltFamilyList.append((family,type,type))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_parentin(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.person.FamilyList.append(self.db.findFamilyNoMap(u2l(attrs["ref"])))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_name(self,attrs):
|
|
|
|
self.name = Name()
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("conf"):
|
2001-10-04 09:52:41 +05:30
|
|
|
self.conf = int(attrs["conf"])
|
|
|
|
else:
|
|
|
|
self.conf = 2
|
2001-07-29 11:36:16 +05:30
|
|
|
if attrs.has_key("priv"):
|
2001-08-24 03:43:56 +05:30
|
|
|
self.name.private = int(attrs["priv"])
|
2001-06-16 08:53:18 +05:30
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_note(self,attrs):
|
|
|
|
self.in_note = 1
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_sourceref(self,attrs):
|
2001-05-30 09:54:27 +05:30
|
|
|
self.source_ref = SourceRef()
|
2001-07-04 04:07:00 +05:30
|
|
|
source = self.db.findSourceNoMap(u2l(attrs["ref"]))
|
2001-10-04 09:52:41 +05:30
|
|
|
if attrs.has_key("conf"):
|
|
|
|
self.source_ref.confidence = int(u2l(attrs["conf"]))
|
|
|
|
else:
|
|
|
|
self.source_ref.confidence = self.conf
|
2001-07-04 04:07:00 +05:30
|
|
|
self.source_ref.setBase(source)
|
2001-09-28 08:04:58 +05:30
|
|
|
if self.event:
|
|
|
|
self.event.setSourceRef(self.source_ref)
|
|
|
|
elif self.address:
|
2001-05-30 09:54:27 +05:30
|
|
|
self.address.setSourceRef(self.source_ref)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.name:
|
2001-06-16 08:53:18 +05:30
|
|
|
self.name.setSourceRef(self.source_ref)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.attribute:
|
2001-05-30 09:54:27 +05:30
|
|
|
self.attribute.setSourceRef(self.source_ref)
|
2001-08-17 04:54:53 +05:30
|
|
|
elif self.placeobj:
|
|
|
|
self.placeobj.setSourceRef(self.source_ref)
|
2001-05-30 09:54:27 +05:30
|
|
|
else:
|
|
|
|
print "Sorry, I'm lost"
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_source(self,attrs):
|
2001-06-26 19:26:06 +05:30
|
|
|
self.source = self.db.findSourceNoMap(u2l(attrs["id"]))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_photo(self,attrs):
|
|
|
|
photo = Photo()
|
2001-07-16 07:36:31 +05:30
|
|
|
for key in attrs.keys():
|
2001-09-14 09:14:26 +05:30
|
|
|
if key == "descrip" or key == "description":
|
|
|
|
photo.setDescription(u2l(attrs[key]))
|
2001-07-16 07:36:31 +05:30
|
|
|
elif key == "src":
|
|
|
|
src = u2l(attrs["src"])
|
|
|
|
if src[0] != os.sep:
|
|
|
|
photo.setPath("%s%s%s" % (self.base,os.sep,src))
|
|
|
|
photo.setPrivate(1)
|
|
|
|
else:
|
|
|
|
photo.setPath(src)
|
|
|
|
photo.setPrivate(0)
|
|
|
|
if self.family:
|
|
|
|
self.family.addPhoto(photo)
|
|
|
|
elif self.source:
|
|
|
|
self.source.addPhoto(photo)
|
2001-08-17 04:54:53 +05:30
|
|
|
elif self.person:
|
2001-07-16 07:36:31 +05:30
|
|
|
self.person.addPhoto(photo)
|
2001-08-17 04:54:53 +05:30
|
|
|
elif self.placeobj:
|
|
|
|
self.placeobj.addPhoto(photo)
|
2001-07-16 07:36:31 +05:30
|
|
|
else:
|
2001-09-28 18:23:05 +05:30
|
|
|
photo.addProperty(key,u2l(attrs[key]))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_created(self,attrs):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.entries = int(attrs["people"]) + int(attrs["families"])
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-08-06 08:30:01 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_pos(self,attrs):
|
2001-09-28 18:23:05 +05:30
|
|
|
self.person.position = (int(attrs["x"]), int(attrs["y"]))
|
2001-08-06 08:30:01 +05:30
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_attribute(self,tag):
|
2001-05-30 09:54:27 +05:30
|
|
|
if self.in_old_attr:
|
2001-06-20 02:18:35 +05:30
|
|
|
self.attribute.setValue(u2l(tag))
|
2001-05-30 09:54:27 +05:30
|
|
|
self.in_old_attr = 0
|
2001-06-17 19:10:57 +05:30
|
|
|
self.attribute = None
|
2001-05-30 09:54:27 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_attr_type(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.attribute.setType(u2l(tag))
|
2001-05-30 09:54:27 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_attr_value(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.attribute.setValue(u2l(tag))
|
2001-05-24 03:48:12 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_address(self,tag):
|
2001-06-17 19:10:57 +05:30
|
|
|
self.address = None
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-08-17 04:54:53 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_places(self,tag):
|
|
|
|
self.placeobj = None
|
|
|
|
|
2001-09-24 04:48:59 +05:30
|
|
|
def stop_placeobj(self,tag):
|
|
|
|
if self.placeobj.get_title() == "":
|
|
|
|
loc = self.placeobj.get_main_location()
|
|
|
|
self.placeobj.set_title(build_place_title(loc))
|
|
|
|
self.palceobj = None
|
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_event(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.event.name = self.event_type
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-08-24 03:43:56 +05:30
|
|
|
if self.family:
|
2001-06-20 02:18:35 +05:30
|
|
|
self.family.EventList.append(self.event)
|
2001-08-24 03:43:56 +05:30
|
|
|
else:
|
|
|
|
if self.event_type == "Birth":
|
|
|
|
self.person.setBirth(self.event)
|
|
|
|
elif self.event_type == "Death":
|
|
|
|
self.person.setDeath(self.event)
|
|
|
|
else:
|
|
|
|
self.person.EventList.append(self.event)
|
2001-06-17 19:10:57 +05:30
|
|
|
self.event = None
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_name(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.person.PrimaryName = self.name
|
2001-06-17 19:10:57 +05:30
|
|
|
self.name = None
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_place(self,tag):
|
2001-08-17 04:54:53 +05:30
|
|
|
if self.placeobj == None:
|
2001-08-19 01:03:46 +05:30
|
|
|
if self.place_map.has_key(u2l(tag)):
|
|
|
|
self.placeobj = self.place_map[u2l(tag)]
|
2001-08-17 04:54:53 +05:30
|
|
|
else:
|
|
|
|
self.placeobj = Place()
|
2001-08-19 01:03:46 +05:30
|
|
|
self.placeobj.set_title(u2l(tag))
|
2001-08-17 04:54:53 +05:30
|
|
|
self.db.addPlace(self.placeobj)
|
2001-08-19 01:03:46 +05:30
|
|
|
self.place_map[u2l(tag)] = self.placeobj
|
2001-08-17 04:54:53 +05:30
|
|
|
self.event.place = self.placeobj
|
2001-09-24 04:48:59 +05:30
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_uid(self,tag):
|
2001-06-22 09:01:09 +05:30
|
|
|
self.person.setPafUid(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_date(self,tag):
|
2001-05-19 08:28:18 +05:30
|
|
|
if tag:
|
2001-06-17 19:10:57 +05:30
|
|
|
if self.address:
|
2001-06-22 09:01:09 +05:30
|
|
|
self.address.setDate(u2l(tag))
|
2001-05-24 03:48:12 +05:30
|
|
|
else:
|
2001-06-22 09:01:09 +05:30
|
|
|
self.event.date.quick_set(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_first(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.name.FirstName = u2l(tag)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-06-17 19:10:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
2001-06-20 02:18:35 +05:30
|
|
|
def stop_families(self,tag):
|
2001-06-17 19:10:57 +05:30
|
|
|
self.family = None
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
2001-06-20 02:18:35 +05:30
|
|
|
def stop_people(self,tag):
|
2001-06-17 19:10:57 +05:30
|
|
|
self.person = None
|
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_description(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.event.setDescription(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-10-04 09:52:41 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_cause(self,tag):
|
|
|
|
self.event.setCause(u2l(tag))
|
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_gender(self,tag):
|
2001-06-22 05:28:44 +05:30
|
|
|
self.person.gender = (u2l(tag) == "M")
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_stitle(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.source.setTitle(u2l(tag))
|
2001-05-30 09:54:27 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_sourceref(self,tag):
|
2001-06-17 19:10:57 +05:30
|
|
|
self.source_ref = None
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_source(self,tag):
|
|
|
|
self.source = None
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_sauthor(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.source.setAuthor(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_sdate(self,tag):
|
|
|
|
date = Date()
|
2001-06-22 05:28:44 +05:30
|
|
|
date.quick_set(u2l(tag))
|
2001-05-30 09:54:27 +05:30
|
|
|
self.source_ref.setDate(date)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
def stop_street(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.address.setStreet(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
def stop_city(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.address.setCity(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
def stop_state(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.address.setState(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
def stop_country(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.address.setCountry(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
def stop_postal(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.address.setPostal(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_spage(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.source_ref.setPage(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_spubinfo(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.source.setPubInfo(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_scallno(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.source.setCallNumber(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_stext(self,tag):
|
2001-05-31 23:27:14 +05:30
|
|
|
if self.use_p:
|
|
|
|
self.use_p = 0
|
|
|
|
note = fix_spaces(self.stext_list)
|
|
|
|
else:
|
2001-06-20 02:18:35 +05:30
|
|
|
note = u2l(tag)
|
2001-05-31 23:27:14 +05:30
|
|
|
self.source_ref.setText(note)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_scomments(self,tag):
|
2001-05-31 23:27:14 +05:30
|
|
|
if self.use_p:
|
|
|
|
self.use_p = 0
|
|
|
|
note = fix_spaces(self.scomments_list)
|
|
|
|
else:
|
2001-06-20 02:18:35 +05:30
|
|
|
note = u2l(tag)
|
2001-05-31 23:27:14 +05:30
|
|
|
self.source_ref.setComments(note)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_last(self,tag):
|
2001-06-20 04:07:25 +05:30
|
|
|
if self.name:
|
|
|
|
self.name.Surname = u2l(tag)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_suffix(self,tag):
|
2001-06-20 04:07:25 +05:30
|
|
|
if self.name:
|
|
|
|
self.name.Suffix = u2l(tag)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_title(self,tag):
|
2001-06-20 04:07:25 +05:30
|
|
|
if self.name:
|
|
|
|
self.name.Title = u2l(tag)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_nick(self,tag):
|
2001-07-05 04:44:40 +05:30
|
|
|
if self.person:
|
2001-06-20 04:07:25 +05:30
|
|
|
self.person.setNickName(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_note(self,tag):
|
|
|
|
self.in_note = 0
|
2001-05-31 23:27:14 +05:30
|
|
|
if self.use_p:
|
|
|
|
self.use_p = 0
|
|
|
|
note = fix_spaces(self.note_list)
|
|
|
|
else:
|
2001-06-20 02:18:35 +05:30
|
|
|
note = u2l(tag)
|
2001-07-04 04:07:00 +05:30
|
|
|
|
2001-06-17 19:10:57 +05:30
|
|
|
if self.address:
|
2001-05-31 23:27:14 +05:30
|
|
|
self.address.setNote(note)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.attribute:
|
2001-05-31 23:27:14 +05:30
|
|
|
self.attribute.setNote(note)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.name:
|
2001-06-16 08:53:18 +05:30
|
|
|
self.name.setNote(note)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.source:
|
2001-05-31 23:27:14 +05:30
|
|
|
self.source.setNote(note)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.event:
|
2001-05-31 23:27:14 +05:30
|
|
|
self.event.setNote(note)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.person:
|
2001-05-31 23:27:14 +05:30
|
|
|
self.person.setNote(note)
|
2001-06-17 19:10:57 +05:30
|
|
|
elif self.family:
|
2001-05-31 23:27:14 +05:30
|
|
|
self.family.setNote(note)
|
2001-08-17 04:54:53 +05:30
|
|
|
elif self.placeobj:
|
|
|
|
self.placeobj.setNote(note)
|
2001-05-13 07:26:57 +05:30
|
|
|
self.note_list = []
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
2001-05-19 08:28:18 +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)
|
|
|
|
|
2001-05-13 07:26:57 +05:30
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
2001-05-19 08:28:18 +05:30
|
|
|
def stop_resname(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.resname = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_resaddr(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.resaddr = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_rescity(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.rescity = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_resstate(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.resstate = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_rescountry(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.rescon = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_respostal(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.respos = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_resphone(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.resphone = u2l(tag)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_resemail(self,tag):
|
2001-06-20 02:18:35 +05:30
|
|
|
self.resemail = u2l(tag)
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_ptag(self,tag):
|
2001-05-31 23:27:14 +05:30
|
|
|
self.use_p = 1
|
2001-05-13 07:26:57 +05:30
|
|
|
if self.in_note:
|
2001-06-20 02:18:35 +05:30
|
|
|
self.note_list.append(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
elif self.in_stext:
|
2001-06-20 02:18:35 +05:30
|
|
|
self.stext_list.append(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
elif self.in_scomments:
|
2001-06-20 02:18:35 +05:30
|
|
|
self.scomments_list.append(u2l(tag))
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def stop_aka(self,tag):
|
|
|
|
self.person.addAlternateName(self.name)
|
2001-08-11 07:38:57 +05:30
|
|
|
self.name = None
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-05-19 08:28:18 +05:30
|
|
|
func_map = {
|
2001-05-24 03:48:12 +05:30
|
|
|
"address" : (start_address, stop_address),
|
2001-08-24 03:43:56 +05:30
|
|
|
"addresses" : (None,None),
|
|
|
|
"childlist" : (None,None),
|
2001-05-19 08:28:18 +05:30
|
|
|
"aka" : (start_name, stop_aka),
|
|
|
|
"attribute" : (start_attribute, stop_attribute),
|
2001-05-30 09:54:27 +05:30
|
|
|
"attr_type" : (None,stop_attr_type),
|
|
|
|
"attr_value" : (None,stop_attr_value),
|
2001-05-19 08:28:18 +05:30
|
|
|
"bookmark" : (start_bmark, None),
|
|
|
|
"bookmarks" : (None, None),
|
|
|
|
"child" : (start_child,None),
|
|
|
|
"childof" : (start_childof,None),
|
|
|
|
"city" : (None, stop_city),
|
|
|
|
"country" : (None, stop_country),
|
|
|
|
"created" : (start_created, None),
|
|
|
|
"database" : (None, None),
|
|
|
|
"date" : (None, stop_date),
|
2001-10-04 09:52:41 +05:30
|
|
|
"cause" : (None, stop_cause),
|
2001-05-19 08:28:18 +05:30
|
|
|
"description": (None, stop_description),
|
|
|
|
"event" : (start_event, stop_event),
|
2001-06-20 02:18:35 +05:30
|
|
|
"families" : (None, stop_families),
|
2001-05-19 08:28:18 +05:30
|
|
|
"family" : (start_family, None),
|
|
|
|
"father" : (start_father, None),
|
|
|
|
"first" : (None, stop_first),
|
|
|
|
"gender" : (None, stop_gender),
|
|
|
|
"header" : (None, None),
|
|
|
|
"last" : (None, stop_last),
|
|
|
|
"mother" : (start_mother,None),
|
|
|
|
"name" : (start_name, stop_name),
|
|
|
|
"nick" : (None, stop_nick),
|
|
|
|
"note" : (start_note, stop_note),
|
|
|
|
"p" : (None, stop_ptag),
|
|
|
|
"parentin" : (start_parentin,None),
|
2001-06-20 02:18:35 +05:30
|
|
|
"people" : (start_people, stop_people),
|
|
|
|
"person" : (start_person, None),
|
2001-05-19 08:28:18 +05:30
|
|
|
"img" : (start_photo, None),
|
2001-08-17 04:54:53 +05:30
|
|
|
"place" : (start_place, stop_place),
|
|
|
|
"places" : (None, stop_places),
|
2001-09-24 04:48:59 +05:30
|
|
|
"placeobj" : (start_placeobj,stop_placeobj),
|
2001-08-17 04:54:53 +05:30
|
|
|
"location" : (start_location,None),
|
|
|
|
"coord" : (start_coord,None),
|
2001-08-06 08:30:01 +05:30
|
|
|
"pos" : (start_pos, None),
|
2001-05-19 08:28:18 +05:30
|
|
|
"postal" : (None, stop_postal),
|
|
|
|
"researcher" : (None, stop_research),
|
|
|
|
"resname" : (None, stop_resname ),
|
|
|
|
"resaddr" : (None, stop_resaddr ),
|
|
|
|
"rescity" : (None, stop_rescity ),
|
|
|
|
"resstate" : (None, stop_resstate ),
|
|
|
|
"rescountry" : (None, stop_rescountry),
|
|
|
|
"respostal" : (None, stop_respostal),
|
|
|
|
"resphone" : (None, stop_resphone),
|
|
|
|
"resemail" : (None, stop_resemail),
|
|
|
|
"sauthor" : (None, stop_sauthor),
|
|
|
|
"scallno" : (None, stop_scallno),
|
|
|
|
"scomments" : (None, stop_scomments),
|
|
|
|
"sdate" : (None,stop_sdate),
|
2001-06-17 19:10:57 +05:30
|
|
|
"source" : (start_source, stop_source),
|
2001-05-30 09:54:27 +05:30
|
|
|
"sourceref" : (start_sourceref, stop_sourceref),
|
2001-06-17 19:10:57 +05:30
|
|
|
"sources" : (None, None),
|
2001-05-19 08:28:18 +05:30
|
|
|
"spage" : (None, stop_spage),
|
|
|
|
"spubinfo" : (None, stop_spubinfo),
|
|
|
|
"state" : (None, stop_state),
|
|
|
|
"stext" : (None, stop_stext),
|
|
|
|
"stitle" : (None, stop_stitle),
|
|
|
|
"street" : (None, stop_street),
|
|
|
|
"suffix" : (None, stop_suffix),
|
|
|
|
"title" : (None, stop_title),
|
|
|
|
"uid" : (None, stop_uid),
|
2001-05-26 20:51:22 +05:30
|
|
|
"url" : (start_url, None)
|
2001-05-19 08:28:18 +05:30
|
|
|
}
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def startElement(self,tag,attrs):
|
|
|
|
|
2001-09-28 08:04:58 +05:30
|
|
|
self.func_list[self.func_index] = (self.func,self.tlist)
|
2001-05-19 08:28:18 +05:30
|
|
|
self.func_index = self.func_index + 1
|
2001-09-28 08:04:58 +05:30
|
|
|
self.tlist = []
|
2001-05-19 08:28:18 +05:30
|
|
|
|
|
|
|
try:
|
|
|
|
f,self.func = GrampsParser.func_map[tag]
|
|
|
|
if f:
|
|
|
|
f(self,attrs)
|
2001-06-26 19:26:06 +05:30
|
|
|
except KeyError:
|
2001-05-19 08:28:18 +05:30
|
|
|
GrampsParser.func_map[tag] = (None,None)
|
|
|
|
self.func = None
|
2001-05-13 07:26:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
2001-05-18 04:38:27 +05:30
|
|
|
|
2001-06-06 10:06:51 +05:30
|
|
|
def endElement(self,tag):
|
2001-05-19 08:28:18 +05:30
|
|
|
|
2001-06-06 10:06:51 +05:30
|
|
|
if self.func:
|
2001-09-28 08:04:58 +05:30
|
|
|
self.func(self,string.join(self.tlist))
|
2001-06-06 10:06:51 +05:30
|
|
|
self.func_index = self.func_index - 1
|
2001-09-28 08:04:58 +05:30
|
|
|
self.func,self.tlist = self.func_list[self.func_index]
|
2001-05-13 07:26:57 +05:30
|
|
|
|
2001-06-28 20:53:16 +05:30
|
|
|
def characters(self, data):
|
|
|
|
if self.func:
|
2001-09-28 08:04:58 +05:30
|
|
|
self.tlist.append(data)
|
2001-05-19 08:28:18 +05:30
|
|
|
|
2001-06-17 19:10:57 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps database parsing class. Derived from SAX XML parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2001-08-10 10:02:31 +05:30
|
|
|
class GrampsImportParser(GrampsParser):
|
2001-06-17 19:10:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_bmark(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
person = self.db.findPerson("x%s" % u2l(attrs["ref"]),self.pmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
self.db.bookmarks.append(person)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_person(self,attrs):
|
2001-08-24 03:43:56 +05:30
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
2001-06-17 19:10:57 +05:30
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2001-06-22 01:01:12 +05:30
|
|
|
self.person = self.db.findPerson("x%s" % u2l(attrs["id"]),self.pmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_father(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
father = self.db.findPerson("x%s" % u2l(attrs["ref"]),self.pmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
self.family.setFather(father)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_mother(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
mother = self.db.findPerson("x%s" % u2l(attrs["ref"]),self.pmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
self.family.setMother(mother)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_child(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
child = self.db.findPerson("x%s" % u2l(attrs["ref"]),self.pmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
self.family.addChild(child)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_family(self,attrs):
|
2001-08-24 03:43:56 +05:30
|
|
|
if self.callback != None and self.count % self.increment == 0:
|
2001-06-17 19:10:57 +05:30
|
|
|
self.callback(float(self.count)/float(self.entries))
|
|
|
|
self.count = self.count + 1
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family = self.db.findFamily(u2l(attrs["id"]),self.fmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
if attrs.has_key("type"):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.family.setRelationship(u2l(attrs["type"]))
|
2001-06-17 19:10:57 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_childof(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
family = self.db.findFamily(u2l(attrs["ref"]),self.fmap)
|
2001-06-17 19:10:57 +05:30
|
|
|
if attrs.has_key("type"):
|
2001-06-22 01:01:12 +05:30
|
|
|
type = u2l(attrs["type"])
|
2001-06-17 19:10:57 +05:30
|
|
|
self.person.addAltFamily(family,type)
|
|
|
|
else:
|
|
|
|
self.person.setMainFamily(family)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_sourceref(self,attrs):
|
|
|
|
self.source_ref = SourceRef()
|
2001-06-22 01:01:12 +05:30
|
|
|
self.source = self.db.findSource(u2l(attrs["ref"]),self.smap)
|
2001-06-17 19:10:57 +05:30
|
|
|
self.source_ref.setBase(self.source)
|
|
|
|
if self.address:
|
|
|
|
self.address.setSourceRef(self.source_ref)
|
|
|
|
elif self.name:
|
|
|
|
self.name.setSourceRef(self.source_ref)
|
|
|
|
elif self.event:
|
|
|
|
self.event.setSourceRef(self.source_ref)
|
|
|
|
elif self.attribute:
|
|
|
|
self.attribute.setSourceRef(self.source_ref)
|
2001-08-17 04:54:53 +05:30
|
|
|
elif self.placeobj:
|
|
|
|
self.placeobj.setSourceRef(self.source_ref)
|
2001-06-17 19:10:57 +05:30
|
|
|
else:
|
|
|
|
print "Sorry, I'm lost"
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
def start_source(self,attrs):
|
2001-06-22 01:01:12 +05:30
|
|
|
self.source = self.db.findSource(u2l(attrs["id"]),self.smap)
|
2001-06-17 19:10:57 +05:30
|
|
|
|
2001-09-24 04:48:59 +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()
|
|
|
|
|
|
|
|
value = ""
|
|
|
|
|
|
|
|
if city:
|
|
|
|
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
|
|
|
|
|