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
@ -41,28 +43,34 @@ from _LocationBase import LocationBase
# Address for Person/Repository
#
#-------------------------------------------------------------------------
class Address(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase,
class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
LocationBase):
"""Provides address information."""
def __init__(self,source=None):
def __init__(self, source=None):
"""Creates a new Address 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)
LocationBase.__init__(self,source)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
DateBase.__init__(self, source)
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),
DateBase.serialize(self),
LocationBase.serialize(self))
def unserialize(self,data):
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
@ -41,7 +43,7 @@ class AddressBase:
Base class for address-aware objects.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a AddressBase. If the source is not None, then object
is initialized from values of the source object.
@ -57,12 +59,18 @@ 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):
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):
def add_address(self, address):
"""
Adds the L{Address} instance to the object's list of addresses
@ -71,7 +79,7 @@ class AddressBase:
"""
self.address_list.append(address)
def remove_address(self,address):
def remove_address(self, address):
"""
Removes the specified L{Address} instance from the address list
If the instance does not exist in the list, the operation has
@ -98,7 +106,7 @@ class AddressBase:
"""
return self.address_list
def set_address_list(self,address_list):
def set_address_list(self, address_list):
"""
Assigns the passed list to the object's list of L{Address} instances.
@param address_list: List of L{Address} instances to be associated

View File

@ -24,6 +24,8 @@
Attribute class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -40,18 +42,18 @@ from _AttributeType import AttributeType
# Attribute for Person/Family/MediaObject/MediaRef
#
#-------------------------------------------------------------------------
class Attribute(SecondaryObject,PrivacyBase,SourceBase,NoteBase):
class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
"""Provides a simple key/value pair for describing properties. Used
by the Person and Family objects to store descriptive information."""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Creates a new Attribute object, copying from the source if provided.
"""
SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
if source:
self.type = source.type
@ -61,16 +63,22 @@ 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)
self.type.serialize(), self.value)
def unserialize(self,data):
(privacy,source_list,note,the_type,self.value) = data
PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
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)
NoteBase.unserialize(self, note)
self.type.unserialize(the_type)
return self
@ -105,7 +113,7 @@ class Attribute(SecondaryObject,PrivacyBase,SourceBase,NoteBase):
"""
return self.source_list
def set_type(self,val):
def set_type(self, val):
"""sets the type (or key) of the Attribute instance"""
self.type.set(val)
@ -113,7 +121,7 @@ class Attribute(SecondaryObject,PrivacyBase,SourceBase,NoteBase):
"""returns the type (or key) or the Attribute instance"""
return self.type
def set_value(self,val):
def set_value(self, val):
"""sets the value of the Attribute instance"""
self.value = val

View File

@ -24,6 +24,8 @@
AttributeBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ class AttributeBase:
Base class for attribute-aware objects.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a AttributeBase. If the source is not None, then object
is initialized from values of the source object.
@ -57,12 +59,18 @@ 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):
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):
def add_attribute(self, attribute):
"""
Adds the L{Attribute} instance to the object's list of attributes
@ -71,7 +79,7 @@ class AttributeBase:
"""
self.attribute_list.append(attribute)
def remove_attribute(self,attribute):
def remove_attribute(self, attribute):
"""
Removes the specified L{Attribute} instance from the attribute list
If the instance does not exist in the list, the operation has
@ -99,7 +107,7 @@ class AttributeBase:
"""
return self.attribute_list
def set_attribute_list(self,attribute_list):
def set_attribute_list(self, attribute_list):
"""
Assigns the passed list to the Person's list of L{Attribute} instances.

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,13 +52,19 @@ 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):
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
def matches_string(self,pattern,case_sensitive=False):
def matches_string(self, pattern, case_sensitive=False):
"""
Returns True if any text data in the object or any of it's child
objects matches a given pattern.
@ -82,12 +90,12 @@ class BaseObject:
# Run through child objects
for obj in self.get_text_data_child_list():
if obj.matches_string(pattern,case_sensitive):
if obj.matches_string(pattern, case_sensitive):
return True
return False
def matches_regexp(self,pattern,case_sensitive=False):
def matches_regexp(self, pattern, case_sensitive=False):
"""
Returns True if any text data in the object or any of it's child
objects matches a given regular expression.
@ -102,14 +110,14 @@ class BaseObject:
if case_sensitive:
pattern_obj = re.compile(pattern)
else:
pattern_obj = re.compile(pattern,re.IGNORECASE)
pattern_obj = re.compile(pattern, re.IGNORECASE)
for item in self.get_text_data_list():
if item and pattern_obj.match(item):
return True
# Run through child objects
for obj in self.get_text_data_child_list():
if obj.matches_regexp(pattern,case_sensitive):
if obj.matches_regexp(pattern, case_sensitive):
return True
return False

View File

@ -20,6 +20,8 @@
# $Id$
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# Python modules
@ -50,11 +52,11 @@ _HBR_NOON = 19440
_HBR_AM3_11_20 = 9924
_HBR_AM9_32_43 = 16789
_HBR_SUNDAY = 0
_HBR_MONDAY = 1
_HBR_TUESDAY = 2
_HBR_WEDNESDAY= 3
_HBR_FRIDAY = 5
_HBR_SUNDAY = 0
_HBR_MONDAY = 1
_HBR_TUESDAY = 2
_HBR_WEDNESDAY = 3
_HBR_FRIDAY = 5
_HBR_MONTHS_PER_YEAR = [
12, 12, 13, 12, 12, 13, 12, 13, 12, 12,
@ -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):
@ -162,7 +164,7 @@ def _molad_of_metonic_cycle(metonic_cycle):
molad_day = (d2 << 16) | d1
molad_halakim = r1
return (molad_day,molad_halakim)
return (molad_day, molad_halakim)
def _start_of_year(year):
@ -184,8 +186,8 @@ def hebrew_sdn(year, month, day):
if month == 1 or month == 2:
# It is Tishri or Heshvan - don't need the year length.
(metonic_cycle,metonic_year,
molad_day,molad_halakim,tishri1) = _start_of_year(year)
(metonic_cycle, metonic_year,
molad_day, molad_halakim, tishri1) = _start_of_year(year)
if month == 1:
sdn = tishri1 + day - 1
else:
@ -194,8 +196,8 @@ def hebrew_sdn(year, month, day):
# It is Kislev - must find the year length.
# Find the start of the year.
(metonic_cycle,metonic_year,
molad_day,molad_halakim,tishri1) = _start_of_year(year)
(metonic_cycle, metonic_year,
molad_day, molad_halakim, tishri1) = _start_of_year(year)
# Find the end of the year.
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
@ -214,8 +216,8 @@ def hebrew_sdn(year, month, day):
elif month == 4 or month == 5 or month == 6:
# It is Tevet, Shevat or Adar I - don't need the year length
(metonic_cycle,metonic_year,
molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1)
(metonic_cycle, metonic_year,
molad_day, molad_halakim, tishri1_after) = _start_of_year(year+1)
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 12:
length_of_adarI_andII = 29
@ -230,8 +232,8 @@ def hebrew_sdn(year, month, day):
sdn = tishri1_after + day - length_of_adarI_andII - 178
else:
# It is Adar II or later - don't need the year length.
(metonic_cycle,metonic_year,
molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1)
(metonic_cycle, metonic_year,
molad_day, molad_halakim, tishri1_after) = _start_of_year(year+1)
if month == 7:
sdn = tishri1_after + day - 207
@ -254,112 +256,112 @@ 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):
def julian_sdn(year, month, day):
"""Converts a Julian calendar date to an SDN number"""
if year < 0:
@ -403,9 +405,9 @@ def julian_ymd(sdn):
if year <= 0:
year -= 1
return (year,month,day)
return (year, month, day)
def gregorian_sdn(year,month,day):
def gregorian_sdn(year, month, day):
"""Converts a gregorian date to an SDN number"""
if year < 0:
year += 4801
@ -453,9 +455,9 @@ def gregorian_ymd(sdn):
year = year - 4800
if year <= 0:
year = year - 1
return (year,month,day)
return (year, month, day)
def french_sdn(year,month,day):
def french_sdn(year, month, day):
"""Converts a French Republican Calendar date to an SDN number"""
return (year*_FR_DAYS_PER_4_YEARS)/4 + \
(month-1)*_FR_DAYS_PER_MONTH + \
@ -468,7 +470,7 @@ def french_ymd(sdn):
day_of_year = (temp%_FR_DAYS_PER_4_YEARS)/4
month = (day_of_year/_FR_DAYS_PER_MONTH)+1
day = (day_of_year%_FR_DAYS_PER_MONTH)+1
return (year,month,day)
return (year, month, day)
def persian_sdn(year, month, day):
if year >= 0:
@ -523,6 +525,6 @@ def islamic_sdn(year, month, day):
def islamic_ymd(sdn):
sdn = math.floor(sdn) + 0.5
year = int(math.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631))
month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year,1,1)))/29.5) + 1))
day = int((sdn - islamic_sdn(year,month,1)) + 1)
return (year,month,day)
month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year, 1, 1)))/29.5) + 1))
day = int((sdn - islamic_sdn(year, month, 1)) + 1)
return (year, month, day)

View File

@ -24,6 +24,8 @@
Child Reference class for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ from _ChildRefType import ChildRefType
# Person References for Person/Family
#
#-------------------------------------------------------------------------
class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
"""
Person reference class.
@ -50,12 +52,12 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
Examples would be: godparent, friend, etc.
"""
def __init__(self,source=None):
def __init__(self, source=None):
SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
RefBase.__init__(self,source)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
RefBase.__init__(self, source)
if source:
self.frel = source.frel
self.mrel = source.mrel
@ -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),
@ -71,12 +76,15 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
self.frel.serialize(),
self.mrel.serialize())
def unserialize(self,data):
(privacy,source_list,note,ref,frel,mrel) = data
PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
RefBase.unserialize(self,ref)
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)
NoteBase.unserialize(self, note)
RefBase.unserialize(self, ref)
self.frel.unserialize(frel)
self.mrel.unserialize(mrel)
return self
@ -111,7 +119,7 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
@rtype: list
"""
if self.ref:
return [('Person',self.ref)]
return [('Person', self.ref)]
else:
return []
@ -125,7 +133,7 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
"""
return self.source_list
def set_mother_relation(self,rel):
def set_mother_relation(self, rel):
"""Sets relation between the person and mother"""
self.mrel.set(rel)
@ -133,7 +141,7 @@ class ChildRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
"""Returns the relation between the person and mother"""
return self.mrel
def set_father_relation(self,frel):
def set_father_relation(self, frel):
"""Sets relation between the person and father"""
self.frel.set(frel)

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
@ -41,7 +43,7 @@ class DateBase:
Base class for storing date information.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Create a new DateBase, copying from source if not None
@ -54,13 +56,19 @@ 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:
date = self.date.serialize(no_text_date)
return date
def unserialize(self,data):
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
if data == None:
self.date = Date()
else:
@ -77,7 +85,7 @@ class DateBase:
self.date = Date()
return self.date
def set_date_object(self,date):
def set_date_object(self, date):
"""
Sets the L{Date} object associated with the DateBase.

