]> jfr.im git - yt-dlp.git/blame_incremental - yt_dlp/compat/_legacy.py
[ie/brightcove] Upgrade requests to HTTPS (#10202)
[yt-dlp.git] / yt_dlp / compat / _legacy.py
... / ...
CommitLineData
1""" Do not use! """
2
3import base64
4import collections
5import ctypes
6import getpass
7import html.entities
8import html.parser
9import http.client
10import http.cookiejar
11import http.cookies
12import http.server
13import itertools
14import os
15import shlex
16import shutil
17import socket
18import struct
19import subprocess
20import tokenize
21import urllib.error
22import urllib.parse
23import urllib.request
24import xml.etree.ElementTree as etree
25
26# isort: split
27import asyncio # noqa: F401
28import re # noqa: F401
29from asyncio import run as compat_asyncio_run # noqa: F401
30from re import Pattern as compat_Pattern # noqa: F401
31from re import match as compat_Match # noqa: F401
32
33from . import compat_expanduser, compat_HTMLParseError, compat_realpath
34from .compat_utils import passthrough_module
35from ..dependencies import brotli as compat_brotli # noqa: F401
36from ..dependencies import websockets as compat_websockets # noqa: F401
37from ..dependencies.Cryptodome import AES as compat_pycrypto_AES # noqa: F401
38from ..networking.exceptions import HTTPError as compat_HTTPError
39
40passthrough_module(__name__, '...utils', ('WINDOWS_VT_MODE', 'windows_enable_vt_mode'))
41
42
43# compat_ctypes_WINFUNCTYPE = ctypes.WINFUNCTYPE
44# will not work since ctypes.WINFUNCTYPE does not exist in UNIX machines
45def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
46 return ctypes.WINFUNCTYPE(*args, **kwargs)
47
48
49def compat_setenv(key, value, env=os.environ):
50 env[key] = value
51
52
53compat_base64_b64decode = base64.b64decode
54compat_basestring = str
55compat_casefold = str.casefold
56compat_chr = chr
57compat_collections_abc = collections.abc
58compat_cookiejar = compat_http_cookiejar = http.cookiejar
59compat_cookiejar_Cookie = compat_http_cookiejar_Cookie = http.cookiejar.Cookie
60compat_cookies = compat_http_cookies = http.cookies
61compat_cookies_SimpleCookie = compat_http_cookies_SimpleCookie = http.cookies.SimpleCookie
62compat_etree_Element = compat_xml_etree_ElementTree_Element = etree.Element
63compat_etree_register_namespace = compat_xml_etree_register_namespace = etree.register_namespace
64compat_filter = filter
65compat_get_terminal_size = shutil.get_terminal_size
66compat_getenv = os.getenv
67compat_getpass = compat_getpass_getpass = getpass.getpass
68compat_html_entities = html.entities
69compat_html_entities_html5 = html.entities.html5
70compat_html_parser_HTMLParseError = compat_HTMLParseError
71compat_HTMLParser = compat_html_parser_HTMLParser = html.parser.HTMLParser
72compat_http_client = http.client
73compat_http_server = http.server
74compat_input = input
75compat_integer_types = (int, )
76compat_itertools_count = itertools.count
77compat_kwargs = lambda kwargs: kwargs
78compat_map = map
79compat_numeric_types = (int, float, complex)
80compat_os_path_expanduser = compat_expanduser
81compat_os_path_realpath = compat_realpath
82compat_print = print
83compat_shlex_split = shlex.split
84compat_socket_create_connection = socket.create_connection
85compat_Struct = struct.Struct
86compat_struct_pack = struct.pack
87compat_struct_unpack = struct.unpack
88compat_subprocess_get_DEVNULL = lambda: subprocess.DEVNULL
89compat_tokenize_tokenize = tokenize.tokenize
90compat_urllib_error = urllib.error
91compat_urllib_HTTPError = compat_HTTPError
92compat_urllib_parse = urllib.parse
93compat_urllib_parse_parse_qs = urllib.parse.parse_qs
94compat_urllib_parse_quote = urllib.parse.quote
95compat_urllib_parse_quote_plus = urllib.parse.quote_plus
96compat_urllib_parse_unquote_plus = urllib.parse.unquote_plus
97compat_urllib_parse_unquote_to_bytes = urllib.parse.unquote_to_bytes
98compat_urllib_parse_urlunparse = urllib.parse.urlunparse
99compat_urllib_request = urllib.request
100compat_urllib_request_DataHandler = urllib.request.DataHandler
101compat_urllib_response = urllib.response
102compat_urlretrieve = compat_urllib_request_urlretrieve = urllib.request.urlretrieve
103compat_xml_parse_error = compat_xml_etree_ElementTree_ParseError = etree.ParseError
104compat_xpath = lambda xpath: xpath
105compat_zip = zip
106workaround_optparse_bug9161 = lambda: None
107
108legacy = []