_legacy.py 3.9 KB

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