2007-02-18 Don Allingham <don@gramps-project.org>
* src/GrampsDbUtils/_GedcomUtils.py: Add IdMapper class * src/GrampsDbUtils/_GedcomParser.py: refactoring svn: r8167
This commit is contained in:
parent
f53f1abc21
commit
358b537986
@ -1,3 +1,7 @@
|
||||
2007-02-18 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsDbUtils/_GedcomUtils.py: Add IdMapper class
|
||||
* src/GrampsDbUtils/_GedcomParser.py: refactoring
|
||||
|
||||
2007-02-18 Brian Matherly <brian@gramps-project.org>
|
||||
* src/ReportBase/_PaperMenu.py: rename PaperStyle to PaperSize
|
||||
* src/docgen/HtmlDoc.py: rename PaperStyle to PaperSize
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -101,7 +101,6 @@ class PlaceParser:
|
||||
for item in items:
|
||||
self.pf[index](loc, item)
|
||||
index += 1
|
||||
|
||||
|
||||
class IdFinder:
|
||||
"""
|
||||
@ -131,6 +130,39 @@ class IdFinder:
|
||||
self.index += 1
|
||||
return index
|
||||
|
||||
class IdMapper:
|
||||
|
||||
def __init__(self, trans, find_next, translate):
|
||||
if translate:
|
||||
self.__getitem__ = self.get_translate
|
||||
else:
|
||||
self.__getitem__ = self.no_translate
|
||||
self.trans = trans
|
||||
self.find_next = find_next
|
||||
self.swap = {}
|
||||
|
||||
def clean(self, gid):
|
||||
temp = gid.strip()
|
||||
if temp[0] == '@' and temp[-1] == '@':
|
||||
temp = temp[1:-1]
|
||||
return temp
|
||||
|
||||
def no_translate(self, gid):
|
||||
return self.clean(gid)
|
||||
|
||||
def get_translate(self, id):
|
||||
gid = self.clean(gid)
|
||||
new_id = self.swap.has_key(gid)
|
||||
if new_id:
|
||||
return new_id
|
||||
else:
|
||||
if self.trans.get(str(gid)):
|
||||
new_val = self.find_next()
|
||||
else:
|
||||
new_val = gid
|
||||
self.swap[gid] = new_val
|
||||
return new_val
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Support functions
|
||||
|
Loading…
Reference in New Issue
Block a user