View File

@ -24,6 +24,8 @@
Event object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -43,8 +45,8 @@ from _EventType import EventType
# Event class
#
#-------------------------------------------------------------------------
class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
DateBase,PlaceBase):
class Event(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
DateBase, PlaceBase):
"""
Introduction
============
@ -53,7 +55,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
such as a birth, death, or marriage.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Creates a new Event instance, copying from the source if present
@ -61,13 +63,13 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@type source: Event
"""
PrimaryObject.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
MediaBase.__init__(self,source)
PrimaryObject.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
MediaBase.__init__(self, source)
AttributeBase.__init__(self)
DateBase.__init__(self,source)
PlaceBase.__init__(self,source)
DateBase.__init__(self, source)
PlaceBase.__init__(self, source)
if source:
self.description = source.description
@ -101,7 +103,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
AttributeBase.serialize(self),
self.change, self.marker.serialize(), self.private)
def unserialize(self,data):
def unserialize(self, data):
"""
Converts the data held in a tuple created by the serialize method
back into the data in an Event structure.
@ -117,22 +119,22 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.marker.unserialize(marker)
self.type.unserialize(the_type)
DateBase.unserialize(self,date)
MediaBase.unserialize(self,media_list)
AttributeBase.unserialize(self,attribute_list)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
DateBase.unserialize(self, date)
MediaBase.unserialize(self, media_list)
AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self, note)
def _has_handle_reference(self,classname,handle):
def _has_handle_reference(self, classname, handle):
if classname == 'Place':
return self.place == handle
return False
def _remove_handle_references(self,classname,handle_list):
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):
def _replace_handle_reference(self, classname, old_handle, new_handle):
if classname == 'Place' and self.place == old_handle:
self.place = new_handle
@ -143,7 +145,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.description,str(self.type),self.gramps_id]
return [self.description, str(self.type), self.gramps_id]
def get_text_data_child_list(self):
"""
@ -176,7 +178,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
ret = []
if self.place:
ret.append(('Place',self.place))
ret.append(('Place', self.place))
return ret
def get_handle_referents(self):
@ -203,7 +205,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
return (the_type == EventType.CUSTOM and date.is_empty()
and not place and not description)
def are_equal(self,other):
def are_equal(self, other):
"""
Returns True if the passed Event is equivalent to the current Event.
@ -232,7 +234,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
return True
def set_type(self,the_type):
def set_type(self, the_type):
"""
Sets the type of the Event to the passed (int,str) tuple.
@ -250,7 +252,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
return self.type
def set_description(self,description):
def set_description(self, description):
"""
Sets the description of the Event to the passed string. The string
may contain any information.

View File

@ -24,6 +24,8 @@
Event Reference class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ from _EventRoleType import EventRoleType
# Event References for Person/Family
#
#-------------------------------------------------------------------------
class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
"""
Event reference class.
@ -49,21 +51,24 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
to the refereneced event.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Creates a new EventRef instance, copying from the source if present.
"""
SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source)
NoteBase.__init__(self,source)
AttributeBase.__init__(self,source)
RefBase.__init__(self,source)
PrivacyBase.__init__(self, source)
NoteBase.__init__(self, source)
AttributeBase.__init__(self, source)
RefBase.__init__(self, source)
if source:
self.role = source.role
else:
self.role = EventRoleType()
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (
PrivacyBase.serialize(self),
NoteBase.serialize(self),
@ -72,12 +77,15 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
self.role.serialize()
)
def unserialize(self,data):
(privacy,note,attribute_list,ref,role) = data
PrivacyBase.unserialize(self,privacy)
NoteBase.unserialize(self,note)
AttributeBase.unserialize(self,attribute_list)
RefBase.unserialize(self,ref)
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)
AttributeBase.unserialize(self, attribute_list)
RefBase.unserialize(self, ref)
self.role.unserialize(role)
return self
@ -120,7 +128,7 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
@rtype: list
"""
if self.ref:
return [('Event',self.ref)]
return [('Event', self.ref)]
else:
return []
@ -130,7 +138,7 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
"""
return self.role
def set_role(self,role):
def set_role(self, role):
"""
Sets the role according to the given argument.
"""

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
@ -51,7 +53,7 @@ from _FamilyRelType import FamilyRelType
# Family class
#
#-------------------------------------------------------------------------
class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
LdsOrdBase):
"""
Introduction
@ -137,23 +139,23 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
for er in event_ref_list]
self.child_ref_list = [ChildRef().unserialize(cr)
for cr in child_ref_list]
MediaBase.unserialize(self,media_list)
AttributeBase.unserialize(self,attribute_list)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
LdsOrdBase.unserialize(self,lds_seal_list)
MediaBase.unserialize(self, media_list)
AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self, note)
LdsOrdBase.unserialize(self, lds_seal_list)
def _has_handle_reference(self,classname,handle):
def _has_handle_reference(self, classname, handle):
if classname == 'Event':
return handle in [ref.ref for ref in self.event_ref_list]
elif classname == 'Person':
return handle in ([ref.ref for ref in self.child_ref_list]
+ [self.father_handle,self.mother_handle])
+ [self.father_handle, self.mother_handle])
elif classname == 'Place':
return handle in [ x.place for x in self.lds_ord_list ]
return False
def _remove_handle_references(self,classname,handle_list):
def _remove_handle_references(self, classname, handle_list):
if classname == 'Event':
new_list = [ ref for ref in self.event_ref_list \
if ref.ref not in handle_list ]
@ -171,7 +173,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
if x.place in handle_list:
x.place = None
def _replace_handle_reference(self,classname,old_handle,new_handle):
def _replace_handle_reference(self, classname, old_handle, new_handle):
if classname == 'Event':
handle_list = [ref.ref for ref in self.event_ref_list]
while old_handle in handle_list:
@ -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):
@ -234,10 +236,10 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@rtype: list
"""
ret = []
ret += [('Event',ref.ref) for ref in self.event_ref_list]
ret += [('Person',handle) for handle
ret += [('Event', ref.ref) for ref in self.event_ref_list]
ret += [('Person', handle) for handle
in ([ref.ref for ref in self.child_ref_list] +
[self.father_handle,self.mother_handle])
[self.father_handle, self.mother_handle])
if handle]
return ret
@ -251,7 +253,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
return self.get_sourcref_child_list() + self.source_list
def set_relationship(self,relationship_type):
def set_relationship(self, relationship_type):
"""
Sets the relationship type between the people identified as the
father and mother in the relationship. The type is a tuple whose
@ -285,7 +287,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
return self.type
def set_father_handle(self,person_handle):
def set_father_handle(self, person_handle):
"""
Sets the database handle for L{Person} that corresponds to
male of the relationship. For a same sex relationship, this
@ -306,7 +308,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
return self.father_handle
def set_mother_handle(self,person_handle):
def set_mother_handle(self, person_handle):
"""
Sets the database handle for L{Person} that corresponds to
male of the relationship. For a same sex relationship, this
@ -327,7 +329,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
"""
return self.mother_handle
def add_child_ref(self,child_ref):
def add_child_ref(self, child_ref):
"""
Adds the database handle for L{Person} to the Family's list
of children.
@ -335,11 +337,11 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@param child_ref: Child Reference instance
@type child_ref: ChildRef
"""
if not isinstance(child_ref,ChildRef):
if not isinstance(child_ref, ChildRef):
raise ValueError("expecting ChildRef instance")
self.child_ref_list.append(child_ref)
def remove_child_ref(self,child_ref):
def remove_child_ref(self, child_ref):
"""
Removes the database handle for L{Person} to the Family's list
of children if the L{Person} is already in the list.
@ -350,13 +352,13 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
in the list.
@rtype: bool
"""
if not isinstance(child_ref,ChildRef):
if not isinstance(child_ref, ChildRef):
raise ValueError("expecting ChildRef instance")
new_list = [ref for ref in self.child_ref_list
if ref.ref != child_ref.ref ]
self.child_ref_list = new_list
def remove_child_handle(self,child_handle):
def remove_child_handle(self, child_handle):
"""
Removes the database handle for L{Person} to the Family's list
of children if the L{Person} is already in the list.
@ -392,15 +394,7 @@ 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):
def add_event_ref(self, event_ref):
"""
Adds the L{EventRef} to the Family instance's L{EventRef} list.
This is accomplished by assigning the L{EventRef} for the valid
@ -410,12 +404,13 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
Person's L{EventRef} list.
@type event_ref: EventRef
"""
if event_ref and not isinstance(event_ref,EventRef):
if event_ref and not isinstance(event_ref, EventRef):
raise ValueError("Expecting EventRef instance")
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,18 +429,7 @@ 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) :
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
@ -42,7 +44,7 @@ class GenderStats:
Gender. This allows the tracking of the liklihood of a person's
given name indicating the gender of the person.
"""
def __init__ (self,stats={}):
def __init__ (self, stats={}):
if stats == None:
self.stats = {}
else:

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,10 +47,12 @@ 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):
if isinstance(value,self.__class__):
if isinstance(value, self.__class__):
self.val = value.val
self.string = value.string
elif type(value) == tuple:
@ -54,7 +62,7 @@ class GrampsType:
self.val = value
self.string = ''
elif type(value) in (str,unicode):
self.val = self._S2IMAP.get(value,self._CUSTOM)
self.val = self._S2IMAP.get(value, self._CUSTOM)
if self.val == self._CUSTOM:
self.string = value
else:
@ -86,16 +94,22 @@ 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):
if self.val == self._CUSTOM:
return self.string
else:
return self._I2SMAP.get(self.val,_('Unknown'))
return self._I2SMAP.get(self.val, _('Unknown'))
def __int__(self):
return self.val
@ -107,14 +121,14 @@ class GrampsType:
"""
Return the list of localized names for all standard types.
"""
return [s for (i,s) in self._I2SMAP.items()
return [s for (i, s) in self._I2SMAP.items()
if (i != self._CUSTOM) and s.strip()]
def get_standard_xml(self):
"""
Return the list of XML (english) names for all standard types.
"""
return [s for (i,s) in self._I2EMAP.items()
return [s for (i, s) in self._I2EMAP.items()
if (i != self._CUSTOM) and s.strip()]
def is_custom(self):
@ -128,16 +142,16 @@ class GrampsType:
def __cmp__(self, value):
if type(value) == int:
return cmp(self.val,value)
elif type(value) in (str,unicode):
return cmp(self.val, value)
elif type(value) in (str, unicode):
if self.val == self._CUSTOM:
return cmp(self.string,value)
return cmp(self.string, value)
else:
return cmp(self._I2SMAP.get(self.val),value)
return cmp(self._I2SMAP.get(self.val), value)
elif type(value) == tuple:
return cmp((self.val,self.string),value)
return cmp((self.val, self.string), value)
else:
if value.val == self._CUSTOM:
return cmp(self.string,value.string)
return cmp(self.string, value.string)
else:
return cmp(self.val,value.val)
return cmp(self.val, value.val)

View File

@ -23,6 +23,7 @@
"""
LDS Ordinance class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
@ -49,8 +50,8 @@ from _PrivacyBase import PrivacyBase
# LDS Ordinance class
#
#-------------------------------------------------------------------------
class LdsOrd(SecondaryObject,SourceBase,NoteBase,
DateBase,PlaceBase,PrivacyBase):
class LdsOrd(SecondaryObject, SourceBase, NoteBase,
DateBase, PlaceBase, PrivacyBase):
"""
Class that contains information about LDS Ordinances. LDS
ordinances are similar to events, but have very specific additional
@ -111,14 +112,14 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
(STATUS_UNCLEARED, _("Uncleared"), "Uncleared"),
]
def __init__(self,source=None):
def __init__(self, source=None):
"""Creates a LDS Ordinance instance"""
SecondaryObject.__init__(self)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
DateBase.__init__(self,source)
PlaceBase.__init__(self,source)
PrivacyBase.__init__(self,source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
DateBase.__init__(self, source)
PlaceBase.__init__(self, source)
PrivacyBase.__init__(self, source)
if source:
self.type = source.type
@ -132,18 +133,24 @@ 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),
self.type,self.place,
self.famc,self.temple,self.status)
self.type, self.place,
self.famc, self.temple, self.status)
def unserialize(self,data):
(source_list,note,date,self.type,self.place,
self.famc,self.temple,self.status) = data
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
DateBase.unserialize(self,date)
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)
NoteBase.unserialize(self, note)
DateBase.unserialize(self, date)
return self
def get_text_data_list(self):
@ -177,7 +184,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
@rtype: list
"""
if self.place:
return [('Place',self.place)]
return [('Place', self.place)]
else:
return []
@ -197,7 +204,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
def set_type(self, ord_type):
self.type = ord_type
def set_family_handle(self,family):
def set_family_handle(self, family):
"""Sets the Family database handle associated with the LDS ordinance"""
self.famc = family
@ -205,7 +212,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
"""Gets the Family database handle associated with the LDS ordinance"""
return self.famc
def set_status(self,val):
def set_status(self, val):
"""
Sets the status of the LDS ordinance. The status is a text string
that matches a predefined set of strings."""
@ -215,7 +222,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
"""Gets the status of the LDS ordinance"""
return self.status
def set_temple(self,temple):
def set_temple(self, temple):
"""Sets the temple assocated with the ordinance"""
self.temple = temple
@ -234,7 +241,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
else:
return True
def are_equal(self,other):
def are_equal(self, other):
"""returns 1 if the specified ordinance is the same as the instance"""
warn( "Use is_equal instead are_equal", DeprecationWarning, 2)
return self.is_equal(other)
@ -257,7 +264,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
return item[1]
return ""
def set_type_from_xml(self,xml_str):
def set_type_from_xml(self, xml_str):
"""
Set type based on a given string from XML.
Return boolean of success.
@ -286,7 +293,7 @@ class LdsOrd(SecondaryObject,SourceBase,NoteBase,
return item[1]
return ""
def set_status_from_xml(self,xml_str):
def set_status_from_xml(self, xml_str):
"""
Set status based on a given string from XML.
Return boolean of success.

