2007-01-07 Don Allingham <don@gramps-project.org>

* src/RelLib/*.py: pylint fixes

2007-01-07  Douglas S. Blank <dblank@cs.brynmawr.edu>
	* src/Utils.py: probably_alive patch



svn: r7878
This commit is contained in:
Don Allingham 2007-01-08 01:49:33 +00:00
parent 9c02ff28df
commit d5ff16800a
56 changed files with 968 additions and 620 deletions

View File

@ -1,3 +1,9 @@
2007-01-07 Don Allingham <don@gramps-project.org>
* src/RelLib/*.py: pylint fixes
2007-01-07 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/Utils.py: probably_alive patch
2007-01-06 Piotr Czubaszek <pioterus@gmail.com>
* src/plugins/rel_pl.py: Update.

View File

@ -72,3 +72,6 @@ GRAMPS_PY_MODPATH = "../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));
pylint:
pylint --disable-msg=W0403,C0103 $(pkgdata_PYTHON)

View File

@ -24,6 +24,8 @@
Address class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -56,6 +58,9 @@ class Address(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase,
LocationBase.__init__(self, source)
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
@ -63,6 +68,9 @@ class Address(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase,
LocationBase.serialize(self))
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, source_list, note, date, location) = data
PrivacyBase.unserialize(self, privacy)

View File

@ -24,6 +24,8 @@
AddressBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -57,9 +59,15 @@ class AddressBase:
self.address_list = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [addr.serialize() for addr in self.address_list]
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.address_list = [Address().unserialize(item) for item in data]
def add_address(self, address):

View File

@ -24,6 +24,8 @@
Attribute class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -61,12 +63,18 @@ class Attribute(SecondaryObject,PrivacyBase,SourceBase,NoteBase):
self.value = ""
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
self.type.serialize(), self.value)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, source_list, note, the_type, self.value) = data
PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self, source_list)

View File

@ -24,6 +24,8 @@
AttributeBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -57,9 +59,15 @@ class AttributeBase:
self.attribute_list = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [attr.serialize() for attr in self.attribute_list]
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.attribute_list = [Attribute().unserialize(item) for item in data]
def add_attribute(self, attribute):

View File

@ -20,9 +20,15 @@
# $Id$
"""
Provides the different Attribute Types for GRAMPS
"""
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
__revision__ = "$Revision$"
class AttributeType(GrampsType):
UNKNOWN = -1

View File

@ -24,6 +24,8 @@
Base Object class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -50,9 +52,15 @@ class BaseObject:
pass
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
assert False, "Needs to be overridden in the derived class"
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
assert False, "Needs to be overridden in the derived class"
return self

View File

@ -20,6 +20,8 @@
# $Id$
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# Python modules
@ -97,43 +99,43 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
return tishri1
def _tishri_molad(inputDay):
def _tishri_molad(input_day):
# Estimate the metonic cycle number. Note that this may be an under
# estimate because there are 6939.6896 days in a metonic cycle not
# 6940, but it will never be an over estimate. The loop below will
# correct for any error in this estimate. */
metonicCycle = (inputDay + 310) / 6940
metonic_cycle = (input_day + 310) / 6940
# Calculate the time of the starting molad for this metonic cycle. */
(moladDay, moladHalakim) = _molad_of_metonic_cycle(metonicCycle)
(molad_day, molad_halakim) = _molad_of_metonic_cycle(metonic_cycle)
# If the above was an under estimate, increment the cycle number until
# the correct one is found. For modern dates this loop is about 98.6%
# likely to not execute, even once, because the above estimate is
# really quite close.
while moladDay < (inputDay - 6940 + 310):
metonicCycle = metonicCycle + 1
moladHalakim = moladHalakim + _HBR_HALAKIM_PER_METONIC_CYCLE
moladDay = moladDay + ( moladHalakim / _HBR_HALAKIM_PER_DAY)
moladHalakim = moladHalakim % _HBR_HALAKIM_PER_DAY
while molad_day < (input_day - 6940 + 310):
metonic_cycle = metonic_cycle + 1
molad_halakim = molad_halakim + _HBR_HALAKIM_PER_METONIC_CYCLE
molad_day = molad_day + ( molad_halakim / _HBR_HALAKIM_PER_DAY)
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
# Find the molad of Tishri closest to this date.
for metonicYear in range(0,18):
if moladDay > inputDay - 74:
for metonic_year in range(0, 18):
if molad_day > input_day - 74:
break
moladHalakim = moladHalakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
* _HBR_MONTHS_PER_YEAR[metonicYear])
moladDay = moladDay + (moladHalakim / _HBR_HALAKIM_PER_DAY)
moladHalakim = moladHalakim % _HBR_HALAKIM_PER_DAY
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
* _HBR_MONTHS_PER_YEAR[metonic_year])
molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY)
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
else:
metonicYear = metonicYear + 1
return (metonicCycle, metonicYear, moladDay, moladHalakim)
metonic_year = metonic_year + 1
return (metonic_cycle, metonic_year, molad_day, molad_halakim)
def _molad_of_metonic_cycle(metonic_cycle):
@ -254,110 +256,110 @@ def hebrew_sdn(year, month, day):
def hebrew_ymd(sdn):
"""Converts an SDN number to a Julian calendar date"""
inputDay = sdn - _HBR_SDN_OFFSET
input_day = sdn - _HBR_SDN_OFFSET
(metonicCycle, metonicYear, day, halakim) = _tishri_molad(inputDay)
tishri1 = _tishri1(metonicYear, day, halakim);
(metonic_cycle, metonic_year, day, halakim) = _tishri_molad(input_day)
tishri1 = _tishri1(metonic_year, day, halakim);
if inputDay >= tishri1:
if input_day >= tishri1:
# It found Tishri 1 at the start of the year
Year = (metonicCycle * 19) + metonicYear + 1
if inputDay < tishri1 + 59:
if inputDay < tishri1 + 30:
Month = 1
Day = inputDay - tishri1 + 1
year = (metonic_cycle * 19) + metonic_year + 1
if input_day < tishri1 + 59:
if input_day < tishri1 + 30:
month = 1
day = input_day - tishri1 + 1
else:
Month = 2
Day = inputDay - tishri1 - 29
return (Year, Month, Day)
month = 2
day = input_day - tishri1 - 29
return (year, month, day)
# We need the length of the year to figure this out, so find
# Tishri 1 of the next year. */
halakim = halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
* _HBR_MONTHS_PER_YEAR[metonicYear])
* _HBR_MONTHS_PER_YEAR[metonic_year])
day = day + (halakim / _HBR_HALAKIM_PER_DAY)
halakim = halakim % _HBR_HALAKIM_PER_DAY;
tishri1After = _tishri1((metonicYear + 1) % 19, day, halakim);
tishri1_after = _tishri1((metonic_year + 1) % 19, day, halakim);
else:
# It found Tishri 1 at the end of the year.
Year = metonicCycle * 19 + metonicYear
if inputDay >= tishri1 - 177:
year = metonic_cycle * 19 + metonic_year
if input_day >= tishri1 - 177:
# It is one of the last 6 months of the year.
if inputDay > tishri1 - 30:
Month = 13
Day = inputDay - tishri1 + 30
elif inputDay > tishri1 - 60:
Month = 12
Day = inputDay - tishri1 + 60
elif inputDay > tishri1 - 89:
Month = 11
Day = inputDay - tishri1 + 89
elif inputDay > tishri1 - 119:
Month = 10
Day = inputDay - tishri1 + 119
elif inputDay > tishri1 - 148:
Month = 9
Day = inputDay - tishri1 + 148
if input_day > tishri1 - 30:
month = 13
day = input_day - tishri1 + 30
elif input_day > tishri1 - 60:
month = 12
day = input_day - tishri1 + 60
elif input_day > tishri1 - 89:
month = 11
day = input_day - tishri1 + 89
elif input_day > tishri1 - 119:
month = 10
day = input_day - tishri1 + 119
elif input_day > tishri1 - 148:
month = 9
day = input_day - tishri1 + 148
else:
Month = 8
Day = inputDay - tishri1 + 178
return (Year,Month,Day)
month = 8
day = input_day - tishri1 + 178
return (year, month, day)
else:
if _HBR_MONTHS_PER_YEAR[(Year - 1) % 19] == 13:
Month = 7
Day = inputDay - tishri1 + 207
if Day > 0:
return (Year,Month,Day)
Month = Month - 1
Day = Day + 30
if Day > 0:
return (Year,Month,Day)
Month = Month - 1
Day = Day + 30
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 13:
month = 7
day = input_day - tishri1 + 207
if day > 0:
return (year, month, day)
month = month - 1
day = day + 30
if day > 0:
return (year, month, day)
month = month - 1
day = day + 30
else:
Month = 6
Day = inputDay - tishri1 + 207
if Day > 0:
return (Year,Month,Day)
Month = Month - 1
Day = Day + 30
month = 6
day = input_day - tishri1 + 207
if day > 0:
return (year, month, day)
month = month - 1
day = day + 30
if Day > 0:
return (Year,Month,Day)
Month = Month - 1
Day = Day + 29
if Day > 0:
return (Year,Month,Day)
if day > 0:
return (year, month, day)
month = month - 1
day = day + 29
if day > 0:
return (year, month, day)
# We need the length of the year to figure this out, so find
# Tishri 1 of this year
tishri1After = tishri1;
(metonicCycle,metonicYear,day,halakim) = _tishri_molad(day-365)
tishri1 = _tishri1(metonicYear, day, halakim)
tishri1_after = tishri1;
(metonic_cycle, metonic_year, day, halakim) = _tishri_molad(day-365)
tishri1 = _tishri1(metonic_year, day, halakim)
yearLength = tishri1After - tishri1;
cday = inputDay - tishri1 - 29;
if yearLength == 355 or yearLength == 385 :
year_length = tishri1_after - tishri1;
cday = input_day - tishri1 - 29;
if year_length == 355 or year_length == 385 :
# Heshvan has 30 days
if day <= 30:
Month = 2
Day = cday
return (Year,Month,Day)
month = 2
day = cday
return (year, month, day)
day = day - 30
else:
# Heshvan has 29 days
if day <= 29:
Month = 2
Day = cday
return (Year,Month,Day)
month = 2
day = cday
return (year, month, day)
cday = cday - 29
# It has to be Kislev
return (Year,3,cday)
return (year, 3, cday)
def julian_sdn(year, month, day):
"""Converts a Julian calendar date to an SDN number"""

