23 import xml
.etree
.ElementTree
as etree
24 from subprocess
import DEVNULL
27 import asyncio
# noqa: F401
28 import re
# noqa: F401
29 from asyncio
import run
as compat_asyncio_run
# noqa: F401
30 from re
import Pattern
as compat_Pattern
# noqa: F401
31 from re
import match
as compat_Match
# noqa: F401
33 from . import compat_expanduser
, compat_HTMLParseError
, compat_realpath
34 from .compat_utils
import passthrough_module
35 from ..dependencies
import brotli
as compat_brotli
# noqa: F401
36 from ..dependencies
import websockets
as compat_websockets
# noqa: F401
37 from ..dependencies
.Cryptodome
import AES
as compat_pycrypto_AES
# noqa: F401
39 passthrough_module(__name__
, '...utils', ('WINDOWS_VT_MODE', 'windows_enable_vt_mode'))
42 # compat_ctypes_WINFUNCTYPE = ctypes.WINFUNCTYPE
43 # will not work since ctypes.WINFUNCTYPE does not exist in UNIX machines
44 def compat_ctypes_WINFUNCTYPE(*args
, **kwargs
):
45 return ctypes
.WINFUNCTYPE(*args
, **kwargs
)
48 def compat_setenv(key
, value
, env
=os
.environ
):
52 compat_base64_b64decode
= base64
.b64decode
53 compat_basestring
= str
54 compat_casefold
= str.casefold
56 compat_collections_abc
= collections
.abc
57 compat_cookiejar
= compat_http_cookiejar
= http
.cookiejar
58 compat_cookiejar_Cookie
= compat_http_cookiejar_Cookie
= http
.cookiejar
.Cookie
59 compat_cookies
= compat_http_cookies
= http
.cookies
60 compat_cookies_SimpleCookie
= compat_http_cookies_SimpleCookie
= http
.cookies
.SimpleCookie
61 compat_etree_Element
= compat_xml_etree_ElementTree_Element
= etree
.Element
62 compat_etree_register_namespace
= compat_xml_etree_register_namespace
= etree
.register_namespace
63 compat_filter
= filter
64 compat_get_terminal_size
= shutil
.get_terminal_size
65 compat_getenv
= os
.getenv
66 compat_getpass
= compat_getpass_getpass
= getpass
.getpass
67 compat_html_entities
= html
.entities
68 compat_html_entities_html5
= html
.entities
.html5
69 compat_html_parser_HTMLParseError
= compat_HTMLParseError
70 compat_HTMLParser
= compat_html_parser_HTMLParser
= html
.parser
.HTMLParser
71 compat_http_client
= http
.client
72 compat_http_server
= http
.server
74 compat_integer_types
= (int, )
75 compat_itertools_count
= itertools
.count
76 compat_kwargs
= lambda kwargs
: kwargs
78 compat_numeric_types
= (int, float, complex)
79 compat_os_path_expanduser
= compat_expanduser
80 compat_os_path_realpath
= compat_realpath
82 compat_shlex_split
= shlex
.split
83 compat_socket_create_connection
= socket
.create_connection
84 compat_Struct
= struct
.Struct
85 compat_struct_pack
= struct
.pack
86 compat_struct_unpack
= struct
.unpack
87 compat_subprocess_get_DEVNULL
= lambda: DEVNULL
88 compat_tokenize_tokenize
= tokenize
.tokenize
89 compat_urllib_error
= urllib
.error
90 compat_urllib_HTTPError
= urllib
.error
.HTTPError
91 compat_urllib_parse
= urllib
.parse
92 compat_urllib_parse_parse_qs
= urllib
.parse
.parse_qs
93 compat_urllib_parse_quote
= urllib
.parse
.quote
94 compat_urllib_parse_quote_plus
= urllib
.parse
.quote_plus
95 compat_urllib_parse_unquote_plus
= urllib
.parse
.unquote_plus
96 compat_urllib_parse_unquote_to_bytes
= urllib
.parse
.unquote_to_bytes
97 compat_urllib_parse_urlunparse
= urllib
.parse
.urlunparse
98 compat_urllib_request
= urllib
.request
99 compat_urllib_request_DataHandler
= urllib
.request
.DataHandler
100 compat_urllib_response
= urllib
.response
101 compat_urlretrieve
= compat_urllib_request_urlretrieve
= urllib
.request
.urlretrieve
102 compat_xml_parse_error
= compat_xml_etree_ElementTree_ParseError
= etree
.ParseError
103 compat_xpath
= lambda xpath
: xpath
105 workaround_optparse_bug9161
= lambda: None