From b4f434357f9afb354be405e6745dbcd37bce3907 Mon Sep 17 00:00:00 2001 From: Tim G L Lyons Date: Tue, 8 Nov 2011 17:39:17 +0000 Subject: [PATCH] Remove has_source_reference because it is only used in mergesource, and it is better to make the test directly, because only citations have source references and they only have one reference. svn: r18417 --- src/Merge/mergesource.py | 2 +- src/gen/lib/citation.py | 20 -------------------- src/gen/lib/eventref.py | 17 ----------------- src/gen/lib/primaryobj.py | 9 --------- src/gen/lib/repo.py | 17 ----------------- src/gen/lib/src.py | 17 ----------------- src/gen/lib/srcbase.py | 3 ++- 7 files changed, 3 insertions(+), 82 deletions(-) diff --git a/src/Merge/mergesource.py b/src/Merge/mergesource.py index 51a3c35ae..44784e1d9 100644 --- a/src/Merge/mergesource.py +++ b/src/Merge/mergesource.py @@ -209,7 +209,7 @@ class MergeSourceQuery(object): old_handle): if class_name == Citation.__name__: citation = self.database.get_citation_from_handle(handle) - assert(citation.has_source_reference(old_handle)) + assert(citation.get_reference_handle() == old_handle) citation.replace_source_references(old_handle, new_handle) self.database.commit_citation(citation, trans) else: diff --git a/src/gen/lib/citation.py b/src/gen/lib/citation.py index 42f3484c3..91cb2183f 100644 --- a/src/gen/lib/citation.py +++ b/src/gen/lib/citation.py @@ -233,26 +233,6 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase): # _HasSourceOf and mergesource, and it is better to make the test directly, # because, only citations refer to sources, and they have only one reference. # need to check remove and replace source reference. - def has_source_reference(self, src_handle) : - """ - Return 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 - :returns: Returns whether any of it's child objects has reference to - this source handle. - :rtype: bool - - Only the Citation Primary object refers to sources, none of the - child objects do. Also, the Citation object only ever refers to one - Source, so only that reference needs to be checked. - """ - if src_handle == self.get_reference_handle(): - return True - - return False - def remove_source_references(self, src_handle_list): """ Remove references to all source handles in the list in all child diff --git a/src/gen/lib/eventref.py b/src/gen/lib/eventref.py index af87b17ec..3a48bff79 100644 --- a/src/gen/lib/eventref.py +++ b/src/gen/lib/eventref.py @@ -152,23 +152,6 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase): """ return self.get_citation_child_list() - def has_source_reference(self, src_handle) : - """ - Return 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 - :returns: 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): """ Remove references to all source handles in the list in all child diff --git a/src/gen/lib/primaryobj.py b/src/gen/lib/primaryobj.py index f8371e10d..0981d317d 100644 --- a/src/gen/lib/primaryobj.py +++ b/src/gen/lib/primaryobj.py @@ -131,15 +131,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase): """ pass - def has_source_reference(self, handle): - """ - Indicate if the object has a source references. - - In the base class, no such references exist. Derived classes should - override this if they provide source references. - """ - return False - def has_media_reference(self, handle): """ Indicate if the object has a media references. diff --git a/src/gen/lib/repo.py b/src/gen/lib/repo.py index 8083a72fd..228d7b21d 100644 --- a/src/gen/lib/repo.py +++ b/src/gen/lib/repo.py @@ -179,23 +179,6 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject): for item in self.get_citation_child_list(): item.replace_citation_references(old_handle, new_handle) - def has_source_reference(self, src_handle) : - """ - Return 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 - :returns: 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): """ Remove references to all source handles in the list in all child diff --git a/src/gen/lib/src.py b/src/gen/lib/src.py index 1146b2fe4..894e1630e 100644 --- a/src/gen/lib/src.py +++ b/src/gen/lib/src.py @@ -192,23 +192,6 @@ class Source(MediaBase, NoteBase, PrimaryObject): """ return self.get_referenced_note_handles() - def has_source_reference(self, src_handle) : - """ - Return 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 - :returns: 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): """ Remove references to all source handles in the list in all child diff --git a/src/gen/lib/srcbase.py b/src/gen/lib/srcbase.py index e0d324548..9a882c929 100644 --- a/src/gen/lib/srcbase.py +++ b/src/gen/lib/srcbase.py @@ -37,13 +37,14 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT #------------------------------------------------------------------------- # # SourceBase classes +# FIXME: CITATION: As of Gramps 3.4, SourceBase is no longer used so this module +# needs to be removed # #------------------------------------------------------------------------- class SourceBase(object): """ Base class for storing source references. """ -# FIXME: SourceBase is no longer used so this module needs to be removed def __init__(self, source=None): """ Create a new SourceBase, copying from source if not None.