View File

@ -24,6 +24,8 @@
Child Reference class for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -64,6 +66,9 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
self.mrel = ChildRefType()
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
@ -72,6 +77,9 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
self.mrel.serialize())
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, source_list, note, ref, frel, mrel) = data
PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self, source_list)

View File

@ -20,9 +20,15 @@
# $Id$
"""
Provides the different child reference types
"""
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
__revision__ = "$Revision$"
class ChildRefType(GrampsType):
NONE = 0

View File

@ -24,6 +24,8 @@
DateBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -54,6 +56,9 @@ class DateBase:
self.date = Date()
def serialize(self, no_text_date=False):
"""
Converts the object to a serialized tuple of data
"""
if self.date == None or (self.date.is_empty() and not self.date.text):
date = None
else:
@ -61,6 +66,9 @@ class DateBase:
return date
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
if data == None:
self.date = Date()
else:

View File

@ -24,6 +24,8 @@
Event object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules

View File

@ -24,6 +24,8 @@
Event Reference class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -64,6 +66,9 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
self.role = EventRoleType()
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (
PrivacyBase.serialize(self),
NoteBase.serialize(self),
@ -73,6 +78,9 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, note, attribute_list, ref, role) = data
PrivacyBase.unserialize(self, privacy)
NoteBase.unserialize(self, note)

