* src/AddrEdit.py: setCountry -> set_country

* src/RelLib.py: Add concept of PrimaryObject
* src/GrampsDbBase.py: add local constants
* src/ReadGedcom.py: support new API


svn: r3374
This commit is contained in:
Don Allingham 2004-08-11 16:22:36 +00:00
parent f1dad71117
commit 90de8501ff
6 changed files with 61 additions and 142 deletions

View File

@ -1,3 +1,9 @@
2004-08-11 Don Allingham <dallingham@users.sourceforge.net>
* src/AddrEdit.py: setCountry -> set_country
* src/RelLib.py: Add concept of PrimaryObject
* src/GrampsDbBase.py: add local constants
* src/ReadGedcom.py: support new API
2004-08-11 Tim Waugh <twaugh@redhat.com>
* src/GrampsDbBase.py: Fixed some missed str()s.

View File

@ -231,7 +231,7 @@ class AddressEditor:
self.parent.lists_changed = 1
self.check(self.addr.get_street,self.addr.set_street,street)
self.check(self.addr.get_country,self.addr.setCountry,country)
self.check(self.addr.get_country,self.addr.set_country,country)
self.check(self.addr.get_city,self.addr.set_city,city)
self.check(self.addr.get_state,self.addr.set_state,state)
self.check(self.addr.get_postal_code,self.addr.set_postal_code,postal)

View File

@ -37,6 +37,13 @@ from gettext import gettext as _
_UNDO_SIZE = 1000
_id_reg = compile("%\d+d")
PERSON_KEY = 0
FAMILY_KEY = 1
SOURCE_KEY = 2
EVENT_KEY = 3
MEDIA_KEY = 4
PLACE_KEY = 5
#-------------------------------------------------------------------------
#
# GrampsDbBase

View File

@ -593,7 +593,6 @@ class GedcomParser:
place.set_handle(intid)
place.set_title(gramps_id)
place.set_gramps_id(self.db.find_next_place_gramps_id())
print place.get_gramps_id()
self.db.add_place(place,self.trans)
self.lid2id[gramps_id] = intid
return place
@ -1141,7 +1140,7 @@ class GedcomParser:
elif matches[1] == "POST":
address.set_postal_code(matches[2])
elif matches[1] == "CTRY":
address.setCountry(matches[2])
address.set_country(matches[2])
else:
self.barf(level+1)

View File

@ -1005,7 +1005,7 @@ class GrampsParser:
self.address.set_state(tag)
def stop_country(self,tag):
self.address.setCountry(tag)
self.address.set_country(tag)
def stop_postal(self,tag):
self.address.set_postal_code(tag)

View File

