diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index caa6ee2fe..79a46e84a 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -298,8 +298,12 @@ class GedcomWriter(UpdateCallback): self.private = self.option_box.private if self.private: - import _PrivateProxyDb - self.db = _PrivateProxyDb.PrivateProxyDb(self.db) + from _PrivateProxyDb import PrivateProxyDb + self.db = PrivateProxyDb(self.db) + + if self.restrict: + from _LivingProxyDb import LivingProxyDb + self.db = LivingProxyDb(self.db, LivingProxyDb.MODE_RESTRICT) if self.option_box.cfilter == None: self.plist = set(self.db.get_person_handles(sort_handles=False)) @@ -457,11 +461,7 @@ class GedcomWriter(UpdateCallback): sorted.sort() for data in sorted: - person = self.db.get_person_from_handle(data[1]) - if self.restrict: - if Utils.probably_alive(person, self.db): - person = ExportOptions.restrict_living(person) - self.__write_person(person) + self.__write_person(self.db.get_person_from_handle(data[1])) self.update() def __write_person(self, person): @@ -729,7 +729,6 @@ class GedcomWriter(UpdateCallback): person = self.db.get_person_from_handle(person_handle) gramps_id = person.get_gramps_id() self.__writeln(1, token, '@%s@' % gramps_id) - return Utils.probably_alive(person, self.db) def __write_family(self, family): @@ -1185,8 +1184,6 @@ def exportData(database, filename, person, option_box, callback=None): try: gw = GedcomWriter(database, person, 0, filename, option_box, callback) ret = gw.export_data(filename) -# except AttributeError, msg: -# RunDatabaseRepair(msg) except Errors.DatabaseError, msg: ErrorDialog(_("Export failed"), str(msg)) return ret diff --git a/src/RelLib/_Address.py b/src/RelLib/_Address.py index a45d62aba..83eb8ba57 100644 --- a/src/RelLib/_Address.py +++ b/src/RelLib/_Address.py @@ -50,7 +50,6 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase, def __init__(self, source=None): """Creates a new Address instance, copying from the source if provided""" - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) SourceBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_AddressBase.py b/src/RelLib/_AddressBase.py index 314fa9ec7..1bc6760b1 100644 --- a/src/RelLib/_AddressBase.py +++ b/src/RelLib/_AddressBase.py @@ -51,10 +51,9 @@ class AddressBase: @param source: Object used to initialize the new object @type source: AddressBase """ - if source: self.address_list = [ Address(address) \ - for address in source.address_list ] + for address in source.address_list ] else: self.address_list = [] diff --git a/src/RelLib/_Attribute.py b/src/RelLib/_Attribute.py index 64184ae3d..4c9f399b4 100644 --- a/src/RelLib/_Attribute.py +++ b/src/RelLib/_Attribute.py @@ -50,7 +50,6 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase): """ Creates a new Attribute object, copying from the source if provided. """ - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) SourceBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_AttributeBase.py b/src/RelLib/_AttributeBase.py index 3dbe6ff42..87ea8efdc 100644 --- a/src/RelLib/_AttributeBase.py +++ b/src/RelLib/_AttributeBase.py @@ -51,7 +51,6 @@ class AttributeBase: @param source: Object used to initialize the new object @type source: AttributeBase """ - if source: self.attribute_list = [ Attribute(attribute) \ for attribute in source.attribute_list ] diff --git a/src/RelLib/_BaseObject.py b/src/RelLib/_BaseObject.py index e62e68981..1cabf6cb5 100644 --- a/src/RelLib/_BaseObject.py +++ b/src/RelLib/_BaseObject.py @@ -45,12 +45,6 @@ class BaseObject: to all objects, such as searching through all available information. """ - def __init__(self): - """ - Initialize a BaseObject. - """ - pass - def serialize(self): """ Converts the object to a serialized tuple of data diff --git a/src/RelLib/_BasicPrimaryObject.py b/src/RelLib/_BasicPrimaryObject.py index 96b62346a..51a017b71 100644 --- a/src/RelLib/_BasicPrimaryObject.py +++ b/src/RelLib/_BasicPrimaryObject.py @@ -76,7 +76,6 @@ class BasicPrimaryObject(BaseObject, PrivacyBase): @param source: Object used to initialize the new object @type source: PrimaryObject """ - BaseObject.__init__(self) PrivacyBase.__init__(self, source) if source: self.gramps_id = source.gramps_id diff --git a/src/RelLib/_ChildRef.py b/src/RelLib/_ChildRef.py index 7c5b58c9b..21ead2293 100644 --- a/src/RelLib/_ChildRef.py +++ b/src/RelLib/_ChildRef.py @@ -53,7 +53,6 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase): """ def __init__(self, source=None): - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) SourceBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_Event.py b/src/RelLib/_Event.py index 1c1043f39..b0d15439b 100644 --- a/src/RelLib/_Event.py +++ b/src/RelLib/_Event.py @@ -70,7 +70,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase, AttributeBase.__init__(self) DateBase.__init__(self, source) PlaceBase.__init__(self, source) - + if source: self.description = source.description self.type = source.type diff --git a/src/RelLib/_EventRef.py b/src/RelLib/_EventRef.py index 1aae70643..f3c6c2fdd 100644 --- a/src/RelLib/_EventRef.py +++ b/src/RelLib/_EventRef.py @@ -55,7 +55,6 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase): """ Creates a new EventRef instance, copying from the source if present. """ - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) NoteBase.__init__(self, source) AttributeBase.__init__(self, source) diff --git a/src/RelLib/_GrampsType.py b/src/RelLib/_GrampsType.py index 83678ab61..71df63ff4 100644 --- a/src/RelLib/_GrampsType.py +++ b/src/RelLib/_GrampsType.py @@ -53,26 +53,40 @@ class GrampsType: """ Creates a new type, initialize the value from one of several possible states. """ - self.value = None - self.string = None - self.set(value) + if value: + self.set(value) + else: + self.val = self._DEFAULT + self.string = u'' + + def __set_tuple(self, value): + self.val = value[0] + self.string = value[1] + + def __set_int(self, value): + self.val = value + self.string = u'' + + def __set_instance(self, value): + self.val = value.val + self.string = value.string + + def __set_str(self, value): + self.val = self._S2IMAP.get(value, self._CUSTOM) + if self.val == self._CUSTOM: + self.string = value + else: + self.string = u'' def set(self, value): - if isinstance(value, self.__class__): - self.val = value.val - self.string = value.string - elif type(value) == tuple: - self.val = value[0] - self.string = value[1] + if type(value) == tuple: + self.__set_tuple(value) elif type(value) == int: - self.val = value - self.string = u'' + self.__set_int(value) + elif isinstance(value, self.__class__): + self.__set_instance(value) elif type(value) in (str,unicode): - self.val = self._S2IMAP.get(value, self._CUSTOM) - if self.val == self._CUSTOM: - self.string = value - else: - self.string = u'' + self.__set_str(value) else: self.val = self._DEFAULT self.string = u'' diff --git a/src/RelLib/_LdsOrd.py b/src/RelLib/_LdsOrd.py index be58beda9..d6234b9ab 100644 --- a/src/RelLib/_LdsOrd.py +++ b/src/RelLib/_LdsOrd.py @@ -114,7 +114,6 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase, def __init__(self, source=None): """Creates a LDS Ordinance instance""" - SecondaryObject.__init__(self) SourceBase.__init__(self, source) NoteBase.__init__(self, source) DateBase.__init__(self, source) diff --git a/src/RelLib/_Location.py b/src/RelLib/_Location.py index 37a3e14c3..1269a8609 100644 --- a/src/RelLib/_Location.py +++ b/src/RelLib/_Location.py @@ -52,8 +52,6 @@ class Location(SecondaryObject, LocationBase): """ Creates a Location object, copying from the source object if it exists. """ - - SecondaryObject.__init__(self) LocationBase.__init__(self, source) if source: self.parish = source.parish diff --git a/src/RelLib/_MediaRef.py b/src/RelLib/_MediaRef.py index b81df5223..f98694603 100644 --- a/src/RelLib/_MediaRef.py +++ b/src/RelLib/_MediaRef.py @@ -47,8 +47,6 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase, AttributeBase): """Media reference class""" def __init__(self, source=None): - - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) SourceBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_Name.py b/src/RelLib/_Name.py index b089e6991..db2f0786e 100644 --- a/src/RelLib/_Name.py +++ b/src/RelLib/_Name.py @@ -58,7 +58,6 @@ class Name(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase): def __init__(self, source=None, data=None): """creates a new Name instance, copying from the source if provided""" - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) SourceBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_NoteType.py b/src/RelLib/_NoteType.py index 0ed3afbfe..d7541810e 100644 --- a/src/RelLib/_NoteType.py +++ b/src/RelLib/_NoteType.py @@ -112,7 +112,6 @@ class NoteType(GrampsType): def __init__(self, value=None): GrampsType.__init__(self, value) - def get_ignore_list(self, exception): """ Return a list of the types to ignore and not include in default lists diff --git a/src/RelLib/_Person.py b/src/RelLib/_Person.py index bbb8c15cc..63c25bc16 100644 --- a/src/RelLib/_Person.py +++ b/src/RelLib/_Person.py @@ -84,26 +84,26 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase, data items have empty or null values, including the database handle. """ - PrimaryObject.__init__(self) - SourceBase.__init__(self) - NoteBase.__init__(self) - MediaBase.__init__(self) - AttributeBase.__init__(self) - AddressBase.__init__(self) - UrlBase.__init__(self) - LdsOrdBase.__init__(self) - self.primary_name = Name() - self.event_ref_list = [] - self.family_list = [] - self.parent_family_list = [] - self.alternate_names = [] - self.person_ref_list = [] - self.gender = Person.UNKNOWN - self.death_ref_index = -1 - self.birth_ref_index = -1 - if data: self.unserialize(data) + else: + PrimaryObject.__init__(self) + SourceBase.__init__(self) + NoteBase.__init__(self) + MediaBase.__init__(self) + AttributeBase.__init__(self) + AddressBase.__init__(self) + UrlBase.__init__(self) + LdsOrdBase.__init__(self) + self.primary_name = Name() + self.event_ref_list = [] + self.family_list = [] + self.parent_family_list = [] + self.alternate_names = [] + self.person_ref_list = [] + self.gender = Person.UNKNOWN + self.death_ref_index = -1 + self.birth_ref_index = -1 # We hold a reference to the GrampsDB so that we can maintain # its genderStats. It doesn't get set here, but from diff --git a/src/RelLib/_PersonRef.py b/src/RelLib/_PersonRef.py index ad2917666..8f23ba8d9 100644 --- a/src/RelLib/_PersonRef.py +++ b/src/RelLib/_PersonRef.py @@ -52,7 +52,6 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase): """ def __init__(self, source=None): - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) SourceBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_RepoRef.py b/src/RelLib/_RepoRef.py index b9e650f1f..f16fbacc3 100644 --- a/src/RelLib/_RepoRef.py +++ b/src/RelLib/_RepoRef.py @@ -48,7 +48,6 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase): """ def __init__(self, source=None): - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) NoteBase.__init__(self, source) RefBase.__init__(self, source) diff --git a/src/RelLib/_SecondaryObject.py b/src/RelLib/_SecondaryObject.py index cdb058409..3f0119d3d 100644 --- a/src/RelLib/_SecondaryObject.py +++ b/src/RelLib/_SecondaryObject.py @@ -47,16 +47,5 @@ class SecondaryObject(BaseObject): ID is the user visible version. """ - def __init__(self, source=None): - """ - Initialize a SecondaryObject. If source is None, both the ID and handle - are assigned as empty strings. If source is not None, then object - is initialized from values of the source object. - - @param source: Object used to initialize the new object - @type source: SecondaryObject - """ - BaseObject.__init__(self) - def is_equal(self, source): return cmp(self.serialize(), source.serialize()) == 0 diff --git a/src/RelLib/_Source.py b/src/RelLib/_Source.py index 01d1c61ff..7b50be1e6 100644 --- a/src/RelLib/_Source.py +++ b/src/RelLib/_Source.py @@ -55,7 +55,7 @@ class Source(MediaBase, NoteBase, PrimaryObject): self.datamap = {} self.abbrev = "" self.reporef_list = [] - + def serialize(self): """ Converts the object to a serialized tuple of data diff --git a/src/RelLib/_SourceRef.py b/src/RelLib/_SourceRef.py index 8d1c61d2a..596ea2d3c 100644 --- a/src/RelLib/_SourceRef.py +++ b/src/RelLib/_SourceRef.py @@ -56,7 +56,6 @@ class SourceRef(SecondaryObject, DateBase, PrivacyBase, NoteBase, RefBase): def __init__(self, source=None): """creates a new SourceRef, copying from the source if present""" - SecondaryObject.__init__(self) DateBase.__init__(self, source) PrivacyBase.__init__(self, source) NoteBase.__init__(self, source) diff --git a/src/RelLib/_Url.py b/src/RelLib/_Url.py index ee40140aa..ec3c5cba4 100644 --- a/src/RelLib/_Url.py +++ b/src/RelLib/_Url.py @@ -53,7 +53,6 @@ class Url(SecondaryObject, PrivacyBase): def __init__(self, source=None): """creates a new URL instance, copying from the source if present""" - SecondaryObject.__init__(self) PrivacyBase.__init__(self, source) if source: self.path = source.path