1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """
24 LdsOrdBase class for GRAMPS.
25 """
26
27
28
29
30
31
32 from gen.lib.ldsord import LdsOrd
33
34
35
36
37
38
40 """
41 Base class for lds_ord-aware objects.
42 """
43
45 """
46 Initialize a LdsOrdBase.
47
48 If the source is not None, then object is initialized from values of
49 the source object.
50
51 @param source: Object used to initialize the new object
52 @type source: LdsOrdBase
53 """
54
55 if source:
56 self.lds_ord_list = [ LdsOrd(lds_ord) \
57 for lds_ord in source.lds_ord_list ]
58 else:
59 self.lds_ord_list = []
60
62 """
63 Convert the object to a serialized tuple of data.
64 """
65 return [lds_ord.serialize() for lds_ord in self.lds_ord_list]
66
68 """
69 Convert a serialized tuple of data to an object
70 """
71 self.lds_ord_list = [LdsOrd().unserialize(item) for item in data]
72
74 """
75 Add the L{LdsOrd} instance to the object's list of lds_ordes.
76
77 @param lds_ord: L{LdsOrd} instance to add to the object's lds_ord list
78 @type lds_ord: list
79 """
80 self.lds_ord_list.append(lds_ord)
81
83 """
84 Remove the specified L{LdsOrd} instance from the lds_ord list.
85
86 If the instance does not exist in the list, the operation has no effect.
87
88 @param lds_ord: L{LdsOrd} instance to remove from the list
89 @type lds_ord: L{LdsOrd}
90
91 @return: True if the lds_ord was removed, False if it was not in the list.
92 @rtype: bool
93 """
94 if lds_ord in self.lds_ord_list:
95 self.lds_ord_list.remove(lds_ord)
96 return True
97 else:
98 return False
99
101 """
102 Return the list of L{LdsOrd} instances associated with the object.
103
104 @return: Returns the list of L{LdsOrd} instances
105 @rtype: list
106 """
107 return self.lds_ord_list
108
110 """
111 Assign the passed list to the object's list of L{LdsOrd} instances.
112
113 @param lds_ord_list: List of L{LdsOrd} instances to be associated
114 with the object
115 @type lds_ord_list: list
116 """
117 self.lds_ord_list = lds_ord_list
118