View File

@ -19,6 +19,12 @@
#
# $Id$
"""
Provides the different event roles
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -20,6 +20,12 @@
# $Id$
"""
Provides the different event types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -24,6 +24,8 @@
Family object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -221,8 +223,8 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@return: Returns the list of child secondary child objects that may refer sources.
@rtype: list
"""
check_list = self.media_list + self.attribute_list + self.lds_ord_list + \
self.child_ref_list
check_list = self.media_list + self.attribute_list + \
self.lds_ord_list + self.child_ref_list
return check_list
def get_referenced_handles(self):
@ -392,14 +394,6 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
self.child_ref_list = child_ref_list
def add_event_handle(self,event_handle):
warn( "Use add_event_ref instead of add_event_handle", DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
event_ref = EventRef()
event_ref.set_reference_handle(event_handle)
self.add_event_ref(event_ref)
def add_event_ref(self, event_ref):
"""
Adds the L{EventRef} to the Family instance's L{EventRef} list.
@ -415,7 +409,8 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.event_ref_list.append(event_ref)
def get_event_list(self) :
warn( "Use get_event_ref_list instead of get_event_list", DeprecationWarning, 2)
warn( "Use get_event_ref_list instead of get_event_list",
DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
event_handle_list = []
@ -434,17 +429,6 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
return self.event_ref_list
def set_event_list(self,event_list) :
warn( "Use set_event_ref_list instead of set_event_list", DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
event_ref_list = []
for event_handle in event_list:
event_ref = EventRef()
event_ref.set_reference_handle(event_handle)
event_ref_list.append( event_ref)
self.set_event_ref_list(event_ref_list)
def set_event_ref_list(self, event_ref_list) :
"""
Sets the Family instance's L{EventRef} list to the passed list.

View File

@ -19,6 +19,12 @@
#
# $Id$
"""
Provides the different family reference types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -24,6 +24,8 @@
Gender statistics kept in GRAMPS database.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules

View File

@ -20,6 +20,12 @@
# $Id$
"""
Base type for all gramps types
"""
__revision__ = "$Revision$"
from gettext import gettext as _
def init_map(data, key_col, data_col):
@ -41,6 +47,8 @@ class GrampsType:
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None):
self.value = None
self.string = None
self.set(value)
def set(self, value):
@ -86,9 +94,15 @@ class GrampsType:
return self._I2EMAP[self.val]
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.val, self.string)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.val, self.string = data
def __str__(self):

