Import Upstream version 4.12.4
This commit is contained in:
@@ -9,12 +9,11 @@ Command line support.
|
||||
import collections
|
||||
import enum
|
||||
import logging
|
||||
import optparse # pylint: disable=deprecated-module
|
||||
import signal
|
||||
|
||||
import six
|
||||
|
||||
from ipapython import admintool
|
||||
from ipapython import admintool, config
|
||||
from ipapython.ipa_log_manager import standard_logging_setup
|
||||
from ipapython.ipautil import (CheckedIPAddress, CheckedIPAddressLoopback,
|
||||
private_ccache)
|
||||
@@ -131,7 +130,9 @@ class ConfigureTool(admintool.AdminTool):
|
||||
raise NotImplementedError
|
||||
|
||||
@classmethod
|
||||
def add_options(cls, parser, positional=False):
|
||||
def add_options( # pylint: disable=arguments-renamed
|
||||
cls, parser, positional=False
|
||||
):
|
||||
transformed_cls = cls._transform(cls.configurable_class)
|
||||
|
||||
if issubclass(transformed_cls, common.Interactive):
|
||||
@@ -156,7 +157,7 @@ class ConfigureTool(admintool.AdminTool):
|
||||
try:
|
||||
opt_group = groups[group_cls]
|
||||
except KeyError:
|
||||
opt_group = groups[group_cls] = optparse.OptionGroup(
|
||||
opt_group = groups[group_cls] = config.OptionGroup(
|
||||
parser, "{0} options".format(group_cls.description))
|
||||
parser.add_option_group(opt_group)
|
||||
|
||||
@@ -230,7 +231,7 @@ class ConfigureTool(admintool.AdminTool):
|
||||
if not hidden:
|
||||
help = knob_cls.description
|
||||
else:
|
||||
help = optparse.SUPPRESS_HELP
|
||||
help = config.SUPPRESS_HELP
|
||||
|
||||
opt_group.add_option(
|
||||
*opt_strs,
|
||||
@@ -254,7 +255,7 @@ class ConfigureTool(admintool.AdminTool):
|
||||
|
||||
# fake option parser to parse positional arguments
|
||||
# (because optparse does not support positional argument parsing)
|
||||
fake_option_parser = optparse.OptionParser()
|
||||
fake_option_parser = config.IPAOptionParser()
|
||||
self.add_options(fake_option_parser, True)
|
||||
|
||||
fake_option_map = {option.dest: option
|
||||
@@ -329,6 +330,8 @@ class ConfigureTool(admintool.AdminTool):
|
||||
except RuntimeError as e:
|
||||
self.option_parser.error(str(e))
|
||||
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
cfgr = self.init_configurator()
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class KnobValueError(ValueError):
|
||||
self.name = name
|
||||
|
||||
|
||||
class PropertyBase(six.with_metaclass(util.InnerClassMeta, object)):
|
||||
class PropertyBase(metaclass=util.InnerClassMeta):
|
||||
# shut up pylint
|
||||
__outer_class__ = None
|
||||
__outer_name__ = None
|
||||
@@ -227,7 +227,7 @@ def extend_knob(base, default=_missing, bases=_missing, group=_missing,
|
||||
)
|
||||
|
||||
|
||||
class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
class Configurable(metaclass=abc.ABCMeta):
|
||||
"""
|
||||
Base class of all configurables.
|
||||
|
||||
@@ -415,7 +415,11 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
def __runner(self, pending_state, running_state, exc_handler):
|
||||
self.__transition(pending_state, running_state)
|
||||
|
||||
step = lambda: next(self.__gen)
|
||||
def step_next():
|
||||
return next(self.__gen)
|
||||
|
||||
step = step_next
|
||||
|
||||
while True:
|
||||
try:
|
||||
step()
|
||||
@@ -440,9 +444,13 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
yield
|
||||
except BaseException:
|
||||
exc_info = sys.exc_info()
|
||||
step = lambda: self.__gen.throw(*exc_info)
|
||||
|
||||
def step_throw():
|
||||
return self.__gen.throw(*exc_info)
|
||||
|
||||
step = step_throw
|
||||
else:
|
||||
step = lambda: next(self.__gen)
|
||||
step = step_next
|
||||
|
||||
def _handle_exception(self, exc_info):
|
||||
assert not hasattr(super(Configurable, self), '_handle_exception')
|
||||
@@ -479,7 +487,7 @@ class ComponentMeta(util.InnerClassMeta, abc.ABCMeta):
|
||||
pass
|
||||
|
||||
|
||||
class ComponentBase(six.with_metaclass(ComponentMeta, Configurable)):
|
||||
class ComponentBase(Configurable, metaclass=ComponentMeta):
|
||||
# shut up pylint
|
||||
__outer_class__ = None
|
||||
__outer_name__ = None
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
import weakref
|
||||
|
||||
import six
|
||||
|
||||
_cache = weakref.WeakValueDictionary()
|
||||
|
||||
@@ -27,7 +26,7 @@ class ListMeta(type):
|
||||
return _cache.get(key, t)
|
||||
|
||||
|
||||
class List(six.with_metaclass(ListMeta, list)):
|
||||
class List(list, metaclass=ListMeta):
|
||||
__parameters__ = ()
|
||||
|
||||
def __init__(self, *_args, **_kwargs):
|
||||
|
||||
Reference in New Issue
Block a user