View File

@ -24,6 +24,8 @@
LdsOrdBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ class LdsOrdBase:
Base class for lds_ord-aware objects.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a LdsOrdBase. If the source is not None, then object
is initialized from values of the source object.
@ -57,12 +59,18 @@ 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):
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):
def add_lds_ord(self, lds_ord):
"""
Adds the L{LdsOrd} instance to the object's list of lds_ordes
@ -71,7 +79,7 @@ class LdsOrdBase:
"""
self.lds_ord_list.append(lds_ord)
def remove_lds_ord(self,lds_ord):
def remove_lds_ord(self, lds_ord):
"""
Removes the specified L{LdsOrd} instance from the lds_ord list
If the instance does not exist in the list, the operation has
@ -98,7 +106,7 @@ class LdsOrdBase:
"""
return self.lds_ord_list
def set_lds_ord_list(self,lds_ord_list):
def set_lds_ord_list(self, lds_ord_list):
"""
Assigns the passed list to the object's list of L{LdsOrd} instances.
@param lds_ord_list: List of L{LdsOrd} instances to be associated

View File

@ -24,6 +24,8 @@
Location class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -37,7 +39,7 @@ from _LocationBase import LocationBase
# Location class for Places
#
#-------------------------------------------------------------------------
class Location(SecondaryObject,LocationBase):
class Location(SecondaryObject, LocationBase):
"""
Provides information about a place.
@ -46,24 +48,30 @@ class Location(SecondaryObject,LocationBase):
of citys, countys, states, and even countries can change with time.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Creates a Location object, copying from the source object if it exists.
"""
SecondaryObject.__init__(self)
LocationBase.__init__(self,source)
LocationBase.__init__(self, source)
if source:
self.parish = source.parish
else:
self.parish = ""
def serialize(self):
return (LocationBase.serialize(self),self.parish)
"""
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)
def unserialize(self, data):
"""
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):
@ -79,7 +87,7 @@ class Location(SecondaryObject,LocationBase):
return not self.city and not self.county and not self.state and \
not self.country and not self.postal and not self.phone
def set_parish(self,data):
def set_parish(self, data):
"""sets the religious parish name"""
self.parish = data

View File

@ -24,6 +24,8 @@
LocationBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# LocationBase class
@ -34,7 +36,7 @@ class LocationBase:
Base class for all things Address.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Creates a LocationBase object,
copying from the source object if it exists.
@ -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):
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
@ -72,9 +80,9 @@ class LocationBase:
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.city,self.state,self.country,self.postal,self.phone]
return [self.city, self.state, self.country, self.postal, self.phone]
def set_street(self,val):
def set_street(self, val):
"""sets the street portion of the Location"""
self.street = val
@ -82,7 +90,7 @@ class LocationBase:
"""returns the street portion of the Location"""
return self.street
def set_city(self,data):
def set_city(self, data):
"""sets the city name of the LocationBase object"""
self.city = data
@ -90,7 +98,7 @@ class LocationBase:
"""returns the city name of the LocationBase object"""
return self.city
def set_postal_code(self,data):
def set_postal_code(self, data):
"""sets the postal code of the LocationBase object"""
self.postal = data
@ -98,7 +106,7 @@ class LocationBase:
"""returns the postal code of the LocationBase object"""
return self.postal
def set_phone(self,data):
def set_phone(self, data):
"""sets the phone number of the LocationBase object"""
self.phone = data
@ -106,7 +114,7 @@ class LocationBase:
"""returns the phone number of the LocationBase object"""
return self.phone
def set_state(self,data):
def set_state(self, data):
"""sets the state name of the LocationBase object"""
self.state = data
@ -114,7 +122,7 @@ class LocationBase:
"""returns the state name of the LocationBase object"""
return self.state
def set_country(self,data):
def set_country(self, data):
"""sets the country name of the LocationBase object"""
self.country = data
@ -122,7 +130,7 @@ class LocationBase:
"""returns the country name of the LocationBase object"""
return self.country
def set_county(self,data):
def set_county(self, data):
"""sets the county name of the LocationBase object"""
self.county = data

View File

@ -19,24 +19,33 @@
#
# $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
NONE = -1
CUSTOM = 0
COMPLETE = 1
TODO_TYPE = 2
_CUSTOM = CUSTOM
_DEFAULT = NONE
_DATAMAP = [
(NONE, "", ""),
(CUSTOM, _("Custom"), "Custom"),
(COMPLETE, _("Complete"), "Complete"),
(TODO, _("ToDo"), "ToDo"),
(NONE, "", ""),
(CUSTOM, _("Custom"), "Custom"),
(COMPLETE, _("Complete"), "Complete"),
(TODO_TYPE, _("ToDo"), "ToDo"),
]
_I2SMAP = init_map(_DATAMAP, 0, 1)
@ -48,7 +57,10 @@ class MarkerType(GrampsType):
GrampsType.__init__(self, value)
def set(self, value):
if isinstance(value,self.__class__):
"""
sets the marker value
"""
if isinstance(value, self.__class__):
if value.val == self.CUSTOM and value.string == '':
self.val = self.NONE
self.string = ''
@ -66,7 +78,7 @@ class MarkerType(GrampsType):
self.val = value
self.string = ''
elif type(value) == str:
self.val = self._S2IMAP.get(value,self._CUSTOM)
self.val = self._S2IMAP.get(value, self._CUSTOM)
if self.val == self._CUSTOM:
self.string = value
else:

View File

@ -24,6 +24,8 @@
MediaBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ class MediaBase:
Base class for storing media references
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Create a new MediaBase, copying from source if not None
@ -55,12 +57,18 @@ 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):
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):
def add_media_reference(self, media_ref):
"""
Adds a L{MediaRef} instance to the object's media list.
@ -79,7 +87,7 @@ class MediaBase:
"""
return self.media_list
def set_media_list(self,media_ref_list):
def set_media_list(self, media_ref_list):
"""
Sets the list of L{MediaRef} instances associated with the object.
It replaces the previous list.
@ -90,7 +98,7 @@ class MediaBase:
"""
self.media_list = media_ref_list
def has_media_reference(self,obj_handle) :
def has_media_reference(self, obj_handle) :
"""
Returns True if the object or any of it's child objects has reference
to this media object handle.
@ -102,7 +110,7 @@ class MediaBase:
"""
return obj_handle in [media_ref.ref for media_ref in self.media_list]
def remove_media_references(self,obj_handle_list):
def remove_media_references(self, obj_handle_list):
"""
Removes references to all media handles in the list.
@ -113,7 +121,7 @@ class MediaBase:
if media_ref.ref not in obj_handle_list ]
self.media_list = new_media_list
def replace_media_references(self,old_handle,new_handle):
def replace_media_references(self, old_handle, new_handle):
"""
Replaces all references to old media handle with the new handle.

View File

@ -24,6 +24,8 @@
Media object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -47,13 +49,13 @@ from _AttributeBase import AttributeBase
# MediaObject class
#
#-------------------------------------------------------------------------
class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
class MediaObject(PrimaryObject, SourceBase, NoteBase, DateBase, AttributeBase):
"""
Containter for information about an image file, including location,
description and privacy
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a MediaObject. If source is not None, then object
is initialized from values of the source object.
@ -61,23 +63,21 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
@param source: Object used to initialize the new object
@type source: MediaObject
"""
PrimaryObject.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
DateBase.__init__(self,source)
AttributeBase.__init__(self,source)
PrimaryObject.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
DateBase.__init__(self, source)
AttributeBase.__init__(self, source)
if source:
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):
@ -105,7 +105,7 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
self.marker.serialize(),
self.private)
def unserialize(self,data):
def unserialize(self, data):
"""
Converts the data held in a tuple created by the serialize method
back into the data in an Event structure.
@ -118,10 +118,10 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
date, marker, self.private) = data
self.marker.unserialize(marker)
AttributeBase.unserialize(self,attribute_list)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
DateBase.unserialize(self,date)
AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self, note)
DateBase.unserialize(self, date)
def get_text_data_list(self):
"""
@ -130,8 +130,7 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
@return: Returns the list of all textual attributes of the object.
@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]
return [self.path, self.mime, self.desc, 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):
"""
@ -182,7 +181,7 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
"""
return self.mime
def set_path(self,path):
def set_path(self, path):
"""set the file path to the passed path"""
self.path = os.path.normpath(path)
@ -190,7 +189,7 @@ class MediaObject(PrimaryObject,SourceBase,NoteBase,DateBase,AttributeBase):
"""return the file path"""
return self.path
def set_description(self,text):
def set_description(self, text):
"""sets the description of the image"""
self.desc = text

View File

@ -24,6 +24,8 @@
Media Reference class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,17 +43,17 @@ from _AttributeBase import AttributeBase
# MediaObject References for Person/Place/Source
#
#-------------------------------------------------------------------------
class MediaRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase,
class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
AttributeBase):
"""Media reference class"""
def __init__(self,source=None):
def __init__(self, source=None):
SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
RefBase.__init__(self,source)
AttributeBase.__init__(self,source)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
RefBase.__init__(self, source)
AttributeBase.__init__(self, source)
if source:
self.rect = source.rect
@ -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),
@ -66,13 +71,16 @@ class MediaRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase,
RefBase.serialize(self),
self.rect)
def unserialize(self,data):
(privacy,source_list,note,attribute_list,ref,self.rect) = data
PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
AttributeBase.unserialize(self,attribute_list)
RefBase.unserialize(self,ref)
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)
NoteBase.unserialize(self, note)
AttributeBase.unserialize(self, attribute_list)
RefBase.unserialize(self, ref)
return self
def get_text_data_child_list(self):
@ -105,7 +113,7 @@ class MediaRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase,
@rtype: list
"""
if self.ref:
return [('MediaObject',self.ref)]
return [('MediaObject', self.ref)]
else:
return []
@ -119,7 +127,7 @@ class MediaRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase,
"""
return self.attribute_list + self.source_list
def set_rectangle(self,coord):
def set_rectangle(self, coord):
"""Sets subection of an image"""
self.rect = coord

View File

@ -24,6 +24,8 @@
Name class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ from _NameType import NameType
# Personal Name
#
#-------------------------------------------------------------------------
class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
class Name(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase):
"""
Provides name information about a person.
@ -54,24 +56,24 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
PTFN = 3 # patronymic first name
FN = 4 # first name
def __init__(self,source=None,data=None):
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,
name_type,self.prefix,self.patronymic,
self.group_as,self.sort_as,self.display_as,self.call) = data
(privacy, source_list, note, date,
self.first_name, self.surname, self.suffix, self.title,
name_type, self.prefix, self.patronymic,
self.group_as, self.sort_as, self.display_as, self.call) = data
self.type = NameType(name_type)
PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
DateBase.unserialize(self,date)
PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self, source_list)
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,29 +99,38 @@ 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),
DateBase.serialize(self),
self.first_name,self.surname,self.suffix,self.title,
self.type.serialize(),self.prefix,self.patronymic,
self.group_as,self.sort_as,self.display_as,self.call)
self.first_name, self.surname, self.suffix, self.title,
self.type.serialize(), self.prefix, self.patronymic,
self.group_as, self.sort_as, self.display_as, self.call)
def is_empty(self):
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"")
"""
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):
(privacy,source_list,note,date,
self.first_name,self.surname,self.suffix,self.title,
name_type,self.prefix,self.patronymic,
self.group_as,self.sort_as,self.display_as,self.call) = data
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,
self.group_as, self.sort_as, self.display_as, self.call) = data
self.type.unserialize(name_type)
PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
DateBase.unserialize(self,date)
PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self, note)
DateBase.unserialize(self, date)
return self
def get_text_data_list(self):
@ -133,8 +140,8 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.first_name,self.surname,self.suffix,self.title,
str(self.type),self.prefix,self.patronymic, self.call]
return [self.first_name, self.surname, self.suffix, self.title,
str(self.type), self.prefix, self.patronymic, self.call]
def get_text_data_child_list(self):
"""
@ -158,7 +165,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""
return self.source_list
def set_group_as(self,name):
def set_group_as(self, name):
"""
Sets the grouping name for a person. Normally, this is the person's
surname. However, some locales group equivalent names (e.g. Ivanova
@ -184,7 +191,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
else:
return self.surname
def set_sort_as(self,value):
def set_sort_as(self, value):
"""
Specifies the sorting method for the specified name. Typically the
locale's default should be used. However, there may be names where
@ -199,7 +206,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""
return self.sort_as
def set_display_as(self,value):
def set_display_as(self, value):
"""
Specifies the display format for the specified name. Typically the
locale's default should be used. However, there may be names where
@ -221,7 +228,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""
return self.call
def set_call_name(self,val):
def set_call_name(self, val):
"""
Returns the call name. The call name's exact definition is not predetermined,
and may be locale specific.
@ -235,14 +242,14 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""
return self.prefix
def set_surname_prefix(self,val):
def set_surname_prefix(self, val):
"""
Sets the prefix (or article) of a surname. Examples of articles
would be 'de' or 'van'.
"""
self.prefix = val
def set_type(self,the_type):
def set_type(self, the_type):
"""sets the type of the Name instance"""
self.type.set(the_type)
@ -250,19 +257,19 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""returns the type of the Name instance"""
return self.type
def set_first_name(self,name):
def set_first_name(self, name):
"""sets the given name for the Name instance"""
self.first_name = name
def set_patronymic(self,name):
def set_patronymic(self, name):
"""sets the patronymic name for the Name instance"""
self.patronymic = name
def set_surname(self,name):
def set_surname(self, name):
"""sets the surname (or last name) for the Name instance"""
self.surname = name
def set_suffix(self,name):
def set_suffix(self, name):
"""sets the suffix (such as Jr., III, etc.) for the Name instance"""
self.suffix = name
@ -286,7 +293,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""returns the suffix for the Name instance"""
return self.suffix
def set_title(self,title):
def set_title(self, title):
"""sets the title (Dr., Reverand, Captain) for the Name instance"""
self.title = title
@ -304,12 +311,13 @@ 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:
if self.prefix:
return "%s %s, %s" % (self.prefix,self.surname, first)
return "%s %s, %s" % (self.prefix, self.surname, first)
else:
return "%s, %s" % (self.surname, first)
@ -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
@ -45,7 +47,7 @@ class Note(SecondaryObject):
to be in paragraphs, separated by newlines.
"""
def __init__(self,text = ""):
def __init__(self, text = ""):
"""
Creates a new Note object, initializing from the passed string.
"""
@ -54,11 +56,17 @@ class Note(SecondaryObject):
self.format = 0
def serialize(self):
return (self.text,self.format)
"""
Converts the object to a serialized tuple of data
"""
return (self.text, self.format)
def unserialize(self,data):
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
if data:
(self.text,self.format) = data
(self.text, self.format) = data
return self
def get_text_data_list(self):
@ -70,7 +78,7 @@ class Note(SecondaryObject):
"""
return [self.text]
def set(self,text):
def set(self, text):
"""
Sets the text associated with the note to the passed string.
@ -87,7 +95,7 @@ class Note(SecondaryObject):
"""
return self.text
def append(self,text):
def append(self, text):
"""
Appends the specified text to the text associated with the note.
@ -96,7 +104,7 @@ class Note(SecondaryObject):
"""
self.text = self.text + text
def set_format(self,format):
def set_format(self, format):
"""
Sets the format of the note to the passed value. The value can
either indicate Flowed or Preformatted.

View File

@ -24,6 +24,8 @@
NoteBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -40,7 +42,7 @@ class NoteBase:
"""
Base class for storing notes.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Create a new NoteBase, copying from source if not None
@ -55,15 +57,21 @@ 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):
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
if data is not None:
self.note = Note().unserialize(data)
def set_note(self,text):
def set_note(self, text):
"""
Assigns the specified text to the associated note.
@ -85,7 +93,7 @@ class NoteBase:
return self.note.get()
return ""
def set_note_format(self,val):
def set_note_format(self, val):
"""
Sets the note's format to the given value. The format indicates
whether the text is flowed (wrapped) or preformatted.
@ -108,7 +116,7 @@ class NoteBase:
else:
return self.note.get_format()
def set_note_object(self,note_obj):
def set_note_object(self, note_obj):
"""
Replaces the current L{Note} object associated with the object

View File

@ -24,6 +24,8 @@
Person object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -48,8 +50,8 @@ from _EventRoleType import EventRoleType
# Person class
#
#-------------------------------------------------------------------------
class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
AttributeBase,AddressBase,UrlBase,LdsOrdBase):
class Person(PrimaryObject, SourceBase, NoteBase, MediaBase,
AttributeBase, AddressBase, UrlBase, LdsOrdBase):
"""
Introduction
============
@ -157,29 +159,28 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
Person object
@type data: tuple
"""
(
self.handle, # 0
self.gramps_id, # 1
self.gender, # 2
primary_name, # 3
alternate_names, # 4
self.death_ref_index, # 5
self.birth_ref_index, # 6
event_ref_list, # 7
self.family_list, # 8
self.parent_family_list, # 9
media_list, # 10
address_list, # 11
attribute_list, # 12
urls, # 13
lds_ord_list, # 14
source_list, # 15
note, # 16
self.change, # 17
marker, # 18
self.private, # 19
person_ref_list, # 20
) = data
(self.handle, # 0
self.gramps_id, # 1
self.gender, # 2
primary_name, # 3
alternate_names, # 4
self.death_ref_index, # 5
self.birth_ref_index, # 6
event_ref_list, # 7
self.family_list, # 8
self.parent_family_list, # 9
media_list, # 10
address_list, # 11
attribute_list, # 12
urls, # 13
lds_ord_list, # 14
source_list, # 15
note, # 16
self.change, # 17
marker, # 18
self.private, # 19
person_ref_list, # 20
) = data
self.marker.unserialize(marker)
self.primary_name.unserialize(primary_name)
@ -659,7 +660,7 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
Person's L{Family} list.
@type family_handle: str
"""
if type(family_handle) not in (str ,unicode ):
if type(family_handle) not in (str, unicode):
raise ValueError("expecting handle")
if family_handle not in self.parent_family_list:
self.parent_family_list.append(family_handle)
@ -726,7 +727,7 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
else:
return self.parent_family_list[0]
def add_person_ref(self,person_ref):
def add_person_ref(self, person_ref):
"""
Adds the L{PersonRef} to the Person instance's L{PersonRef} list.

View File

@ -24,6 +24,8 @@
Person Reference class for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -40,7 +42,7 @@ from _RefBase import RefBase
# Person References for Person/Family
#
#-------------------------------------------------------------------------
class PersonRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
"""
Person reference class.
@ -49,30 +51,36 @@ class PersonRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
Examples would be: godparent, friend, etc.
"""
def __init__(self,source=None):
def __init__(self, source=None):
SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
RefBase.__init__(self,source)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
RefBase.__init__(self, source)
if source:
self.rel = source.rel
else:
self.rel = ''
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self),
SourceBase.serialize(self),
NoteBase.serialize(self),
RefBase.serialize(self),
self.rel)
def unserialize(self,data):
(privacy,source_list,note,ref,self.rel) = data
PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
RefBase.unserialize(self,ref)
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)
NoteBase.unserialize(self, note)
RefBase.unserialize(self, ref)
return self
def get_text_data_list(self):
@ -105,7 +113,7 @@ class PersonRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
@rtype: list
"""
if self.ref:
return [('Person',self.ref)]
return [('Person', self.ref)]
else:
return []
@ -119,7 +127,7 @@ class PersonRef(SecondaryObject,PrivacyBase,SourceBase,NoteBase,RefBase):
"""
return self.source_list
def set_relation(self,rel):
def set_relation(self, rel):
"""Sets relation to a person"""
self.rel = rel

View File

@ -24,6 +24,8 @@
Place object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -43,25 +45,25 @@ _EMPTY_LOC = Location().serialize()
# Place class
#
#-------------------------------------------------------------------------
class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
class Place(PrimaryObject, SourceBase, NoteBase, MediaBase, UrlBase):
"""
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
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Creates a new Place object, copying from the source if present.
@param source: A Place object used to initialize the new Place
@type source: Place
"""
PrimaryObject.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
MediaBase.__init__(self,source)
UrlBase.__init__(self,source)
PrimaryObject.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
MediaBase.__init__(self, source)
UrlBase.__init__(self, source)
if source:
self.long = source.long
self.lat = source.lat
@ -105,7 +107,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
NoteBase.serialize(self),
self.change, self.marker.serialize() ,self.private)
def unserialize(self,data):
def unserialize(self, data):
"""
Converts the data held in a tuple created by the serialize method
back into the data in a Place object.
@ -124,10 +126,10 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
self.main_loc = Location().unserialize(main_loc)
self.alt_loc = [Location().unserialize(al) for al in alt_loc]
self.marker.unserialize(marker)
UrlBase.unserialize(self,urls)
MediaBase.unserialize(self,media_list)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
UrlBase.unserialize(self, urls)
MediaBase.unserialize(self, media_list)
SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self, note)
def get_text_data_list(self):
"""
@ -136,7 +138,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.long,self.lat,self.title,self.gramps_id]
return [self.long, self.lat, self.title, self.gramps_id]
def get_text_data_child_list(self):
"""
@ -146,7 +148,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
@rtype: list
"""
check_list = [self.main_loc,self.note]
check_list = [self.main_loc, self.note]
add_list = [item for item in check_list if item]
return self.media_list + self.source_list + self.alt_loc \
+ self.urls + add_list
@ -170,7 +172,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
"""
return self.media_list + self.source_list
def set_title(self,title):
def set_title(self, title):
"""
Sets the descriptive title of the Place object
@ -188,7 +190,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
"""
return self.title
def set_longitude(self,longitude):
def set_longitude(self, longitude):
"""
Sets the longitude of the Place object
@ -206,7 +208,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
"""
return self.long
def set_latitude(self,latitude):
def set_latitude(self, latitude):
"""
Sets the latitude of the Place object
@ -238,7 +240,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
self.main_loc = Location()
return self.main_loc
def set_main_location(self,location):
def set_main_location(self, location):
"""
Assigns the main location information about the Place to the L{Location}
object passed
@ -260,7 +262,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
"""
return self.alt_loc
def set_alternate_locations(self,location_list):
def set_alternate_locations(self, location_list):
"""
Replaces the current alternate L{Location} object list with the new one.
@ -270,7 +272,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
"""
self.alt_loc = location_list
def add_alternate_locations(self,location):
def add_alternate_locations(self, location):
"""
Adds a L{Location} object to the alternate location list
@ -295,12 +297,12 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
"""
if self.main_loc:
return [self.title,self.gramps_id,self.main_loc.parish,
self.main_loc.city,self.main_loc.county,
self.main_loc.state,self.main_loc.country,
return [self.title, self.gramps_id, self.main_loc.parish,
self.main_loc.city, self.main_loc.county,
self.main_loc.state, self.main_loc.country,
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.upper()]
else:
return [self.title,self.gramps_id,'','','','','',
self.title.upper(), '','','','','']
return [self.title, self.gramps_id, '', '', '', '', '',
self.title.upper(), '', '', '', '', '']

View File

@ -24,6 +24,8 @@
PlaceBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# PlaceBase class
@ -33,7 +35,7 @@ class PlaceBase:
"""
Base class for place-aware objects.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a PlaceBase. If the source is not None, then object
is initialized from values of the source object.
@ -46,7 +48,7 @@ class PlaceBase:
else:
self.place = ""
def set_place_handle(self,place_handle):
def set_place_handle(self, place_handle):
"""
Sets the database handle for L{Place} associated with the object.

View File

@ -24,6 +24,8 @@
Primary Object class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# standard python modules
@ -55,7 +57,7 @@ _codeset = GrampsLocale.codeset
# Primary Object class
#
#-------------------------------------------------------------------------
class PrimaryObject(BaseObject,PrivacyBase):
class PrimaryObject(BaseObject, PrivacyBase):
"""
The PrimaryObject is the base class for all primary objects in the
database. Primary objects are the core objects in the database.
@ -64,9 +66,9 @@ class PrimaryObject(BaseObject,PrivacyBase):
ID is the user visible version.
"""
def __init__(self,source=None):
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.
@ -74,7 +76,7 @@ class PrimaryObject(BaseObject,PrivacyBase):
@type source: PrimaryObject
"""
BaseObject.__init__(self)
PrivacyBase.__init__(self,source)
PrivacyBase.__init__(self, source)
if source:
self.gramps_id = source.gramps_id
self.handle = source.handle
@ -106,12 +108,12 @@ class PrimaryObject(BaseObject,PrivacyBase):
"""
if self.change:
return unicode(time.strftime('%x %X',time.localtime(self.change)),
return unicode(time.strftime('%x %X', time.localtime(self.change)),
_codeset)
else:
return u''
def set_handle(self,handle):
def set_handle(self, handle):
"""
Sets the database handle for the primary object
@ -129,7 +131,7 @@ class PrimaryObject(BaseObject,PrivacyBase):
"""
return self.handle
def set_gramps_id(self,gramps_id):
def set_gramps_id(self, gramps_id):
"""
Sets the GRAMPS ID for the primary object
@ -147,7 +149,7 @@ class PrimaryObject(BaseObject,PrivacyBase):
"""
return self.gramps_id
def has_handle_reference(self,classname,handle):
def has_handle_reference(self, classname, handle):
"""
Returns True if the object has reference to a given handle
of given primary object type.
@ -159,14 +161,14 @@ class PrimaryObject(BaseObject,PrivacyBase):
@return: Returns whether the object has reference to this handle of this object type.
@rtype: bool
"""
if classname == 'Source' and isinstance(self,SourceBase):
if classname == 'Source' and isinstance(self, SourceBase):
return self.has_source_reference(handle)
elif classname == 'MediaObject' and isinstance(self,MediaBase):
elif classname == 'MediaObject' and isinstance(self, MediaBase):
return self.has_media_reference(handle)
else:
return self._has_handle_reference(classname,handle)
return self._has_handle_reference(classname, handle)
def remove_handle_references(self,classname,handle_list):
def remove_handle_references(self, classname, handle_list):
"""
Removes all references in this object to object handles in the list.
@ -175,14 +177,14 @@ class PrimaryObject(BaseObject,PrivacyBase):
@param handle_list: The list of handles to be removed.
@type handle_list: str
"""
if classname == 'Source' and isinstance(self,SourceBase):
if classname == 'Source' and isinstance(self, SourceBase):
self.remove_source_references(handle_list)
elif classname == 'MediaObject' and isinstance(self,MediaBase):
elif classname == 'MediaObject' and isinstance(self, MediaBase):
self.remove_media_references(handle_list)
else:
self._remove_handle_references(classname,handle_list)
self._remove_handle_references(classname, handle_list)
def replace_handle_reference(self,classname,old_handle,new_handle):
def replace_handle_reference(self, classname, old_handle, new_handle):
"""
Replaces all references to old handle with those to the new handle.
@ -193,23 +195,32 @@ class PrimaryObject(BaseObject,PrivacyBase):
@param new_handle: The handle to replace the old one with.
@type new_handle: str
"""
if classname == 'Source' and isinstance(self,SourceBase):
self.replace_source_references(old_handle,new_handle)
elif classname == 'MediaObject' and isinstance(self,MediaBase):
self.replace_media_references(old_handle,new_handle)
if classname == 'Source' and isinstance(self, SourceBase):
self.replace_source_references(old_handle, new_handle)
elif classname == 'MediaObject' and isinstance(self, MediaBase):
self.replace_media_references(old_handle, new_handle)
else:
self._replace_handle_reference(classname,old_handle,new_handle)
self._replace_handle_reference(classname, old_handle, new_handle)
def _has_handle_reference(self,classname,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):
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):
def _replace_handle_reference(self, classname, old_handle, new_handle):
"""
replaces the handle reference with the new reference
"""
pass
def set_marker(self,marker):
def set_marker(self, marker):
self.marker.set(marker)
def get_marker(self):

View File

@ -24,6 +24,8 @@
PrivacyBase Object class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# PrivacyBase Object
@ -34,7 +36,7 @@ class PrivacyBase:
Base class for privacy-aware objects.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a PrivacyBase. If the source is not None, then object
is initialized from values of the source object.
@ -49,13 +51,19 @@ class PrivacyBase:
self.private = False
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return self.private
def unserialize(self,data):
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.private = data
return self
def set_privacy(self,val):
def set_privacy(self, val):
"""
Sets or clears the privacy flag of the data