@ -58,12 +58,37 @@ CONF_NORMAL = 2
CONF_LOW = 1
CONF_VERY_LOW = 0
PERSON_KEY = 0
FAMILY_KEY = 1
SOURCE_KEY = 2
EVENT_KEY = 3
MEDIA_KEY = 4
PLACE_KEY = 5
#-------------------------------------------------------------------------
#
# Primary Object
#
#-------------------------------------------------------------------------
class PrimaryObject:
def __init__(self,source=None):
if source:
self.gramps_id = source.gramps_id
self.handle = source.handle
else:
self.gramps_id = ""
self.handle = ""
def set_handle(self,handle):
"""Sets the database handle for the place object"""
self.handle = handle
def get_handle(self):
"""Returns the database handle for the place object"""
return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
#-------------------------------------------------------------------------
#
@ -282,7 +307,7 @@ class DataObj(SourceNote):
# Place
#
#-------------------------------------------------------------------------
class Place(SourceNote):
class Place(PrimaryObject,SourceNote):
"""Contains information related to a place, including multiple address
information (since place names can change with time), longitude, latitude,
a collection of images and URLs, a note and a source"""
@ -291,7 +316,7 @@ class Place(SourceNote):
"""Creates a new Place object.
source - Object to copy. If none supplied, create an empty place object"""
PrimaryObject.__init__(self,source)
SourceNote.__init__(self,source)
if source:
self.long = source.long
@ -301,8 +326,6 @@ class Place(SourceNote):
self.alt_loc = []
for loc in source.alt_loc:
self.alt_loc = Location(loc)
self.handle = source.handle
self.gramps_id = source.gramps_id
self.urls = []
for u in source.urls:
self.urls.append(Url(u))
@ -315,8 +338,6 @@ class Place(SourceNote):
self.title = ""
self.main_loc = None
self.alt_loc = []
self.handle = ""
self.gramps_id = ""
self.urls = []
self.media_list = []
@ -342,22 +363,6 @@ class Place(SourceNote):
"""Add a URL to the URL list"""
self.urls.append(url)
def set_handle(self,handle):
"""Sets the database handle for the place object"""
self.handle = handle
def get_handle(self):
"""Returns the database handle for the place object"""
return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_title(self,name):
"""Sets the title of the place object"""
self.title = name
@ -633,13 +638,13 @@ class Note:
# MediaObject
#
#-------------------------------------------------------------------------
class MediaObject(SourceNote):
class MediaObject(PrimaryObject,SourceNote):
"""Containter for information about an image file, including location,
description and privacy"""
def __init__(self,source=None):
"""Create a new MediaObject object, copying from the source if provided"""
PrimaryObject.__init__(self,source)
SourceNote.__init__(self,source)
self.attrlist = []
@ -647,14 +652,10 @@ class MediaObject(SourceNote):
self.path = source.path
self.mime = source.mime
self.desc = source.desc
self.handle = source.handle
self.gramps_id = source.gramps_id
self.thumb = source.thumb
for attr in source.attrlist:
self.attrlist.append(Attribute(attr))
else:
self.handle = ""
self.gramps_id = ""
self.path = ""
self.mime = ""
self.desc = ""
@ -668,22 +669,6 @@ class MediaObject(SourceNote):
(self.handle, self.gramps_id, self.path, self.mime, self.desc,
self.attrlist, self.source_list, self.note) = data
def set_handle(self,handle):
"""Sets the database handle for the place object"""
self.handle = handle
def get_handle(self):
"""Returns the database handle for the place object"""
return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_mime_type(self,type):
self.mime = type
@ -891,7 +876,7 @@ class Address(DataObj):
"""returns the state portion of the Address"""
return self.state
def setCountry(self,val):
def set_country(self,val):
"""sets the country portion of the Address"""
self.country = val
@ -1145,7 +1130,7 @@ class Url:
# Person
#
#-------------------------------------------------------------------------
class Person(SourceNote):
class Person(PrimaryObject,SourceNote):
"""Represents an individual person in the gramps database"""
unknown = 2
@ -1154,9 +1139,8 @@ class Person(SourceNote):
def __init__(self,handle=""):
"""creates a new Person instance"""
PrimaryObject.__init__(self)
SourceNote.__init__(self)
self.handle = handle
self.gramps_id = ""
self.primary_name = Name()
self.event_list = []
self.family_list = []
@ -1273,30 +1257,6 @@ class Person(SourceNote):
"""adds a URL instance to the list"""
self.urls.append(url)
def set_gramps_id(self,gramps_id):
"""sets the GRAMPS ID for the Person"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""returns the GRAMPS ID for the Person"""
return self.gramps_id
def set_handle(self,handle):
"""sets the database handle for the Person"""
self.handle = handle
def get_handle(self):
"""returns the database handle for the Person"""
return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_nick_name(self,name):
"""sets the nickname for the Person"""
self.nickname = name
@ -1628,7 +1588,7 @@ class Person(SourceNote):
# Event
#
#-------------------------------------------------------------------------
class Event(DataObj):
class Event(PrimaryObject,DataObj):
"""Event record, recording the event type, description, place, and date
of a particular event"""
@ -1637,7 +1597,8 @@ class Event(DataObj):
def __init__(self,source=None):
"""creates a new Event instance, copying from the source if present"""
PrimaryObject.__init__(self,source)
DataObj.__init__(self,source)
if source:
@ -1646,8 +1607,6 @@ class Event(DataObj):
self.description = source.description
self.name = source.name
self.cause = source.cause
self.handle = source.handle
self.gramps_id = source.gramps_id
self.media_list = [MediaRef(media_id) for media_id in source.media_list]
try:
if source.witness:
@ -1663,8 +1622,6 @@ class Event(DataObj):
self.name = ""
self.cause = ""
self.witness = None
self.handle = ""
self.gramps_id = ""
self.media_list = []
def clone(self,source):
@ -1709,22 +1666,6 @@ class Event(DataObj):
"""Sets the list of Photo objects"""
self.media_list = mlist
def set_handle(self,handle):
"""Sets the database handle for the place object"""
self.handle = handle
def get_handle(self):
"""Returns the database handle for the place object"""
return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def get_witness_list(self):
return self.witness
@ -1894,19 +1835,18 @@ class Witness:
# Family
#
#-------------------------------------------------------------------------
class Family(SourceNote):
class Family(PrimaryObject,SourceNote):
"""Represents a family unit in the gramps database"""
def __init__(self):
"""creates a new Family instance"""
PrimaryObject.__init__(self)
SourceNote.__init__(self)
self.father_handle = None
self.mother_handle = None
self.child_list = []
self.type = const.FAMILY_MARRIED
self.event_list = []
self.handle = ""
self.gramps_id = ""
self.media_list = []
self.attribute_list = []
self.lds_seal = None
@ -1954,22 +1894,6 @@ class Family(SourceNote):
"""sets the attribute list to the specified list"""
self.attribute_list = list
def set_handle(self,handle) :
"""sets the database handle for the Family"""
self.handle = str(handle)
def get_handle(self) :
"""returns the database handle for the Family"""
return unicode(self.handle)
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_relationship(self,type):
"""assigns a string indicating the relationship between the
father and the mother"""
@ -2084,18 +2008,17 @@ class Family(SourceNote):
# Source
#
#-------------------------------------------------------------------------
class Source:
class Source(PrimaryObject):
"""A record of a source of information"""
def __init__(self):
"""creates a new Source instance"""
PrimaryObject.__init__(self)
self.title = ""
self.author = ""
self.pubinfo = ""
self.note = Note()
self.media_list = []
self.handle = ""
self.gramps_id = ""
self.abbrev = ""
def serialize(self):
@ -2109,22 +2032,6 @@ class Source:
def get_display_info(self):
return [self.title,self.gramps_id,self.author,self.title.upper(),self.author.upper()]
def set_handle(self,handle):
"""sets the gramps' ID for the Source instance"""
self.handle = str(handle)
def get_handle(self):
"""returns the gramps' ID of the Source instance"""
return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def add_media_reference(self,media_id):
"""Adds a MediaObject object to the Source instance's image list"""
self.media_list.append(media_id)