* src/RelLib.py (EventRef): Add class.

svn: r4693
This commit is contained in:
Alex Roitman 2005-05-26 21:03:24 +00:00
parent 5cc4c5b9b6
commit 8f894a12a8
2 changed files with 66 additions and 0 deletions

View File

@ -1,3 +1,6 @@
2005-05-26 Alex Roitman <shura@gramps-project.org>
* src/RelLib.py (EventRef): Add class.
2005-05-26 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/TestcaseGenerator.py: Add place, media and source
references.

View File

@ -4024,6 +4024,69 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase):
else:
return False
class EventRef:
"""
Event reference class.
This class is for keeping information about how the person relates
to the refereneced event.
"""
ROLE_CUSTOM = 0
ROLE_WITNESS = 1
ROLE_CLERGY = 2
ROLE_CELEBRANT = 3
ROLE_AIDE = 4
ROLE_BRIDE = 5
ROLE_GROOM = 6
def __init__(self,source=None):
"""
Creates a new EventRef instance, copying from the source if present.
"""
if source:
self.ref = source.ref
self.role_int = source.role_int
self.role_str = source.role_str
else:
self.ref = None
self.role_int = self.ROLE_CUSTOM
self.role_str = ""
def get_reference_handle(self):
"""
Returns the handle of the referred Event object.
"""
return self.ref
def set_reference_handle(self,handle):
"""
Sets the handle of the referred Event object.
"""
self.ref = handle
def get_role(self):
"""
Returns the integer corresponding to the preset role.
If custom then the string is returned.
"""
if self.role_int == self.ROLE_CUSTOM:
return self.role_str
else:
return self.role_int
def set_role(self,role):
"""
Sets the role according to the given argument.
If integer, it is set as is. If string, it is recorded as custom role.
"""
if type(role) == str:
self.role_int = self.ROLE_CUSTOM
self.role_str = role
elif type(role) == int:
self.role_int = role
self.role_str = ""
class GenderStats:
"""
Class for keeping track of statistics related to Given Name vs.