Merge pull request #756 from lbryio/fix_integer_resolve
Fix error when resolving an integer
This commit is contained in:
commit
690ef15ba1
3 changed files with 21 additions and 5 deletions
|
@ -24,6 +24,8 @@ at anytime.
|
|||
* Fixed incorrect formatting of "amount" fields
|
||||
* Fixed handling of SIGINT, SIGTERM.
|
||||
* Fixed shutdown sequence
|
||||
* Fix error when resolving an integer
|
||||
*
|
||||
|
||||
### Deprecated
|
||||
* The API will no longer be served at the /lbryapi path. It will now be at the root.
|
||||
|
@ -81,7 +83,7 @@ at anytime.
|
|||
### Fixed
|
||||
* Fixed timeout behaviour when calling API command get
|
||||
* Fixed https://github.com/lbryio/lbry/issues/765
|
||||
|
||||
|
||||
### Removed
|
||||
* Removed stream_info_cache.json from daemon.py
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ def set_flag_vals(flag_names, parsed_args):
|
|||
elif key.startswith("--"):
|
||||
if remove_brackets(key[2:]) not in kwargs:
|
||||
k = remove_brackets(key[2:])
|
||||
kwargs[k] = guess_type(arg)
|
||||
elif key in flag_names:
|
||||
if remove_brackets(flag_names[key]) not in kwargs:
|
||||
kwargs[remove_brackets(flag_names[key])] = guess_type(arg)
|
||||
k = remove_brackets(flag_names[key])
|
||||
elif remove_brackets(key) not in kwargs:
|
||||
kwargs[remove_brackets(key)] = guess_type(arg)
|
||||
k = remove_brackets(key)
|
||||
kwargs[k] = guess_type(arg, k)
|
||||
return kwargs
|
||||
|
||||
|
||||
|
@ -130,9 +130,11 @@ def main():
|
|||
return 1
|
||||
|
||||
|
||||
def guess_type(x):
|
||||
def guess_type(x, key=None):
|
||||
if not isinstance(x, (unicode, str)):
|
||||
return x
|
||||
if key in ('uri', 'channel_name', 'name', 'file_name', 'download_directory'):
|
||||
return x
|
||||
if x in ('true', 'True', 'TRUE'):
|
||||
return True
|
||||
if x in ('false', 'False', 'FALSE'):
|
||||
|
|
|
@ -16,3 +16,15 @@ class DaemonCLITests(unittest.TestCase):
|
|||
self.assertEqual(False, DaemonCLI.guess_type('false'))
|
||||
self.assertEqual(False, DaemonCLI.guess_type('False'))
|
||||
|
||||
|
||||
self.assertEqual('3', DaemonCLI.guess_type('3', key="uri"))
|
||||
self.assertEqual('0.3', DaemonCLI.guess_type('0.3', key="uri"))
|
||||
self.assertEqual('True', DaemonCLI.guess_type('True', key="uri"))
|
||||
self.assertEqual('False', DaemonCLI.guess_type('False', key="uri"))
|
||||
|
||||
self.assertEqual('3', DaemonCLI.guess_type('3', key="file_name"))
|
||||
self.assertEqual('3', DaemonCLI.guess_type('3', key="name"))
|
||||
self.assertEqual('3', DaemonCLI.guess_type('3', key="download_directory"))
|
||||
self.assertEqual('3', DaemonCLI.guess_type('3', key="channel_name"))
|
||||
|
||||
self.assertEqual(3, DaemonCLI.guess_type('3', key="some_other_thing"))
|
||||
|
|
Loading…
Reference in a new issue