View File

@ -23,6 +23,7 @@
"""
LDS Ordinance class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
@ -132,6 +133,9 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
self.status = LdsOrd.DEFAULT_STATUS
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (SourceBase.serialize(self),
NoteBase.serialize(self),
DateBase.serialize(self),
@ -139,6 +143,9 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
self.famc, self.temple, self.status)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(source_list, note, date, self.type, self.place,
self.famc, self.temple, self.status) = data
SourceBase.unserialize(self, source_list)

View File

@ -24,6 +24,8 @@
LdsOrdBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -57,9 +59,15 @@ class LdsOrdBase:
self.lds_ord_list = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [lds_ord.serialize() for lds_ord in self.lds_ord_list]
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.lds_ord_list = [LdsOrd().unserialize(item) for item in data]
def add_lds_ord(self, lds_ord):

View File

@ -24,6 +24,8 @@
Location class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -59,11 +61,17 @@ class Location(SecondaryObject,LocationBase):
self.parish = ""
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (LocationBase.serialize(self), self.parish)
def unserialize(self, data):
(lb, self.parish) = data
LocationBase.unserialize(self, lb)
"""
Converts a serialized tuple of data to an object
"""
(lbase, self.parish) = data
LocationBase.unserialize(self, lbase)
return self
def get_text_data_list(self):

View File

@ -24,6 +24,8 @@
LocationBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# LocationBase class
@ -57,10 +59,16 @@ class LocationBase:
self.phone = ""
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.street, self.city, self.county, self.state,
self.country, self.postal, self.phone)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(self.street, self.city, self.county, self.state, self.country,
self.postal, self.phone) = data
return self

View File

@ -19,15 +19,24 @@
#
# $Id$
"""
Marker types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
class MarkerType(GrampsType):
"""
Class for handling data markers.
"""
NONE = -1
CUSTOM = 0
COMPLETE = 1
TODO = 2
TODO_TYPE = 2
_CUSTOM = CUSTOM
_DEFAULT = NONE
@ -36,7 +45,7 @@ class MarkerType(GrampsType):
(NONE, "", ""),
(CUSTOM, _("Custom"), "Custom"),
(COMPLETE, _("Complete"), "Complete"),
(TODO, _("ToDo"), "ToDo"),
(TODO_TYPE, _("ToDo"), "ToDo"),
]
_I2SMAP = init_map(_DATAMAP, 0, 1)
@ -48,6 +57,9 @@ class MarkerType(GrampsType):
GrampsType.__init__(self, value)
def set(self, value):
"""
sets the marker value
"""
if isinstance(value, self.__class__):
if value.val == self.CUSTOM and value.string == '':
self.val = self.NONE

View File

