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
This commit is contained in:
parent
ee77b6882e
commit
b4f434357f
@ -209,7 +209,7 @@ class MergeSourceQuery(object):
|
|||||||
old_handle):
|
old_handle):
|
||||||
if class_name == Citation.__name__:
|
if class_name == Citation.__name__:
|
||||||
citation = self.database.get_citation_from_handle(handle)
|
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)
|
citation.replace_source_references(old_handle, new_handle)
|
||||||
self.database.commit_citation(citation, trans)
|
self.database.commit_citation(citation, trans)
|
||||||
else:
|
else:
|
||||||
|
@ -233,26 +233,6 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
|
|||||||
# _HasSourceOf and mergesource, and it is better to make the test directly,
|
# _HasSourceOf and mergesource, and it is better to make the test directly,
|
||||||
# because, only citations refer to sources, and they have only one reference.
|
# because, only citations refer to sources, and they have only one reference.
|
||||||
# need to check remove and replace source 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):
|
def remove_source_references(self, src_handle_list):
|
||||||
"""
|
"""
|
||||||
Remove references to all source handles in the list in all child
|
Remove references to all source handles in the list in all child
|
||||||
|
@ -152,23 +152,6 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
|||||||
"""
|
"""
|
||||||
return self.get_citation_child_list()
|
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):
|
def remove_source_references(self, src_handle_list):
|
||||||
"""
|
"""
|
||||||
Remove references to all source handles in the list in all child
|
Remove references to all source handles in the list in all child
|
||||||
|
@ -131,15 +131,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase):
|
|||||||
"""
|
"""
|
||||||
pass
|
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):
|
def has_media_reference(self, handle):
|
||||||
"""
|
"""
|
||||||
Indicate if the object has a media references.
|
Indicate if the object has a media references.
|
||||||
|
@ -179,23 +179,6 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
|
|||||||
for item in self.get_citation_child_list():
|
for item in self.get_citation_child_list():
|
||||||
item.replace_citation_references(old_handle, new_handle)
|
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):
|
def remove_source_references(self, src_handle_list):
|
||||||
"""
|
"""
|
||||||
Remove references to all source handles in the list in all child
|
Remove references to all source handles in the list in all child
|
||||||
|
@ -192,23 +192,6 @@ class Source(MediaBase, NoteBase, PrimaryObject):
|
|||||||
"""
|
"""
|
||||||
return self.get_referenced_note_handles()
|
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):
|
def remove_source_references(self, src_handle_list):
|
||||||
"""
|
"""
|
||||||
Remove references to all source handles in the list in all child
|
Remove references to all source handles in the list in all child
|
||||||
|
@ -37,13 +37,14 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# SourceBase classes
|
# SourceBase classes
|
||||||
|
# FIXME: CITATION: As of Gramps 3.4, SourceBase is no longer used so this module
|
||||||
|
# needs to be removed
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class SourceBase(object):
|
class SourceBase(object):
|
||||||
"""
|
"""
|
||||||
Base class for storing source references.
|
Base class for storing source references.
|
||||||
"""
|
"""
|
||||||
# FIXME: SourceBase is no longer used so this module needs to be removed
|
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
"""
|
"""
|
||||||
Create a new SourceBase, copying from source if not None.
|
Create a new SourceBase, copying from source if not None.
|
||||||
|
Loading…
Reference in New Issue
Block a user