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