[elbe-devel] [PATCH 14/25] py3: fixup map vs. list issues
Manuel Traut
manut at linutronix.de
Mon Dec 11 10:11:08 CET 2017
map returns an iterator in py3 and a list in py2.
If it is wrapped by list() it can be used the same way in py2 and py3.
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
elbepack/commands/pkgdiff.py | 14 ++++++--------
elbepack/debianize/base.py | 2 +-
elbepack/debianreleases.py | 2 +-
elbepack/fstab.py | 2 +-
elbepack/templates.py | 2 +-
elbepack/treeutils.py | 2 +-
6 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/elbepack/commands/pkgdiff.py b/elbepack/commands/pkgdiff.py
index ec14f017..0cc27465 100644
--- a/elbepack/commands/pkgdiff.py
+++ b/elbepack/commands/pkgdiff.py
@@ -77,16 +77,14 @@ def run_command( argv ):
if p.current_ver and not p.essential:
fix_pkgs[p.name] = p.current_ver
- for p in fix_pkgs.keys():
- if not p in gen_pkgs.keys():
+ for p in list(fix_pkgs.keys()):
+ if not p in list(gen_pkgs.keys()):
print "+<pkg>%s</pkg>" % p
- for p in gen_pkgs.keys():
- if not p in fix_pkgs.keys():
+ for p in list(gen_pkgs.keys()):
+ if not p in list(fix_pkgs.keys()):
print "-<pkg>%s</pkg>" % p
- for p in fix_pkgs.keys():
- if p in gen_pkgs.keys() and fix_pkgs[p] != gen_pkgs[p]:
+ for p in list(fix_pkgs.keys()):
+ if p in list(gen_pkgs.keys()) and fix_pkgs[p] != gen_pkgs[p]:
print "%s: Version mismatch %s != %s" % (p, fix_pkgs[p], gen_pkgs[p])
-
-
diff --git a/elbepack/debianize/base.py b/elbepack/debianize/base.py
index 71948001..10a5558b 100644
--- a/elbepack/debianize/base.py
+++ b/elbepack/debianize/base.py
@@ -40,7 +40,7 @@ class DebianizeBase (FormMultiPage):
@classmethod
def get_debianizer (cls):
- for t in cls.srctypes.values ():
+ for t in list(cls.srctypes.values ()):
match = True
for f in t.files:
if not os.path.exists (f):
diff --git a/elbepack/debianreleases.py b/elbepack/debianreleases.py
index ee2d793f..96e653ca 100644
--- a/elbepack/debianreleases.py
+++ b/elbepack/debianreleases.py
@@ -32,4 +32,4 @@ suite2codename = { 'oldoldoldstable': 'squeeze',
# generate reverse mapping
-codename2suite = dict( [(v,k) for k,v in suite2codename.items()] )
+codename2suite = dict( [(v,k) for k,v in list(suite2codename.items())] )
diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index 47633002..5ea56077 100644
--- a/elbepack/fstab.py
+++ b/elbepack/fstab.py
@@ -71,7 +71,7 @@ class mountpoint_dict (dict):
depth += 1
def depthlist (self):
- mplist = self.keys()
+ mplist = list(self.keys())
mplist.sort (key=mountpoint_dict.mountdepth)
return [self[x] for x in mplist]
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 634b7ccd..9bbca711 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -92,7 +92,7 @@ def get_initvm_preseed( xml ):
def preseed_to_text( pres ):
retval = ""
- for k,v in pres.items():
+ for k,v in list(pres.items()):
retval += "%s\t%s\t%s\t%s\n" % (k[0], k[1], v[0], v[1])
return retval
diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
index bcbd415e..8efc401c 100644
--- a/elbepack/treeutils.py
+++ b/elbepack/treeutils.py
@@ -71,7 +71,7 @@ class ebase(object):
return None
def all( self, path ):
- return map(elem, self.et.findall(path))
+ return list(map(elem, self.et.findall(path)))
def __iter__( self ):
return eiter(iter(self.et))
--
2.15.1
More information about the elbe-devel
mailing list