View File

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

View File

@ -24,6 +24,8 @@
Base Reference class for GRAMPS.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# RefBase class
@ -36,16 +38,22 @@ class RefBase:
Any *Ref class should derive from this class.
"""
def __init__(self,source=None):
def __init__(self, source=None):
if source:
self.ref = source.ref
else:
self.ref = None
def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return self.ref
def unserialize(self,data):
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.ref = str(data)
return self
@ -59,7 +67,7 @@ class RefBase:
"""
assert False, "Must be overridden in the derived class"
def set_reference_handle(self,val):
def set_reference_handle(self, val):
self.ref = val
def get_reference_handle(self):

View File

@ -24,6 +24,8 @@
Repository Reference class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -39,15 +41,15 @@ from _SourceMediaType import SourceMediaType
# Repository Reference for Sources
#
#-------------------------------------------------------------------------
class RepoRef(SecondaryObject,NoteBase,RefBase):
class RepoRef(SecondaryObject, NoteBase, RefBase):
"""
Repository reference class.
"""
def __init__(self,source=None):
def __init__(self, source=None):
SecondaryObject.__init__(self)
NoteBase.__init__(self,source)
RefBase.__init__(self,source)
NoteBase.__init__(self, source)
RefBase.__init__(self, source)
if source:
self.call_number = source.call_number
self.media_type = source.media_type
@ -56,16 +58,22 @@ 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())
self.call_number, self.media_type.serialize())
def unserialize(self,data):
(note,ref,self.call_number,media_type) = data
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)
RefBase.unserialize(self,ref)
NoteBase.unserialize(self, note)
RefBase.unserialize(self, ref)
return self
def get_text_data_list(self):
@ -75,7 +83,7 @@ class RepoRef(SecondaryObject,NoteBase,RefBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.call_number,str(self.media_type)]
return [self.call_number, str(self.media_type)]
def get_text_data_child_list(self):
"""
@ -97,11 +105,11 @@ class RepoRef(SecondaryObject,NoteBase,RefBase):
@rtype: list
"""
if self.ref:
return [('Repository',self.ref)]
return [('Repository', self.ref)]
else:
return []
def set_call_number(self,number):
def set_call_number(self, number):
self.call_number = number
def get_call_number(self):
@ -110,5 +118,5 @@ class RepoRef(SecondaryObject,NoteBase,RefBase):
def get_media_type(self):
return self.media_type
def set_media_type(self,media_type):
def set_media_type(self, media_type):
self.media_type.set(media_type)

