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> 2007-01-06 Piotr Czubaszek <pioterus@gmail.com>
* src/plugins/rel_pl.py: Update. * src/plugins/rel_pl.py: Update.

View File

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

View File

@ -24,6 +24,8 @@
Address class for GRAMPS Address class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -41,28 +43,34 @@ from _LocationBase import LocationBase
# Address for Person/Repository # Address for Person/Repository
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Address(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase, class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
LocationBase): LocationBase):
"""Provides address information.""" """Provides address information."""
def __init__(self,source=None): def __init__(self, source=None):
"""Creates a new Address instance, copying from the source """Creates a new Address instance, copying from the source
if provided""" if provided"""
SecondaryObject.__init__(self) SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source) PrivacyBase.__init__(self, source)
SourceBase.__init__(self,source) SourceBase.__init__(self, source)
NoteBase.__init__(self,source) NoteBase.__init__(self, source)
DateBase.__init__(self,source) DateBase.__init__(self, source)
LocationBase.__init__(self,source) LocationBase.__init__(self, source)
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self), return (PrivacyBase.serialize(self),
SourceBase.serialize(self), SourceBase.serialize(self),
NoteBase.serialize(self), NoteBase.serialize(self),
DateBase.serialize(self), DateBase.serialize(self),
LocationBase.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 (privacy, source_list, note, date, location) = data
PrivacyBase.unserialize(self, privacy) PrivacyBase.unserialize(self, privacy)

View File

@ -24,6 +24,8 @@
AddressBase class for GRAMPS AddressBase class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -41,7 +43,7 @@ class AddressBase:
Base class for address-aware objects. 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 Initialize a AddressBase. If the source is not None, then object
is initialized from values of the source object. is initialized from values of the source object.
@ -57,12 +59,18 @@ class AddressBase:
self.address_list = [] self.address_list = []
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [addr.serialize() for addr in self.address_list] 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] 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 Adds the L{Address} instance to the object's list of addresses
@ -71,7 +79,7 @@ class AddressBase:
""" """
self.address_list.append(address) 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 Removes the specified L{Address} instance from the address list
If the instance does not exist in the list, the operation has If the instance does not exist in the list, the operation has
@ -98,7 +106,7 @@ class AddressBase:
""" """
return self.address_list 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. Assigns the passed list to the object's list of L{Address} instances.
@param address_list: List of L{Address} instances to be associated @param address_list: List of L{Address} instances to be associated

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Base Object class for GRAMPS Base Object class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# standard python modules # standard python modules
@ -50,13 +52,19 @@ class BaseObject:
pass pass
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
assert False, "Needs to be overridden in the derived class" 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" assert False, "Needs to be overridden in the derived class"
return self 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 Returns True if any text data in the object or any of it's child
objects matches a given pattern. objects matches a given pattern.
@ -82,12 +90,12 @@ class BaseObject:
# Run through child objects # Run through child objects
for obj in self.get_text_data_child_list(): 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 True
return False 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 Returns True if any text data in the object or any of it's child
objects matches a given regular expression. objects matches a given regular expression.
@ -102,14 +110,14 @@ class BaseObject:
if case_sensitive: if case_sensitive:
pattern_obj = re.compile(pattern) pattern_obj = re.compile(pattern)
else: else:
pattern_obj = re.compile(pattern,re.IGNORECASE) pattern_obj = re.compile(pattern, re.IGNORECASE)
for item in self.get_text_data_list(): for item in self.get_text_data_list():
if item and pattern_obj.match(item): if item and pattern_obj.match(item):
return True return True
# Run through child objects # Run through child objects
for obj in self.get_text_data_child_list(): 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 True
return False return False

View File

