[elbe-devel] [PATCH v4] py3: fixup map vs. list issues

Manuel Traut manut at linutronix.de
Mon Dec 18 17:19:53 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 | 4 ++--
 elbepack/debianreleases.py   | 2 +-
 elbepack/fstab.py            | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/elbepack/commands/pkgdiff.py b/elbepack/commands/pkgdiff.py
index 7df30cb1..06abba13 100644
--- a/elbepack/commands/pkgdiff.py
+++ b/elbepack/commands/pkgdiff.py
@@ -79,8 +79,8 @@ 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 fix_pkgs:
+        if not p in gen_pkgs:
             print("+<pkg>%s</pkg>" % p)
 
     for p in gen_pkgs.keys():
diff --git a/elbepack/debianreleases.py b/elbepack/debianreleases.py
index ee2d793f..0b91cec6 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 = { v:k for k,v in suite2codename.items() }
diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index 47633002..05f8a7a0 100644
--- a/elbepack/fstab.py
+++ b/elbepack/fstab.py
@@ -71,8 +71,7 @@ class mountpoint_dict (dict):
             depth += 1
 
     def depthlist (self):
-        mplist = self.keys()
-        mplist.sort (key=mountpoint_dict.mountdepth)
+        mplist = sorted (self.keys(), key=mountpoint_dict.mountdepth)
 
         return [self[x] for x in mplist]
 
-- 
2.15.1




More information about the elbe-devel mailing list