View File

@ -24,6 +24,8 @@
Repository object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -40,7 +42,7 @@ from _RepositoryType import RepositoryType
# Repository class
#
#-------------------------------------------------------------------------
class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
class Repository(PrimaryObject, NoteBase, AddressBase, UrlBase):
"""A location where collections of Sources are found"""
def __init__(self):
@ -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),
@ -60,7 +65,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
UrlBase.serialize(self),
self.marker.serialize(), self.private)
def unserialize(self,data):
def unserialize(self, data):
"""
Converts the data held in a tuple created by the serialize method
back into the data in an Repository structure.
@ -70,9 +75,9 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
self.marker.unserialize(marker)
self.type.unserialize(the_type)
NoteBase.unserialize(self,note)
AddressBase.unserialize(self,address_list)
UrlBase.unserialize(self,urls)
NoteBase.unserialize(self, note)
AddressBase.unserialize(self, address_list)
UrlBase.unserialize(self, urls)
def get_text_data_list(self):
"""
@ -81,7 +86,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.name,str(self.type)]
return [self.name, str(self.type)]
def get_text_data_child_list(self):
"""
@ -95,7 +100,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
check_list.append(self.note)
return check_list
def has_source_reference(self,src_handle) :
def has_source_reference(self, src_handle) :
"""
Returns True if any of the child objects has reference
to this source handle.
@ -107,7 +112,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
"""
return False
def remove_source_references(self,src_handle_list):
def remove_source_references(self, src_handle_list):
"""
Removes references to all source handles in the list
in all child objects.
@ -117,7 +122,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
"""
pass
def replace_source_references(self,old_handle,new_handle):
def replace_source_references(self, old_handle, new_handle):
"""
Replaces references to source handles in the list
in this object and all child objects.
@ -129,7 +134,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
"""
pass
def set_type(self,the_type):
def set_type(self, the_type):
"""
@param the_type: descriptive type of the Repository
@type the_type: str
@ -143,7 +148,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
"""
return self.type
def set_name(self,name):
def set_name(self, name):
"""
@param name: descriptive name of the Repository
@type name: str

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
@ -59,7 +61,7 @@ class Researcher(LocationBase):
"""returns the database owner's email"""
return self.email
def set(self,name,addr,city,state,country,postal,phone,email):
def set(self, name, addr, city, state, country, postal, phone, email):
"""sets the information about the database owner"""
if name:
self.name = name.strip()