@ -20,6 +20,8 @@
# $Id$ # $Id$
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Python modules # Python modules
@ -50,11 +52,11 @@ _HBR_NOON = 19440
_HBR_AM3_11_20 = 9924 _HBR_AM3_11_20 = 9924
_HBR_AM9_32_43 = 16789 _HBR_AM9_32_43 = 16789
_HBR_SUNDAY = 0 _HBR_SUNDAY = 0
_HBR_MONDAY = 1 _HBR_MONDAY = 1
_HBR_TUESDAY = 2 _HBR_TUESDAY = 2
_HBR_WEDNESDAY= 3 _HBR_WEDNESDAY = 3
_HBR_FRIDAY = 5 _HBR_FRIDAY = 5
_HBR_MONTHS_PER_YEAR = [ _HBR_MONTHS_PER_YEAR = [
12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 12, 12, 13, 12, 12, 13, 12, 13, 12, 12,
@ -97,43 +99,43 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
return tishri1 return tishri1
def _tishri_molad(inputDay): def _tishri_molad(input_day):
# Estimate the metonic cycle number. Note that this may be an under # Estimate the metonic cycle number. Note that this may be an under
# estimate because there are 6939.6896 days in a metonic cycle not # 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 # 6940, but it will never be an over estimate. The loop below will
# correct for any error in this estimate. */ # 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. */ # 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 # 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% # 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 # likely to not execute, even once, because the above estimate is
# really quite close. # really quite close.
while moladDay < (inputDay - 6940 + 310): while molad_day < (input_day - 6940 + 310):
metonicCycle = metonicCycle + 1 metonic_cycle = metonic_cycle + 1
moladHalakim = moladHalakim + _HBR_HALAKIM_PER_METONIC_CYCLE molad_halakim = molad_halakim + _HBR_HALAKIM_PER_METONIC_CYCLE
moladDay = moladDay + ( moladHalakim / _HBR_HALAKIM_PER_DAY) molad_day = molad_day + ( molad_halakim / _HBR_HALAKIM_PER_DAY)
moladHalakim = moladHalakim % _HBR_HALAKIM_PER_DAY molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
# Find the molad of Tishri closest to this date. # Find the molad of Tishri closest to this date.
for metonicYear in range(0,18): for metonic_year in range(0, 18):
if moladDay > inputDay - 74: if molad_day > input_day - 74:
break break
moladHalakim = moladHalakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
* _HBR_MONTHS_PER_YEAR[metonicYear]) * _HBR_MONTHS_PER_YEAR[metonic_year])
moladDay = moladDay + (moladHalakim / _HBR_HALAKIM_PER_DAY) molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY)
moladHalakim = moladHalakim % _HBR_HALAKIM_PER_DAY molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
else: else:
metonicYear = metonicYear + 1 metonic_year = metonic_year + 1
return (metonicCycle, metonicYear, moladDay, moladHalakim) return (metonic_cycle, metonic_year, molad_day, molad_halakim)
def _molad_of_metonic_cycle(metonic_cycle): def _molad_of_metonic_cycle(metonic_cycle):
@ -162,7 +164,7 @@ def _molad_of_metonic_cycle(metonic_cycle):
molad_day = (d2 << 16) | d1 molad_day = (d2 << 16) | d1
molad_halakim = r1 molad_halakim = r1
return (molad_day,molad_halakim) return (molad_day, molad_halakim)
def _start_of_year(year): def _start_of_year(year):
@ -184,8 +186,8 @@ def hebrew_sdn(year, month, day):
if month == 1 or month == 2: if month == 1 or month == 2:
# It is Tishri or Heshvan - don't need the year length. # It is Tishri or Heshvan - don't need the year length.
(metonic_cycle,metonic_year, (metonic_cycle, metonic_year,
molad_day,molad_halakim,tishri1) = _start_of_year(year) molad_day, molad_halakim, tishri1) = _start_of_year(year)
if month == 1: if month == 1:
sdn = tishri1 + day - 1 sdn = tishri1 + day - 1
else: else:
@ -194,8 +196,8 @@ def hebrew_sdn(year, month, day):
# It is Kislev - must find the year length. # It is Kislev - must find the year length.
# Find the start of the year. # Find the start of the year.
(metonic_cycle,metonic_year, (metonic_cycle, metonic_year,
molad_day,molad_halakim,tishri1) = _start_of_year(year) molad_day, molad_halakim, tishri1) = _start_of_year(year)
# Find the end of the year. # Find the end of the year.
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE 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: elif month == 4 or month == 5 or month == 6:
# It is Tevet, Shevat or Adar I - don't need the year length # It is Tevet, Shevat or Adar I - don't need the year length
(metonic_cycle,metonic_year, (metonic_cycle, metonic_year,
molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1) molad_day, molad_halakim, tishri1_after) = _start_of_year(year+1)
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 12: if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 12:
length_of_adarI_andII = 29 length_of_adarI_andII = 29
@ -230,8 +232,8 @@ def hebrew_sdn(year, month, day):
sdn = tishri1_after + day - length_of_adarI_andII - 178 sdn = tishri1_after + day - length_of_adarI_andII - 178
else: else:
# It is Adar II or later - don't need the year length. # It is Adar II or later - don't need the year length.
(metonic_cycle,metonic_year, (metonic_cycle, metonic_year,
molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1) molad_day, molad_halakim, tishri1_after) = _start_of_year(year+1)
if month == 7: if month == 7:
sdn = tishri1_after + day - 207 sdn = tishri1_after + day - 207
@ -254,112 +256,112 @@ def hebrew_sdn(year, month, day):
def hebrew_ymd(sdn): def hebrew_ymd(sdn):
"""Converts an SDN number to a Julian calendar date""" """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) (metonic_cycle, metonic_year, day, halakim) = _tishri_molad(input_day)
tishri1 = _tishri1(metonicYear, day, halakim); tishri1 = _tishri1(metonic_year, day, halakim);
if inputDay >= tishri1: if input_day >= tishri1:
# It found Tishri 1 at the start of the year # It found Tishri 1 at the start of the year
Year = (metonicCycle * 19) + metonicYear + 1 year = (metonic_cycle * 19) + metonic_year + 1
if inputDay < tishri1 + 59: if input_day < tishri1 + 59:
if inputDay < tishri1 + 30: if input_day < tishri1 + 30:
Month = 1 month = 1
Day = inputDay - tishri1 + 1 day = input_day - tishri1 + 1
else: else:
Month = 2 month = 2
Day = inputDay - tishri1 - 29 day = input_day - tishri1 - 29
return (Year, Month, Day) return (year, month, day)
# We need the length of the year to figure this out, so find # We need the length of the year to figure this out, so find
# Tishri 1 of the next year. */ # Tishri 1 of the next year. */
halakim = halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE 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) day = day + (halakim / _HBR_HALAKIM_PER_DAY)
halakim = 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: else:
# It found Tishri 1 at the end of the year. # It found Tishri 1 at the end of the year.
Year = metonicCycle * 19 + metonicYear year = metonic_cycle * 19 + metonic_year
if inputDay >= tishri1 - 177: if input_day >= tishri1 - 177:
# It is one of the last 6 months of the year. # It is one of the last 6 months of the year.
if inputDay > tishri1 - 30: if input_day > tishri1 - 30:
Month = 13 month = 13
Day = inputDay - tishri1 + 30 day = input_day - tishri1 + 30
elif inputDay > tishri1 - 60: elif input_day > tishri1 - 60:
Month = 12 month = 12
Day = inputDay - tishri1 + 60 day = input_day - tishri1 + 60
elif inputDay > tishri1 - 89: elif input_day > tishri1 - 89:
Month = 11 month = 11
Day = inputDay - tishri1 + 89 day = input_day - tishri1 + 89
elif inputDay > tishri1 - 119: elif input_day > tishri1 - 119:
Month = 10 month = 10
Day = inputDay - tishri1 + 119 day = input_day - tishri1 + 119
elif inputDay > tishri1 - 148: elif input_day > tishri1 - 148:
Month = 9 month = 9
Day = inputDay - tishri1 + 148 day = input_day - tishri1 + 148
else: else:
Month = 8 month = 8
Day = inputDay - tishri1 + 178 day = input_day - tishri1 + 178
return (Year,Month,Day) return (year, month, day)
else: else:
if _HBR_MONTHS_PER_YEAR[(Year - 1) % 19] == 13: if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 13:
Month = 7 month = 7
Day = inputDay - tishri1 + 207 day = input_day - tishri1 + 207
if Day > 0: if day > 0:
return (Year,Month,Day) return (year, month, day)
Month = Month - 1 month = month - 1
Day = Day + 30 day = day + 30
if Day > 0: if day > 0:
return (Year,Month,Day) return (year, month, day)
Month = Month - 1 month = month - 1
Day = Day + 30 day = day + 30
else: else:
Month = 6 month = 6
Day = inputDay - tishri1 + 207 day = input_day - tishri1 + 207
if Day > 0: if day > 0:
return (Year,Month,Day) return (year, month, day)
Month = Month - 1 month = month - 1
Day = Day + 30 day = day + 30
if Day > 0: if day > 0:
return (Year,Month,Day) return (year, month, day)
Month = Month - 1 month = month - 1
Day = Day + 29 day = day + 29
if Day > 0: if day > 0:
return (Year,Month,Day) return (year, month, day)
# We need the length of the year to figure this out, so find # We need the length of the year to figure this out, so find
# Tishri 1 of this year # Tishri 1 of this year
tishri1After = tishri1; tishri1_after = tishri1;
(metonicCycle,metonicYear,day,halakim) = _tishri_molad(day-365) (metonic_cycle, metonic_year, day, halakim) = _tishri_molad(day-365)
tishri1 = _tishri1(metonicYear, day, halakim) tishri1 = _tishri1(metonic_year, day, halakim)
yearLength = tishri1After - tishri1; year_length = tishri1_after - tishri1;
cday = inputDay - tishri1 - 29; cday = input_day - tishri1 - 29;
if yearLength == 355 or yearLength == 385 : if year_length == 355 or year_length == 385 :
# Heshvan has 30 days # Heshvan has 30 days
if day <= 30: if day <= 30:
Month = 2 month = 2
Day = cday day = cday
return (Year,Month,Day) return (year, month, day)
day = day - 30 day = day - 30
else: else:
# Heshvan has 29 days # Heshvan has 29 days
if day <= 29: if day <= 29:
Month = 2 month = 2
Day = cday day = cday
return (Year,Month,Day) return (year, month, day)
cday = cday - 29 cday = cday - 29
# It has to be Kislev # 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""" """Converts a Julian calendar date to an SDN number"""
if year < 0: if year < 0:
@ -403,9 +405,9 @@ def julian_ymd(sdn):
if year <= 0: if year <= 0:
year -= 1 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""" """Converts a gregorian date to an SDN number"""
if year < 0: if year < 0:
year += 4801 year += 4801
@ -453,9 +455,9 @@ def gregorian_ymd(sdn):
year = year - 4800 year = year - 4800
if year <= 0: if year <= 0:
year = year - 1 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""" """Converts a French Republican Calendar date to an SDN number"""
return (year*_FR_DAYS_PER_4_YEARS)/4 + \ return (year*_FR_DAYS_PER_4_YEARS)/4 + \
(month-1)*_FR_DAYS_PER_MONTH + \ (month-1)*_FR_DAYS_PER_MONTH + \
@ -468,7 +470,7 @@ def french_ymd(sdn):
day_of_year = (temp%_FR_DAYS_PER_4_YEARS)/4 day_of_year = (temp%_FR_DAYS_PER_4_YEARS)/4
month = (day_of_year/_FR_DAYS_PER_MONTH)+1 month = (day_of_year/_FR_DAYS_PER_MONTH)+1
day = (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): def persian_sdn(year, month, day):
if year >= 0: if year >= 0:
@ -523,6 +525,6 @@ def islamic_sdn(year, month, day):
def islamic_ymd(sdn): def islamic_ymd(sdn):
sdn = math.floor(sdn) + 0.5 sdn = math.floor(sdn) + 0.5
year = int(math.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631)) 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)) 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) day = int((sdn - islamic_sdn(year, month, 1)) + 1)
return (year,month,day) return (year, month, day)

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Event object for GRAMPS Event object for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -43,8 +45,8 @@ from _EventType import EventType
# Event class # Event class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, class Event(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
DateBase,PlaceBase): DateBase, PlaceBase):
""" """
Introduction Introduction
============ ============
@ -53,7 +55,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
such as a birth, death, or marriage. 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 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 @type source: Event
""" """
PrimaryObject.__init__(self,source) PrimaryObject.__init__(self, source)
SourceBase.__init__(self,source) SourceBase.__init__(self, source)
NoteBase.__init__(self,source) NoteBase.__init__(self, source)
MediaBase.__init__(self,source) MediaBase.__init__(self, source)
AttributeBase.__init__(self) AttributeBase.__init__(self)
DateBase.__init__(self,source) DateBase.__init__(self, source)
PlaceBase.__init__(self,source) PlaceBase.__init__(self, source)
if source: if source:
self.description = source.description self.description = source.description
@ -101,7 +103,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
AttributeBase.serialize(self), AttributeBase.serialize(self),
self.change, self.marker.serialize(), self.private) 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 Converts the data held in a tuple created by the serialize method
back into the data in an Event structure. back into the data in an Event structure.
@ -117,22 +119,22 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.marker.unserialize(marker) self.marker.unserialize(marker)
self.type.unserialize(the_type) self.type.unserialize(the_type)
DateBase.unserialize(self,date) DateBase.unserialize(self, date)
MediaBase.unserialize(self,media_list) MediaBase.unserialize(self, media_list)
AttributeBase.unserialize(self,attribute_list) AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self, note)
def _has_handle_reference(self,classname,handle): def _has_handle_reference(self, classname, handle):
if classname == 'Place': if classname == 'Place':
return self.place == handle return self.place == handle
return False 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: if classname == 'Place' and self.place in handle_list:
self.place = "" 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: if classname == 'Place' and self.place == old_handle:
self.place = new_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. @return: Returns the list of all textual attributes of the object.
@rtype: list @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): def get_text_data_child_list(self):
""" """
@ -176,7 +178,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
""" """
ret = [] ret = []
if self.place: if self.place:
ret.append(('Place',self.place)) ret.append(('Place', self.place))
return ret return ret
def get_handle_referents(self): 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() return (the_type == EventType.CUSTOM and date.is_empty()
and not place and not description) 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. 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 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. 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 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 Sets the description of the Event to the passed string. The string
may contain any information. may contain any information.

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Family object for GRAMPS Family object for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# standard python modules # standard python modules
@ -51,7 +53,7 @@ from _FamilyRelType import FamilyRelType
# Family class # Family class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
LdsOrdBase): LdsOrdBase):
""" """
Introduction Introduction
@ -137,23 +139,23 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
for er in event_ref_list] for er in event_ref_list]
self.child_ref_list = [ChildRef().unserialize(cr) self.child_ref_list = [ChildRef().unserialize(cr)
for cr in child_ref_list] for cr in child_ref_list]
MediaBase.unserialize(self,media_list) MediaBase.unserialize(self, media_list)
AttributeBase.unserialize(self,attribute_list) AttributeBase.unserialize(self, attribute_list)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self, note)
LdsOrdBase.unserialize(self,lds_seal_list) LdsOrdBase.unserialize(self, lds_seal_list)
def _has_handle_reference(self,classname,handle): def _has_handle_reference(self, classname, handle):
if classname == 'Event': if classname == 'Event':
return handle in [ref.ref for ref in self.event_ref_list] return handle in [ref.ref for ref in self.event_ref_list]
elif classname == 'Person': elif classname == 'Person':
return handle in ([ref.ref for ref in self.child_ref_list] 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': elif classname == 'Place':
return handle in [ x.place for x in self.lds_ord_list ] return handle in [ x.place for x in self.lds_ord_list ]
return False return False
def _remove_handle_references(self,classname,handle_list): def _remove_handle_references(self, classname, handle_list):
if classname == 'Event': if classname == 'Event':
new_list = [ ref for ref in self.event_ref_list \ new_list = [ ref for ref in self.event_ref_list \
if ref.ref not in handle_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: if x.place in handle_list:
x.place = None 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': if classname == 'Event':
handle_list = [ref.ref for ref in self.event_ref_list] handle_list = [ref.ref for ref in self.event_ref_list]
while old_handle in handle_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. @return: Returns the list of child secondary child objects that may refer sources.
@rtype: list @rtype: list
""" """
check_list = self.media_list + self.attribute_list + self.lds_ord_list + \ check_list = self.media_list + self.attribute_list + \
self.child_ref_list self.lds_ord_list + self.child_ref_list
return check_list return check_list
def get_referenced_handles(self): def get_referenced_handles(self):
@ -234,10 +236,10 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@rtype: list @rtype: list
""" """
ret = [] ret = []
ret += [('Event',ref.ref) for ref in self.event_ref_list] ret += [('Event', ref.ref) for ref in self.event_ref_list]
ret += [('Person',handle) for handle ret += [('Person', handle) for handle
in ([ref.ref for ref in self.child_ref_list] + in ([ref.ref for ref in self.child_ref_list] +
[self.father_handle,self.mother_handle]) [self.father_handle, self.mother_handle])
if handle] if handle]
return ret return ret
@ -251,7 +253,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
""" """
return self.get_sourcref_child_list() + self.source_list 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 Sets the relationship type between the people identified as the
father and mother in the relationship. The type is a tuple whose 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 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 Sets the database handle for L{Person} that corresponds to
male of the relationship. For a same sex relationship, this 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 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 Sets the database handle for L{Person} that corresponds to
male of the relationship. For a same sex relationship, this 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 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 Adds the database handle for L{Person} to the Family's list
of children. of children.
@ -335,11 +337,11 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@param child_ref: Child Reference instance @param child_ref: Child Reference instance
@type child_ref: ChildRef @type child_ref: ChildRef
""" """
if not isinstance(child_ref,ChildRef): if not isinstance(child_ref, ChildRef):
raise ValueError("expecting ChildRef instance") raise ValueError("expecting ChildRef instance")
self.child_ref_list.append(child_ref) 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 Removes the database handle for L{Person} to the Family's list
of children if the L{Person} is already in the 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. in the list.
@rtype: bool @rtype: bool
""" """
if not isinstance(child_ref,ChildRef): if not isinstance(child_ref, ChildRef):
raise ValueError("expecting ChildRef instance") raise ValueError("expecting ChildRef instance")
new_list = [ref for ref in self.child_ref_list new_list = [ref for ref in self.child_ref_list
if ref.ref != child_ref.ref ] if ref.ref != child_ref.ref ]
self.child_ref_list = new_list 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 Removes the database handle for L{Person} to the Family's list
of children if the L{Person} is already in the 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 self.child_ref_list = child_ref_list
def add_event_handle(self,event_handle): def add_event_ref(self, event_ref):
warn( "Use add_event_ref instead of add_event_handle", DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
event_ref = EventRef()
event_ref.set_reference_handle(event_handle)
self.add_event_ref(event_ref)
def add_event_ref(self,event_ref):
""" """
Adds the L{EventRef} to the Family instance's L{EventRef} list. Adds the L{EventRef} to the Family instance's L{EventRef} list.
This is accomplished by assigning the L{EventRef} for the valid 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. Person's L{EventRef} list.
@type event_ref: EventRef @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") raise ValueError("Expecting EventRef instance")
self.event_ref_list.append(event_ref) self.event_ref_list.append(event_ref)
def get_event_list(self) : 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 # Wrapper for old API
# remove when transitition done. # remove when transitition done.
event_handle_list = [] event_handle_list = []
@ -434,18 +429,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
""" """
return self.event_ref_list return self.event_ref_list
def set_event_list(self,event_list) : def set_event_ref_list(self, event_ref_list) :
warn( "Use set_event_ref_list instead of set_event_list", DeprecationWarning, 2)
# Wrapper for old API
# remove when transitition done.
event_ref_list = []
for event_handle in event_list:
event_ref = EventRef()
event_ref.set_reference_handle(event_handle)
event_ref_list.append( event_ref)
self.set_event_ref_list(event_ref_list)
def set_event_ref_list(self,event_ref_list) :
""" """
Sets the Family instance's L{EventRef} list to the passed list. Sets the Family instance's L{EventRef} list to the passed list.

View File

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

View File

@ -24,6 +24,8 @@
Gender statistics kept in GRAMPS database. Gender statistics kept in GRAMPS database.
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -42,7 +44,7 @@ class GenderStats:
Gender. This allows the tracking of the liklihood of a person's Gender. This allows the tracking of the liklihood of a person's
given name indicating the gender of the person. given name indicating the gender of the person.
""" """
def __init__ (self,stats={}): def __init__ (self, stats={}):
if stats == None: if stats == None:
self.stats = {} self.stats = {}
else: else:

View File

@ -20,6 +20,12 @@
# $Id$ # $Id$
"""
Base type for all gramps types
"""
__revision__ = "$Revision$"
from gettext import gettext as _ from gettext import gettext as _
def init_map(data, key_col, data_col): def init_map(data, key_col, data_col):
@ -41,10 +47,12 @@ class GrampsType:
_E2IMAP = init_map(_DATAMAP, 2, 0) _E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None): def __init__(self, value=None):
self.value = None
self.string = None
self.set(value) self.set(value)
def set(self, value): def set(self, value):
if isinstance(value,self.__class__): if isinstance(value, self.__class__):
self.val = value.val self.val = value.val
self.string = value.string self.string = value.string
elif type(value) == tuple: elif type(value) == tuple:
@ -54,7 +62,7 @@ class GrampsType:
self.val = value self.val = value
self.string = '' self.string = ''
elif type(value) in (str,unicode): 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: if self.val == self._CUSTOM:
self.string = value self.string = value
else: else:
@ -86,16 +94,22 @@ class GrampsType:
return self._I2EMAP[self.val] return self._I2EMAP[self.val]
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.val, self.string) return (self.val, self.string)
def unserialize(self, data): def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
self.val, self.string = data self.val, self.string = data
def __str__(self): def __str__(self):
if self.val == self._CUSTOM: if self.val == self._CUSTOM:
return self.string return self.string
else: else:
return self._I2SMAP.get(self.val,_('Unknown')) return self._I2SMAP.get(self.val, _('Unknown'))
def __int__(self): def __int__(self):
return self.val return self.val
@ -107,14 +121,14 @@ class GrampsType:
""" """
Return the list of localized names for all standard types. 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()] if (i != self._CUSTOM) and s.strip()]
def get_standard_xml(self): def get_standard_xml(self):
""" """
Return the list of XML (english) names for all standard types. 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()] if (i != self._CUSTOM) and s.strip()]
def is_custom(self): def is_custom(self):
@ -128,16 +142,16 @@ class GrampsType:
def __cmp__(self, value): def __cmp__(self, value):
if type(value) == int: if type(value) == int:
return cmp(self.val,value) return cmp(self.val, value)
elif type(value) in (str,unicode): elif type(value) in (str, unicode):
if self.val == self._CUSTOM: if self.val == self._CUSTOM:
return cmp(self.string,value) return cmp(self.string, value)
else: else:
return cmp(self._I2SMAP.get(self.val),value) return cmp(self._I2SMAP.get(self.val), value)
elif type(value) == tuple: elif type(value) == tuple:
return cmp((self.val,self.string),value) return cmp((self.val, self.string), value)
else: else:
if value.val == self._CUSTOM: if value.val == self._CUSTOM:
return cmp(self.string,value.string) return cmp(self.string, value.string)
else: else:
return cmp(self.val,value.val) return cmp(self.val, value.val)

