[cleanup] Sort imports

Using https://github.com/PyCQA/isort

    isort -m VERTICAL_HANGING_INDENT --py 36 -l 80 --rr -n --tc .
This commit is contained in:
pukkandan
2022-04-12 04:02:57 +05:30
parent 86e5f3ed2e
commit f82711587c
86 changed files with 556 additions and 671 deletions

View File

@@ -3,21 +3,14 @@ import hashlib
import json
import os.path
import re
import types
import ssl
import sys
import types
import yt_dlp.extractor
from yt_dlp import YoutubeDL
from yt_dlp.compat import (
compat_os_name,
compat_str,
)
from yt_dlp.utils import (
preferredencoding,
write_string,
)
from yt_dlp.compat import compat_os_name, compat_str
from yt_dlp.utils import preferredencoding, write_string
if 'pytest' in sys.modules:
import pytest

View File

@@ -3,15 +3,21 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL, expect_dict, expect_value, http_server_port
from yt_dlp.compat import compat_etree_fromstring, compat_http_server
from yt_dlp.extractor.common import InfoExtractor
from yt_dlp.extractor import YoutubeIE, get_info_extractor
from yt_dlp.utils import encode_data_uri, strip_jsonp, ExtractorError, RegexNotFoundError
import threading
from test.helper import FakeYDL, expect_dict, expect_value, http_server_port
from yt_dlp.compat import compat_etree_fromstring, compat_http_server
from yt_dlp.extractor import YoutubeIE, get_info_extractor
from yt_dlp.extractor.common import InfoExtractor
from yt_dlp.utils import (
ExtractorError,
RegexNotFoundError,
encode_data_uri,
strip_jsonp,
)
TEAPOT_RESPONSE_STATUS = 418
TEAPOT_RESPONSE_BODY = "<h1>418 I'm a teapot</h1>"

View File

@@ -3,18 +3,29 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import copy
import json
from test.helper import FakeYDL, assertRegexpMatches
from yt_dlp import YoutubeDL
from yt_dlp.compat import compat_os_name, compat_setenv, compat_str, compat_urllib_error
from yt_dlp.compat import (
compat_os_name,
compat_setenv,
compat_str,
compat_urllib_error,
)
from yt_dlp.extractor import YoutubeIE
from yt_dlp.extractor.common import InfoExtractor
from yt_dlp.postprocessor.common import PostProcessor
from yt_dlp.utils import ExtractorError, int_or_none, match_filter_func, LazyList
from yt_dlp.utils import (
ExtractorError,
LazyList,
int_or_none,
match_filter_func,
)
TEST_URL = 'http://localhost/sample.mp4'

View File

@@ -4,6 +4,7 @@ import re
import sys
import tempfile
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from yt_dlp.utils import YoutubeDLCookieJar

View File

@@ -3,26 +3,28 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import base64
from yt_dlp.aes import (
aes_decrypt,
aes_encrypt,
aes_ecb_encrypt,
aes_ecb_decrypt,
BLOCK_SIZE_BYTES,
aes_cbc_decrypt,
aes_cbc_decrypt_bytes,
aes_cbc_encrypt,
aes_ctr_decrypt,
aes_ctr_encrypt,
aes_decrypt,
aes_decrypt_text,
aes_ecb_decrypt,
aes_ecb_encrypt,
aes_encrypt,
aes_gcm_decrypt_and_verify,
aes_gcm_decrypt_and_verify_bytes,
aes_decrypt_text,
BLOCK_SIZE_BYTES,
)
from yt_dlp.compat import compat_pycrypto_AES
from yt_dlp.utils import bytes_to_intlist, intlist_to_bytes
import base64
# the encrypted data can be generate with 'devscripts/generate_aes_testdata.py'

View File

@@ -3,9 +3,10 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import try_rm, is_download_test
from test.helper import is_download_test, try_rm
from yt_dlp import YoutubeDL

View File

@@ -1,19 +1,16 @@
#!/usr/bin/env python3
# Allow direct execution
import collections
import os
import sys
import unittest
import collections
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import gettestcases
from yt_dlp.extractor import (
FacebookIE,
gen_extractors,
YoutubeIE,
)
from yt_dlp.extractor import FacebookIE, YoutubeIE, gen_extractors
class TestAllURLsMatching(unittest.TestCase):

View File

@@ -1,14 +1,15 @@
#!/usr/bin/env python3
import shutil
# Allow direct execution
import os
import shutil
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL
from yt_dlp.cache import Cache

View File

