* src/RelLib.py (BaseObject): add get_referenced_handles,
get_handle_referents, and get_referenced_handles_recursively methods. (various subclasses): override get_referenced_handles and/or get_handle_referents as appropriate. svn: r4339
This commit is contained in:
parent
9fe2349434
commit
0b88a1b15e
@ -3,6 +3,11 @@
|
||||
he bravely turned his tail and fled" released.
|
||||
* configure.in: Bump up the version number.
|
||||
|
||||
* src/RelLib.py (BaseObject): add get_referenced_handles,
|
||||
get_handle_referents, and get_referenced_handles_recursively methods.
|
||||
(various subclasses): override get_referenced_handles and/or
|
||||
get_handle_referents as appropriate.
|
||||
|
||||
2005-04-10 Alex Roitman <shura@gramps-project.org>
|
||||
* NEWS: Update.
|
||||
|
||||
|
243
src/RelLib.py
243
src/RelLib.py
@ -147,6 +147,42 @@ class BaseObject:
|
||||
"""
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return []
|
||||
|
||||
def get_referenced_handles_recursively(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all referenced
|
||||
primary objects, whether directly or through child objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_handles()
|
||||
|
||||
# Run through child objects
|
||||
for obj in self.get_handle_referents():
|
||||
ret += obj.get_referenced_handles_recursively()
|
||||
|
||||
return ret
|
||||
|
||||
class PrimaryObject(BaseObject):
|
||||
"""
|
||||
The PrimaryObject is the base class for all primary objects in the
|
||||
@ -1021,6 +1057,32 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
|
||||
self.alternate_names + self.address_list + \
|
||||
self.attribute_list + lds_check_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
ret = []
|
||||
ret += [('Event',handle) for handle in
|
||||
self.event_list + [self.birth_handle,self.death_handle]
|
||||
if handle]
|
||||
ret += [('Family',handle) for handle in self.family_list
|
||||
+ [item[0] for item in self.parent_family_list]]
|
||||
return ret
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.get_sourcref_child_list() + self.source_list
|
||||
|
||||
def set_complete_flag(self,val):
|
||||
"""
|
||||
Sets or clears the complete flag, which is used to indicate that the
|
||||
@ -1720,6 +1782,31 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
|
||||
check_list.append(self.lds_seal)
|
||||
return check_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
ret = []
|
||||
ret += [('Event',handle) for handle in self.event_list]
|
||||
ret += [('Person',handle) for handle in
|
||||
self.child_list + [self.father_handle,self.mother_handle]
|
||||
if handle]
|
||||
return ret
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return get_sourcref_child_list() + self.source_list
|
||||
|
||||
def set_complete_flag(self,val):
|
||||
"""
|
||||
Sets or clears the complete flag, which is used to indicate that the
|
||||
@ -2047,6 +2134,30 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase):
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
ret = []
|
||||
if self.place:
|
||||
ret.append(('Place',self.place))
|
||||
return ret
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.media_list + self.source_list + \
|
||||
[witness for witness in self.witness
|
||||
if witness.type == Event.ID]
|
||||
def get_witness_list(self):
|
||||
"""
|
||||
Returns the list of L{Witness} instances associated with the Event.
|
||||
@ -2297,6 +2408,16 @@ class Place(PrimaryObject,SourceNote,MediaBase):
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.media_list + self.source_list
|
||||
|
||||
def get_url_list(self):
|
||||
"""
|
||||
Returns the list of L{Url} instances associated with the Place
|
||||
@ -2545,6 +2666,16 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
"""
|
||||
return self.attribute_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
|
||||
def set_mime_type(self,type):
|
||||
"""
|
||||
Sets the MIME type associated with the MediaObject
|
||||
@ -2639,6 +2770,16 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def has_source_reference(self,src_handle) :
|
||||
"""
|
||||
Returns True if any of the child objects has reference
|
||||
@ -2777,6 +2918,29 @@ class LdsOrd(SourceNote,DateBase,PlaceBase):
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
if self.place:
|
||||
return [('Place',self.place)]
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
|
||||
def set_family_handle(self,family):
|
||||
"""Sets the Family database handle associated with the LDS ordinance"""
|
||||
self.famc = family
|
||||
@ -3100,6 +3264,29 @@ class MediaRef(PrivateSourceNote,AttributeBase):
|
||||
"""
|
||||
return self.attribute_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
if self.ref:
|
||||
return [('MediaObject',self.ref)]
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
|
||||
def set_rectangle(self,coord):
|
||||
"""Sets subection of an image"""
|
||||
self.rect = coord
|
||||
@ -3150,6 +3337,16 @@ class Attribute(PrivateSourceNote):
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
|
||||
def set_type(self,val):
|
||||
"""sets the type (or key) of the Attribute instance"""
|
||||
self.type = val
|
||||
@ -3212,6 +3409,16 @@ class Address(PrivateSourceNote,DateBase):
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
|
||||
def set_street(self,val):
|
||||
"""sets the street portion of the Address"""
|
||||
self.street = val
|
||||
@ -3320,6 +3527,16 @@ class Name(PrivateSourceNote,DateBase):
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
|
||||
def set_group_as(self,name):
|
||||
"""
|
||||
Sets the grouping name for a person. Normally, this is the person's
|
||||
@ -3641,6 +3858,19 @@ class Witness(BaseObject,PrivacyBase):
|
||||
"""
|
||||
return [self.val,self.comment]
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
if self.type == Event.ID:
|
||||
return [('Person',self.val)]
|
||||
else:
|
||||
return []
|
||||
|
||||
def set_type(self,type):
|
||||
self.type = type
|
||||
|
||||
@ -3698,6 +3928,19 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase):
|
||||
"""
|
||||
return [self.note]
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
if self.ref:
|
||||
return [('Source',self.ref)]
|
||||
else:
|
||||
return []
|
||||
|
||||
def set_confidence_level(self,val):
|
||||
"""Sets the confidence level"""
|
||||
self.confidence = val
|
||||
|
Loading…
Reference in New Issue
Block a user