[PATCH 1/2] Make reduce function usage Python 3 compatible
Martin Kolman
mkolman at redhat.com
Fri Jun 27 13:17:38 UTC 2014
The built-in reduce function has been removed in Python 3,
but in both Python 2.7 and Python 3+ the reduce function
is available from the functools module.
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
pyanaconda/addons.py | 5 +++--
pyanaconda/ui/tui/simpleline/base.py | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/addons.py b/pyanaconda/addons.py
index da80958..c95f41a 100644
--- a/pyanaconda/addons.py
+++ b/pyanaconda/addons.py
@@ -22,6 +22,7 @@
__all__ = ["AddonSection", "AddonRegistry", "AddonData", "collect_addon_paths"]
import os
+import functools
from pykickstart.sections import Section
from pykickstart.errors import KickstartParseError, formatErrorMsg
from pyanaconda.i18n import _
@@ -75,8 +76,8 @@ class AddonRegistry(object):
self.__dict__ = dictionary
def __str__(self):
- return reduce(lambda acc,(id, addon): acc + str(addon),
- self.__dict__.iteritems(), "")
+ return functools.reduce(lambda acc, (id, addon): acc + str(addon),
+ self.__dict__.iteritems(), "")
def execute(self, storage, ksdata, instClass, users):
"""This method calls execute on all the registered addons."""
diff --git a/pyanaconda/ui/tui/simpleline/base.py b/pyanaconda/ui/tui/simpleline/base.py
index 0ae0f57..fefbf80 100644
--- a/pyanaconda/ui/tui/simpleline/base.py
+++ b/pyanaconda/ui/tui/simpleline/base.py
@@ -25,6 +25,7 @@ import sys
import Queue
import getpass
import threading
+import functools
from pyanaconda.threads import threadMgr, AnacondaThread
from pyanaconda.ui.communication import hubQ
from pyanaconda import constants
@@ -653,7 +654,7 @@ class Widget(object):
def width(self):
"""The current width of the internal buffer
(id of the first empty column)."""
- return reduce(lambda acc,l: max(acc, len(l)), self._buffer, 0)
+ return functools.reduce(lambda acc, l: max(acc, len(l)), self._buffer, 0)
def clear(self):
"""Clears this widgets buffer and resets cursor."""
--
1.9.3
More information about the anaconda-patches
mailing list