First pass at ZODB support
svn: r994
This commit is contained in:
parent
fe470d9e3a
commit
3538e1ee56
@ -39,6 +39,12 @@ import VersionControl
|
||||
from intl import gettext
|
||||
_ = gettext
|
||||
|
||||
try:
|
||||
import ZODB
|
||||
_zodb = 1
|
||||
except:
|
||||
_zodb = 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# DbPrompter
|
||||
@ -60,11 +66,18 @@ class DbPrompter:
|
||||
"on_opendb_delete_event": self.open_delete_event,
|
||||
})
|
||||
self.new = opendb.get_widget("new")
|
||||
self.zodb = opendb.get_widget("zodb")
|
||||
if self.want_new:
|
||||
self.new.set_active(1)
|
||||
if _zodb:
|
||||
self.zodb.show()
|
||||
|
||||
def open_ok_clicked(self,obj):
|
||||
if self.new.get_active():
|
||||
self.db.clear_database(0)
|
||||
self.save_as_activate()
|
||||
elif self.zodb.get_active():
|
||||
self.db.clear_database(1)
|
||||
self.save_as_activate()
|
||||
else:
|
||||
self.open_activate()
|
||||
@ -110,7 +123,6 @@ class DbPrompter:
|
||||
return
|
||||
|
||||
Utils.destroy_passed_object(obj)
|
||||
self.db.clear_database()
|
||||
|
||||
if self.getoldrev.get_active():
|
||||
vc = VersionControl.RcsVersionControl(filename)
|
||||
|
@ -249,7 +249,7 @@ class EditPerson:
|
||||
self.autoplace = AutoComp.AutoCombo(self.bpcombo,self.pmap.keys())
|
||||
self.autodeath = AutoComp.AutoCombo(self.dpcombo,self.pmap.keys(),
|
||||
self.autoplace)
|
||||
self.comp = AutoComp.AutoCombo(self.sncombo,const.surnames)
|
||||
self.comp = AutoComp.AutoCombo(self.sncombo,self.db.getSurnames())
|
||||
|
||||
self.gid.set_text(person.getId())
|
||||
self.gid.set_editable(GrampsCfg.id_edit)
|
||||
@ -1140,9 +1140,7 @@ class EditPerson:
|
||||
|
||||
if surname != name.getSurname():
|
||||
name.setSurname(surname)
|
||||
if surname not in const.surnames:
|
||||
const.surnames.append(surname)
|
||||
const.surnames.sort()
|
||||
self.db.addSurname(name)
|
||||
|
||||
if given != name.getFirstName():
|
||||
name.setFirstName(given)
|
||||
|
@ -84,6 +84,9 @@ class MediaView:
|
||||
self.media_list.set_sort_column(self.sort_map[self.sort_col])
|
||||
self.set_arrow(self.sort_col)
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
|
||||
def moveto(self,row):
|
||||
self.media_list.unselect_all()
|
||||
self.media_list.select_row(row,0)
|
||||
@ -260,7 +263,7 @@ class MediaView:
|
||||
object = self.media_list.get_row_data(self.media_list.selection[0])
|
||||
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
|
||||
|
||||
def on_delete_media_clicked(self,obj):
|
||||
def on_delete_clicked(self,obj):
|
||||
if len(self.media_list.selection) <= 0:
|
||||
return
|
||||
else:
|
||||
|
@ -57,7 +57,7 @@ class NameEditor:
|
||||
self.type_field = self.top.get_widget("name_type")
|
||||
self.note_field = self.top.get_widget("alt_note")
|
||||
slist = self.top.get_widget("alt_surname_list")
|
||||
self.combo = AutoComp.AutoCombo(slist,const.surnames)
|
||||
self.combo = AutoComp.AutoCombo(slist,self.parent.db.getSurnames())
|
||||
self.priv = self.top.get_widget("priv")
|
||||
|
||||
types = const.NameTypesMap.keys()
|
||||
@ -138,9 +138,7 @@ class NameEditor:
|
||||
|
||||
if self.name.getSurname() != last:
|
||||
self.name.setSurname(last)
|
||||
if last not in const.surnames:
|
||||
const.surnames.append(last)
|
||||
const.surnames.sort()
|
||||
self.parent.db.addSurname(last)
|
||||
self.parent.lists_changed = 1
|
||||
|
||||
if self.name.getSuffix() != suffix:
|
||||
|
@ -93,6 +93,9 @@ class PlaceView:
|
||||
self.place_list.set_sort_column(self.sort_map[self.sort_col])
|
||||
self.place_list.set_sort_type(self.sort_dir)
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
|
||||
def load_places(self):
|
||||
"""Rebuilds the entire place view. This can be very time consuming
|
||||
on large databases, and should only be called when absolutely
|
||||
@ -105,23 +108,12 @@ class PlaceView:
|
||||
|
||||
self.place_list.freeze()
|
||||
self.place_list.clear()
|
||||
|
||||
self.place_list.set_column_visibility(1,GrampsCfg.id_visible)
|
||||
|
||||
|
||||
index = 0
|
||||
u = string.upper
|
||||
for src in self.db.getPlaceMap().values():
|
||||
title = src.get_title()
|
||||
id = src.getId()
|
||||
mloc = src.get_main_location()
|
||||
city = mloc.get_city()
|
||||
county = mloc.get_county()
|
||||
state = mloc.get_state()
|
||||
parish = mloc.get_parish()
|
||||
country = mloc.get_country()
|
||||
self.place_list.append([title,id,parish,city,county,state,country,
|
||||
u(title), u(parish), u(city),
|
||||
u(county),u(state), u(country)])
|
||||
for key in self.db.getPlaceKeys():
|
||||
src = self.db.getPlaceMap()[key]
|
||||
self.place_list.append(src.getDisplayInfo())
|
||||
self.place_list.set_row_data(index,src)
|
||||
index = index + 1
|
||||
|
||||
@ -194,18 +186,7 @@ class PlaceView:
|
||||
obj.thaw()
|
||||
|
||||
def insert_place(self,place):
|
||||
title = place.get_title()
|
||||
id = place.getId()
|
||||
mloc = place.get_main_location()
|
||||
city = mloc.get_city()
|
||||
county = mloc.get_county()
|
||||
state = mloc.get_state()
|
||||
parish = mloc.get_parish()
|
||||
country = mloc.get_country()
|
||||
u = string.upper
|
||||
self.place_list.append([title,id,parish,city,county,state,country,
|
||||
u(title), u(parish), u(city),
|
||||
u(county),u(state), u(country)])
|
||||
self.place_list.append(place.getDisplayInfo())
|
||||
self.place_list.set_row_data(self.place_list.rows-1,place)
|
||||
|
||||
def new_place_after_edit(self,place):
|
||||
@ -231,7 +212,7 @@ class PlaceView:
|
||||
self.place_list.select_row(row,0)
|
||||
self.place_list.moveto(row)
|
||||
|
||||
def on_delete_place_clicked(self,obj):
|
||||
def on_delete_clicked(self,obj):
|
||||
if len(obj.selection) == 0:
|
||||
return
|
||||
elif len(obj.selection) > 1:
|
||||
|
@ -41,7 +41,7 @@ class QuickAdd:
|
||||
self.window.editable_enters(self.xml.get_widget("given"))
|
||||
self.window.editable_enters(self.xml.get_widget("surname"))
|
||||
self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"),
|
||||
const.surnames)
|
||||
self.db.getSurnames())
|
||||
|
||||
def close(self,obj):
|
||||
surname = self.xml.get_widget("surname").get_text()
|
||||
|
@ -23,26 +23,75 @@
|
||||
__author__ = "Don Allingham"
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from re import compile
|
||||
from Date import Date, compare_dates, not_too_old
|
||||
from string import strip
|
||||
from string import strip, upper
|
||||
import os
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Date import Date, compare_dates, not_too_old
|
||||
import sort
|
||||
import const
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Attempt to load the ZODB libraries, otherwise provide alternates
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
try:
|
||||
from ZODB import Persistent
|
||||
from ZODB.PersistentList import PersistentList
|
||||
|
||||
except ImportError:
|
||||
class Persistent:
|
||||
pass
|
||||
|
||||
from UserList import UserList
|
||||
class PersistentList(UserList):
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Confidence levels
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CONF_VERY_HIGH = 4
|
||||
CONF_HIGH = 3
|
||||
CONF_NORMAL = 2
|
||||
CONF_LOW = 1
|
||||
CONF_VERY_LOW = 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# ID regular expression
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_id_reg = compile("%\d+d")
|
||||
|
||||
class SourceNote:
|
||||
|
||||
def extlist(lst):
|
||||
return lst[:] # Make a copy.
|
||||
|
||||
def extmap(map):
|
||||
return map
|
||||
|
||||
|
||||
class SourceNote(Persistent):
|
||||
"""Base class for storing source references and notes"""
|
||||
|
||||
def __init__(self,source=None):
|
||||
"""Create a new SourceNote, copying from source if not None"""
|
||||
|
||||
self.source_list = []
|
||||
self.source_list = PersistentList()
|
||||
|
||||
if source:
|
||||
if len(source.source_list) > 0:
|
||||
@ -58,10 +107,11 @@ class SourceNote:
|
||||
def addSourceRef(self,id) :
|
||||
"""Set the source reference"""
|
||||
self.source_list.append(id)
|
||||
self._p_changed = 1
|
||||
|
||||
def getSourceRefList(self) :
|
||||
"""Return the source reference"""
|
||||
return self.source_list
|
||||
return extlist(self.source_list)
|
||||
|
||||
def setSourceRefList(self,list) :
|
||||
"""Replaces the source reference"""
|
||||
@ -219,14 +269,14 @@ class Place(SourceNote):
|
||||
self.lat = source.lat
|
||||
self.title = source.title
|
||||
self.main_loc = Location(source.main_loc)
|
||||
self.alt_loc = []
|
||||
self.alt_loc = PersistentList()
|
||||
for loc in source.alt_loc:
|
||||
self.alt_loc = Location(loc)
|
||||
self.id = source.id
|
||||
self.urls = []
|
||||
self.urls = PersistentList()
|
||||
for u in source.urls:
|
||||
self.urls.append(Url(u))
|
||||
self.photoList = []
|
||||
self.photoList = PersistentList()
|
||||
for photo in source.photoList:
|
||||
self.photoList.append(ObjectRef(photo))
|
||||
else:
|
||||
@ -234,14 +284,14 @@ class Place(SourceNote):
|
||||
self.lat = ""
|
||||
self.title = ""
|
||||
self.main_loc = None
|
||||
self.alt_loc = []
|
||||
self.alt_loc = PersistentList()
|
||||
self.id = ""
|
||||
self.urls = []
|
||||
self.photoList = []
|
||||
self.urls = PersistentList()
|
||||
self.photoList = PersistentList()
|
||||
|
||||
def getUrlList(self):
|
||||
"""Return the list of URLs"""
|
||||
return self.urls
|
||||
return extlist(self.urls)
|
||||
|
||||
def setUrlList(self,list):
|
||||
"""Replace the current URL list with the new one"""
|
||||
@ -250,6 +300,7 @@ class Place(SourceNote):
|
||||
def addUrl(self,url):
|
||||
"""Add a URL to the URL list"""
|
||||
self.urls.append(url)
|
||||
self._p_changed = 1
|
||||
|
||||
def setId(self,id):
|
||||
"""Sets the gramps ID for the place object"""
|
||||
@ -295,7 +346,7 @@ class Place(SourceNote):
|
||||
|
||||
def get_alternate_locations(self):
|
||||
"""Returns a list of alternate location information objects"""
|
||||
return self.alt_loc
|
||||
return extlist(self.alt_loc)
|
||||
|
||||
def set_alternate_locations(self,list):
|
||||
"""Replaces the current alternate location list with the new one"""
|
||||
@ -305,20 +356,33 @@ class Place(SourceNote):
|
||||
"""Adds a Location to the alternate location list"""
|
||||
if loc not in self.alt_loc:
|
||||
self.alt_loc.append(loc)
|
||||
self._p_changed = 1
|
||||
|
||||
def addPhoto(self,photo):
|
||||
"""Adds a Photo object to the place object's image list"""
|
||||
self.photoList.append(photo)
|
||||
self._p_changed = 1
|
||||
|
||||
def getPhotoList(self):
|
||||
"""Returns the list of Photo objects"""
|
||||
return self.photoList
|
||||
return extlist(self.photoList)
|
||||
|
||||
def setPhotoList(self,list):
|
||||
"""Sets the list of Photo objects"""
|
||||
self.photoList = list
|
||||
|
||||
class Researcher:
|
||||
def getDisplayInfo(self):
|
||||
if self.main_loc:
|
||||
return [self.title,self.id,self.main_loc.parish,self.main_loc.city,
|
||||
self.main_loc.county,self.main_loc.state,self.main_loc.country,
|
||||
upper(self.title), upper(self.main_loc.parish),
|
||||
upper(self.main_loc.city), upper(self.main_loc.county),
|
||||
upper(self.main_loc.state), upper(self.main_loc.country)]
|
||||
else:
|
||||
return [self.title,self.id,'','','','','',
|
||||
upper(self.title), '','','','','']
|
||||
|
||||
class Researcher(Persistent):
|
||||
"""Contains the information about the owner of the database"""
|
||||
|
||||
def __init__(self):
|
||||
@ -383,7 +447,7 @@ class Researcher:
|
||||
if email:
|
||||
self.email = strip(email)
|
||||
|
||||
class Location:
|
||||
class Location(Persistent):
|
||||
"""Provides information about a place, including city, county, state,
|
||||
and country. Multiple Location objects can represent the same place,
|
||||
since names of citys, countys, states, and even countries can change
|
||||
@ -405,7 +469,7 @@ class Location:
|
||||
self.country = ""
|
||||
|
||||
def is_empty(self):
|
||||
return self.city == "" and self.county == "" and self.state == "" and self.country == ""
|
||||
return self.city=="" and self.county=="" and self.state=="" and self.country==""
|
||||
|
||||
def set_city(self,data):
|
||||
"""sets the city name of the Location object"""
|
||||
@ -447,7 +511,7 @@ class Location:
|
||||
"""returns the country name of the Location object"""
|
||||
return self.country
|
||||
|
||||
class Note:
|
||||
class Note(Persistent):
|
||||
"""Provides general text information"""
|
||||
|
||||
def __init__(self,text = ""):
|
||||
@ -475,7 +539,7 @@ class Photo(SourceNote):
|
||||
|
||||
SourceNote.__init__(self,source)
|
||||
|
||||
self.attrlist = []
|
||||
self.attrlist = PersistentList()
|
||||
if source:
|
||||
self.path = source.path
|
||||
self.mime = source.mime
|
||||
@ -534,18 +598,20 @@ class Photo(SourceNote):
|
||||
but provides a means for XML users to attach other properties to
|
||||
the image"""
|
||||
self.attrlist.append(attr)
|
||||
self._p_changed = 1
|
||||
|
||||
def getAttributeList(self):
|
||||
"""returns the property list associated with the image"""
|
||||
return self.attrlist
|
||||
return extlist(self.attrlist)
|
||||
|
||||
def setAttributeList(self,list):
|
||||
self.attrlist = list
|
||||
|
||||
class ObjectRef:
|
||||
|
||||
class ObjectRef(Persistent):
|
||||
"""Object reference class"""
|
||||
def __init__(self,source=None):
|
||||
self.attrlist = []
|
||||
self.attrlist = PersistentList()
|
||||
if source:
|
||||
self.private = source.private
|
||||
self.ref = source.ref
|
||||
@ -600,15 +666,17 @@ class ObjectRef:
|
||||
but provides a means for XML users to attach other properties to
|
||||
the image"""
|
||||
self.attrlist.append(attr)
|
||||
self._p_changed = 1
|
||||
|
||||
def getAttributeList(self):
|
||||
"""returns the property list associated with the image"""
|
||||
return self.attrlist
|
||||
return extlist(self.attrlist)
|
||||
|
||||
def setAttributeList(self,list):
|
||||
"""sets the property list associated with the image"""
|
||||
self.attrlist = list
|
||||
|
||||
|
||||
class Attribute(DataObj):
|
||||
"""Provides a simple key/value pair for describing properties. Used
|
||||
by the Person and Family objects to store descriptive information."""
|
||||
@ -645,7 +713,8 @@ class Address(DataObj):
|
||||
"""Provides address information for a person"""
|
||||
|
||||
def __init__(self,source=None):
|
||||
"""Creates a new Address instance, copying from the source if provided"""
|
||||
"""Creates a new Address instance, copying from the source
|
||||
if provided"""
|
||||
DataObj.__init__(self,source)
|
||||
|
||||
if source:
|
||||
@ -726,6 +795,7 @@ class Address(DataObj):
|
||||
"""returns the postal code of the Address"""
|
||||
return self.postal
|
||||
|
||||
|
||||
class Name(DataObj):
|
||||
"""Provides name information about a person. A person may have more
|
||||
that one name throughout his or her life."""
|
||||
@ -788,8 +858,8 @@ class Name(DataObj):
|
||||
return self.Title
|
||||
|
||||
def getName(self):
|
||||
"""returns a name string built from the components of the Name instance,
|
||||
in the form of Surname, Firstname"""
|
||||
"""returns a name string built from the components of the Name
|
||||
instance, in the form of Surname, Firstname"""
|
||||
|
||||
if (self.Suffix == ""):
|
||||
return "%s, %s" % (self.Surname, self.FirstName)
|
||||
@ -797,15 +867,16 @@ class Name(DataObj):
|
||||
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
|
||||
|
||||
def getRegularName(self):
|
||||
"""returns a name string built from the components of the Name instance,
|
||||
in the form of Firstname Surname"""
|
||||
"""returns a name string built from the components of the Name
|
||||
instance, in the form of Firstname Surname"""
|
||||
if (self.Suffix == ""):
|
||||
return "%s %s" % (self.FirstName, self.Surname)
|
||||
else:
|
||||
return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix)
|
||||
|
||||
def are_equal(self,other):
|
||||
"""compares to names to see if they are equal, return 0 if they are not"""
|
||||
"""compares to names to see if they are equal, return 0 if they
|
||||
are not"""
|
||||
if self.FirstName != other.FirstName:
|
||||
return 0
|
||||
if self.Surname != other.Surname:
|
||||
@ -828,10 +899,9 @@ class Name(DataObj):
|
||||
if not a.are_equal(olist[index]):
|
||||
return 0
|
||||
index = index + 1
|
||||
|
||||
return 1
|
||||
|
||||
class Url:
|
||||
class Url(Persistent):
|
||||
"""Contains information related to internet Uniform Resource Locators,
|
||||
allowing gramps to store information about internet resources"""
|
||||
|
||||
@ -879,8 +949,9 @@ class Url:
|
||||
if self.desc != other.desc:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
class Person:
|
||||
|
||||
|
||||
class Person(Persistent):
|
||||
"""Represents an individual person in the gramps database"""
|
||||
|
||||
unknown = 2
|
||||
@ -892,18 +963,18 @@ class Person:
|
||||
|
||||
self.id = ""
|
||||
self.PrimaryName = None
|
||||
self.EventList = []
|
||||
self.FamilyList = []
|
||||
self.AltFamilyList = []
|
||||
self.photoList = []
|
||||
self.EventList = PersistentList()
|
||||
self.FamilyList = PersistentList()
|
||||
self.AltFamilyList = PersistentList()
|
||||
self.photoList = PersistentList()
|
||||
self.nickname = ""
|
||||
self.alternateNames = []
|
||||
self.alternateNames = PersistentList()
|
||||
self.gender = 2
|
||||
self.death = None
|
||||
self.birth = None
|
||||
self.addressList = []
|
||||
self.attributeList = []
|
||||
self.urls = []
|
||||
self.addressList = PersistentList()
|
||||
self.attributeList = PersistentList()
|
||||
self.urls = PersistentList()
|
||||
self.note = None
|
||||
self.paf_uid = ""
|
||||
self.position = None
|
||||
@ -912,8 +983,23 @@ class Person:
|
||||
self.lds_endow = None
|
||||
self.lds_seal = None
|
||||
|
||||
def getDisplayInfo(self):
|
||||
if self.gender == Person.male:
|
||||
gender = const.male
|
||||
elif self.gender == Person.female:
|
||||
gender = const.female
|
||||
else:
|
||||
gender = const.unknown
|
||||
bday = self.getBirth().getDateObj()
|
||||
dday = self.getDeath().getDateObj()
|
||||
return [self.PrimaryName.getName(),self.id,gender,bday.getQuoteDate(),
|
||||
dday.getQuoteDate(),sort.build_sort_name(self.PrimaryName),
|
||||
sort.build_sort_date(bday),sort.build_sort_date(dday)]
|
||||
|
||||
|
||||
def setPrimaryName(self,name):
|
||||
"""sets the primary name of the Person to the specified Name instance"""
|
||||
"""sets the primary name of the Person to the specified
|
||||
Name instance"""
|
||||
self.PrimaryName = name
|
||||
|
||||
def getPrimaryName(self):
|
||||
@ -932,7 +1018,7 @@ class Person:
|
||||
|
||||
def getAlternateNames(self):
|
||||
"""returns the list of alternate Names"""
|
||||
return self.alternateNames
|
||||
return extlist(self.alternateNames)
|
||||
|
||||
def setAlternateNames(self,list):
|
||||
"""changes the list of alternate names to the passed list"""
|
||||
@ -941,10 +1027,11 @@ class Person:
|
||||
def addAlternateName(self,name):
|
||||
"""adds an alternate Name instance to the list"""
|
||||
self.alternateNames.append(name)
|
||||
self._p_changed = 1
|
||||
|
||||
def getUrlList(self):
|
||||
"""returns the list of URL instances"""
|
||||
return self.urls
|
||||
return extlist(self.urls)
|
||||
|
||||
def setUrlList(self,list):
|
||||
"""sets the list of URL instances to list"""
|
||||
@ -953,6 +1040,7 @@ class Person:
|
||||
def addUrl(self,url):
|
||||
"""adds a URL instance to the list"""
|
||||
self.urls.append(url)
|
||||
self._p_changed = 1
|
||||
|
||||
def setId(self,id):
|
||||
"""sets the gramps ID for the Person"""
|
||||
@ -1003,10 +1091,11 @@ class Person:
|
||||
def addPhoto(self,photo):
|
||||
"""adds a Photo instance to the image list"""
|
||||
self.photoList.append(photo)
|
||||
self._p_changed = 1
|
||||
|
||||
def getPhotoList(self):
|
||||
"""returns the list of Photos"""
|
||||
return self.photoList
|
||||
return extlist(self.photoList)
|
||||
|
||||
def setPhotoList(self,list):
|
||||
"""Sets the list of Photo objects"""
|
||||
@ -1015,10 +1104,11 @@ class Person:
|
||||
def addEvent(self,event):
|
||||
"""adds an Event to the event list"""
|
||||
self.EventList.append(event)
|
||||
self._p_changed = 1
|
||||
|
||||
def getEventList(self):
|
||||
"""returns the list of Event instances"""
|
||||
return self.EventList
|
||||
return extlist(self.EventList)
|
||||
|
||||
def setEventList(self,list):
|
||||
"""sets the event list to the passed list"""
|
||||
@ -1029,6 +1119,7 @@ class Person:
|
||||
families/marriages/partnerships in which the person is a
|
||||
parent or spouse"""
|
||||
self.FamilyList.append(family)
|
||||
self._p_changed = 1
|
||||
|
||||
def setPreferred(self,family):
|
||||
if family in self.FamilyList:
|
||||
@ -1038,26 +1129,32 @@ class Person:
|
||||
def getFamilyList(self) :
|
||||
"""returns the list of Family instances in which the
|
||||
person is a parent or spouse"""
|
||||
return self.FamilyList
|
||||
return extlist(self.FamilyList)
|
||||
|
||||
def clearFamilyList(self) :
|
||||
self.FamilyList = PersistentList()
|
||||
|
||||
def removeFamily(self,family):
|
||||
"""removes the specified Family instance from the list
|
||||
of marriages/partnerships"""
|
||||
if family in self.FamilyList:
|
||||
self.FamilyList.remove(family)
|
||||
self._p_changed = 1
|
||||
|
||||
def addAddress(self,address):
|
||||
"""adds the Address instance to the list of addresses"""
|
||||
self.addressList.append(address)
|
||||
self._p_changed = 1
|
||||
|
||||
def removeAddress(self,address):
|
||||
"""removes the Address instance from the list of addresses"""
|
||||
for address in self.addressList:
|
||||
if address in self.addressList:
|
||||
self.addressList.remove(address)
|
||||
self._p_changed = 1
|
||||
|
||||
def getAddressList(self):
|
||||
"""returns the list of addresses"""
|
||||
return self.addressList
|
||||
return extlist(self.addressList)
|
||||
|
||||
def setAddressList(self,list):
|
||||
"""sets the address list to the specified list"""
|
||||
@ -1066,15 +1163,17 @@ class Person:
|
||||
def addAttribute(self,attribute):
|
||||
"""adds an Attribute instance to the attribute list"""
|
||||
self.attributeList.append(attribute)
|
||||
self._p_changed = 1
|
||||
|
||||
def removeAttribute(self,attribute):
|
||||
"""removes the specified Attribute instance from the attribute list"""
|
||||
for attribute in self.attributeList:
|
||||
if attribute in self.attributeList:
|
||||
self.attributeList.remove(attribute)
|
||||
self._p_changed = 1
|
||||
|
||||
def getAttributeList(self):
|
||||
"""returns the attribute list"""
|
||||
return self.attributeList
|
||||
return extlist(self.attributeList)
|
||||
|
||||
def setAttributeList(self,list):
|
||||
"""sets the attribute list to the specified list"""
|
||||
@ -1083,18 +1182,22 @@ class Person:
|
||||
def getParentList(self):
|
||||
"""returns the list of alternate Family instances, in which the Person
|
||||
is a child of the family, but not a natural child of both parents"""
|
||||
return self.AltFamilyList
|
||||
return extlist(self.AltFamilyList)
|
||||
|
||||
def addAltFamily(self,family,mrel,frel):
|
||||
"""adds a Family to the alternate family list, indicating the
|
||||
relationship to the mother (mrel) and the father (frel)"""
|
||||
self.AltFamilyList.append((family,mrel,frel))
|
||||
|
||||
def clearAltFamilyList(self):
|
||||
self.AltFamilyList = PersistentList()
|
||||
|
||||
def removeAltFamily(self,family):
|
||||
"""removes a Family instance from the alternate family list"""
|
||||
for f in self.AltFamilyList[:]:
|
||||
if f[0] == family:
|
||||
self.AltFamilyList.remove(f)
|
||||
self._p_changed = 1
|
||||
return f
|
||||
else:
|
||||
return None
|
||||
@ -1170,10 +1273,10 @@ class Person:
|
||||
if family.Father:
|
||||
# Don't waste time if the ancestor is already flagged.
|
||||
# This will happen when cousins marry.
|
||||
if not family.Father.ancestor:
|
||||
if not family.Father.getAncestor():
|
||||
family.Father.setAncestor(value)
|
||||
if family.Mother:
|
||||
if not family.Mother.ancestor:
|
||||
if family.getMother():
|
||||
if not family.Mother.getAncestor():
|
||||
family.Mother.setAncestor(value)
|
||||
|
||||
def getAncestor(self):
|
||||
@ -1330,22 +1433,23 @@ class Event(DataObj):
|
||||
"""sets the Date object associated with the Event"""
|
||||
self.date = date
|
||||
|
||||
class Family:
|
||||
|
||||
class Family(Persistent):
|
||||
"""Represents a family unit in the gramps database"""
|
||||
|
||||
def __init__(self):
|
||||
"""creates a new Family instance"""
|
||||
self.Father = None
|
||||
self.Mother = None
|
||||
self.Children = []
|
||||
self.Children = PersistentList()
|
||||
self.Marriage = None
|
||||
self.Divorce = None
|
||||
self.type = "Married"
|
||||
self.EventList = []
|
||||
self.EventList = PersistentList()
|
||||
self.id = ""
|
||||
self.photoList = []
|
||||
self.photoList = PersistentList()
|
||||
self.note = Note()
|
||||
self.attributeList = []
|
||||
self.attributeList = PersistentList()
|
||||
self.position = None
|
||||
self.lds_seal = None
|
||||
|
||||
@ -1366,15 +1470,17 @@ class Family:
|
||||
def addAttribute(self,attribute) :
|
||||
"""adds an Attribute instance to the attribute list"""
|
||||
self.attributeList.append(attribute)
|
||||
self._p_changed = 1
|
||||
|
||||
def removeAttribute(self,attribute):
|
||||
"""removes the specified Attribute instance from the attribute list"""
|
||||
for attribute in self.attributeList:
|
||||
if attribute in self.attributeList:
|
||||
self.attributeList.remove(attribute)
|
||||
self._p_changed = 1
|
||||
|
||||
def getAttributeList(self) :
|
||||
"""returns the attribute list"""
|
||||
return self.attributeList
|
||||
return extlist(self.attributeList)
|
||||
|
||||
def setAttributeList(self,list) :
|
||||
"""sets the attribute list to the specified list"""
|
||||
@ -1448,7 +1554,8 @@ class Family:
|
||||
to the child list"""
|
||||
if person not in self.Children:
|
||||
self.Children.append(person)
|
||||
if person.ancestor:
|
||||
self._p_changed = 1
|
||||
if person.getAncestor():
|
||||
if self.Father:
|
||||
self.Father.setAncestor(1)
|
||||
if self.Mother:
|
||||
@ -1458,7 +1565,8 @@ class Family:
|
||||
"""removes the specified Person from the child list"""
|
||||
if person in self.Children:
|
||||
self.Children.remove(person)
|
||||
if person.ancestor:
|
||||
self._p_changed = 1
|
||||
if person.getAncestor():
|
||||
if self.Father:
|
||||
self.Father.setAncestor(0)
|
||||
if self.Mother:
|
||||
@ -1466,7 +1574,7 @@ class Family:
|
||||
|
||||
def getChildList(self):
|
||||
"""returns the list of children"""
|
||||
return self.Children
|
||||
return extlist(self.Children)
|
||||
|
||||
def setChildList(self, list):
|
||||
"""sets the list of children"""
|
||||
@ -1489,10 +1597,11 @@ class Family:
|
||||
def addEvent(self,event):
|
||||
"""adds an Event to the event list"""
|
||||
self.EventList.append(event)
|
||||
self._p_changed = 1
|
||||
|
||||
def getEventList(self) :
|
||||
"""returns the list of Event instances"""
|
||||
return self.EventList
|
||||
return extlist(self.EventList)
|
||||
|
||||
def setEventList(self,list) :
|
||||
"""sets the event list to the passed list"""
|
||||
@ -1501,22 +1610,26 @@ class Family:
|
||||
def addPhoto(self,photo):
|
||||
"""Adds a Photo object to the Family instance's image list"""
|
||||
self.photoList.append(photo)
|
||||
self._p_changed = 1
|
||||
|
||||
def getPhotoList(self):
|
||||
"""Returns the list of Photo objects"""
|
||||
return self.photoList
|
||||
return extlist(self.photoList)
|
||||
|
||||
def setPhotoList(self,list):
|
||||
"""Sets the list of Photo objects"""
|
||||
self.photoList = list
|
||||
|
||||
def unique_note(self):
|
||||
self.note = Note(self.note.get())
|
||||
|
||||
def someChildIsAncestor(self):
|
||||
for child in self.Children:
|
||||
if (child.ancestor):
|
||||
if (child.getAncestor()):
|
||||
return 1
|
||||
return None
|
||||
|
||||
class Source:
|
||||
class Source(Persistent):
|
||||
"""A record of a source of information"""
|
||||
|
||||
def __init__(self):
|
||||
@ -1526,9 +1639,13 @@ class Source:
|
||||
self.pubinfo = ""
|
||||
self.callno = ""
|
||||
self.note = Note()
|
||||
self.photoList = []
|
||||
self.photoList = PersistentList()
|
||||
self.id = ""
|
||||
|
||||
def getDisplayInfo(self):
|
||||
return [self.title,self.id,self.author,upper(self.title),
|
||||
upper(self.author)]
|
||||
|
||||
def setId(self,newId):
|
||||
"""sets the gramps' ID for the Source instance"""
|
||||
self.id = str(newId)
|
||||
@ -1540,10 +1657,11 @@ class Source:
|
||||
def addPhoto(self,photo):
|
||||
"""Adds a Photo object to the Source instance's image list"""
|
||||
self.photoList.append(photo)
|
||||
self._p_changed = 1
|
||||
|
||||
def getPhotoList(self):
|
||||
"""Returns the list of Photo objects"""
|
||||
return self.photoList
|
||||
return extlist(self.photoList)
|
||||
|
||||
def setPhotoList(self,list):
|
||||
"""Sets the list of Photo objects"""
|
||||
@ -1602,7 +1720,7 @@ class Source:
|
||||
of the Source"""
|
||||
return self.callno
|
||||
|
||||
class SourceRef:
|
||||
class SourceRef(Persistent):
|
||||
"""Source reference, containing detailed information about how a
|
||||
referenced source relates to it"""
|
||||
|
||||
@ -1699,11 +1817,15 @@ class SourceRef:
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class GrampsDB:
|
||||
class GrampsDB(Persistent):
|
||||
"""Gramps database object"""
|
||||
|
||||
def __init__(self):
|
||||
"""creates a new GrampsDB"""
|
||||
self.surnames = PersistentList()
|
||||
self.personTable = {}
|
||||
self.placeTable = {}
|
||||
self.sourceTable = {}
|
||||
self.iprefix = "I%d"
|
||||
self.sprefix = "S%d"
|
||||
self.oprefix = "O%d"
|
||||
@ -1715,6 +1837,18 @@ class GrampsDB:
|
||||
self.placeMap = {}
|
||||
self.new()
|
||||
|
||||
def get_base(self):
|
||||
return ""
|
||||
|
||||
def need_autosave(self):
|
||||
return 1
|
||||
|
||||
def getPersonKeys(self):
|
||||
return self.personTable.keys()
|
||||
|
||||
def getPersonDisplay(self,key):
|
||||
return self.personTable[key]
|
||||
|
||||
def set_iprefix(self,val):
|
||||
if _id_reg.search(val):
|
||||
self.iprefix = val
|
||||
@ -1756,10 +1890,11 @@ class GrampsDB:
|
||||
self.familyMap = {}
|
||||
|
||||
for p in self.personMap.values():
|
||||
p.AltFamilyList = []
|
||||
p.FamilyList = []
|
||||
self.personMap = {}
|
||||
p.clearAltFamilyList()
|
||||
p.clearFamilyList()
|
||||
|
||||
self.surnames = PersistentList()
|
||||
self.personMap = {}
|
||||
self.sourceMap = {}
|
||||
self.placeMap = {}
|
||||
self.objectMap = {}
|
||||
@ -1770,13 +1905,21 @@ class GrampsDB:
|
||||
self.omapIndex = 0
|
||||
self.default = None
|
||||
self.owner = Researcher()
|
||||
self.bookmarks = []
|
||||
self.bookmarks = PersistentList()
|
||||
self.path = ""
|
||||
self.place2title = {}
|
||||
|
||||
def getSurnames(self):
|
||||
return self.surnames
|
||||
|
||||
def addSurname(self,name):
|
||||
if name and name not in self.surnames:
|
||||
self.surnames.append(name)
|
||||
self.surnames.sort()
|
||||
|
||||
def getBookmarks(self):
|
||||
"""returns the list of Person instances in the bookmarks"""
|
||||
return self.bookmarks
|
||||
return extlist(self.bookmarks)
|
||||
|
||||
def clean_bookmarks(self):
|
||||
"""cleans up the bookmark list, removing empty slots"""
|
||||
@ -1809,7 +1952,7 @@ class GrampsDB:
|
||||
|
||||
def getPersonMap(self):
|
||||
"""returns a map of gramps's IDs to Person instances"""
|
||||
return self.personMap
|
||||
return extmap(self.personMap)
|
||||
|
||||
def setPersonMap(self,map):
|
||||
"""sets the map of gramps's IDs to Person instances"""
|
||||
@ -1817,7 +1960,7 @@ class GrampsDB:
|
||||
|
||||
def getPlaceMap(self):
|
||||
"""returns a map of gramps's IDs to Place instances"""
|
||||
return self.placeMap
|
||||
return extmap(self.placeMap)
|
||||
|
||||
def setPlaceMap(self,map):
|
||||
"""sets the map of gramps's IDs to Place instances"""
|
||||
@ -1825,7 +1968,7 @@ class GrampsDB:
|
||||
|
||||
def getFamilyMap(self):
|
||||
"""returns a map of gramps's IDs to Family instances"""
|
||||
return self.familyMap
|
||||
return extmap(self.familyMap)
|
||||
|
||||
def setFamilyMap(self,map):
|
||||
"""sets the map of gramps's IDs to Family instances"""
|
||||
@ -1833,7 +1976,8 @@ class GrampsDB:
|
||||
|
||||
def getSourceMap(self):
|
||||
"""returns a map of gramps's IDs to Source instances"""
|
||||
return self.sourceMap
|
||||
return extmap(self.sourceMap)
|
||||
|
||||
|
||||
def getObjectMap(self):
|
||||
"""returns a map of gramps's IDs to Object instances"""
|
||||
@ -1895,6 +2039,12 @@ class GrampsDB:
|
||||
map[family.getRelationship()] = 1
|
||||
return map.keys()
|
||||
|
||||
def removePerson(self,id):
|
||||
del self.personMap[id]
|
||||
|
||||
def addPersonAs(self,person):
|
||||
self.personMap[person.getId()] = person
|
||||
|
||||
def addPerson(self,person):
|
||||
"""adds a Person to the database, assigning a gramps' ID"""
|
||||
index = self.iprefix % self.pmapIndex
|
||||
@ -2054,6 +2204,12 @@ class GrampsDB:
|
||||
self.lmapIndex = self.lmapIndex + 1
|
||||
return index
|
||||
|
||||
def removePlace(self,id):
|
||||
del self.placeMap[id]
|
||||
|
||||
def addPlaceAs(self,place):
|
||||
self.placeMap[place.getId()] = place
|
||||
|
||||
def findPlace(self,idVal,map):
|
||||
"""finds a Place in the database using the idVal and map
|
||||
variables to translate between the external ID and gramps'
|
||||
@ -2092,6 +2248,18 @@ class GrampsDB:
|
||||
self.lmapIndex = self.lmapIndex + 1
|
||||
return place
|
||||
|
||||
def getPlaceKeys(self):
|
||||
return self.placeTable.keys()
|
||||
|
||||
def getPlaceDisplay(self,key):
|
||||
return self.placeTable[key]
|
||||
|
||||
def getSourceKeys(self):
|
||||
return self.sourceTable.keys()
|
||||
|
||||
def getSourceDisplay(self,key):
|
||||
return self.sourceTable[key]
|
||||
|
||||
def newFamily(self):
|
||||
"""adds a Family to the database, assigning a gramps' ID"""
|
||||
index = self.fprefix % self.fmapIndex
|
||||
|
@ -244,7 +244,7 @@ class NewChild:
|
||||
self.surname = self.xml.get_widget("surname")
|
||||
self.given = self.xml.get_widget("childGiven")
|
||||
if GrampsCfg.autocomp:
|
||||
self.comp = AutoComp.AutoEntry(self.surname,const.surnames)
|
||||
self.comp = AutoComp.AutoEntry(self.surname,self.db.getSurnames())
|
||||
|
||||
self.surname.set_text(self.update_surname(2))
|
||||
|
||||
|
@ -71,13 +71,16 @@ class SourceView:
|
||||
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
|
||||
self.source_list.connect('click-column',self.click_column)
|
||||
|
||||
self.sort_col,self.sort_dir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING)
|
||||
if self.sort_col >= len(self.sort_arrow):
|
||||
self.sort_col = 0
|
||||
self.scol,self.sdir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING)
|
||||
if self.scol >= len(self.sort_arrow):
|
||||
self.scol = 0
|
||||
|
||||
self.source_list.set_sort_type(self.sort_dir)
|
||||
self.source_list.set_sort_column(self.sort_map[self.sort_col])
|
||||
self.set_arrow(self.sort_col)
|
||||
self.source_list.set_sort_type(self.sdir)
|
||||
self.source_list.set_sort_column(self.sort_map[self.scol])
|
||||
self.set_arrow(self.scol)
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
|
||||
def moveto(self,row):
|
||||
self.source_list.unselect_all()
|
||||
@ -91,7 +94,7 @@ class SourceView:
|
||||
|
||||
a = self.sort_arrow[column]
|
||||
a.show()
|
||||
if self.sort_dir == GTK.SORT_ASCENDING:
|
||||
if self.sdir == GTK.SORT_ASCENDING:
|
||||
a.set(GTK.ARROW_DOWN,2)
|
||||
else:
|
||||
a.set(GTK.ARROW_UP,2)
|
||||
@ -107,20 +110,20 @@ class SourceView:
|
||||
data = obj.get_row_data(obj.selection[0])
|
||||
|
||||
obj.freeze()
|
||||
if new_col == self.sort_col:
|
||||
if self.sort_dir == GTK.SORT_ASCENDING:
|
||||
self.sort_dir = GTK.SORT_DESCENDING
|
||||
if new_col == self.scol:
|
||||
if self.sdir == GTK.SORT_ASCENDING:
|
||||
self.sdir = GTK.SORT_DESCENDING
|
||||
else:
|
||||
self.sort_dir = GTK.SORT_ASCENDING
|
||||
self.sdir = GTK.SORT_ASCENDING
|
||||
else:
|
||||
self.sort_dir = GTK.SORT_ASCENDING
|
||||
self.sdir = GTK.SORT_ASCENDING
|
||||
|
||||
self.set_arrow(column)
|
||||
|
||||
obj.set_sort_type(self.sort_dir)
|
||||
obj.set_sort_type(self.sdir)
|
||||
obj.set_sort_column(new_col)
|
||||
self.sort_col = new_col
|
||||
GrampsCfg.save_sort_cols("source",self.sort_col,self.sort_dir)
|
||||
self.scol = new_col
|
||||
GrampsCfg.save_sort_cols("source",self.scol,self.sdir)
|
||||
obj.sort()
|
||||
if data:
|
||||
row = obj.find_row_from_data(data)
|
||||
@ -139,13 +142,9 @@ class SourceView:
|
||||
self.source_list.set_column_visibility(1,GrampsCfg.id_visible)
|
||||
|
||||
index = 0
|
||||
for src in self.db.getSourceMap().values():
|
||||
id = src.getId()
|
||||
title = src.getTitle()
|
||||
author = src.getAuthor()
|
||||
stitle = string.upper(title)
|
||||
sauthor = string.upper(author)
|
||||
self.source_list.append([title,id,author,stitle,sauthor])
|
||||
for key in self.db.getSourceKeys():
|
||||
src = self.db.getSourceMap()[key]
|
||||
self.source_list.append(src.getDisplayInfo())
|
||||
self.source_list.set_row_data(index,src)
|
||||
index = index + 1
|
||||
|
||||
@ -156,17 +155,18 @@ class SourceView:
|
||||
self.source_list.sort()
|
||||
self.source_list.thaw()
|
||||
|
||||
def on_button_press_event(self,obj,event):
|
||||
def button_press(self,obj,event):
|
||||
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
||||
if len(obj.selection) > 0:
|
||||
index = obj.selection[0]
|
||||
source = obj.get_row_data(index)
|
||||
EditSource.EditSource(source,self.db,self.update_display_after_edit)
|
||||
EditSource.EditSource(source,self.db,
|
||||
self.update_display_after_edit)
|
||||
|
||||
def on_add_source_clicked(self,obj):
|
||||
EditSource.EditSource(Source(),self.db,self.new_source_after_edit)
|
||||
|
||||
def on_delete_source_clicked(self,obj):
|
||||
def on_delete_clicked(self,obj):
|
||||
if len(obj.selection) == 0:
|
||||
return
|
||||
else:
|
||||
@ -228,7 +228,8 @@ class SourceView:
|
||||
if len(obj.selection) > 0:
|
||||
index = obj.selection[0]
|
||||
source = obj.get_row_data(index)
|
||||
EditSource.EditSource(source,self.db,self.update_display_after_edit)
|
||||
EditSource.EditSource(source,self.db,
|
||||
self.update_display_after_edit)
|
||||
|
||||
def new_source_after_edit(self,source):
|
||||
self.db.addSource(source)
|
||||
|
@ -429,20 +429,6 @@ def thumb_path(dir,mobj):
|
||||
else:
|
||||
return find_icon(type)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
# Common setup code for a combo box for inputting a surname.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def attach_surnames(combo):
|
||||
if len(const.surnames) > 0:
|
||||
# Surnames are always sorted
|
||||
combo.set_popdown_strings(const.surnames)
|
||||
combo.disable_activate()
|
||||
combo.entry.set_text("")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Sets up a delayed (0.005 sec) handler for text completion. Text
|
||||
|
@ -157,14 +157,14 @@ class XmlWriter:
|
||||
date = string.split(time.ctime(time.time()))
|
||||
owner = self.db.getResearcher()
|
||||
personList = self.db.getPersonMap().values()
|
||||
personList.sort(sortById)
|
||||
#personList.sort(sortById)
|
||||
familyList = self.db.getFamilyMap().values()
|
||||
familyList.sort(sortById)
|
||||
#familyList.sort(sortById)
|
||||
sourceList = self.db.getSourceMap().values()
|
||||
placeList = self.db.getPlaceMap().values()
|
||||
placeList.sort(sortById)
|
||||
#placeList.sort(sortById)
|
||||
objList = self.db.getObjectMap().values()
|
||||
objList.sort(sortById)
|
||||
#objList.sort(sortById)
|
||||
|
||||
total = len(personList) + len(familyList) + len(placeList) + len(sourceList)
|
||||
|
||||
|
@ -106,7 +106,8 @@ comments = _("GRAMPS (Genealogical Research and Analysis "
|
||||
#-------------------------------------------------------------------------
|
||||
picWidth = 275.0
|
||||
thumbScale = 96.0
|
||||
indexFile = "data.gramps"
|
||||
xmlFile = "data.gramps"
|
||||
zodbFile = "gramps.zodb"
|
||||
male = _("male")
|
||||
female = _("female")
|
||||
unknown = _("unknown")
|
||||
|
@ -2364,7 +2364,7 @@
|
||||
</signal>
|
||||
<signal>
|
||||
<name>button_press_event</name>
|
||||
<handler>on_child_list_button_press_event</handler>
|
||||
<handler>on_child_list_button_press</handler>
|
||||
<last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
@ -2797,7 +2797,7 @@
|
||||
</signal>
|
||||
<signal>
|
||||
<name>button_press_event</name>
|
||||
<handler>on_source_list_button_press_event</handler>
|
||||
<handler>on_source_list_button_press</handler>
|
||||
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
|
||||
</signal>
|
||||
<columns>5</columns>
|
||||
@ -7428,7 +7428,24 @@ Unknown
|
||||
<name>new</name>
|
||||
<border_width>5</border_width>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Create a New Database</label>
|
||||
<label>Create a New XML Database</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>open</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>zodb</name>
|
||||
<border_width>5</border_width>
|
||||
<visible>False</visible>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Create a New ZODB Database</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>open</group>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -81,7 +81,7 @@ class Merge:
|
||||
self.person_list = database.getPersonMap().values()[:]
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
self.glade_file = base + os.sep + "merge.glade"
|
||||
self.glade_file = "%s/%s" % (base,"merge.glade")
|
||||
top = GladeXML(self.glade_file,"dialog")
|
||||
|
||||
my_menu = GtkMenu()
|
||||
|
@ -112,7 +112,7 @@ def importData(database, filename):
|
||||
# add some checking here
|
||||
|
||||
glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__)
|
||||
|
||||
|
||||
statusTop = libglade.GladeXML(glade_file,"status")
|
||||
statusWindow = statusTop.get_widget("status")
|
||||
statusTop.get_widget("close").set_sensitive(0)
|
||||
@ -423,7 +423,7 @@ class GedcomParser:
|
||||
self.update(self.people_obj,str(self.indi_count))
|
||||
self.indi_count = self.indi_count + 1
|
||||
self.person = self.db.findPerson(matches[1],self.pmap)
|
||||
self.added[self.person] = 1
|
||||
self.added[self.person.getId()] = self.person
|
||||
self.parse_individual()
|
||||
elif matches[2] in ["SUBM","SUBN"]:
|
||||
self.ignore_sub_junk(1)
|
||||
@ -618,6 +618,7 @@ class GedcomParser:
|
||||
name.setFirstName(names[0])
|
||||
if names[2]:
|
||||
name.setSurname(names[2])
|
||||
self.db.addSurname(names[2])
|
||||
if names[4]:
|
||||
name.setSuffix(names[4])
|
||||
if name_cnt == 0:
|
||||
@ -638,6 +639,7 @@ class GedcomParser:
|
||||
aka.setFirstName(names[0])
|
||||
if names[2]:
|
||||
aka.setSurname(names[2])
|
||||
self.db.addSurname(names[2])
|
||||
if names[4]:
|
||||
aka.setSuffix(names[4])
|
||||
self.person.addAlternateName(aka)
|
||||
@ -765,7 +767,7 @@ class GedcomParser:
|
||||
self.person.getPrimaryName().addSourceRef(source_ref)
|
||||
elif matches[1] == "REFN":
|
||||
if intRE.match(matches[2]):
|
||||
self.refn[self.person] = int(matches[2])
|
||||
self.refn[self.person.getId()] = int(matches[2])
|
||||
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
|
||||
self.ignore_sub_junk(2)
|
||||
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
|
||||
@ -1028,6 +1030,7 @@ class GedcomParser:
|
||||
elif matches[1] == "FAMC":
|
||||
ord.setFamily(self.db.findFamily(matches[2],self.fmap))
|
||||
elif matches[1] == "PLAC":
|
||||
try:
|
||||
val = matches[2]
|
||||
if self.placemap.has_key(val):
|
||||
place = self.placemap[val]
|
||||
@ -1038,6 +1041,8 @@ class GedcomParser:
|
||||
self.placemap[val] = place
|
||||
ord.setPlace(place)
|
||||
self.ignore_sub_junk(level+1)
|
||||
except NameError:
|
||||
print 'please fix the val NameError'
|
||||
elif matches[1] == "SOUR":
|
||||
source_ref = SourceRef()
|
||||
if matches[2] and matches[2][0] != "@":
|
||||
@ -1432,6 +1437,7 @@ class GedcomParser:
|
||||
aka.setFirstName(names[0])
|
||||
if names[2]:
|
||||
aka.setSurname(names[2])
|
||||
self.db.addSurname(names[2])
|
||||
if names[4]:
|
||||
aka.setSuffix(names[4])
|
||||
self.person.addAlternateName(aka)
|
||||
@ -1443,6 +1449,7 @@ class GedcomParser:
|
||||
pass
|
||||
elif matches[1] == "SURN":
|
||||
name.setSurname(matches[2])
|
||||
self.db.addSurname(matches[2])
|
||||
elif matches[1] == "TITL":
|
||||
name.setSuffix(matches[2])
|
||||
elif matches[1] == "NSFX":
|
||||
@ -1458,6 +1465,7 @@ class GedcomParser:
|
||||
else:
|
||||
name = Name()
|
||||
name.setSurname(lname[-1])
|
||||
self.db.addSurname(lname[-1])
|
||||
name.setFirstName(string.join(lname[0:l-1]))
|
||||
self.person.addAlternateName(name)
|
||||
elif matches[1] == "SOUR":
|
||||
@ -1707,35 +1715,34 @@ class GedcomParser:
|
||||
|
||||
def resolve_refns(self):
|
||||
prefix = self.db.iprefix
|
||||
pmap = self.db.getPersonMap()
|
||||
renamed = []
|
||||
index = 0
|
||||
new_pmax = self.db.pmapIndex
|
||||
for person in self.added.keys():
|
||||
pmap = self.db.getPersonMap()
|
||||
for pid, person in self.added.items():
|
||||
index = index + 1
|
||||
if self.refn.has_key(person):
|
||||
val = self.refn[person]
|
||||
if self.refn.has_key(pid):
|
||||
val = self.refn[pid]
|
||||
new_key = prefix % val
|
||||
new_pmax = max(new_pmax,val)
|
||||
|
||||
# new ID is not used
|
||||
if not pmap.has_key(new_key):
|
||||
del pmap[person.getId()]
|
||||
pmap[new_key] = person
|
||||
self.db.removePerson(person.getId())
|
||||
person.setId(new_key)
|
||||
self.db.addPersonAs(person)
|
||||
else:
|
||||
tp = pmap[new_key]
|
||||
# same person, just change it
|
||||
if person == tp:
|
||||
del pmap[person.getId()]
|
||||
pmap[new_key] = person
|
||||
self.db.removePerson(person.getId())
|
||||
person.setId(new_key)
|
||||
self.db.addPersonAs(person)
|
||||
# person currently using it was just added, change it
|
||||
elif self.added.has_key(tp):
|
||||
del pmap[person.getId()]
|
||||
pmap[new_key] = person
|
||||
elif self.added.has_key(tp.getId()):
|
||||
self.db.removePerson(person.getId())
|
||||
person.setId(new_key)
|
||||
self.db.addPerson(tp)
|
||||
self.db.addPersonAs(person)
|
||||
|
||||
self.db.pmapIndex = new_pmax
|
||||
|
||||
|
@ -44,7 +44,10 @@ def build_sort_name(n):
|
||||
"""Builds a name from a RelLib.Name instance that is suitable for
|
||||
use as a sort key in a GtkCList. The name is converted to upper case
|
||||
to provide for case-insenstive sorting"""
|
||||
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
|
||||
if n.Surname:
|
||||
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
|
||||
else:
|
||||
return "%s" % chr(255)
|
||||
|
||||
def build_sort_date(n):
|
||||
"""Builds a date from a Date.Date instance that is suitable for
|
||||
|
Loading…
Reference in New Issue
Block a user