1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-02 09:12:40 +01:00

[utils] Skip missing params in cli_bool_option (closes #13865)

This commit is contained in:
Sergey M․ 2017-08-09 22:28:19 +07:00
parent 4bf22f7a10
commit 5b232f46dc
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D
2 changed files with 6 additions and 0 deletions

View File

@ -1182,6 +1182,10 @@ def test_cli_bool_option(self):
cli_bool_option( cli_bool_option(
{'nocheckcertificate': False}, '--check-certificate', 'nocheckcertificate', 'false', 'true', '='), {'nocheckcertificate': False}, '--check-certificate', 'nocheckcertificate', 'false', 'true', '='),
['--check-certificate=true']) ['--check-certificate=true'])
self.assertEqual(
cli_bool_option(
{}, '--check-certificate', 'nocheckcertificate', 'false', 'true', '='),
[])
def test_ohdave_rsa_encrypt(self): def test_ohdave_rsa_encrypt(self):
N = 0xab86b6371b5318aaa1d3c9e612a9f1264f372323c8c0f19875b5fc3b3fd3afcc1e5bec527aa94bfa85bffc157e4245aebda05389a5357b75115ac94f074aefcd N = 0xab86b6371b5318aaa1d3c9e612a9f1264f372323c8c0f19875b5fc3b3fd3afcc1e5bec527aa94bfa85bffc157e4245aebda05389a5357b75115ac94f074aefcd

View File

@ -2733,6 +2733,8 @@ def cli_option(params, command_option, param):
def cli_bool_option(params, command_option, param, true_value='true', false_value='false', separator=None): def cli_bool_option(params, command_option, param, true_value='true', false_value='false', separator=None):
param = params.get(param) param = params.get(param)
if param is None:
return []
assert isinstance(param, bool) assert isinstance(param, bool)
if separator: if separator:
return [command_option + separator + (true_value if param else false_value)] return [command_option + separator + (true_value if param else false_value)]