View File

@ -24,6 +24,8 @@
Secondary Object class for GRAMPS
"""
__revision__ = "$Revision: $"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -45,7 +47,7 @@ class SecondaryObject(BaseObject):
ID is the user visible version.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize a SecondaryObject. If source is None, both the ID and handle
are assigned as empty strings. If source is not None, then object
@ -57,4 +59,4 @@ class SecondaryObject(BaseObject):
BaseObject.__init__(self)
def is_equal(self, source):
return cmp(self.serialize(),source.serialize()) == 0
return cmp(self.serialize(), source.serialize()) == 0

View File

@ -24,6 +24,8 @@
Source object for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -40,7 +42,7 @@ from _RepoRef import RepoRef
# Source class
#
#-------------------------------------------------------------------------
class Source(PrimaryObject,MediaBase,NoteBase):
class Source(PrimaryObject, MediaBase, NoteBase):
"""A record of a source of information"""
def __init__(self):
@ -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),
@ -65,7 +70,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
[rr.serialize() for rr in self.reporef_list],
self.marker.serialize(),self.private)
def unserialize(self,data):
def unserialize(self, data):
"""
Converts the data held in a tuple created by the serialize method
back into the data in an Event structure.
@ -76,8 +81,8 @@ class Source(PrimaryObject,MediaBase,NoteBase):
marker, self.private) = data
self.marker.unserialize(marker)
NoteBase.unserialize(self,note)
MediaBase.unserialize(self,media_list)
NoteBase.unserialize(self, note)
MediaBase.unserialize(self, media_list)
self.reporef_list = [RepoRef().unserialize(rr) for rr in reporef_list]
def get_text_data_list(self):
@ -87,7 +92,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.title,self.author,self.pubinfo,self.abbrev,
return [self.title, self.author, self.pubinfo, self.abbrev,
self.gramps_id] + self.datamap.keys() + self.datamap.values()
def get_text_data_child_list(self):
@ -121,7 +126,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""
return self.media_list + self.reporef_list
def has_source_reference(self,src_handle) :
def has_source_reference(self, src_handle) :
"""
Returns True if any of the child objects has reference
to this source handle.
@ -137,7 +142,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
return False
def remove_source_references(self,src_handle_list):
def remove_source_references(self, src_handle_list):
"""
Removes references to all source handles in the list
in all child objects.
@ -148,7 +153,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
for item in self.get_sourcref_child_list():
item.remove_source_references(src_handle_list)
def replace_source_references(self,old_handle,new_handle):
def replace_source_references(self, old_handle, new_handle):
"""
Replaces references to source handles in the list
in this object and all child objects.
@ -159,21 +164,21 @@ class Source(PrimaryObject,MediaBase,NoteBase):
@type new_handle: str
"""
for item in self.get_sourcref_child_list():
item.replace_source_references(old_handle,new_handle)
item.replace_source_references(old_handle, new_handle)
def get_data_map(self):
"""Returns the data map of attributes for the source"""
return self.datamap
def set_data_map(self,datamap):
def set_data_map(self, datamap):
"""Sets the data map of attributes for the source"""
self.datamap = datamap
def set_data_item(self,key,value):
def set_data_item(self, key, value):
"""Sets the particular data item in the attribute data map"""
self.datamap[key] = value
def set_title(self,title):
def set_title(self, title):
"""
Sets the descriptive title of the Source object
@ -191,7 +196,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""
return self.title
def set_author(self,author):
def set_author(self, author):
"""sets the author of the Source"""
self.author = author
@ -199,7 +204,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""returns the author of the Source"""
return self.author
def set_publication_info(self,text):
def set_publication_info(self, text):
"""sets the publication information of the Source"""
self.pubinfo = text
@ -207,7 +212,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""returns the publication information of the Source"""
return self.pubinfo
def set_abbreviation(self,abbrev):
def set_abbreviation(self, abbrev):
"""sets the title abbreviation of the Source"""
self.abbrev = abbrev
@ -215,7 +220,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""returns the title abbreviation of the Source"""
return self.abbrev
def add_repo_reference(self,repo_ref):
def add_repo_reference(self, repo_ref):
"""
Adds a L{RepoRef} instance to the Source's reporef list.
@ -233,7 +238,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""
return self.reporef_list
def set_reporef_list(self,reporef_list):
def set_reporef_list(self, reporef_list):
"""
Sets the list of L{RepoRef} instances associated with the Source.
It replaces the previous list.
@ -243,7 +248,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""
self.reporef_list = reporef_list
def has_repo_reference(self,repo_handle):
def has_repo_reference(self, repo_handle):
"""
Returns True if the Source has reference to this Repository handle.
@ -254,7 +259,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""
return repo_handle in [repo_ref.ref for repo_ref in self.reporef_list]
def remove_repo_references(self,repo_handle_list):
def remove_repo_references(self, repo_handle_list):
"""
Removes references to all Repository handles in the list.
@ -265,7 +270,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
if repo_ref.ref not in repo_handle_list ]
self.reporef_list = new_reporef_list
def replace_repo_references(self,old_handle,new_handle):
def replace_repo_references(self, old_handle, new_handle):
"""
Replaces all references to old Repository handle with the new handle.

View File

@ -24,6 +24,8 @@
SourceBase class for GRAMPS
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -41,7 +43,7 @@ class SourceBase:
Base class for storing source references
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Create a new SourceBase, copying from source if not None
@ -54,12 +56,18 @@ 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):
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) :
def add_source_reference(self, src_ref) :
"""
Adds a source reference to this object.
@ -88,7 +96,7 @@ class SourceBase:
"""
return []
def has_source_reference(self,src_handle) :
def has_source_reference(self, src_handle) :
"""
Returns True if the object or any of it's child objects has reference
to this source handle.
@ -109,7 +117,7 @@ class SourceBase:
return False
def remove_source_references(self,src_handle_list):
def remove_source_references(self, src_handle_list):
"""
Removes references to all source handles in the list
in this object and all child objects.
@ -124,7 +132,7 @@ class SourceBase:
for item in self.get_sourcref_child_list():
item.remove_source_references(src_handle_list)
def replace_source_references(self,old_handle,new_handle):
def replace_source_references(self, old_handle, new_handle):
"""
Replaces references to source handles in the list
in this object and all child objects.
@ -142,9 +150,9 @@ class SourceBase:
refs_list[ix] = new_handle
for item in self.get_sourcref_child_list():
item.replace_source_references(old_handle,new_handle)
item.replace_source_references(old_handle, new_handle)
def set_source_reference_list(self,src_ref_list) :
def set_source_reference_list(self, src_ref_list) :
"""
Assigns the passed list to the object's list of source references.

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
#-------------------------------------------------------------------------
@ -42,7 +44,7 @@ from _RefBase import RefBase
# Source References for all primary objects
#
#-------------------------------------------------------------------------
class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
class SourceRef(SecondaryObject, DateBase, PrivacyBase, NoteBase, RefBase):
"""Source reference, containing detailed information about how a
referenced source relates to it"""
@ -52,13 +54,13 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
CONF_LOW = 1
CONF_VERY_LOW = 0
def __init__(self,source=None):
def __init__(self, source=None):
"""creates a new SourceRef, copying from the source if present"""
SecondaryObject.__init__(self)
DateBase.__init__(self,source)
PrivacyBase.__init__(self,source)
NoteBase.__init__(self,source)
RefBase.__init__(self,source)
DateBase.__init__(self, source)
PrivacyBase.__init__(self, source)
NoteBase.__init__(self, source)
RefBase.__init__(self, source)
if source:
self.confidence = source.confidence
self.page = source.page
@ -69,20 +71,26 @@ 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),
self.confidence,
RefBase.serialize(self),
self.page,self.text)
self.page, self.text)
def unserialize(self,data):
(date,privacy,note,
self.confidence,ref,self.page,self.text) = data
DateBase.unserialize(self,date)
PrivacyBase.unserialize(self,privacy)
NoteBase.unserialize(self,note)
RefBase.unserialize(self,ref)
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)
PrivacyBase.unserialize(self, privacy)
NoteBase.unserialize(self, note)
RefBase.unserialize(self, ref)
return self
def get_text_data_list(self):
@ -92,8 +100,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.page,self.text]
#return [self.page,self.text,self.get_date()]
return [self.page, self.text]
def get_text_data_child_list(self):
"""
@ -113,11 +120,11 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
@rtype: list
"""
if self.ref:
return [('Source',self.ref)]
return [('Source', self.ref)]
else:
return []
def set_confidence_level(self,val):
def set_confidence_level(self, val):
"""Sets the confidence level"""
self.confidence = val
@ -125,7 +132,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""Returns the confidence level"""
return self.confidence
def set_page(self,page):
def set_page(self, page):
"""sets the page indicator of the SourceRef"""
self.page = page
@ -133,7 +140,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""gets the page indicator of the SourceRef"""
return self.page
def set_text(self,text):
def set_text(self, text):
"""sets the text related to the SourceRef"""
self.text = text
@ -141,6 +148,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""returns the text related to the SourceRef"""
return self.text
def are_equal(self,other):
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
@ -45,14 +47,14 @@ from _UrlType import UrlType
# Url for Person/Place/Repository
#
#-------------------------------------------------------------------------
class Url(SecondaryObject,PrivacyBase):
class Url(SecondaryObject, PrivacyBase):
"""Contains information related to internet Uniform Resource Locators,
allowing gramps to store information about internet resources"""
def __init__(self,source=None):
def __init__(self, source=None):
"""creates a new URL instance, copying from the source if present"""
SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source)
PrivacyBase.__init__(self, source)
if source:
self.path = source.path
self.desc = source.desc
@ -65,8 +67,8 @@ class Url(SecondaryObject,PrivacyBase):
def serialize(self):
return (self.private,self.path,self.desc,self.type.serialize())
def unserialize(self,data):
(self.private,self.path,self.desc,type_value) = data
def unserialize(self, data):
(self.private, self.path, self.desc, type_value) = data
self.type.unserialize(type_value)
return self
@ -77,9 +79,9 @@ class Url(SecondaryObject,PrivacyBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.path,self.desc]
return [self.path, self.desc]
def set_path(self,path):
def set_path(self, path):
"""sets the URL path"""
self.path = path
@ -87,7 +89,7 @@ class Url(SecondaryObject,PrivacyBase):
"""returns the URL path"""
return self.path
def set_description(self,description):
def set_description(self, description):
"""sets the description of the URL"""
self.desc = description
@ -95,7 +97,7 @@ class Url(SecondaryObject,PrivacyBase):
"""returns the description of the URL"""
return self.desc
def set_type(self,the_type):
def set_type(self, the_type):
"""
@param the_type: descriptive type of the Url
@type the_type: str
@ -109,6 +111,8 @@ class Url(SecondaryObject,PrivacyBase):
"""
return self.type
def are_equal(self,other):
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
@ -41,7 +43,7 @@ class UrlBase:
Base class for url-aware objects.
"""
def __init__(self,source=None):
def __init__(self, source=None):
"""
Initialize an UrlBase. If the source is not None, then object
is initialized from values of the source object.
@ -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):
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):
@ -70,7 +78,7 @@ class UrlBase:
"""
return self.urls
def set_url_list(self,url_list):
def set_url_list(self, url_list):
"""
Sets the list of L{Url} instances to passed the list.
@ -79,7 +87,7 @@ class UrlBase:
"""
self.urls = url_list
def add_url(self,url):
def add_url(self, url):
"""
Adds a L{Url} instance to the object's list of L{Url} instances
@ -89,8 +97,7 @@ class UrlBase:
"""
self.urls.append(url)
def remove_url(self,url):
def remove_url(self, url):
"""
Removes the specified L{Url} instance from the url list
If the instance does not exist in the list, the operation has

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

@ -608,9 +608,42 @@ def probably_alive(person,db,current_year=None,limit=0):
if death_year > current_year + 110:
# person died more tha 110 after current year
return False
# Neither birth nor death events are available. Try looking
# for descendants that were born more than a lifespan ago.
# Neither birth nor death events are available. Try looking
# 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