mirror of
				https://github.com/ytdl-org/youtube-dl.git
				synced 2025-10-29 09:26:20 -07:00 
			
		
		
		
	Update coding style after pycodestyle 2.1.0
In pycodestyle 2.1.0, E305 was introduced, which requires two blank lines after top level declarations, too. See https://github.com/PyCQA/pycodestyle/issues/400 See also #10689; thanks @stepshal for first mentioning this issue and initial patches
This commit is contained in:
		| @@ -25,5 +25,6 @@ def build_completion(opt_parser): | |||||||
|         filled_template = template.replace("{{flags}}", " ".join(opts_flag)) |         filled_template = template.replace("{{flags}}", " ".join(opts_flag)) | ||||||
|         f.write(filled_template) |         f.write(filled_template) | ||||||
|  |  | ||||||
|  |  | ||||||
| parser = youtube_dl.parseOpts()[0] | parser = youtube_dl.parseOpts()[0] | ||||||
| build_completion(parser) | build_completion(parser) | ||||||
|   | |||||||
| @@ -44,5 +44,6 @@ def build_completion(opt_parser): | |||||||
|     with open(FISH_COMPLETION_FILE, 'w') as f: |     with open(FISH_COMPLETION_FILE, 'w') as f: | ||||||
|         f.write(filled_template) |         f.write(filled_template) | ||||||
|  |  | ||||||
|  |  | ||||||
| parser = youtube_dl.parseOpts()[0] | parser = youtube_dl.parseOpts()[0] | ||||||
| build_completion(parser) | build_completion(parser) | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ def openssl_encode(algo, key, iv): | |||||||
|     out, _ = prog.communicate(secret_msg) |     out, _ = prog.communicate(secret_msg) | ||||||
|     return out |     return out | ||||||
|  |  | ||||||
|  |  | ||||||
| iv = key = [0x20, 0x15] + 14 * [0] | iv = key = [0x20, 0x15] + 14 * [0] | ||||||
|  |  | ||||||
| r = openssl_encode('aes-128-cbc', key, iv) | r = openssl_encode('aes-128-cbc', key, iv) | ||||||
|   | |||||||
| @@ -32,5 +32,6 @@ def main(): | |||||||
|     with open('supportedsites.html', 'w', encoding='utf-8') as sitesf: |     with open('supportedsites.html', 'w', encoding='utf-8') as sitesf: | ||||||
|         sitesf.write(template) |         sitesf.write(template) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
|   | |||||||
| @@ -28,5 +28,6 @@ def main(): | |||||||
|     with io.open(outfile, 'w', encoding='utf-8') as outf: |     with io.open(outfile, 'w', encoding='utf-8') as outf: | ||||||
|         outf.write(out) |         outf.write(out) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
|   | |||||||
| @@ -59,6 +59,7 @@ def build_lazy_ie(ie, name): | |||||||
|         s += make_valid_template.format(valid_url=ie._make_valid_url()) |         s += make_valid_template.format(valid_url=ie._make_valid_url()) | ||||||
|     return s |     return s | ||||||
|  |  | ||||||
|  |  | ||||||
| # find the correct sorting and add the required base classes so that sublcasses | # find the correct sorting and add the required base classes so that sublcasses | ||||||
| # can be correctly created | # can be correctly created | ||||||
| classes = _ALL_CLASSES[:-1] | classes = _ALL_CLASSES[:-1] | ||||||
|   | |||||||
| @@ -41,5 +41,6 @@ def main(): | |||||||
|     with io.open(outfile, 'w', encoding='utf-8') as outf: |     with io.open(outfile, 'w', encoding='utf-8') as outf: | ||||||
|         outf.write(out) |         outf.write(out) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
|   | |||||||
| @@ -74,5 +74,6 @@ def filter_options(readme): | |||||||
|  |  | ||||||
|     return ret |     return ret | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
|   | |||||||
| @@ -44,5 +44,6 @@ def build_completion(opt_parser): | |||||||
|     with open(ZSH_COMPLETION_FILE, "w") as f: |     with open(ZSH_COMPLETION_FILE, "w") as f: | ||||||
|         f.write(template) |         f.write(template) | ||||||
|  |  | ||||||
|  |  | ||||||
| parser = youtube_dl.parseOpts()[0] | parser = youtube_dl.parseOpts()[0] | ||||||
| build_completion(parser) | build_completion(parser) | ||||||
|   | |||||||
| @@ -84,5 +84,6 @@ class TestInfoExtractor(unittest.TestCase): | |||||||
|         self.assertRaises(ExtractorError, self.ie._download_json, uri, None) |         self.assertRaises(ExtractorError, self.ie._download_json, uri, None) | ||||||
|         self.assertEqual(self.ie._download_json(uri, None, fatal=False), None) |         self.assertEqual(self.ie._download_json(uri, None, fatal=False), None) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -51,5 +51,6 @@ class TestAES(unittest.TestCase): | |||||||
|         decrypted = (aes_decrypt_text(encrypted, password, 32)) |         decrypted = (aes_decrypt_text(encrypted, password, 32)) | ||||||
|         self.assertEqual(decrypted, self.secret_msg) |         self.assertEqual(decrypted, self.secret_msg) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -60,6 +60,7 @@ def _file_md5(fn): | |||||||
|     with open(fn, 'rb') as f: |     with open(fn, 'rb') as f: | ||||||
|         return hashlib.md5(f.read()).hexdigest() |         return hashlib.md5(f.read()).hexdigest() | ||||||
|  |  | ||||||
|  |  | ||||||
| defs = gettestcases() | defs = gettestcases() | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -217,6 +218,7 @@ def generator(test_case): | |||||||
|  |  | ||||||
|     return test_template |     return test_template | ||||||
|  |  | ||||||
|  |  | ||||||
| # And add them to TestDownload | # And add them to TestDownload | ||||||
| for n, test_case in enumerate(defs): | for n, test_case in enumerate(defs): | ||||||
|     test_method = generator(test_case) |     test_method = generator(test_case) | ||||||
|   | |||||||
| @@ -39,5 +39,6 @@ class TestExecution(unittest.TestCase): | |||||||
|         _, stderr = p.communicate() |         _, stderr = p.communicate() | ||||||
|         self.assertFalse(stderr) |         self.assertFalse(stderr) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -169,5 +169,6 @@ class TestProxy(unittest.TestCase): | |||||||
|         # b'xn--fiq228c' is '中文'.encode('idna') |         # b'xn--fiq228c' is '中文'.encode('idna') | ||||||
|         self.assertEqual(response, 'normal: http://xn--fiq228c.tw/') |         self.assertEqual(response, 'normal: http://xn--fiq228c.tw/') | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -43,5 +43,6 @@ class TestIqiyiSDKInterpreter(unittest.TestCase): | |||||||
|         ie._login() |         ie._login() | ||||||
|         self.assertTrue('unable to log in:' in logger.messages[0]) |         self.assertTrue('unable to log in:' in logger.messages[0]) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -112,5 +112,6 @@ class TestJSInterpreter(unittest.TestCase): | |||||||
|         ''') |         ''') | ||||||
|         self.assertEqual(jsi.call_function('z'), 5) |         self.assertEqual(jsi.call_function('z'), 5) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -1075,5 +1075,6 @@ The first line | |||||||
|         self.assertEqual(get_element_by_class('foo', html), 'nice') |         self.assertEqual(get_element_by_class('foo', html), 'nice') | ||||||
|         self.assertEqual(get_element_by_class('no-such-class', html), None) |         self.assertEqual(get_element_by_class('no-such-class', html), None) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -66,5 +66,6 @@ class TestVerboseOutput(unittest.TestCase): | |||||||
|         self.assertTrue(b'-p' in serr) |         self.assertTrue(b'-p' in serr) | ||||||
|         self.assertTrue(b'secret' not in serr) |         self.assertTrue(b'secret' not in serr) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ class YoutubeDL(youtube_dl.YoutubeDL): | |||||||
|         super(YoutubeDL, self).__init__(*args, **kwargs) |         super(YoutubeDL, self).__init__(*args, **kwargs) | ||||||
|         self.to_stderr = self.to_screen |         self.to_stderr = self.to_screen | ||||||
|  |  | ||||||
|  |  | ||||||
| params = get_params({ | params = get_params({ | ||||||
|     'writeannotations': True, |     'writeannotations': True, | ||||||
|     'skip_download': True, |     'skip_download': True, | ||||||
| @@ -74,5 +75,6 @@ class TestAnnotations(unittest.TestCase): | |||||||
|     def tearDown(self): |     def tearDown(self): | ||||||
|         try_rm(ANNOTATIONS_FILE) |         try_rm(ANNOTATIONS_FILE) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -66,5 +66,6 @@ class TestYoutubeLists(unittest.TestCase): | |||||||
|         for entry in result['entries']: |         for entry in result['entries']: | ||||||
|             self.assertTrue(entry.get('title')) |             self.assertTrue(entry.get('title')) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -114,6 +114,7 @@ def make_tfunc(url, stype, sig_input, expected_sig): | |||||||
|     test_func.__name__ = str('test_signature_' + stype + '_' + test_id) |     test_func.__name__ = str('test_signature_' + stype + '_' + test_id) | ||||||
|     setattr(TestSignature, test_func.__name__, test_func) |     setattr(TestSignature, test_func.__name__, test_func) | ||||||
|  |  | ||||||
|  |  | ||||||
| for test_spec in _TESTS: | for test_spec in _TESTS: | ||||||
|     make_tfunc(*test_spec) |     make_tfunc(*test_spec) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -449,4 +449,5 @@ def main(argv=None): | |||||||
|     except KeyboardInterrupt: |     except KeyboardInterrupt: | ||||||
|         sys.exit('\nERROR: Interrupted by user') |         sys.exit('\nERROR: Interrupted by user') | ||||||
|  |  | ||||||
|  |  | ||||||
| __all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors'] | __all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors'] | ||||||
|   | |||||||
| @@ -174,6 +174,7 @@ def aes_decrypt_text(data, password, key_size_bytes): | |||||||
|  |  | ||||||
|     return plaintext |     return plaintext | ||||||
|  |  | ||||||
|  |  | ||||||
| RCON = (0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36) | RCON = (0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36) | ||||||
| SBOX = (0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, | SBOX = (0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, | ||||||
|         0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, |         0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, | ||||||
| @@ -328,4 +329,5 @@ def inc(data): | |||||||
|             break |             break | ||||||
|     return data |     return data | ||||||
|  |  | ||||||
|  |  | ||||||
| __all__ = ['aes_encrypt', 'key_expansion', 'aes_ctr_decrypt', 'aes_cbc_decrypt', 'aes_decrypt_text'] | __all__ = ['aes_encrypt', 'key_expansion', 'aes_ctr_decrypt', 'aes_cbc_decrypt', 'aes_decrypt_text'] | ||||||
|   | |||||||
| @@ -2491,6 +2491,7 @@ class _TreeBuilder(etree.TreeBuilder): | |||||||
|     def doctype(self, name, pubid, system): |     def doctype(self, name, pubid, system): | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|  |  | ||||||
| if sys.version_info[0] >= 3: | if sys.version_info[0] >= 3: | ||||||
|     def compat_etree_fromstring(text): |     def compat_etree_fromstring(text): | ||||||
|         return etree.XML(text, parser=etree.XMLParser(target=_TreeBuilder())) |         return etree.XML(text, parser=etree.XMLParser(target=_TreeBuilder())) | ||||||
| @@ -2787,6 +2788,7 @@ def workaround_optparse_bug9161(): | |||||||
|             return real_add_option(self, *bargs, **bkwargs) |             return real_add_option(self, *bargs, **bkwargs) | ||||||
|         optparse.OptionGroup.add_option = _compat_add_option |         optparse.OptionGroup.add_option = _compat_add_option | ||||||
|  |  | ||||||
|  |  | ||||||
| if hasattr(shutil, 'get_terminal_size'):  # Python >= 3.3 | if hasattr(shutil, 'get_terminal_size'):  # Python >= 3.3 | ||||||
|     compat_get_terminal_size = shutil.get_terminal_size |     compat_get_terminal_size = shutil.get_terminal_size | ||||||
| else: | else: | ||||||
|   | |||||||
| @@ -293,6 +293,7 @@ class FFmpegFD(ExternalFD): | |||||||
| class AVconvFD(FFmpegFD): | class AVconvFD(FFmpegFD): | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
|  |  | ||||||
| _BY_NAME = dict( | _BY_NAME = dict( | ||||||
|     (klass.get_basename(), klass) |     (klass.get_basename(), klass) | ||||||
|     for name, klass in globals().items() |     for name, klass in globals().items() | ||||||
|   | |||||||
| @@ -103,6 +103,7 @@ class ProxyType(object): | |||||||
|     SOCKS4A = 1 |     SOCKS4A = 1 | ||||||
|     SOCKS5 = 2 |     SOCKS5 = 2 | ||||||
|  |  | ||||||
|  |  | ||||||
| Proxy = collections.namedtuple('Proxy', ( | Proxy = collections.namedtuple('Proxy', ( | ||||||
|     'type', 'host', 'port', 'username', 'password', 'remote_dns')) |     'type', 'host', 'port', 'username', 'password', 'remote_dns')) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -115,6 +115,8 @@ def _u30(reader): | |||||||
|     res = _read_int(reader) |     res = _read_int(reader) | ||||||
|     assert res & 0xf0000000 == 0 |     assert res & 0xf0000000 == 0 | ||||||
|     return res |     return res | ||||||
|  |  | ||||||
|  |  | ||||||
| _u32 = _read_int | _u32 = _read_int | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -176,6 +178,7 @@ class _Undefined(object): | |||||||
|         return 'undefined' |         return 'undefined' | ||||||
|     __repr__ = __str__ |     __repr__ = __str__ | ||||||
|  |  | ||||||
|  |  | ||||||
| undefined = _Undefined() | undefined = _Undefined() | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user