[misc] Fixes formatting.
This commit is contained in:
@ -51,7 +51,7 @@ class ConfigurableMeta(type):
|
||||
return (processor for _, processor in cls.__processors)
|
||||
|
||||
def __repr__(self):
|
||||
return ' '.join(('<Configurable', super(ConfigurableMeta, self).__repr__().split(' ', 1)[1],))
|
||||
return ' '.join(('<Configurable', super(ConfigurableMeta, self).__repr__().split(' ', 1)[1], ))
|
||||
|
||||
|
||||
try:
|
||||
@ -61,6 +61,7 @@ except:
|
||||
|
||||
PartiallyConfigured = functools.partial
|
||||
else:
|
||||
|
||||
class PartiallyConfigured(_functools.partial):
|
||||
@property # TODO XXX cache this shit
|
||||
def _options_values(self):
|
||||
@ -160,9 +161,7 @@ class Configurable(metaclass=ConfigurableMeta):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# initialize option's value dictionary, used by descriptor implementation (see Option).
|
||||
self._options_values = {
|
||||
**kwargs
|
||||
}
|
||||
self._options_values = {**kwargs}
|
||||
|
||||
# set option values.
|
||||
for name, value in kwargs.items():
|
||||
|
||||
@ -130,13 +130,12 @@ class Method(Option):
|
||||
|
||||
def __set__(self, inst, value):
|
||||
if not hasattr(value, '__call__'):
|
||||
raise TypeError('Option of type {!r} is expecting a callable value, got {!r} object (which is not).'.format(
|
||||
type(self).__name__, type(value).__name__))
|
||||
raise TypeError(
|
||||
'Option of type {!r} is expecting a callable value, got {!r} object (which is not).'.
|
||||
format(type(self).__name__, type(value).__name__)
|
||||
)
|
||||
inst._options_values[self.name] = self.type(value) if self.type else value
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
# only here to trick IDEs into thinking this is callable.
|
||||
raise NotImplementedError('You cannot call the descriptor')
|
||||
|
||||
|
||||
|
||||
|
||||
@ -73,15 +73,15 @@ def display(row):
|
||||
|
||||
print(
|
||||
' - {}address{}: {address}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, address=', '.join(address))
|
||||
format(Fore.BLUE, Style.RESET_ALL, address=', '.join(address))
|
||||
)
|
||||
print(
|
||||
' - {}links{}: {links}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, links=', '.join(row['links']))
|
||||
format(Fore.BLUE, Style.RESET_ALL, links=', '.join(row['links']))
|
||||
)
|
||||
print(
|
||||
' - {}geometry{}: {geometry}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, **row)
|
||||
format(Fore.BLUE, Style.RESET_ALL, **row)
|
||||
)
|
||||
print(
|
||||
' - {}source{}: {source}'.format(
|
||||
|
||||
@ -12,7 +12,7 @@ class IOFormatEnabled(Configurable):
|
||||
if len(args) != 1 or len(kwargs):
|
||||
raise UnrecoverableValueError(
|
||||
'Wrong input formating: IOFORMAT=ARG0 implies one arg and no kwargs, got args={!r} and kwargs={!r}.'.
|
||||
format(args, kwargs)
|
||||
format(args, kwargs)
|
||||
)
|
||||
return args[0]
|
||||
|
||||
@ -20,7 +20,7 @@ class IOFormatEnabled(Configurable):
|
||||
if len(args) or not len(kwargs):
|
||||
raise UnrecoverableValueError(
|
||||
'Wrong input formating: IOFORMAT=KWARGS ioformat implies no arg, got args={!r} and kwargs={!r}.'.
|
||||
format(args, kwargs)
|
||||
format(args, kwargs)
|
||||
)
|
||||
return kwargs
|
||||
|
||||
|
||||
@ -68,14 +68,15 @@ def istype(mixed):
|
||||
return isinstance(mixed, type)
|
||||
|
||||
|
||||
ConfigurableInspection = namedtuple('ConfigurableInspection',
|
||||
[
|
||||
'type',
|
||||
'instance',
|
||||
'options',
|
||||
'processors',
|
||||
'partial',
|
||||
])
|
||||
ConfigurableInspection = namedtuple(
|
||||
'ConfigurableInspection', [
|
||||
'type',
|
||||
'instance',
|
||||
'options',
|
||||
'processors',
|
||||
'partial',
|
||||
]
|
||||
)
|
||||
|
||||
ConfigurableInspection.__enter__ = lambda self: self
|
||||
ConfigurableInspection.__exit__ = lambda *exc_details: None
|
||||
@ -103,7 +104,8 @@ def inspect_node(mixed, *, _partial=None):
|
||||
return inspect_node(mixed.func, _partial=(mixed.args, mixed.keywords))
|
||||
else:
|
||||
raise TypeError(
|
||||
'Not a Configurable, nor a Configurable instance and not even a partially configured Configurable. Check your inputs.')
|
||||
'Not a Configurable, nor a Configurable instance and not even a partially configured Configurable. Check your inputs.'
|
||||
)
|
||||
|
||||
return ConfigurableInspection(
|
||||
typ,
|
||||
|
||||
Reference in New Issue
Block a user