* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-04 03:33:53 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
"""
|
|
|
|
Event object for GRAMPS
|
|
|
|
"""
|
2005-12-21 02:18:18 +05:30
|
|
|
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from warnings import warn
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-21 02:18:18 +05:30
|
|
|
from _PrimaryObject import PrimaryObject
|
2006-04-13 08:45:22 +05:30
|
|
|
from _SourceBase import SourceBase
|
|
|
|
from _NoteBase import NoteBase
|
2005-12-21 02:18:18 +05:30
|
|
|
from _MediaBase import MediaBase
|
|
|
|
from _DateBase import DateBase
|
|
|
|
from _PlaceBase import PlaceBase
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
|
2005-12-21 02:18:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Event class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-13 08:45:22 +05:30
|
|
|
class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
"""
|
|
|
|
Introduction
|
|
|
|
============
|
|
|
|
The Event record is used to store information about some type of
|
|
|
|
action that occurred at a particular place at a particular time,
|
|
|
|
such as a birth, death, or marriage.
|
|
|
|
"""
|
|
|
|
|
|
|
|
UNKNOWN = -1
|
|
|
|
CUSTOM = 0
|
|
|
|
MARRIAGE = 1
|
|
|
|
MARR_SETTL = 2
|
|
|
|
MARR_LIC = 3
|
|
|
|
MARR_CONTR = 4
|
|
|
|
MARR_BANNS = 5
|
|
|
|
ENGAGEMENT = 6
|
|
|
|
DIVORCE = 7
|
|
|
|
DIV_FILING = 8
|
|
|
|
ANNULMENT = 9
|
|
|
|
MARR_ALT = 10
|
|
|
|
ADOPT = 11
|
|
|
|
BIRTH = 12
|
|
|
|
DEATH = 13
|
|
|
|
ADULT_CHRISTEN = 14
|
|
|
|
BAPTISM = 15
|
|
|
|
BAR_MITZVAH = 16
|
|
|
|
BAS_MITZVAH = 17
|
|
|
|
BLESS = 18
|
|
|
|
BURIAL = 19
|
|
|
|
CAUSE_DEATH = 20
|
|
|
|
CENSUS = 21
|
|
|
|
CHRISTEN = 22
|
|
|
|
CONFIRMATION = 23
|
|
|
|
CREMATION = 24
|
|
|
|
DEGREE = 25
|
|
|
|
EDUCATION = 26
|
|
|
|
ELECTED = 27
|
|
|
|
EMIGRATION = 28
|
|
|
|
FIRST_COMMUN = 29
|
|
|
|
IMMIGRATION = 30
|
|
|
|
GRADUATION = 31
|
|
|
|
MED_INFO = 32
|
|
|
|
MILITARY_SERV = 33
|
|
|
|
NATURALIZATION = 34
|
|
|
|
NOB_TITLE = 35
|
|
|
|
NUM_MARRIAGES = 36
|
|
|
|
OCCUPATION = 37
|
|
|
|
ORDINATION = 38
|
|
|
|
PROBATE = 39
|
|
|
|
PROPERTY = 40
|
|
|
|
RELIGION = 41
|
|
|
|
RESIDENCE = 42
|
|
|
|
RETIREMENT = 43
|
|
|
|
WILL = 44
|
|
|
|
|
|
|
|
def __init__(self,source=None):
|
|
|
|
"""
|
|
|
|
Creates a new Event instance, copying from the source if present
|
|
|
|
|
|
|
|
@param source: An event used to initialize the new event
|
|
|
|
@type source: Event
|
|
|
|
"""
|
|
|
|
|
|
|
|
PrimaryObject.__init__(self,source)
|
2006-04-13 08:45:22 +05:30
|
|
|
SourceBase.__init__(self,source)
|
|
|
|
NoteBase.__init__(self,source)
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
MediaBase.__init__(self,source)
|
|
|
|
DateBase.__init__(self,source)
|
|
|
|
PlaceBase.__init__(self,source)
|
|
|
|
|
|
|
|
if source:
|
|
|
|
self.description = source.description
|
|
|
|
self.type = source.type
|
|
|
|
self.cause = source.cause
|
|
|
|
else:
|
|
|
|
self.description = ""
|
|
|
|
self.type = (Event.CUSTOM,"")
|
|
|
|
self.cause = ""
|
|
|
|
|
|
|
|
def serialize(self):
|
|
|
|
"""
|
|
|
|
Converts the data held in the event to a Python tuple that
|
|
|
|
represents all the data elements. This method is used to convert
|
|
|
|
the object into a form that can easily be saved to a database.
|
|
|
|
|
|
|
|
These elements may be primative Python types (string, integers),
|
|
|
|
complex Python types (lists or tuples, or Python objects. If the
|
|
|
|
target database cannot handle complex types (such as objectes or
|
|
|
|
lists), the database is responsible for converting the data into
|
|
|
|
a form that it can use.
|
|
|
|
|
|
|
|
@returns: Returns a python tuple containing the data that should
|
|
|
|
be considered persistent.
|
|
|
|
@rtype: tuple
|
|
|
|
"""
|
2006-02-04 03:33:53 +05:30
|
|
|
return (self.handle, self.gramps_id, self.type,
|
|
|
|
DateBase.serialize(self),
|
2005-12-21 05:38:47 +05:30
|
|
|
self.description, self.place, self.cause,
|
2006-04-13 08:45:22 +05:30
|
|
|
SourceBase.serialize(self),
|
|
|
|
NoteBase.serialize(self),
|
2006-02-04 03:33:53 +05:30
|
|
|
MediaBase.serialize(self),
|
2006-04-19 23:24:17 +05:30
|
|
|
self.change, self.marker, self.private)
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
|
|
|
|
def unserialize(self,data):
|
|
|
|
"""
|
|
|
|
Converts the data held in a tuple created by the serialize method
|
|
|
|
back into the data in an Event structure.
|
|
|
|
|
|
|
|
@param data: tuple containing the persistent data associated the
|
|
|
|
Person object
|
|
|
|
@type data: tuple
|
|
|
|
"""
|
2006-02-04 03:33:53 +05:30
|
|
|
(self.handle, self.gramps_id, self.type, date,
|
2006-04-19 23:01:20 +05:30
|
|
|
self.description, self.place, self.cause,
|
|
|
|
source_list, note, media_list,
|
2006-04-19 23:24:17 +05:30
|
|
|
self.change, self.marker, self.private) = data
|
2006-02-04 03:33:53 +05:30
|
|
|
|
|
|
|
DateBase.unserialize(self,date)
|
|
|
|
MediaBase.unserialize(self,media_list)
|
2006-04-13 08:45:22 +05:30
|
|
|
SourceBase.unserialize(self,source_list)
|
2006-04-13 16:51:33 +05:30
|
|
|
NoteBase.unserialize(self,note)
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
|
|
|
|
def _has_handle_reference(self,classname,handle):
|
|
|
|
if classname == 'Place':
|
|
|
|
return self.place == handle
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _remove_handle_references(self,classname,handle_list):
|
|
|
|
if classname == 'Place' and self.place in handle_list:
|
|
|
|
self.place = ""
|
|
|
|
|
|
|
|
def _replace_handle_reference(self,classname,old_handle,new_handle):
|
|
|
|
if classname == 'Place' and self.place == old_handle:
|
|
|
|
self.place = new_handle
|
|
|
|
|
|
|
|
def get_text_data_list(self):
|
|
|
|
"""
|
|
|
|
Returns the list of all textual attributes of the object.
|
|
|
|
|
|
|
|
@return: Returns the list of all textual attributes of the object.
|
|
|
|
@rtype: list
|
|
|
|
"""
|
|
|
|
return [self.description,self.type[1],self.cause,self.gramps_id]
|
|
|
|
#return [self.description,self.type[1],self.cause,
|
|
|
|
# self.get_date(),self.gramps_id]
|
|
|
|
|
|
|
|
def get_text_data_child_list(self):
|
|
|
|
"""
|
|
|
|
Returns the list of child objects that may carry textual data.
|
|
|
|
|
|
|
|
@return: Returns the list of child objects that may carry textual data.
|
|
|
|
@rtype: list
|
|
|
|
"""
|
|
|
|
check_list = self.media_list + self.source_list
|
|
|
|
if self.note:
|
|
|
|
check_list.append(self.note)
|
|
|
|
return check_list
|
|
|
|
|
|
|
|
def get_sourcref_child_list(self):
|
|
|
|
"""
|
|
|
|
Returns the list of child secondary objects that may refer sources.
|
|
|
|
|
|
|
|
@return: Returns the list of child secondary child objects that may refer sources.
|
|
|
|
@rtype: list
|
|
|
|
"""
|
|
|
|
return self.media_list
|
|
|
|
|
|
|
|
def get_referenced_handles(self):
|
|
|
|
"""
|
|
|
|
Returns the list of (classname,handle) tuples for all directly
|
|
|
|
referenced primary objects.
|
|
|
|
|
|
|
|
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
|
|
|
@rtype: list
|
|
|
|
"""
|
|
|
|
ret = []
|
|
|
|
if self.place:
|
|
|
|
ret.append(('Place',self.place))
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def get_handle_referents(self):
|
|
|
|
"""
|
|
|
|
Returns the list of child objects which may, directly or through
|
|
|
|
their children, reference primary objects..
|
|
|
|
|
|
|
|
@return: Returns the list of objects refereincing primary objects.
|
|
|
|
@rtype: list
|
|
|
|
"""
|
|
|
|
return self.media_list + self.source_list
|
|
|
|
|
|
|
|
def is_empty(self):
|
|
|
|
"""
|
|
|
|
Returns True if the Event is an empty object (no values set).
|
|
|
|
|
|
|
|
@returns: True if the Event is empty
|
|
|
|
@rtype: bool
|
|
|
|
"""
|
|
|
|
date = self.get_date_object()
|
|
|
|
place = self.get_place_handle()
|
|
|
|
description = self.description
|
|
|
|
cause = self.cause
|
|
|
|
the_type = self.type
|
|
|
|
return (the_type == (Event.CUSTOM,"") and date.is_empty()
|
|
|
|
and not place and not description and not cause)
|
|
|
|
|
|
|
|
def are_equal(self,other):
|
|
|
|
"""
|
|
|
|
Returns True if the passed Event is equivalent to the current Event.
|
|
|
|
|
|
|
|
@param other: Event to compare against
|
|
|
|
@type other: Event
|
|
|
|
@returns: True if the Events are equal
|
|
|
|
@rtype: bool
|
|
|
|
"""
|
|
|
|
if other == None:
|
|
|
|
other = Event (None)
|
|
|
|
|
|
|
|
if self.type[0] != other.type[0] or \
|
|
|
|
(self.type[0] == Event.CUSTOM and self.type[1] != other.type[1]) or\
|
|
|
|
((self.place or other.place) and (self.place != other.place)) or \
|
|
|
|
self.description != other.description or self.cause != other.cause \
|
|
|
|
or self.private != other.private or \
|
|
|
|
(not self.get_date_object().is_equal(other.get_date_object())) or \
|
|
|
|
len(self.get_source_references()) != len(other.get_source_references()):
|
|
|
|
return False
|
|
|
|
|
|
|
|
index = 0
|
|
|
|
olist = other.get_source_references()
|
|
|
|
for a in self.get_source_references():
|
|
|
|
if not a.are_equal(olist[index]):
|
|
|
|
return False
|
|
|
|
index += 1
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def set_name(self,name):
|
|
|
|
warn( "Use set_type instead of set_name", DeprecationWarning, 2)
|
|
|
|
# INCOMPLETE Wrapper for old API
|
|
|
|
# remove when transitition done.
|
|
|
|
if name in range(-1,45):
|
|
|
|
the_type = (name,'')
|
|
|
|
else:
|
|
|
|
the_type = (Event.CUSTOM,name)
|
|
|
|
self.set_type(the_type)
|
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
warn( "Use get_type instead of get_name", DeprecationWarning, 2)
|
|
|
|
# INCOMPLETE Wrapper for old API
|
|
|
|
# remove when transitition done.
|
|
|
|
type = self.get_type()
|
|
|
|
return type[1]
|
|
|
|
|
|
|
|
def set_type(self,the_type):
|
|
|
|
"""
|
|
|
|
Sets the type of the Event to the passed (int,str) tuple.
|
|
|
|
|
|
|
|
@param the_type: Type to assign to the Event
|
|
|
|
@type the_type: tuple
|
|
|
|
"""
|
|
|
|
if not type(the_type) == tuple:
|
|
|
|
warn( "set_type now takes a tuple", DeprecationWarning, 2)
|
|
|
|
# Wrapper for old API
|
|
|
|
# remove when transitition done.
|
|
|
|
if the_type in range(-1,45):
|
|
|
|
the_type = (the_type,'')
|
|
|
|
else:
|
|
|
|
the_type = (Event.CUSTOM,the_type)
|
2006-01-25 02:39:34 +05:30
|
|
|
assert(type(the_type[0]) == int)
|
|
|
|
assert(type(the_type[1]) == unicode or type(the_type[1]) == str)
|
* src/RelLib.py: Remove file (replaced by the package dir).
* src/RelLib: Add directory.
* src/RelLib/__init__.py, src/RelLib/_helper.py,
src/RelLib/_secondary.py, src/RelLib/Researcher.py,
src/RelLib/GenderStats.py, src/RelLib/Person.py,
src/RelLib/Family.py, src/RelLib/Event.py, src/RelLib/Place.py,
src/RelLib/Source.py, src/RelLib/MediaObject.py,
src/RelLib/Repository.py, src/RelLib/Makefile.am,
src/RelLib/.cvsignore: Add to CVS.
* src/configure.in: Create Makefile in src/RelLib.
svn: r5587
2005-12-20 08:08:07 +05:30
|
|
|
self.type = the_type
|
|
|
|
|
|
|
|
def get_type(self):
|
|
|
|
"""
|
|
|
|
Returns the type of the Event.
|
|
|
|
|
|
|
|
@return: Type of the Event
|
|
|
|
@rtype: tuple
|
|
|
|
"""
|
|
|
|
return self.type
|
|
|
|
|
|
|
|
def set_cause(self,cause):
|
|
|
|
"""
|
|
|
|
Sets the cause of the Event to the passed string. The string
|
|
|
|
may contain any information.
|
|
|
|
|
|
|
|
@param cause: Cause to assign to the Event
|
|
|
|
@type cause: str
|
|
|
|
"""
|
|
|
|
self.cause = cause
|
|
|
|
|
|
|
|
def get_cause(self):
|
|
|
|
"""
|
|
|
|
Returns the cause of the Event.
|
|
|
|
|
|
|
|
@return: Returns the cause of the Event
|
|
|
|
@rtype: str
|
|
|
|
"""
|
|
|
|
return self.cause
|
|
|
|
|
|
|
|
def set_description(self,description):
|
|
|
|
"""
|
|
|
|
Sets the description of the Event to the passed string. The string
|
|
|
|
may contain any information.
|
|
|
|
|
|
|
|
@param description: Description to assign to the Event
|
|
|
|
@type description: str
|
|
|
|
"""
|
|
|
|
self.description = description
|
|
|
|
|
|
|
|
def get_description(self) :
|
|
|
|
"""
|
|
|
|
Returns the description of the Event.
|
|
|
|
|
|
|
|
@return: Returns the description of the Event
|
|
|
|
@rtype: str
|
|
|
|
"""
|
|
|
|
return self.description
|