1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """
24 Base Object class for GRAMPS
25 """
26
27
28
29
30
31
32 import re
33
34
35
36
37
38
40 """
41 The BaseObject is the base class for all data objects in GRAMPS,
42 whether primary or not.
43
44 Its main goal is to provide common capabilites to all objects, such as
45 searching through all available information.
46 """
47
49 """
50 Convert the object to a serialized tuple of data.
51 """
52 assert False, "Needs to be overridden in the derived class"
53
55 """
56 Convert a serialized tuple of data to an object.
57 """
58 assert False, "Needs to be overridden in the derived class"
59 return self
60
62 """
63 Return True if any text data in the object or any of it's child
64 objects matches a given pattern.
65
66 @param pattern: The pattern to match.
67 @type pattern: str
68 @param case_sensitive: Whether the match is case-sensitive.
69 @type case_sensitive: bool
70 @return: Returns whether any text data in the object or any of it's child objects matches a given pattern.
71 @rtype: bool
72 """
73
74 patern_upper = pattern.upper()
75 for item in self.get_text_data_list():
76 if not item:
77 continue
78 if case_sensitive:
79 if item.find(pattern) != -1:
80 return True
81 else:
82 if item.upper().find(patern_upper) != -1:
83 return True
84
85
86 for obj in self.get_text_data_child_list():
87 if obj.matches_string(pattern, case_sensitive):
88 return True
89
90 return False
91
93 """
94 Return True if any text data in the object or any of it's child
95 objects matches a given regular expression.
96
97 @param pattern: The pattern to match.
98 @type pattern: str
99 @return: Returns whether any text data in the object or any of it's child objects matches a given regexp.
100 @rtype: bool
101 """
102
103
104 if case_sensitive:
105 pattern_obj = re.compile(pattern)
106 else:
107 pattern_obj = re.compile(pattern, re.IGNORECASE)
108 for item in self.get_text_data_list():
109 if item and pattern_obj.match(item):
110 return True
111
112
113 for obj in self.get_text_data_child_list():
114 if obj.matches_regexp(pattern, case_sensitive):
115 return True
116
117 return False
118
120 """
121 Return the list of all textual attributes of the object.
122
123 @return: Returns the list of all textual attributes of the object.
124 @rtype: list
125 """
126 return []
127
129 """
130 Return the list of child objects that may carry textual data.
131
132 @return: Returns the list of child objects that may carry textual data.
133 @rtype: list
134 """
135 return []
136
138 """
139 Return the list of (classname, handle) tuples for all directly
140 referenced primary objects.
141
142 @return: Returns the list of (classname, handle) tuples for referenced objects.
143 @rtype: list
144 """
145 return []
146
148 """
149 Return the list of child objects which may, directly or through
150 their children, reference primary objects.
151
152 @return: Returns the list of objects refereincing primary objects.
153 @rtype: list
154 """
155 return []
156
158 """
159 Return the list of (classname, handle) tuples for all referenced
160 primary objects, whether directly or through child objects.
161
162 @return: Returns the list of (classname, handle) tuples for referenced objects.
163 @rtype: list
164 """
165 ret = self.get_referenced_handles()
166
167
168 for obj in self.get_handle_referents():
169 ret += obj.get_referenced_handles_recursively()
170 return ret
171