Fix formatting, support null argument only
This commit is contained in:
parent
32cc077e1f
commit
9b0910767d
2 changed files with 7 additions and 9 deletions
|
@ -148,10 +148,12 @@ class MaxKeyFee(Setting[dict]):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_list(l):
|
def _parse_list(l):
|
||||||
if len(l) == 1 and (l[0] == 'null' or not l[0]):
|
if len(l) == 1 and l[0] == 'null':
|
||||||
return None
|
return None
|
||||||
assert len(l) == 2, ('Max key fee is made up of either two values: '
|
assert len(l) == 2, (
|
||||||
'"AMOUNT CURRENCY", or "null" (to set no limit)')
|
'Max key fee is made up of either two values: '
|
||||||
|
'"AMOUNT CURRENCY", or "null" (to set no limit)'
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
amount = float(l[0])
|
amount = float(l[0])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -162,8 +164,8 @@ class MaxKeyFee(Setting[dict]):
|
||||||
return {'amount': amount, 'currency': currency}
|
return {'amount': amount, 'currency': currency}
|
||||||
|
|
||||||
def deserialize(self, value):
|
def deserialize(self, value):
|
||||||
if not value:
|
if value is None:
|
||||||
return None
|
return
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return {
|
return {
|
||||||
'currency': value['currency'],
|
'currency': value['currency'],
|
||||||
|
|
|
@ -231,10 +231,6 @@ class ConfigurationTests(unittest.TestCase):
|
||||||
c = Config.create_from_arguments(args)
|
c = Config.create_from_arguments(args)
|
||||||
self.assertEqual(c.max_key_fee, None)
|
self.assertEqual(c.max_key_fee, None)
|
||||||
|
|
||||||
args = parser.parse_args(['--max-key-fee', ''])
|
|
||||||
c = Config.create_from_arguments(args)
|
|
||||||
self.assertEqual(c.max_key_fee, None)
|
|
||||||
|
|
||||||
# set
|
# set
|
||||||
args = parser.parse_args(['--max-key-fee', '1.0', 'BTC'])
|
args = parser.parse_args(['--max-key-fee', '1.0', 'BTC'])
|
||||||
c = Config.create_from_arguments(args)
|
c = Config.create_from_arguments(args)
|
||||||
|
|
Loading…
Add table
Reference in a new issue