[PATCH 8/9] Replace callable with collections.Callable (#1014220)
Vratislav Podzimek
vpodzime at redhat.com
Thu Jan 29 08:29:22 UTC 2015
On Wed, 2015-01-28 at 18:43 +0100, Martin Kolman wrote:
> The callable() function has been deprecated in Python 3,
> so replace it with collections.Callable, which is available
> in both Python 2 & 3.
>
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
> pyanaconda/network.py | 3 ++-
> pyanaconda/ui/tui/spokes/__init__.py | 5 +++--
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/pyanaconda/network.py b/pyanaconda/network.py
> index b1d006a..513f905 100644
> --- a/pyanaconda/network.py
> +++ b/pyanaconda/network.py
> @@ -49,6 +49,7 @@ from pyanaconda.regexes import HOSTNAME_PATTERN_WITHOUT_ANCHORS
> from gi.repository import NetworkManager
>
> import logging
> +import collections
> log = logging.getLogger("anaconda")
>
> sysconfigDir = "/etc/sysconfig"
> @@ -766,7 +767,7 @@ def find_ifcfg_file(values, root_path=""):
> ifcfg = IfcfgFile(filepath)
> ifcfg.read()
> for key, value in values:
> - if callable(value):
> + if isinstance(value, collections.Callable):
> if not value(ifcfg.get(key)):
> break
> else:
> diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
> index 8429bbf..ddd7c70 100644
> --- a/pyanaconda/ui/tui/spokes/__init__.py
> +++ b/pyanaconda/ui/tui/spokes/__init__.py
> @@ -27,6 +27,7 @@ from collections import namedtuple
> from pyanaconda.iutil import setdeepattr, getdeepattr
> from pyanaconda.i18n import N_, _
> from pyanaconda.constants import PASSWORD_CONFIRM_ERROR_TUI, PW_ASCII_CHARS
> +import collections
>
> __all__ = ["TUISpoke", "EditTUISpoke", "EditTUIDialog", "EditTUISpokeEntry",
> "StandaloneSpoke", "NormalTUISpoke"]
> @@ -238,9 +239,9 @@ class EditTUISpoke(NormalTUISpoke):
> # changes dynamically
> ret = []
> for entry in self.edit_fields:
> - if callable(entry.visible) and entry.visible(self, self.args):
> + if isinstance(entry.visible, collections.Callable) and entry.visible(self, self.args):
> ret.append(entry)
> - elif not callable(entry.visible) and entry.visible:
> + elif not isinstance(entry.visible, collections.Callable) and entry.visible:
> ret.append(entry)
>
> return ret
I collections.Callable really working this way? If yes, I'm really
curious about its implementation because it seems just weird that our
object is all of a sudden an instance of some class that has to be
imported from an external module.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list