@@ -3,14 +3,15 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from yt_dlp.compat import (
compat_getenv,
compat_setenv,
compat_etree_fromstring,
compat_expanduser,
compat_getenv,
compat_setenv,
compat_str,
compat_struct_unpack,
compat_urllib_parse_unquote,

View File

@@ -6,10 +6,10 @@ from yt_dlp.cookies import (
LinuxChromeCookieDecryptor,
MacChromeCookieDecryptor,
WindowsChromeCookieDecryptor,
parse_safari_cookies,
pbkdf2_sha1,
_get_linux_desktop_environment,
_LinuxDesktopEnvironment,
parse_safari_cookies,
pbkdf2_sha1,
)

View File

@@ -1,8 +1,12 @@
#!/usr/bin/env python3
# Allow direct execution
import hashlib
import json
import os
import socket
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import (
@@ -16,24 +20,19 @@ from test.helper import (
try_rm,
)
import hashlib
import json
import socket
import yt_dlp.YoutubeDL
from yt_dlp.compat import (
compat_http_client,
compat_urllib_error,
compat_HTTPError,
compat_urllib_error,
)
from yt_dlp.extractor import get_info_extractor
from yt_dlp.utils import (
DownloadError,
ExtractorError,
format_bytes,
UnavailableVideoError,
format_bytes,
)
from yt_dlp.extractor import get_info_extractor
RETRIES = 3

View File

@@ -4,14 +4,16 @@ import os
import re
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import threading
from test.helper import http_server_port, try_rm
from yt_dlp import YoutubeDL
from yt_dlp.compat import compat_http_server
from yt_dlp.downloader.http import HttpFD
from yt_dlp.utils import encodeFilename
import threading
TEST_DIR = os.path.dirname(os.path.abspath(__file__))

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import unittest
import sys
import os
import subprocess
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from yt_dlp.utils import encodeArgument

View File

@@ -3,13 +3,15 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import http_server_port
from yt_dlp import YoutubeDL
from yt_dlp.compat import compat_http_server, compat_urllib_request
import ssl
import threading
from test.helper import http_server_port
from yt_dlp import YoutubeDL
from yt_dlp.compat import compat_http_server, compat_urllib_request
TEST_DIR = os.path.dirname(os.path.abspath(__file__))

View File

@@ -3,9 +3,11 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL, is_download_test
from yt_dlp.extractor import IqiyiIE

View File

@@ -3,6 +3,7 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from yt_dlp.jsinterp import JSInterpreter

View File

@@ -1,6 +1,7 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env python3
import os
from os.path import join
import subprocess
import sys
import unittest
from os.path import join
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import is_download_test, try_rm
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
download_file = join(root_dir, 'test.webm')

View File

@@ -2,9 +2,11 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import get_params, try_rm, is_download_test
from test.helper import get_params, is_download_test, try_rm
import yt_dlp.YoutubeDL
from yt_dlp.utils import DownloadError

View File

@@ -13,7 +13,7 @@ from yt_dlp.postprocessor import (
FFmpegThumbnailsConvertorPP,
MetadataFromFieldPP,
MetadataParserPP,
ModifyChaptersPP
ModifyChaptersPP,
)

View File

@@ -3,20 +3,14 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import random
import subprocess
from test.helper import FakeYDL, get_params, is_download_test
from test.helper import (
FakeYDL,
get_params,
is_download_test,
)
from yt_dlp.compat import (
compat_str,
compat_urllib_request,
)
from yt_dlp.compat import compat_str, compat_urllib_request
@is_download_test

View File

@@ -3,29 +3,29 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL, md5, is_download_test
from test.helper import FakeYDL, is_download_test, md5
from yt_dlp.extractor import (
YoutubeIE,
NPOIE,
NRKTVIE,
PBSIE,
CeskaTelevizeIE,
ComedyCentralIE,
DailymotionIE,
DemocracynowIE,
LyndaIE,
RaiPlayIE,
RTVEALaCartaIE,
TedTalkIE,
ThePlatformFeedIE,
ThePlatformIE,
VikiIE,
VimeoIE,
WallaIE,
CeskaTelevizeIE,
LyndaIE,
NPOIE,
PBSIE,
ComedyCentralIE,
NRKTVIE,
RaiPlayIE,
VikiIE,
ThePlatformIE,
ThePlatformFeedIE,
RTVEALaCartaIE,
DemocracynowIE,
YoutubeIE,
)

View File

@@ -3,10 +3,12 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import json
from yt_dlp.update import rsa_verify

View File

@@ -3,6 +3,7 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -12,75 +13,95 @@ import itertools
import json
import xml.etree.ElementTree
from yt_dlp.compat import (
compat_chr,
compat_etree_fromstring,
compat_getenv,
compat_HTMLParseError,
compat_os_name,
compat_setenv,
)
from yt_dlp.utils import (
Config,
DateRange,
ExtractorError,
InAdvancePagedList,
LazyList,
OnDemandPagedList,
age_restricted,
args_to_str,
encode_base_n,
base_url,
caesar,
clean_html,
clean_podcast_url,
Config,
cli_bool_option,
cli_option,
cli_valueless_option,
date_from_str,
datetime_from_str,
DateRange,
detect_exe_version,
determine_ext,
dfxp2srt,
dict_get,
encode_base_n,
encode_compat_str,
encodeFilename,
escape_rfc3986,
escape_url,
expand_path,
extract_attributes,
ExtractorError,
find_xpath_attr,
fix_xml_ampersands,
format_bytes,
float_or_none,
get_element_by_class,
format_bytes,
get_element_by_attribute,
get_elements_by_class,
get_elements_by_attribute,
get_element_html_by_class,
get_element_by_class,
get_element_html_by_attribute,
get_elements_html_by_class,
get_elements_html_by_attribute,
get_elements_text_and_html_by_attribute,
get_element_html_by_class,
get_element_text_and_html_by_tag,
InAdvancePagedList,
get_elements_by_attribute,
get_elements_by_class,
get_elements_html_by_attribute,
get_elements_html_by_class,
get_elements_text_and_html_by_attribute,
int_or_none,
intlist_to_bytes,
iri_to_uri,
is_html,
js_to_json,
limit_length,
locked_file,
lowercase_escape,
match_str,
merge_dicts,
mimetype2ext,
month_by_name,
multipart_encode,
ohdave_rsa_encrypt,
OnDemandPagedList,
orderedSet,
parse_age_limit,
parse_bitrate,
parse_codecs,
parse_count,
parse_dfxp_time_expr,
parse_duration,
parse_filesize,
parse_count,
parse_iso8601,
parse_resolution,
parse_bitrate,
parse_qs,
parse_resolution,
pkcs1pad,
prepend_extension,
read_batch_urls,
remove_end,
remove_quotes,
remove_start,
render_table,
replace_extension,
rot47,
sanitize_filename,
sanitize_path,
sanitize_url,
sanitized_Request,
expand_path,
prepend_extension,
replace_extension,
remove_start,
remove_end,
remove_quotes,
rot47,
shell_quote,
smuggle_url,
str_to_int,
@@ -92,38 +113,18 @@ from yt_dlp.utils import (
unified_strdate,
unified_timestamp,
unsmuggle_url,
update_url_query,
uppercase_escape,
lowercase_escape,
url_basename,
url_or_none,
base_url,
urljoin,
urlencode_postdata,
urljoin,
urshift,
update_url_query,
version_tuple,
xpath_with_ns,
xpath_attr,
xpath_element,
xpath_text,
xpath_attr,
render_table,
match_str,
parse_dfxp_time_expr,
dfxp2srt,
cli_option,
cli_valueless_option,
cli_bool_option,
parse_codecs,
iri_to_uri,
LazyList,
)
from yt_dlp.compat import (
compat_chr,
compat_etree_fromstring,
compat_getenv,
compat_HTMLParseError,
compat_os_name,
compat_setenv,
xpath_with_ns,
)

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import unittest
import sys
import os
import subprocess
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

View File

@@ -3,17 +3,15 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import get_params, try_rm, is_download_test
import io
import xml.etree.ElementTree
from test.helper import get_params, is_download_test, try_rm
import yt_dlp.YoutubeDL
import yt_dlp.extractor
import yt_dlp.YoutubeDL
class YoutubeDL(yt_dlp.YoutubeDL):

View File

@@ -3,14 +3,12 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL, is_download_test
from yt_dlp.extractor import (
YoutubeIE,
YoutubeTabIE,
)
from yt_dlp.extractor import YoutubeIE, YoutubeTabIE
@is_download_test

View File

@@ -3,6 +3,7 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

View File

@@ -3,16 +3,17 @@
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import re
import string
import urllib.request
from test.helper import FakeYDL, is_download_test
from yt_dlp.compat import compat_str
from yt_dlp.extractor import YoutubeIE
from yt_dlp.jsinterp import JSInterpreter
from yt_dlp.compat import compat_str
_SIG_TESTS = [
(