Code formating.
This commit is contained in:
@ -5,6 +5,7 @@ __all__ = [
|
|||||||
'Option',
|
'Option',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class ConfigurableMeta(type):
|
class ConfigurableMeta(type):
|
||||||
"""
|
"""
|
||||||
Metaclass for Configurables that will add options to a special __options__ dict.
|
Metaclass for Configurables that will add options to a special __options__ dict.
|
||||||
|
|||||||
@ -26,5 +26,3 @@ class Option:
|
|||||||
|
|
||||||
def __set__(self, inst, value):
|
def __set__(self, inst, value):
|
||||||
inst.__options_values__[self.name] = self.type(value) if self.type else value
|
inst.__options_values__[self.name] = self.type(value) if self.type else value
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class CsvReader(CsvHandler, FileReader):
|
|||||||
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if len(row) != field_count:
|
if len(row) != field_count:
|
||||||
raise ValueError('Got a line with %d fields, expecting %d.' % (len(row), field_count,))
|
raise ValueError('Got a line with %d fields, expecting %d.' % (len(row), field_count, ))
|
||||||
|
|
||||||
yield dict(zip(headers.value, row))
|
yield dict(zip(headers.value, row))
|
||||||
|
|
||||||
|
|||||||
@ -129,10 +129,10 @@ class ValueHolder:
|
|||||||
return divmod(other, self.value)
|
return divmod(other, self.value)
|
||||||
|
|
||||||
def __pow__(self, other):
|
def __pow__(self, other):
|
||||||
return self.value ** other
|
return self.value**other
|
||||||
|
|
||||||
def __rpow__(self, other):
|
def __rpow__(self, other):
|
||||||
return other ** self.value
|
return other**self.value
|
||||||
|
|
||||||
def __ipow__(self, other):
|
def __ipow__(self, other):
|
||||||
self.value **= other
|
self.value **= other
|
||||||
|
|||||||
@ -18,6 +18,7 @@ class MyHarderConfigurable(MyConfigurable):
|
|||||||
class MyBetterConfigurable(MyConfigurable):
|
class MyBetterConfigurable(MyConfigurable):
|
||||||
required_str = Option(str, required=False, default='kaboom')
|
required_str = Option(str, required=False, default='kaboom')
|
||||||
|
|
||||||
|
|
||||||
class MyConfigurableUsingPositionalOptions(MyConfigurable):
|
class MyConfigurableUsingPositionalOptions(MyConfigurable):
|
||||||
first = Option(str, required=True, positional=True)
|
first = Option(str, required=True, positional=True)
|
||||||
second = Option(str, required=True, positional=True)
|
second = Option(str, required=True, positional=True)
|
||||||
@ -142,4 +143,3 @@ def test_service_dependency_unavailable():
|
|||||||
|
|
||||||
def test_option_positional():
|
def test_option_positional():
|
||||||
o = MyConfigurableUsingPositionalOptions('1', '2', '3', required_str='hello')
|
o = MyConfigurableUsingPositionalOptions('1', '2', '3', required_str='hello')
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,3 @@ def test_valueholder():
|
|||||||
assert y == x
|
assert y == x
|
||||||
assert y is not x
|
assert y is not x
|
||||||
assert repr(x) == repr(y) == repr(43)
|
assert repr(x) == repr(y) == repr(43)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user