View File

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

View File

@ -24,6 +24,8 @@
LdsOrdBase class for GRAMPS LdsOrdBase class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -41,7 +43,7 @@ class LdsOrdBase:
Base class for lds_ord-aware objects. 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 Initialize a LdsOrdBase. If the source is not None, then object
is initialized from values of the source object. is initialized from values of the source object.
@ -57,12 +59,18 @@ class LdsOrdBase:
self.lds_ord_list = [] self.lds_ord_list = []
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [lds_ord.serialize() for lds_ord in self.lds_ord_list] 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] 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 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) 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 Removes the specified L{LdsOrd} instance from the lds_ord list
If the instance does not exist in the list, the operation has If the instance does not exist in the list, the operation has
@ -98,7 +106,7 @@ class LdsOrdBase:
""" """
return self.lds_ord_list 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. 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 @param lds_ord_list: List of L{LdsOrd} instances to be associated

View File

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

View File

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

View File

@ -19,24 +19,33 @@
# #
# $Id$ # $Id$
"""
Marker types
"""
__revision__ = "$Revision$"
from _GrampsType import GrampsType, init_map from _GrampsType import GrampsType, init_map
from gettext import gettext as _ from gettext import gettext as _
class MarkerType(GrampsType): class MarkerType(GrampsType):
"""
Class for handling data markers.
"""
NONE = -1 NONE = -1
CUSTOM = 0 CUSTOM = 0
COMPLETE = 1 COMPLETE = 1
TODO = 2 TODO_TYPE = 2
_CUSTOM = CUSTOM _CUSTOM = CUSTOM
_DEFAULT = NONE _DEFAULT = NONE
_DATAMAP = [ _DATAMAP = [
(NONE, "", ""), (NONE, "", ""),
(CUSTOM, _("Custom"), "Custom"), (CUSTOM, _("Custom"), "Custom"),
(COMPLETE, _("Complete"), "Complete"), (COMPLETE, _("Complete"), "Complete"),
(TODO, _("ToDo"), "ToDo"), (TODO_TYPE, _("ToDo"), "ToDo"),
] ]
_I2SMAP = init_map(_DATAMAP, 0, 1) _I2SMAP = init_map(_DATAMAP, 0, 1)
@ -48,7 +57,10 @@ class MarkerType(GrampsType):
GrampsType.__init__(self, value) GrampsType.__init__(self, value)
def set(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 == '': if value.val == self.CUSTOM and value.string == '':
self.val = self.NONE self.val = self.NONE
self.string = '' self.string = ''
@ -66,7 +78,7 @@ class MarkerType(GrampsType):
self.val = value self.val = value
self.string = '' self.string = ''
elif type(value) == str: 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: if self.val == self._CUSTOM:
self.string = value self.string = value
else: else:

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Name class for GRAMPS Name class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -41,7 +43,7 @@ from _NameType import NameType
# Personal Name # Personal Name
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase): class Name(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase):
""" """
Provides name information about a person. Provides name information about a person.
@ -54,24 +56,24 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
PTFN = 3 # patronymic first name PTFN = 3 # patronymic first name
FN = 4 # 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""" """creates a new Name instance, copying from the source if provided"""
SecondaryObject.__init__(self) SecondaryObject.__init__(self)
PrivacyBase.__init__(self, source)
SourceBase.__init__(self, source)
NoteBase.__init__(self, source)
DateBase.__init__(self, source)
if data: if data:
(privacy,source_list,note,date, (privacy, source_list, note, date,
self.first_name,self.surname,self.suffix,self.title, self.first_name, self.surname, self.suffix, self.title,
name_type,self.prefix,self.patronymic, name_type, self.prefix, self.patronymic,
self.group_as,self.sort_as,self.display_as,self.call) = data self.group_as, self.sort_as, self.display_as, self.call) = data
self.type = NameType(name_type) self.type = NameType(name_type)
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self, note)
DateBase.unserialize(self,date) DateBase.unserialize(self, date)
elif source: 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.first_name = source.first_name
self.surname = source.surname self.surname = source.surname
self.suffix = source.suffix self.suffix = source.suffix
@ -84,10 +86,6 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.display_as = source.display_as self.display_as = source.display_as
self.call = source.call self.call = source.call
else: else:
PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
DateBase.__init__(self,source)
self.first_name = "" self.first_name = ""
self.surname = "" self.surname = ""
self.suffix = "" self.suffix = ""
@ -101,29 +99,38 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.call = '' self.call = ''
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (PrivacyBase.serialize(self), return (PrivacyBase.serialize(self),
SourceBase.serialize(self), SourceBase.serialize(self),
NoteBase.serialize(self), NoteBase.serialize(self),
DateBase.serialize(self), DateBase.serialize(self),
self.first_name,self.surname,self.suffix,self.title, self.first_name, self.surname, self.suffix, self.title,
self.type.serialize(),self.prefix,self.patronymic, self.type.serialize(), self.prefix, self.patronymic,
self.group_as,self.sort_as,self.display_as,self.call) self.group_as, self.sort_as, self.display_as, self.call)
def is_empty(self): def is_empty(self):
return (self.first_name == u"" and self.surname == u"" and """
self.suffix == u"" and self.title == u"" and Indicates if the name is empty
self.prefix == u"" and self.patronymic == u"") """
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): def unserialize(self, data):
(privacy,source_list,note,date, """
self.first_name,self.surname,self.suffix,self.title, Converts a serialized tuple of data to an object
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.unserialize(name_type) self.type.unserialize(name_type)
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self, privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self, note)
DateBase.unserialize(self,date) DateBase.unserialize(self, date)
return self return self
def get_text_data_list(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. @return: Returns the list of all textual attributes of the object.
@rtype: list @rtype: list
""" """
return [self.first_name,self.surname,self.suffix,self.title, return [self.first_name, self.surname, self.suffix, self.title,
str(self.type),self.prefix,self.patronymic, self.call] str(self.type), self.prefix, self.patronymic, self.call]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -158,7 +165,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
""" """
return self.source_list 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 Sets the grouping name for a person. Normally, this is the person's
surname. However, some locales group equivalent names (e.g. Ivanova surname. However, some locales group equivalent names (e.g. Ivanova
@ -184,7 +191,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
else: else:
return self.surname 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 Specifies the sorting method for the specified name. Typically the
locale's default should be used. However, there may be names where 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 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 Specifies the display format for the specified name. Typically the
locale's default should be used. However, there may be names where 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 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, Returns the call name. The call name's exact definition is not predetermined,
and may be locale specific. and may be locale specific.
@ -235,14 +242,14 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
""" """
return self.prefix 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 Sets the prefix (or article) of a surname. Examples of articles
would be 'de' or 'van'. would be 'de' or 'van'.
""" """
self.prefix = val self.prefix = val
def set_type(self,the_type): def set_type(self, the_type):
"""sets the type of the Name instance""" """sets the type of the Name instance"""
self.type.set(the_type) self.type.set(the_type)
@ -250,19 +257,19 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""returns the type of the Name instance""" """returns the type of the Name instance"""
return self.type return self.type
def set_first_name(self,name): def set_first_name(self, name):
"""sets the given name for the Name instance""" """sets the given name for the Name instance"""
self.first_name = name self.first_name = name
def set_patronymic(self,name): def set_patronymic(self, name):
"""sets the patronymic name for the Name instance""" """sets the patronymic name for the Name instance"""
self.patronymic = name self.patronymic = name
def set_surname(self,name): def set_surname(self, name):
"""sets the surname (or last name) for the Name instance""" """sets the surname (or last name) for the Name instance"""
self.surname = name 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""" """sets the suffix (such as Jr., III, etc.) for the Name instance"""
self.suffix = name self.suffix = name
@ -286,7 +293,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
"""returns the suffix for the Name instance""" """returns the suffix for the Name instance"""
return self.suffix return self.suffix
def set_title(self,title): def set_title(self, title):
"""sets the title (Dr., Reverand, Captain) for the Name instance""" """sets the title (Dr., Reverand, Captain) for the Name instance"""
self.title = title self.title = title
@ -304,12 +311,13 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
first = self.first_name first = self.first_name
if self.suffix: if self.suffix:
if self.prefix: 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: else:
return "%s, %s %s" % (self.surname, first, self.suffix) return "%s, %s %s" % (self.surname, first, self.suffix)
else: else:
if self.prefix: if self.prefix:
return "%s %s, %s" % (self.prefix,self.surname, first) return "%s %s, %s" % (self.prefix, self.surname, first)
else: else:
return "%s, %s" % (self.surname, first) return "%s, %s" % (self.surname, first)
@ -323,12 +331,16 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
first = self.first_name first = self.first_name
if self.suffix: if self.suffix:
if self.prefix: 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: else:
return "%s, %s %s" % (self.surname.upper(), first, self.suffix) return "%s, %s %s" % (self.surname.upper(), first, self.suffix)
else: else:
if self.prefix: 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: else:
return "%s, %s" % (self.surname.upper(), first) return "%s, %s" % (self.surname.upper(), first)
@ -346,6 +358,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
return "%s %s" % (first, self.surname) return "%s %s" % (first, self.surname)
else: else:
if self.prefix: 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: else:
return "%s %s, %s" % (first, self.surname, self.suffix) return "%s %s, %s" % (first, self.surname, self.suffix)

View File

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

View File

@ -24,6 +24,8 @@
Note class for GRAMPS Note class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -45,7 +47,7 @@ class Note(SecondaryObject):
to be in paragraphs, separated by newlines. 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. Creates a new Note object, initializing from the passed string.
""" """
@ -54,11 +56,17 @@ class Note(SecondaryObject):
self.format = 0 self.format = 0
def serialize(self): 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: if data:
(self.text,self.format) = data (self.text, self.format) = data
return self return self
def get_text_data_list(self): def get_text_data_list(self):
@ -70,7 +78,7 @@ class Note(SecondaryObject):
""" """
return [self.text] return [self.text]
def set(self,text): def set(self, text):
""" """
Sets the text associated with the note to the passed string. Sets the text associated with the note to the passed string.
@ -87,7 +95,7 @@ class Note(SecondaryObject):
""" """
return self.text return self.text
def append(self,text): def append(self, text):
""" """
Appends the specified text to the text associated with the note. Appends the specified text to the text associated with the note.
@ -96,7 +104,7 @@ class Note(SecondaryObject):
""" """
self.text = self.text + text 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 Sets the format of the note to the passed value. The value can
either indicate Flowed or Preformatted. either indicate Flowed or Preformatted.

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Place object for GRAMPS Place object for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -43,25 +45,25 @@ _EMPTY_LOC = Location().serialize()
# Place class # 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 Contains information related to a place, including multiple address
information (since place names can change with time), longitude, latitude, information (since place names can change with time), longitude, latitude,
a collection of images and URLs, a note and a source 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. Creates a new Place object, copying from the source if present.
@param source: A Place object used to initialize the new Place @param source: A Place object used to initialize the new Place
@type source: Place @type source: Place
""" """
PrimaryObject.__init__(self,source) PrimaryObject.__init__(self, source)
SourceBase.__init__(self,source) SourceBase.__init__(self, source)
NoteBase.__init__(self,source) NoteBase.__init__(self, source)
MediaBase.__init__(self,source) MediaBase.__init__(self, source)
UrlBase.__init__(self,source) UrlBase.__init__(self, source)
if source: if source:
self.long = source.long self.long = source.long
self.lat = source.lat self.lat = source.lat
@ -105,7 +107,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
NoteBase.serialize(self), NoteBase.serialize(self),
self.change, self.marker.serialize() ,self.private) 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 Converts the data held in a tuple created by the serialize method
back into the data in a Place object. 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.main_loc = Location().unserialize(main_loc)
self.alt_loc = [Location().unserialize(al) for al in alt_loc] self.alt_loc = [Location().unserialize(al) for al in alt_loc]
self.marker.unserialize(marker) self.marker.unserialize(marker)
UrlBase.unserialize(self,urls) UrlBase.unserialize(self, urls)
MediaBase.unserialize(self,media_list) MediaBase.unserialize(self, media_list)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self, source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self, note)
def get_text_data_list(self): 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. @return: Returns the list of all textual attributes of the object.
@rtype: list @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): def get_text_data_child_list(self):
""" """
@ -146,7 +148,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
@rtype: list @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] add_list = [item for item in check_list if item]
return self.media_list + self.source_list + self.alt_loc \ return self.media_list + self.source_list + self.alt_loc \
+ self.urls + add_list + self.urls + add_list
@ -170,7 +172,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
""" """
return self.media_list + self.source_list 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 Sets the descriptive title of the Place object
@ -188,7 +190,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
""" """
return self.title return self.title
def set_longitude(self,longitude): def set_longitude(self, longitude):
""" """
Sets the longitude of the Place object Sets the longitude of the Place object
@ -206,7 +208,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
""" """
return self.long return self.long
def set_latitude(self,latitude): def set_latitude(self, latitude):
""" """
Sets the latitude of the Place object Sets the latitude of the Place object
@ -238,7 +240,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
self.main_loc = Location() self.main_loc = Location()
return self.main_loc 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} Assigns the main location information about the Place to the L{Location}
object passed object passed
@ -260,7 +262,7 @@ class Place(PrimaryObject,SourceBase,NoteBase,MediaBase,UrlBase):
""" """
return self.alt_loc 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. 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 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 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: if self.main_loc:
return [self.title,self.gramps_id,self.main_loc.parish, return [self.title, self.gramps_id, self.main_loc.parish,
self.main_loc.city,self.main_loc.county, self.main_loc.city, self.main_loc.county,
self.main_loc.state,self.main_loc.country, self.main_loc.state, self.main_loc.country,
self.title.upper(), self.main_loc.parish.upper(), self.title.upper(), self.main_loc.parish.upper(),
self.main_loc.city.upper(), self.main_loc.county.upper(), self.main_loc.city.upper(), self.main_loc.county.upper(),
self.main_loc.state.upper(), self.main_loc.country.upper()] self.main_loc.state.upper(), self.main_loc.country.upper()]
else: else:
return [self.title,self.gramps_id,'','','','','', return [self.title, self.gramps_id, '', '', '', '', '',
self.title.upper(), '','','','',''] self.title.upper(), '', '', '', '', '']

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Researcher informaiton for GRAMPS. Researcher informaiton for GRAMPS.
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -59,7 +61,7 @@ class Researcher(LocationBase):
"""returns the database owner's email""" """returns the database owner's email"""
return self.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""" """sets the information about the database owner"""
if name: if name:
self.name = name.strip() self.name = name.strip()

View File

@ -24,6 +24,8 @@
Secondary Object class for GRAMPS Secondary Object class for GRAMPS
""" """
__revision__ = "$Revision: $"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -45,7 +47,7 @@ class SecondaryObject(BaseObject):
ID is the user visible version. 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 Initialize a SecondaryObject. If source is None, both the ID and handle
are assigned as empty strings. If source is not None, then object are assigned as empty strings. If source is not None, then object
@ -57,4 +59,4 @@ class SecondaryObject(BaseObject):
BaseObject.__init__(self) BaseObject.__init__(self)
def is_equal(self, source): 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 Source object for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -40,7 +42,7 @@ from _RepoRef import RepoRef
# Source class # Source class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Source(PrimaryObject,MediaBase,NoteBase): class Source(PrimaryObject, MediaBase, NoteBase):
"""A record of a source of information""" """A record of a source of information"""
def __init__(self): def __init__(self):
@ -57,6 +59,9 @@ class Source(PrimaryObject,MediaBase,NoteBase):
self.reporef_list = [] self.reporef_list = []
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (self.handle, self.gramps_id, unicode(self.title), return (self.handle, self.gramps_id, unicode(self.title),
unicode(self.author), unicode(self.pubinfo), unicode(self.author), unicode(self.pubinfo),
NoteBase.serialize(self), NoteBase.serialize(self),
@ -65,7 +70,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
[rr.serialize() for rr in self.reporef_list], [rr.serialize() for rr in self.reporef_list],
self.marker.serialize(),self.private) 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 Converts the data held in a tuple created by the serialize method
back into the data in an Event structure. back into the data in an Event structure.
@ -76,8 +81,8 @@ class Source(PrimaryObject,MediaBase,NoteBase):
marker, self.private) = data marker, self.private) = data
self.marker.unserialize(marker) self.marker.unserialize(marker)
NoteBase.unserialize(self,note) NoteBase.unserialize(self, note)
MediaBase.unserialize(self,media_list) MediaBase.unserialize(self, media_list)
self.reporef_list = [RepoRef().unserialize(rr) for rr in reporef_list] self.reporef_list = [RepoRef().unserialize(rr) for rr in reporef_list]
def get_text_data_list(self): 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. @return: Returns the list of all textual attributes of the object.
@rtype: list @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() self.gramps_id] + self.datamap.keys() + self.datamap.values()
def get_text_data_child_list(self): def get_text_data_child_list(self):
@ -121,7 +126,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
""" """
return self.media_list + self.reporef_list 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 Returns True if any of the child objects has reference
to this source handle. to this source handle.
@ -137,7 +142,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
return False 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 Removes references to all source handles in the list
in all child objects. in all child objects.
@ -148,7 +153,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
for item in self.get_sourcref_child_list(): for item in self.get_sourcref_child_list():
item.remove_source_references(src_handle_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 Replaces references to source handles in the list
in this object and all child objects. in this object and all child objects.
@ -159,21 +164,21 @@ class Source(PrimaryObject,MediaBase,NoteBase):
@type new_handle: str @type new_handle: str
""" """
for item in self.get_sourcref_child_list(): 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): def get_data_map(self):
"""Returns the data map of attributes for the source""" """Returns the data map of attributes for the source"""
return self.datamap return self.datamap
def set_data_map(self,datamap): def set_data_map(self, datamap):
"""Sets the data map of attributes for the source""" """Sets the data map of attributes for the source"""
self.datamap = datamap 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""" """Sets the particular data item in the attribute data map"""
self.datamap[key] = value self.datamap[key] = value
def set_title(self,title): def set_title(self, title):
""" """
Sets the descriptive title of the Source object Sets the descriptive title of the Source object
@ -191,7 +196,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
""" """
return self.title return self.title
def set_author(self,author): def set_author(self, author):
"""sets the author of the Source""" """sets the author of the Source"""
self.author = author self.author = author
@ -199,7 +204,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""returns the author of the Source""" """returns the author of the Source"""
return self.author return self.author
def set_publication_info(self,text): def set_publication_info(self, text):
"""sets the publication information of the Source""" """sets the publication information of the Source"""
self.pubinfo = text self.pubinfo = text
@ -207,7 +212,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""returns the publication information of the Source""" """returns the publication information of the Source"""
return self.pubinfo return self.pubinfo
def set_abbreviation(self,abbrev): def set_abbreviation(self, abbrev):
"""sets the title abbreviation of the Source""" """sets the title abbreviation of the Source"""
self.abbrev = abbrev self.abbrev = abbrev
@ -215,7 +220,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
"""returns the title abbreviation of the Source""" """returns the title abbreviation of the Source"""
return self.abbrev 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. Adds a L{RepoRef} instance to the Source's reporef list.
@ -233,7 +238,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
""" """
return self.reporef_list 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. Sets the list of L{RepoRef} instances associated with the Source.
It replaces the previous list. It replaces the previous list.
@ -243,7 +248,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
""" """
self.reporef_list = reporef_list 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. 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] 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. 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 ] if repo_ref.ref not in repo_handle_list ]
self.reporef_list = new_reporef_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. Replaces all references to old Repository handle with the new handle.

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
Source Reference class for GRAMPS Source Reference class for GRAMPS
""" """
__revision__ = "$Revision$"
from warnings import warn from warnings import warn
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -42,7 +44,7 @@ from _RefBase import RefBase
# Source References for all primary objects # 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 """Source reference, containing detailed information about how a
referenced source relates to it""" referenced source relates to it"""
@ -52,13 +54,13 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
CONF_LOW = 1 CONF_LOW = 1
CONF_VERY_LOW = 0 CONF_VERY_LOW = 0
def __init__(self,source=None): def __init__(self, source=None):
"""creates a new SourceRef, copying from the source if present""" """creates a new SourceRef, copying from the source if present"""
SecondaryObject.__init__(self) SecondaryObject.__init__(self)
DateBase.__init__(self,source) DateBase.__init__(self, source)
PrivacyBase.__init__(self,source) PrivacyBase.__init__(self, source)
NoteBase.__init__(self,source) NoteBase.__init__(self, source)
RefBase.__init__(self,source) RefBase.__init__(self, source)
if source: if source:
self.confidence = source.confidence self.confidence = source.confidence
self.page = source.page self.page = source.page
@ -69,20 +71,26 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
self.text = "" self.text = ""
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return (DateBase.serialize(self), return (DateBase.serialize(self),
PrivacyBase.serialize(self), PrivacyBase.serialize(self),
NoteBase.serialize(self), NoteBase.serialize(self),
self.confidence, self.confidence,
RefBase.serialize(self), RefBase.serialize(self),
self.page,self.text) self.page, self.text)
def unserialize(self,data): def unserialize(self, data):
(date,privacy,note, """
self.confidence,ref,self.page,self.text) = data Converts a serialized tuple of data to an object
DateBase.unserialize(self,date) """
PrivacyBase.unserialize(self,privacy) (date, privacy, note,
NoteBase.unserialize(self,note) self.confidence, ref, self.page, self.text) = data
RefBase.unserialize(self,ref) DateBase.unserialize(self, date)
PrivacyBase.unserialize(self, privacy)
NoteBase.unserialize(self, note)
RefBase.unserialize(self, ref)
return self return self
def get_text_data_list(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. @return: Returns the list of all textual attributes of the object.
@rtype: list @rtype: list
""" """
return [self.page,self.text] return [self.page, self.text]
#return [self.page,self.text,self.get_date()]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -113,11 +120,11 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
@rtype: list @rtype: list
""" """
if self.ref: if self.ref:
return [('Source',self.ref)] return [('Source', self.ref)]
else: else:
return [] return []
def set_confidence_level(self,val): def set_confidence_level(self, val):
"""Sets the confidence level""" """Sets the confidence level"""
self.confidence = val self.confidence = val
@ -125,7 +132,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""Returns the confidence level""" """Returns the confidence level"""
return self.confidence return self.confidence
def set_page(self,page): def set_page(self, page):
"""sets the page indicator of the SourceRef""" """sets the page indicator of the SourceRef"""
self.page = page self.page = page
@ -133,7 +140,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""gets the page indicator of the SourceRef""" """gets the page indicator of the SourceRef"""
return self.page return self.page
def set_text(self,text): def set_text(self, text):
"""sets the text related to the SourceRef""" """sets the text related to the SourceRef"""
self.text = text self.text = text
@ -141,6 +148,7 @@ class SourceRef(SecondaryObject,DateBase,PrivacyBase,NoteBase,RefBase):
"""returns the text related to the SourceRef""" """returns the text related to the SourceRef"""
return self.text 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) warn( "Use is_equal instead of are_equal", DeprecationWarning, 2)
return self.is_equal(other) return self.is_equal(other)

View File

@ -24,6 +24,8 @@
Url class for GRAMPS Url class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# standard python modules # standard python modules
@ -45,14 +47,14 @@ from _UrlType import UrlType
# Url for Person/Place/Repository # Url for Person/Place/Repository
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Url(SecondaryObject,PrivacyBase): class Url(SecondaryObject, PrivacyBase):
"""Contains information related to internet Uniform Resource Locators, """Contains information related to internet Uniform Resource Locators,
allowing gramps to store information about internet resources""" 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""" """creates a new URL instance, copying from the source if present"""
SecondaryObject.__init__(self) SecondaryObject.__init__(self)
PrivacyBase.__init__(self,source) PrivacyBase.__init__(self, source)
if source: if source:
self.path = source.path self.path = source.path
self.desc = source.desc self.desc = source.desc
@ -65,8 +67,8 @@ class Url(SecondaryObject,PrivacyBase):
def serialize(self): def serialize(self):
return (self.private,self.path,self.desc,self.type.serialize()) return (self.private,self.path,self.desc,self.type.serialize())
def unserialize(self,data): def unserialize(self, data):
(self.private,self.path,self.desc,type_value) = data (self.private, self.path, self.desc, type_value) = data
self.type.unserialize(type_value) self.type.unserialize(type_value)
return self return self
@ -77,9 +79,9 @@ class Url(SecondaryObject,PrivacyBase):
@return: Returns the list of all textual attributes of the object. @return: Returns the list of all textual attributes of the object.
@rtype: list @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""" """sets the URL path"""
self.path = path self.path = path
@ -87,7 +89,7 @@ class Url(SecondaryObject,PrivacyBase):
"""returns the URL path""" """returns the URL path"""
return self.path return self.path
def set_description(self,description): def set_description(self, description):
"""sets the description of the URL""" """sets the description of the URL"""
self.desc = description self.desc = description
@ -95,7 +97,7 @@ class Url(SecondaryObject,PrivacyBase):
"""returns the description of the URL""" """returns the description of the URL"""
return self.desc return self.desc
def set_type(self,the_type): def set_type(self, the_type):
""" """
@param the_type: descriptive type of the Url @param the_type: descriptive type of the Url
@type the_type: str @type the_type: str
@ -109,6 +111,8 @@ class Url(SecondaryObject,PrivacyBase):
""" """
return self.type 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) warn( "Use is_equal instead of are_equal", DeprecationWarning, 2)
return self.is_equal(other) return self.is_equal(other)

View File

@ -24,6 +24,8 @@
UrlBase class for GRAMPS UrlBase class for GRAMPS
""" """
__revision__ = "$Revision$"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -41,7 +43,7 @@ class UrlBase:
Base class for url-aware objects. 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 Initialize an UrlBase. If the source is not None, then object
is initialized from values of the source object. is initialized from values of the source object.
@ -56,9 +58,15 @@ class UrlBase:
self.urls = [] self.urls = []
def serialize(self): def serialize(self):
"""
Converts the object to a serialized tuple of data
"""
return [url.serialize() for url in self.urls] 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] self.urls = [Url().unserialize(item) for item in data]
def get_url_list(self): def get_url_list(self):
@ -70,7 +78,7 @@ class UrlBase:
""" """
return self.urls 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. Sets the list of L{Url} instances to passed the list.
@ -79,7 +87,7 @@ class UrlBase:
""" """
self.urls = url_list 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 Adds a L{Url} instance to the object's list of L{Url} instances
@ -89,8 +97,7 @@ class UrlBase:
""" """
self.urls.append(url) self.urls.append(url)
def remove_url(self, url):
def remove_url(self,url):
""" """
Removes the specified L{Url} instance from the url list Removes the specified L{Url} instance from the url list
If the instance does not exist in the list, the operation has If the instance does not exist in the list, the operation has

View File

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

View File

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

View File

@ -24,6 +24,7 @@
__author__ = "Donald N. Allingham" __author__ = "Donald N. Allingham"
__version__ = "$Revision$" __version__ = "$Revision$"
__revision__ = "$Revision$"
# Dates # Dates
from _Date import Date, DateError 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: if death_year > current_year + 110:
# person died more tha 110 after current year # person died more tha 110 after current year
return False return False
# Neither birth nor death events are available. Try looking # Neither birth nor death events are available. Try looking
# for descendants that were born more than a lifespan ago. # at siblings. If a sibling was born more than 120 years past,
# or more than 20 future, then problem then this person is
# probably not alive. If the sibling died more than 120 years
# past, or more than 120 years future, then probably not alive.
family_list = person.get_parent_family_handle_list()
for family_handle in family_list:
family = db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():
child_handle = child_ref.ref
child = db.get_person_from_handle(child_handle)
child_birth_ref = child.get_birth_ref()
if child_birth_ref:
child_birth = db.get_event_from_handle(child_birth_ref.ref)
dobj = child_birth.get_date_object()
if dobj.get_start_date() != RelLib.Date.EMPTY:
# if sibling birth date too far away, then not alive:
year = dobj.get_year()
if year != 0:
if not (current_year - 120 < year < current_year + 20):
return False
child_death_ref = child.get_death_ref()
if child_death_ref:
child_death = db.get_event_from_handle(child_death_ref.ref)
dobj = child_death.get_date_object()
if dobj.get_start_date() != RelLib.Date.EMPTY:
# if sibling death date too far away, then not alive:
year = dobj.get_year()
if year != 0:
if not (current_year - 120 < year < current_year + 120):
return False
# Try looking for descendants that were born more than a lifespan
# ago.
min_generation = 13 min_generation = 13