forked from LBRYCommunity/lbry-sdk
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
|
||||
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
|
||||
assert len(l) == 2, ('Max key fee is made up of either two values: '
|
||||
'"AMOUNT CURRENCY", or "null" (to set no limit)')
|
||||
assert len(l) == 2, (
|
||||
'Max key fee is made up of either two values: '
|
||||
'"AMOUNT CURRENCY", or "null" (to set no limit)'
|
||||
)
|
||||
try:
|
||||
amount = float(l[0])
|
||||
except ValueError:
|
||||
|
@ -162,8 +164,8 @@ class MaxKeyFee(Setting[dict]):
|
|||
return {'amount': amount, 'currency': currency}
|
||||
|
||||
def deserialize(self, value):
|
||||
if not value:
|
||||
return None
|
||||
if value is None:
|
||||
return
|
||||
if isinstance(value, dict):
|
||||
return {
|
||||
'currency': value['currency'],
|
||||
|
|
|
@ -231,10 +231,6 @@ class ConfigurationTests(unittest.TestCase):
|
|||
c = Config.create_from_arguments(args)
|
||||
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
|
||||
args = parser.parse_args(['--max-key-fee', '1.0', 'BTC'])
|
||||
c = Config.create_from_arguments(args)
|
||||
|
|
Loading…
Reference in a new issue