@ -24,6 +24,8 @@
MediaBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -55,9 +57,15 @@ class MediaBase:
self.media_list = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [mref.serialize() for mref in self.media_list]
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.media_list = [MediaRef().unserialize(item) for item in data]
def add_media_reference(self, media_ref):

View File

@ -24,6 +24,8 @@
Media object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -71,13 +73,11 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
self.path = source.path
self.mime = source.mime
self.desc = source.desc
# FIXME: thumb is not currently being serialized!
self.thumb = source.thumb
else:
self.path = ""
self.mime = ""
self.desc = ""
# FIXME: thumb is not currently being serialized!
self.thumb = None
def serialize(self):
@ -131,7 +131,6 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
@rtype: list
"""
return [self.path, self.mime, self.desc, self.gramps_id]
#return [self.path,self.mime,self.desc,self.get_date(),self.gramps_id]
def get_text_data_child_list(self):
"""
@ -164,14 +163,14 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
"""
return self.attribute_list + self.source_list
def set_mime_type(self,type):
def set_mime_type(self, mime_type):
"""
Sets the MIME type associated with the MediaObject
@param type: MIME type to be assigned to the object
@type type: str
"""
self.mime = type
self.mime = mime_type
def get_mime_type(self):
"""

View File

@ -24,6 +24,8 @@
Media Reference class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -59,6 +61,9 @@ class MediaRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase,
self.rect = None
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
@ -67,6 +72,9 @@ class MediaRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase,
self.rect)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, source_list, note, attribute_list, ref, self.rect) = data
PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self, source_list)

View File

@ -24,6 +24,8 @@
Name class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -57,6 +59,10 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
def __init__(self, source=None, data=None):
"""creates a new Name instance, copying from the source if provided"""
SecondaryObject.__init__(self)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
DateBase.__init__(self, source)
if data:
(privacy, source_list, note, date,
self.first_name, self.surname, self.suffix, self.title,
@ -68,10 +74,6 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
NoteBase.unserialize(self, note)
DateBase.unserialize(self, date)
elif source:
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
DateBase.__init__(self,source)
self.first_name = source.first_name
self.surname = source.surname
self.suffix = source.suffix
@ -84,10 +86,6 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.display_as = source.display_as
self.call = source.call
else:
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
DateBase.__init__(self,source)
self.first_name = ""
self.surname = ""
self.suffix = ""
@ -101,6 +99,9 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.call = ''
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
@ -110,11 +111,17 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.group_as, self.sort_as, self.display_as, self.call)
def is_empty(self):
"""
Indicates if the name is empty
"""
return (self.first_name == u"" and self.surname == u"" and
self.suffix == u"" and self.title == u"" and
self.prefix == u"" and self.patronymic == u"")
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, source_list, note, date,
self.first_name, self.surname, self.suffix, self.title,
name_type, self.prefix, self.patronymic,
@ -304,7 +311,8 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
first = self.first_name
if self.suffix:
if self.prefix:
return "%s %s, %s %s" % (self.prefix, self.surname, first, self.suffix)
return "%s %s, %s %s" % (self.prefix, self.surname,
first, self.suffix)
else:
return "%s, %s %s" % (self.surname, first, self.suffix)
else:
@ -323,12 +331,16 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
first = self.first_name
if self.suffix:
if self.prefix:
return "%s %s, %s %s" % (self.prefix.upper(), self.surname.upper(), first, self.suffix)
return "%s %s, %s %s" % (self.prefix.upper(),
self.surname.upper(), first,
self.suffix)
else:
return "%s, %s %s" % (self.surname.upper(), first, self.suffix)
else:
if self.prefix:
return "%s %s, %s" % (self.prefix.upper(), self.surname.upper(), first)
return "%s %s, %s" % (self.prefix.upper(),
self.surname.upper(),
first)
else:
return "%s, %s" % (self.surname.upper(), first)
@ -346,6 +358,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
return "%s %s" % (first, self.surname)
else:
if self.prefix:
return "%s %s %s, %s" % (first, self.prefix, self.surname, self.suffix)
return "%s %s %s, %s" % (first, self.prefix, self.surname,
self.suffix)
else:
return "%s %s, %s" % (first, self.surname, self.suffix)

View File

