2006-04-04 23:37:23 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2006-04-21 00:00:28 +05:30
|
|
|
# $Id$
|
2006-04-04 23:37:23 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
LdsOrdBase class for GRAMPS
|
|
|
|
"""
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
__revision__ = "$Revision$"
|
|
|
|
|
2006-04-04 23:37:23 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from _LdsOrd import LdsOrd
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# LdsOrdBase classes
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class LdsOrdBase:
|
|
|
|
"""
|
|
|
|
Base class for lds_ord-aware objects.
|
|
|
|
"""
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def __init__(self, source=None):
|
2006-04-04 23:37:23 +05:30
|
|
|
"""
|
|
|
|
Initialize a LdsOrdBase. If the 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: LdsOrdBase
|
|
|
|
"""
|
|
|
|
|
|
|
|
if source:
|
|
|
|
self.lds_ord_list = [ LdsOrd(lds_ord) \
|
|
|
|
for lds_ord in source.lds_ord_list ]
|
|
|
|
else:
|
|
|
|
self.lds_ord_list = []
|
|
|
|
|
|
|
|
def serialize(self):
|
2007-01-08 07:19:33 +05:30
|
|
|
"""
|
|
|
|
Converts the object to a serialized tuple of data
|
|
|
|
"""
|
2006-04-05 22:45:44 +05:30
|
|
|
return [lds_ord.serialize() for lds_ord in self.lds_ord_list]
|
2006-04-04 23:37:23 +05:30
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def unserialize(self, data):
|
|
|
|
"""
|
|
|
|
Converts a serialized tuple of data to an object
|
|
|
|
"""
|
2006-04-04 23:37:23 +05:30
|
|
|
self.lds_ord_list = [LdsOrd().unserialize(item) for item in data]
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def add_lds_ord(self, lds_ord):
|
2006-04-04 23:37:23 +05:30
|
|
|
"""
|
|
|
|
Adds the L{LdsOrd} instance to the object's list of lds_ordes
|
|
|
|
|
|
|
|
@param lds_ord: L{LdsOrd} instance to add to the object's lds_ord list
|
|
|
|
@type lds_ord: list
|
|
|
|
"""
|
|
|
|
self.lds_ord_list.append(lds_ord)
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def remove_lds_ord(self, lds_ord):
|
2006-04-04 23:37:23 +05:30
|
|
|
"""
|
|
|
|
Removes the specified L{LdsOrd} instance from the lds_ord list
|
|
|
|
If the instance does not exist in the list, the operation has
|
|
|
|
no effect.
|
|
|
|
|
|
|
|
@param lds_ord: L{LdsOrd} instance to remove from the list
|
|
|
|
@type lds_ord: L{LdsOrd}
|
|
|
|
|
|
|
|
@return: True if the lds_ord was removed, False if it was not in the list.
|
|
|
|
@rtype: bool
|
|
|
|
"""
|
|
|
|
if lds_ord in self.lds_ord_list:
|
|
|
|
self.lds_ord_list.remove(lds_ord)
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_lds_ord_list(self):
|
|
|
|
"""
|
|
|
|
Returns the list of L{LdsOrd} instances associated with the object
|
|
|
|
|
|
|
|
@return: Returns the list of L{LdsOrd} instances
|
|
|
|
@rtype: list
|
|
|
|
"""
|
|
|
|
return self.lds_ord_list
|
|
|
|
|
2007-01-08 07:19:33 +05:30
|
|
|
def set_lds_ord_list(self, lds_ord_list):
|
2006-04-04 23:37:23 +05:30
|
|
|
"""
|
|
|
|
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
|
|
|
|
with the object
|
|
|
|
@type lds_ord_list: list
|
|
|
|
"""
|
|
|
|
self.lds_ord_list = lds_ord_list
|