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