@ -20,6 +20,12 @@
# $Id$
"""
Name types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -24,6 +24,8 @@
Note class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -54,9 +56,15 @@ class Note(SecondaryObject):
self.format = 0
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.text, self.format)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
if data:
(self.text, self.format) = data
return self

View File

@ -24,6 +24,8 @@
NoteBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -55,11 +57,17 @@ class NoteBase:
self.note = Note(text)
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
if self.note == None:
self.note = Note()
return self.note.serialize()
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
if data is not None:
self.note = Note().unserialize(data)

View File

@ -24,6 +24,8 @@
Person object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -157,8 +159,7 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
Person object
@type data: tuple
"""
(
self.handle, # 0
(self.handle, # 0
self.gramps_id, # 1
self.gender, # 2
primary_name, # 3

View File

@ -24,6 +24,8 @@
Person Reference class for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -61,6 +63,9 @@ class PersonRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
self.rel = ''
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
@ -68,6 +73,9 @@ class PersonRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
self.rel)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(privacy, source_list, note, ref, self.rel) = data
PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self, source_list)

View File

@ -24,6 +24,8 @@
Place object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules

View File

@ -24,6 +24,8 @@
PlaceBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# PlaceBase class

View File

@ -24,6 +24,8 @@
Primary Object class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -66,7 +68,7 @@ class PrimaryObject(BaseObject,PrivacyBase):
def __init__(self, source=None):
"""
Initialize a PrimaryObject. If source is None, both the ID and handle
o Initialize a PrimaryObject. If source is None, both the ID and handle
are assigned as empty strings. If source is not None, then object
is initialized from values of the source object.
@ -201,12 +203,21 @@ class PrimaryObject(BaseObject,PrivacyBase):
self._replace_handle_reference(classname, old_handle, new_handle)
def _has_handle_reference(self, classname, handle):
"""
returns True if the handle is referenced by the object
"""
return False
def _remove_handle_references(self, classname, handle_list):
"""
removes the handle references from the object
"""
pass
def _replace_handle_reference(self, classname, old_handle, new_handle):
"""
replaces the handle reference with the new reference
"""
pass
def set_marker(self, marker):

View File

@ -24,6 +24,8 @@
PrivacyBase Object class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# PrivacyBase Object
@ -49,9 +51,15 @@ class PrivacyBase:
self.private = False
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return self.private
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.private = data
return self

View File

@ -24,6 +24,8 @@
PrivateSourceNote class for GRAMPS
"""
__revision__ = "$Revision$"
from _SourceNote import SourceNote
from _PrivacyBase import PrivacyBase
@ -33,7 +35,7 @@ from _PrivacyBase import PrivacyBase
#
#-------------------------------------------------------------------------
class PrivateSourceNote(SourceNote, PrivacyBase):
# FIXME: this class is only present to enable db upgrade
def __init__(self):
SourceNote.__init__(self)
PrivacyBase.__init__(self)

View File

@ -24,6 +24,8 @@
Base Reference class for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# RefBase class
@ -43,9 +45,15 @@ class RefBase:
self.ref = None
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return self.ref
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.ref = str(data)
return self

View File

@ -24,6 +24,8 @@
Repository Reference class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -56,12 +58,18 @@ class RepoRef(SecondaryObject,NoteBase,RefBase):
self.media_type = SourceMediaType()
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (
NoteBase.serialize(self),
RefBase.serialize(self),
self.call_number, self.media_type.serialize())
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(note, ref, self.call_number, media_type) = data
self.media_type.unserialize(media_type)
NoteBase.unserialize(self, note)

View File

@ -24,6 +24,8 @@
Repository object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -53,6 +55,9 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
self.name = ""
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.handle, self.gramps_id, self.type.serialize(),
unicode(self.name),
NoteBase.serialize(self),

View File

@ -20,6 +20,12 @@
# $Id$
"""
Respository types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -24,6 +24,8 @@
Researcher informaiton for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules

View File

@ -24,6 +24,8 @@
Secondary Object class for GRAMPS
"""
__revision__ = "$Revision: $"
#-------------------------------------------------------------------------
#
# GRAMPS modules

View File

@ -24,6 +24,8 @@
Source object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -57,6 +59,9 @@ class Source(PrimaryObject,MediaBase,NoteBase):
self.reporef_list = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.handle, self.gramps_id, unicode(self.title),
unicode(self.author), unicode(self.pubinfo),
NoteBase.serialize(self),

View File

