[PATCH 2/3] Make map() usage Python 3 compatible (#1014220)
Martin Kolman
mkolman at redhat.com
Fri Feb 13 18:33:56 UTC 2015
In Python 3 map() no longer returns a list, but an iterator.
So replace map() with list comprehension or wrap it with list()
where a list is expected. No changes are needed in code that either
works fine with an iterator or just uses map() for the side effects.
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
pyanaconda/keyboard.py | 7 +------
pyanaconda/rescue.py | 2 +-
pyanaconda/ui/gui/spokes/filter.py | 3 +--
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
index 1f3e572..0de3111 100644
--- a/pyanaconda/keyboard.py
+++ b/pyanaconda/keyboard.py
@@ -395,12 +395,7 @@ class LocaledWrapper(object):
# if there are more layouts than variants, empty strings should be appended
diff = len(layouts) - len(variants)
variants.extend(diff * [""])
-
- # if there are more variants than layouts, throw the trailing ones away
- variants = variants[:len(layouts)]
-
- # map can be used with multiple lists and works like zipWith (Haskell)
- return map(join_layout_variant, layouts, variants)
+ return [join_layout_variant(layout, variant) for layout, variant in zip(layouts, variants)]
@property
def options(self):
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index c808558..68a1d06 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -382,7 +382,7 @@ def doRescue(intf, rescue_mount, ksdata):
# set a library path to use mounted fs
libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":")
- mounted = map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)
+ mounted = ["/mnt/sysimage%s" % mdir for mdir in libdirs]
iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted))
# find groff data dir
diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py
index d0ddfc3..0a59f2b 100644
--- a/pyanaconda/ui/gui/spokes/filter.py
+++ b/pyanaconda/ui/gui/spokes/filter.py
@@ -509,8 +509,7 @@ class FilterSpoke(NormalSpoke):
self.disks = getDisks(self.storage.devicetree)
self.selected_disks = self.data.ignoredisk.onlyuse[:]
- self.ancestors = itertools.chain(*map(self._real_ancestors, self.disks))
- self.ancestors = map(lambda d: d.name, self.ancestors)
+ self.ancestors = [d.name for disk in self.disks for d in self._real_ancestors(disk)]
self._store.clear()
--
2.1.0
More information about the anaconda-patches
mailing list