2007-12-17 Benny Malengier <benny.malengier@gramps-project.org>
* src/RelLib/_Person.py: sources in attributes of eventref are not seen in ref tables * src/RelLib/_EventRef.py: can contain sources, add methods for that * src/plugins/Check.py: low level check of repo table, add check to clean up referenced but not existing repos svn: r9531
This commit is contained in:
parent
ab29b78e6d
commit
8b7136ddd9
@ -1,3 +1,10 @@
|
||||
2007-12-17 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/RelLib/_Person.py: sources in attributes of eventref are not seen
|
||||
in ref tables
|
||||
* src/RelLib/_EventRef.py: can contain sources, add methods for that
|
||||
* src/plugins/Check.py: low level check of repo table, add check to
|
||||
clean up referenced but not existing repos
|
||||
|
||||
2007-12-15 Gary Burton <gary.burton@zen.co.uk>
|
||||
* src/Editors/_EditFamily.py: emit family-update signal #1416
|
||||
|
||||
|
@ -105,7 +105,7 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
||||
@return: Returns the list of child objects that may carry textual data.
|
||||
@rtype: list
|
||||
"""
|
||||
check_list = self.attribute_list[:]
|
||||
check_list = self.attribute_list
|
||||
if self.note:
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
@ -117,7 +117,7 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
||||
@return: Returns the list of child secondary child objects that may refer sources.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.attribute_list[:]
|
||||
return self.attribute_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -132,6 +132,56 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
||||
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.get_sourcref_child_list()
|
||||
|
||||
def has_source_reference(self, src_handle) :
|
||||
"""
|
||||
Returns True if any of the child objects has reference
|
||||
to this source handle.
|
||||
|
||||
@param src_handle: The source handle to be checked.
|
||||
@type src_handle: str
|
||||
@return: Returns whether any of it's child objects has reference to this source handle.
|
||||
@rtype: bool
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
if item.has_source_reference(src_handle):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def remove_source_references(self, src_handle_list):
|
||||
"""
|
||||
Removes references to all source handles in the list
|
||||
in all child objects.
|
||||
|
||||
@param src_handle_list: The list of source handles to be removed.
|
||||
@type src_handle_list: list
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.remove_source_references(src_handle_list)
|
||||
|
||||
def replace_source_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replaces references to source handles in the list
|
||||
in this object and all child objects.
|
||||
|
||||
@param old_handle: The source handle to be replaced.
|
||||
@type old_handle: str
|
||||
@param new_handle: The source handle to replace the old one with.
|
||||
@type new_handle: str
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.replace_source_references(old_handle, new_handle)
|
||||
|
||||
def get_role(self):
|
||||
"""
|
||||
Returns the tuple corresponding to the preset role.
|
||||
|
@ -324,7 +324,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
return [self.primary_name] + self.media_list + \
|
||||
self.alternate_names + self.address_list + \
|
||||
self.attribute_list + self.lds_ord_list + \
|
||||
self.person_ref_list
|
||||
self.person_ref_list + self.event_ref_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -345,8 +345,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return self.get_sourcref_child_list() + self.source_list \
|
||||
+ self.event_ref_list
|
||||
return self.get_sourcref_child_list() + self.source_list
|
||||
|
||||
def set_primary_name(self, name):
|
||||
"""
|
||||
|
@ -83,7 +83,8 @@ def low_level(db):
|
||||
('Event',db.event_map),
|
||||
('Place',db.place_map),
|
||||
('Source',db.source_map),
|
||||
('Media',db.media_map)]:
|
||||
('Media',db.media_map),
|
||||
('Repository', db.repository_map)]:
|
||||
|
||||
print "Low-level repair: table: %s" % the_map[0]
|
||||
if _table_low_level(db,the_map[1]):
|
||||
@ -887,7 +888,8 @@ class CheckIntegrity:
|
||||
total = self.db.get_number_of_people() + self.db.get_number_of_families() + \
|
||||
self.db.get_number_of_events() + self.db.get_number_of_places() + \
|
||||
self.db.get_number_of_media_objects() + \
|
||||
self.db.get_number_of_sources()
|
||||
self.db.get_number_of_sources() + \
|
||||
self.db.get_number_of_repositories()
|
||||
|
||||
self.progress.set_pass(_('Looking for source reference problems'),
|
||||
total)
|
||||
@ -989,6 +991,22 @@ class CheckIntegrity:
|
||||
not in self.invalid_source_references]
|
||||
self.invalid_source_references += new_bad_handles
|
||||
|
||||
for handle in self.db.repository_map.keys():
|
||||
self.progress.step()
|
||||
info = self.db.repository_map[handle]
|
||||
repo = RelLib.Repository()
|
||||
repo.unserialize(info)
|
||||
handle_list = repo.get_referenced_handles_recursively()
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Source' and
|
||||
item[1] not in known_handles ]
|
||||
if bad_handles:
|
||||
repo.remove_source_references(bad_handles)
|
||||
self.db.commit_repository(repo,self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_source_references]
|
||||
self.invalid_source_references += new_bad_handles
|
||||
|
||||
def check_media_references(self):
|
||||
known_handles = self.db.get_media_object_handles(False)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user