@ -24,6 +24,8 @@
SourceBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -54,9 +56,15 @@ class SourceBase:
self.source_list = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [sref.serialize() for sref in self.source_list]
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.source_list = [SourceRef().unserialize(item) for item in data]
def add_source_reference(self, src_ref) :

View File

@ -19,6 +19,12 @@
#
# $Id$
"""
SourceMedia types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -24,12 +24,15 @@
SourceNote class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# SourceNote classes
#
#-------------------------------------------------------------------------
class SourceNote:
# FIXME: this class is only present to enable db upgrade
"""this class is only present to enable db upgrade"""
def __init__(self):
pass

View File

@ -24,6 +24,8 @@
Source Reference class for GRAMPS
"""
__revision__ = "$Revision$"
from warnings import warn
#-------------------------------------------------------------------------
@ -69,6 +71,9 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
self.text = ""
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (DateBase.serialize(self),
PrivacyBase.serialize(self),
NoteBase.serialize(self),
@ -77,6 +82,9 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
self.page, self.text)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(date, privacy, note,
self.confidence, ref, self.page, self.text) = data
DateBase.unserialize(self, date)
@ -93,7 +101,6 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
@rtype: list
"""
return [self.page, self.text]
#return [self.page,self.text,self.get_date()]
def get_text_data_child_list(self):
"""
@ -142,5 +149,6 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
return self.text
def are_equal(self, other):
"""deprecated function - use are_equal instead"""
warn( "Use is_equal instead of are_equal", DeprecationWarning, 2)
return self.is_equal(other)

View File

@ -24,6 +24,8 @@
Url class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -110,5 +112,7 @@ class Url(SecondaryObject,PrivacyBase):
return self.type
def are_equal(self, other):
"""Deprecated - use is_equal instead"""
warn( "Use is_equal instead of are_equal", DeprecationWarning, 2)
return self.is_equal(other)

View File

@ -24,6 +24,8 @@
UrlBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -56,9 +58,15 @@ class UrlBase:
self.urls = []
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [url.serialize() for url in self.urls]
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.urls = [Url().unserialize(item) for item in data]
def get_url_list(self):
@ -89,7 +97,6 @@ class UrlBase:
"""
self.urls.append(url)
def remove_url(self, url):
"""
Removes the specified L{Url} instance from the url list

View File

@ -20,6 +20,12 @@
# $Id$
"""
URL types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map
from gettext import gettext as _

View File

@ -24,12 +24,14 @@
Witness class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# Witness class
#
#-------------------------------------------------------------------------
class Witness:
# FIXME: this class is only present to enable db upgrade
"""this class is only present to enable db upgrade"""
def __init__(self):
pass

View File

@ -24,6 +24,7 @@
__author__ = "Donald N. Allingham"
__version__ = "$Revision$"
__revision__ = "$Revision$"
# Dates
from _Date import Date, DateError

View File

@ -610,7 +610,40 @@ def probably_alive(person,db,current_year=None,limit=0):
return False
# Neither birth nor death events are available. Try looking
# for descendants that were born more than a lifespan ago.
# at siblings. If a sibling was born more than 120 years past,
# or more than 20 future, then problem then this person is
# probably not alive. If the sibling died more than 120 years
# past, or more than 120 years future, then probably not alive.
family_list = person.get_parent_family_handle_list()
for family_handle in family_list:
family = db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():
child_handle = child_ref.ref
child = db.get_person_from_handle(child_handle)
child_birth_ref = child.get_birth_ref()
if child_birth_ref:
child_birth = db.get_event_from_handle(child_birth_ref.ref)
dobj = child_birth.get_date_object()
if dobj.get_start_date() != RelLib.Date.EMPTY:
# if sibling birth date too far away, then not alive:
year = dobj.get_year()
if year != 0:
if not (current_year - 120 < year < current_year + 20):
return False
child_death_ref = child.get_death_ref()
if child_death_ref:
child_death = db.get_event_from_handle(child_death_ref.ref)
dobj = child_death.get_date_object()
if dobj.get_start_date() != RelLib.Date.EMPTY:
# if sibling death date too far away, then not alive:
year = dobj.get_year()
if year != 0:
if not (current_year - 120 < year < current_year + 120):
return False
# Try looking for descendants that were born more than a lifespan
# ago.
min_generation = 13