* src/RelLib.py (try_to_find_person_from_id): Remove transaction;

(try_to_find_source_from_id, try_to_find_object_from_id,
try_to_find_place_from_id): Add functions.
* src/plugins/WriteCD.py, src/plugins/WritePkg.py,
src/plugins/WebPage.py, src/plugins/Verify.py,
src/plugins/TimeLine.py, src/plugins/Summary.py,
src/plugins/SoundGen.py, src/plugins/RelGraph.py,
src/plugins/RelCalc.py, src/plugins/PatchNames.py,
src/plugins/Merge.py, src/plugins/IndivSummary.py,
src/plugins/IndivComplete.py, src/plugins/GraphViz.py,
src/plugins/FtmStyleDescendants.py,
src/plugins/FtmStyleAncestors.py, src/plugins/FilterEditor.py,
src/plugins/FanChart.py, src/plugins/FamilyGroup.py,
src/plugins/EventCmp.py, src/plugins/DetDescendantReport.py,
src/plugins/DetAncestralReport.py, src/plugins/DescendReport.py,
src/plugins/Desbrowser.py, src/plugins/CountAncestors.py,
src/plugins/Check.py, src/plugins/ChangeTypes.py,
src/plugins/BookReport.py, src/plugins/Ancestors.py,
src/plugins/AncestorReport.py, src/plugins/AncestorChart.py,
src/plugins/AncestorChart2.py, src/Relationship.py,
src/Sort.py, src/GenericFilter.py, src/SubstKeywords.py,
src/GraphLayout.py: Switch from find_* to try_to_find_* methods.


svn: r3191
This commit is contained in:
Alex Roitman
2004-05-26 02:05:02 +00:00
parent 60a6973bbf
commit 8ddbce94f0
39 changed files with 377 additions and 315 deletions

View File

@ -2958,14 +2958,14 @@ class GrampsDB:
def has_family_id(self,val):
return self.family_map.get(str(val))
def try_to_find_person_from_id(self,val,trans):
def try_to_find_person_from_id(self,val):
"""finds a Person in the database from the passed gramps' ID.
If no such Person exists, a new Person is added to the database."""
person = Person()
data = self.person_map.get(str(val))
if data:
person = Person()
person.unserialize(data)
return person
else:
@ -3084,6 +3084,18 @@ class GrampsDB:
map[gid] = self.add_event(event,trans)
return event
def try_to_find_source_from_id(self,val):
"""finds a Source in the database from the passed gramps' ID.
If no such Source exists, None is returned."""
data = self.source_map.get(str(val))
if data:
source = Source()
source.unserialize(data)
return source
else:
return None
def find_source_from_id(self,val,trans):
"""finds a Source in the database from the passed gramps' ID.
If no such Source exists, a new Source is added to the database."""
@ -3172,9 +3184,21 @@ class GrampsDB:
self.added_files.append(object)
return index
def try_to_find_object_from_id(self,gid):
"""finds an Object in the database from the passed gramps' ID.
If no such Object exists, None is returned."""
data = self.media_map.get(str(gid))
if data:
mobject = MediaObject()
mobject.unserialize(data)
return mobject
else:
return None
def find_object_from_id(self,gid,trans):
"""finds an Object in the database from the passed gramps' ID.
If no such Source exists, a new Source is added to the database."""
If no such Object exists, a new Object is added to the database."""
object = MediaObject()
if self.media_map.get(str(gid)):
@ -3272,6 +3296,19 @@ class GrampsDB:
place.unserialize(data)
return place
def try_to_find_place_from_id(self,gid):
"""finds a Place in the database from the passed gramps' ID.
If no such Place exists, None is returned."""
data = self.place_map.get(str(gid))
if data:
place = Place()
place.unserialize(data)
return place
else:
return None
def sortbyplace(self,f,s):
fp = self.place_map[f][1].upper()
sp = self.place_map[s][1].upper()