GEDCOM import: IdMapper can sometimes be passed @F2002@ and sometimes F2002. These were not mapping to the same swapped Gramps Id.(Partly a consequence of revision 19053).

svn: r19094
This commit is contained in:
Tim G L Lyons 2012-03-19 16:04:31 +00:00
parent 24d4788c76
commit 1ab0f4276d

View File

@ -1674,17 +1674,27 @@ class IdMapper(object):
while new_val in self.swap.values(): while new_val in self.swap.values():
new_val = self.find_next() new_val = self.find_next()
else: else:
clean_gid = self.clean(gid) # remove any @ signs
gid = self.clean(gid)
if gid in self.swap: if gid in self.swap:
return self.swap[gid] return self.swap[gid]
else: else:
if self.trans.get(str(clean_gid)) or \ # now standardise the format
(clean_gid in self.swap.values()): formatted_gid = self.id2user_format(gid)
# I1 and I0001 will both format as I0001. If we had already
# encountered I1, it would be in self.swap, so we would already
# have found it. If we had already encountered I0001 and we are
# now looking for I1, it wouldn't be in self.swap, and we now
# find that I0001 is in use, so we have to create a new id.
if self.trans.get(str(formatted_gid)) or \
(formatted_gid in self.swap.values()):
new_val = self.find_next() new_val = self.find_next()
while new_val in self.swap.values(): while new_val in self.swap.values():
new_val = self.find_next() new_val = self.find_next()
else: else:
new_val = clean_gid new_val = formatted_gid
# we need to distinguish between I1 and I0001, so we record the map
# from the original format
self.swap[gid] = new_val self.swap[gid] = new_val
return new_val return new_val
@ -1692,7 +1702,6 @@ class IdMapper(object):
temp = gid.strip() temp = gid.strip()
if len(temp) > 1 and temp[0] == '@' and temp[-1] == '@': if len(temp) > 1 and temp[0] == '@' and temp[-1] == '@':
temp = temp[1:-1] temp = temp[1:-1]
temp = self.id2user_format(temp)
return temp return temp
def map(self): def map(self):
@ -4240,7 +4249,8 @@ class GedcomParser(UpdateCallback):
@param state: The current state @param state: The current state
@type state: CurrentState @type state: CurrentState
""" """
handle = self.__find_family_handle(self.fid_map[line.data]) gid = self.fid_map[line.data]
handle = self.__find_family_handle(gid)
state.person.add_family_handle(handle) state.person.add_family_handle(handle)
sub_state = CurrentState(level=state.level+1) sub_state = CurrentState(level=state.level+1)
@ -4348,7 +4358,8 @@ class GedcomParser(UpdateCallback):
""" """
# create a family # create a family
family = self.__find_or_create_family(self.fid_map[line.token_text]) gid = self.fid_map[line.token_text]
family = self.__find_or_create_family(gid)
# parse the family # parse the family