7470: Upgrade to db version 17 fails in Python 3 due to use of iteritems

This commit is contained in:
Marc Hulsman 2014-02-13 18:16:58 -08:00 committed by Paul Franklin
parent 8752d173af
commit 7346496214
4 changed files with 9 additions and 19 deletions

View File

@ -290,7 +290,7 @@ def upgrade_datamap_17(datamap):
new_srcattr_list = []
private = False
from ..lib.srcattrtype import SrcAttributeType
for (key, value) in datamap.iteritems():
for (key, value) in datamap.items():
the_type = SrcAttributeType(key).serialize()
new_srcattr_list.append((private, the_type, value))
return new_srcattr_list

View File

@ -91,7 +91,7 @@ class HasPlace(Rule):
"""
Check each location for a match.
"""
for place_type, field in self.TYPE2FIELD.iteritems():
for place_type, field in self.TYPE2FIELD.items():
name = location.get(place_type, '')
if not self.match_substring(field, name):
return False

View File

@ -398,14 +398,9 @@ class FlatNodeMap(object):
insert_pos = bisect.bisect_left(self._index2hndl, srtkey_hndl)
self._index2hndl.insert(insert_pos, srtkey_hndl)
#make sure the index map is updated
if sys.version_info[0] < 3:
for hndl, index in self._hndl2index.iteritems():
if index >= insert_pos:
self._hndl2index[hndl] += 1
else:
for hndl, index in self._hndl2index.items():
if index >= insert_pos:
self._hndl2index[hndl] += 1
for hndl, index in self._hndl2index.items():
if index >= insert_pos:
self._hndl2index[hndl] += 1
self._hndl2index[srtkey_hndl[1]] = insert_pos
#update self.__corr so it remains correct
if self._reverse:
@ -447,14 +442,9 @@ class FlatNodeMap(object):
if self._reverse:
self.__corr = (len(self._index2hndl) - 1, -1)
#update the handle2path map so it remains correct
if sys.version_info[0] < 3:
for key, val in self._hndl2index.iteritems():
if val > index:
self._hndl2index[key] -= 1
else:
for key, val in self._hndl2index.items():
if val > index:
self._hndl2index[key] -= 1
for key, val in self._hndl2index.items():
if val > index:
self._hndl2index[key] -= 1
return Gtk.TreePath((delpath,))
#-------------------------------------------------------------------------

View File

@ -2491,7 +2491,7 @@ class GrampsParser(UpdateCallback):
element_name = xml_element_name,
attrs = " ".join(
['{}="{}"'.format(k,escape(v, entities={'"' : "&quot;"}))
for k,v in xml_attrs.iteritems()]))
for k,v in xml_attrs.items()]))
# TRANSLATORS: leave the {date} and {xml} untranslated in the format string,
# but you may re-order them if needed.
LOG.warning(_("Invalid date {date} in XML {xml}, preserving XML as text"