Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__init__.py +44 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/codec.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/compat.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/core.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/idnadata.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/intranges.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/package_data.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/uts46data.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/codec.py +112 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/compat.py +13 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/core.py +397 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/idnadata.py +2137 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/intranges.py +54 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/package_data.py +2 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/uts46data.py +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__init__.py +85 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/_collections.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/_version.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/connection.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/connectionpool.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/exceptions.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/fields.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/filepost.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/poolmanager.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/request.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/response.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/_collections.py +355 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/connection.py +569 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/connectionpool.py +1113 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__pycache__/bindings.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__pycache__/low_level.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/__pycache__/six.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/__pycache__/makefile.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/six.py +1077 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/poolmanager.py +539 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/request.py +170 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/response.py +821 -0
- llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__init__.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .package_data import __version__
|
2 |
+
from .core import (
|
3 |
+
IDNABidiError,
|
4 |
+
IDNAError,
|
5 |
+
InvalidCodepoint,
|
6 |
+
InvalidCodepointContext,
|
7 |
+
alabel,
|
8 |
+
check_bidi,
|
9 |
+
check_hyphen_ok,
|
10 |
+
check_initial_combiner,
|
11 |
+
check_label,
|
12 |
+
check_nfc,
|
13 |
+
decode,
|
14 |
+
encode,
|
15 |
+
ulabel,
|
16 |
+
uts46_remap,
|
17 |
+
valid_contextj,
|
18 |
+
valid_contexto,
|
19 |
+
valid_label_length,
|
20 |
+
valid_string_length,
|
21 |
+
)
|
22 |
+
from .intranges import intranges_contain
|
23 |
+
|
24 |
+
__all__ = [
|
25 |
+
"IDNABidiError",
|
26 |
+
"IDNAError",
|
27 |
+
"InvalidCodepoint",
|
28 |
+
"InvalidCodepointContext",
|
29 |
+
"alabel",
|
30 |
+
"check_bidi",
|
31 |
+
"check_hyphen_ok",
|
32 |
+
"check_initial_combiner",
|
33 |
+
"check_label",
|
34 |
+
"check_nfc",
|
35 |
+
"decode",
|
36 |
+
"encode",
|
37 |
+
"intranges_contain",
|
38 |
+
"ulabel",
|
39 |
+
"uts46_remap",
|
40 |
+
"valid_contextj",
|
41 |
+
"valid_contexto",
|
42 |
+
"valid_label_length",
|
43 |
+
"valid_string_length",
|
44 |
+
]
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (848 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/codec.cpython-310.pyc
ADDED
Binary file (2.82 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/compat.cpython-310.pyc
ADDED
Binary file (748 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/core.cpython-310.pyc
ADDED
Binary file (9.56 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/idnadata.cpython-310.pyc
ADDED
Binary file (38.2 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/intranges.cpython-310.pyc
ADDED
Binary file (1.99 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/package_data.cpython-310.pyc
ADDED
Binary file (212 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/uts46data.cpython-310.pyc
ADDED
Binary file (151 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/codec.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .core import encode, decode, alabel, ulabel, IDNAError
|
2 |
+
import codecs
|
3 |
+
import re
|
4 |
+
from typing import Tuple, Optional
|
5 |
+
|
6 |
+
_unicode_dots_re = re.compile('[\u002e\u3002\uff0e\uff61]')
|
7 |
+
|
8 |
+
class Codec(codecs.Codec):
|
9 |
+
|
10 |
+
def encode(self, data: str, errors: str = 'strict') -> Tuple[bytes, int]:
|
11 |
+
if errors != 'strict':
|
12 |
+
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
|
13 |
+
|
14 |
+
if not data:
|
15 |
+
return b"", 0
|
16 |
+
|
17 |
+
return encode(data), len(data)
|
18 |
+
|
19 |
+
def decode(self, data: bytes, errors: str = 'strict') -> Tuple[str, int]:
|
20 |
+
if errors != 'strict':
|
21 |
+
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
|
22 |
+
|
23 |
+
if not data:
|
24 |
+
return '', 0
|
25 |
+
|
26 |
+
return decode(data), len(data)
|
27 |
+
|
28 |
+
class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
|
29 |
+
def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
|
30 |
+
if errors != 'strict':
|
31 |
+
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
|
32 |
+
|
33 |
+
if not data:
|
34 |
+
return "", 0
|
35 |
+
|
36 |
+
labels = _unicode_dots_re.split(data)
|
37 |
+
trailing_dot = ''
|
38 |
+
if labels:
|
39 |
+
if not labels[-1]:
|
40 |
+
trailing_dot = '.'
|
41 |
+
del labels[-1]
|
42 |
+
elif not final:
|
43 |
+
# Keep potentially unfinished label until the next call
|
44 |
+
del labels[-1]
|
45 |
+
if labels:
|
46 |
+
trailing_dot = '.'
|
47 |
+
|
48 |
+
result = []
|
49 |
+
size = 0
|
50 |
+
for label in labels:
|
51 |
+
result.append(alabel(label))
|
52 |
+
if size:
|
53 |
+
size += 1
|
54 |
+
size += len(label)
|
55 |
+
|
56 |
+
# Join with U+002E
|
57 |
+
result_str = '.'.join(result) + trailing_dot # type: ignore
|
58 |
+
size += len(trailing_dot)
|
59 |
+
return result_str, size
|
60 |
+
|
61 |
+
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
62 |
+
def _buffer_decode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
|
63 |
+
if errors != 'strict':
|
64 |
+
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
|
65 |
+
|
66 |
+
if not data:
|
67 |
+
return ('', 0)
|
68 |
+
|
69 |
+
labels = _unicode_dots_re.split(data)
|
70 |
+
trailing_dot = ''
|
71 |
+
if labels:
|
72 |
+
if not labels[-1]:
|
73 |
+
trailing_dot = '.'
|
74 |
+
del labels[-1]
|
75 |
+
elif not final:
|
76 |
+
# Keep potentially unfinished label until the next call
|
77 |
+
del labels[-1]
|
78 |
+
if labels:
|
79 |
+
trailing_dot = '.'
|
80 |
+
|
81 |
+
result = []
|
82 |
+
size = 0
|
83 |
+
for label in labels:
|
84 |
+
result.append(ulabel(label))
|
85 |
+
if size:
|
86 |
+
size += 1
|
87 |
+
size += len(label)
|
88 |
+
|
89 |
+
result_str = '.'.join(result) + trailing_dot
|
90 |
+
size += len(trailing_dot)
|
91 |
+
return (result_str, size)
|
92 |
+
|
93 |
+
|
94 |
+
class StreamWriter(Codec, codecs.StreamWriter):
|
95 |
+
pass
|
96 |
+
|
97 |
+
|
98 |
+
class StreamReader(Codec, codecs.StreamReader):
|
99 |
+
pass
|
100 |
+
|
101 |
+
|
102 |
+
def getregentry() -> codecs.CodecInfo:
|
103 |
+
# Compatibility as a search_function for codecs.register()
|
104 |
+
return codecs.CodecInfo(
|
105 |
+
name='idna',
|
106 |
+
encode=Codec().encode, # type: ignore
|
107 |
+
decode=Codec().decode, # type: ignore
|
108 |
+
incrementalencoder=IncrementalEncoder,
|
109 |
+
incrementaldecoder=IncrementalDecoder,
|
110 |
+
streamwriter=StreamWriter,
|
111 |
+
streamreader=StreamReader,
|
112 |
+
)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/compat.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .core import *
|
2 |
+
from .codec import *
|
3 |
+
from typing import Any, Union
|
4 |
+
|
5 |
+
def ToASCII(label: str) -> bytes:
|
6 |
+
return encode(label)
|
7 |
+
|
8 |
+
def ToUnicode(label: Union[bytes, bytearray]) -> str:
|
9 |
+
return decode(label)
|
10 |
+
|
11 |
+
def nameprep(s: Any) -> None:
|
12 |
+
raise NotImplementedError('IDNA 2008 does not utilise nameprep protocol')
|
13 |
+
|
llmeval-env/lib/python3.10/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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from . import idnadata
|
2 |
+
import bisect
|
3 |
+
import unicodedata
|
4 |
+
import re
|
5 |
+
from typing import Union, Optional
|
6 |
+
from .intranges import intranges_contain
|
7 |
+
|
8 |
+
_virama_combining_class = 9
|
9 |
+
_alabel_prefix = b'xn--'
|
10 |
+
_unicode_dots_re = re.compile('[\u002e\u3002\uff0e\uff61]')
|
11 |
+
|
12 |
+
class IDNAError(UnicodeError):
|
13 |
+
""" Base exception for all IDNA-encoding related problems """
|
14 |
+
pass
|
15 |
+
|
16 |
+
|
17 |
+
class IDNABidiError(IDNAError):
|
18 |
+
""" Exception when bidirectional requirements are not satisfied """
|
19 |
+
pass
|
20 |
+
|
21 |
+
|
22 |
+
class InvalidCodepoint(IDNAError):
|
23 |
+
""" Exception when a disallowed or unallocated codepoint is used """
|
24 |
+
pass
|
25 |
+
|
26 |
+
|
27 |
+
class InvalidCodepointContext(IDNAError):
|
28 |
+
""" Exception when the codepoint is not valid in the context it is used """
|
29 |
+
pass
|
30 |
+
|
31 |
+
|
32 |
+
def _combining_class(cp: int) -> int:
|
33 |
+
v = unicodedata.combining(chr(cp))
|
34 |
+
if v == 0:
|
35 |
+
if not unicodedata.name(chr(cp)):
|
36 |
+
raise ValueError('Unknown character in unicodedata')
|
37 |
+
return v
|
38 |
+
|
39 |
+
def _is_script(cp: str, script: str) -> bool:
|
40 |
+
return intranges_contain(ord(cp), idnadata.scripts[script])
|
41 |
+
|
42 |
+
def _punycode(s: str) -> bytes:
|
43 |
+
return s.encode('punycode')
|
44 |
+
|
45 |
+
def _unot(s: int) -> str:
|
46 |
+
return 'U+{:04X}'.format(s)
|
47 |
+
|
48 |
+
|
49 |
+
def valid_label_length(label: Union[bytes, str]) -> bool:
|
50 |
+
if len(label) > 63:
|
51 |
+
return False
|
52 |
+
return True
|
53 |
+
|
54 |
+
|
55 |
+
def valid_string_length(label: Union[bytes, str], trailing_dot: bool) -> bool:
|
56 |
+
if len(label) > (254 if trailing_dot else 253):
|
57 |
+
return False
|
58 |
+
return True
|
59 |
+
|
60 |
+
|
61 |
+
def check_bidi(label: str, check_ltr: bool = False) -> bool:
|
62 |
+
# Bidi rules should only be applied if string contains RTL characters
|
63 |
+
bidi_label = False
|
64 |
+
for (idx, cp) in enumerate(label, 1):
|
65 |
+
direction = unicodedata.bidirectional(cp)
|
66 |
+
if direction == '':
|
67 |
+
# String likely comes from a newer version of Unicode
|
68 |
+
raise IDNABidiError('Unknown directionality in label {} at position {}'.format(repr(label), idx))
|
69 |
+
if direction in ['R', 'AL', 'AN']:
|
70 |
+
bidi_label = True
|
71 |
+
if not bidi_label and not check_ltr:
|
72 |
+
return True
|
73 |
+
|
74 |
+
# Bidi rule 1
|
75 |
+
direction = unicodedata.bidirectional(label[0])
|
76 |
+
if direction in ['R', 'AL']:
|
77 |
+
rtl = True
|
78 |
+
elif direction == 'L':
|
79 |
+
rtl = False
|
80 |
+
else:
|
81 |
+
raise IDNABidiError('First codepoint in label {} must be directionality L, R or AL'.format(repr(label)))
|
82 |
+
|
83 |
+
valid_ending = False
|
84 |
+
number_type = None # type: Optional[str]
|
85 |
+
for (idx, cp) in enumerate(label, 1):
|
86 |
+
direction = unicodedata.bidirectional(cp)
|
87 |
+
|
88 |
+
if rtl:
|
89 |
+
# Bidi rule 2
|
90 |
+
if not direction in ['R', 'AL', 'AN', 'EN', 'ES', 'CS', 'ET', 'ON', 'BN', 'NSM']:
|
91 |
+
raise IDNABidiError('Invalid direction for codepoint at position {} in a right-to-left label'.format(idx))
|
92 |
+
# Bidi rule 3
|
93 |
+
if direction in ['R', 'AL', 'EN', 'AN']:
|
94 |
+
valid_ending = True
|
95 |
+
elif direction != 'NSM':
|
96 |
+
valid_ending = False
|
97 |
+
# Bidi rule 4
|
98 |
+
if direction in ['AN', 'EN']:
|
99 |
+
if not number_type:
|
100 |
+
number_type = direction
|
101 |
+
else:
|
102 |
+
if number_type != direction:
|
103 |
+
raise IDNABidiError('Can not mix numeral types in a right-to-left label')
|
104 |
+
else:
|
105 |
+
# Bidi rule 5
|
106 |
+
if not direction in ['L', 'EN', 'ES', 'CS', 'ET', 'ON', 'BN', 'NSM']:
|
107 |
+
raise IDNABidiError('Invalid direction for codepoint at position {} in a left-to-right label'.format(idx))
|
108 |
+
# Bidi rule 6
|
109 |
+
if direction in ['L', 'EN']:
|
110 |
+
valid_ending = True
|
111 |
+
elif direction != 'NSM':
|
112 |
+
valid_ending = False
|
113 |
+
|
114 |
+
if not valid_ending:
|
115 |
+
raise IDNABidiError('Label ends with illegal codepoint directionality')
|
116 |
+
|
117 |
+
return True
|
118 |
+
|
119 |
+
|
120 |
+
def check_initial_combiner(label: str) -> bool:
|
121 |
+
if unicodedata.category(label[0])[0] == 'M':
|
122 |
+
raise IDNAError('Label begins with an illegal combining character')
|
123 |
+
return True
|
124 |
+
|
125 |
+
|
126 |
+
def check_hyphen_ok(label: str) -> bool:
|
127 |
+
if label[2:4] == '--':
|
128 |
+
raise IDNAError('Label has disallowed hyphens in 3rd and 4th position')
|
129 |
+
if label[0] == '-' or label[-1] == '-':
|
130 |
+
raise IDNAError('Label must not start or end with a hyphen')
|
131 |
+
return True
|
132 |
+
|
133 |
+
|
134 |
+
def check_nfc(label: str) -> None:
|
135 |
+
if unicodedata.normalize('NFC', label) != label:
|
136 |
+
raise IDNAError('Label must be in Normalization Form C')
|
137 |
+
|
138 |
+
|
139 |
+
def valid_contextj(label: str, pos: int) -> bool:
|
140 |
+
cp_value = ord(label[pos])
|
141 |
+
|
142 |
+
if cp_value == 0x200c:
|
143 |
+
|
144 |
+
if pos > 0:
|
145 |
+
if _combining_class(ord(label[pos - 1])) == _virama_combining_class:
|
146 |
+
return True
|
147 |
+
|
148 |
+
ok = False
|
149 |
+
for i in range(pos-1, -1, -1):
|
150 |
+
joining_type = idnadata.joining_types.get(ord(label[i]))
|
151 |
+
if joining_type == ord('T'):
|
152 |
+
continue
|
153 |
+
if joining_type in [ord('L'), ord('D')]:
|
154 |
+
ok = True
|
155 |
+
break
|
156 |
+
|
157 |
+
if not ok:
|
158 |
+
return False
|
159 |
+
|
160 |
+
ok = False
|
161 |
+
for i in range(pos+1, len(label)):
|
162 |
+
joining_type = idnadata.joining_types.get(ord(label[i]))
|
163 |
+
if joining_type == ord('T'):
|
164 |
+
continue
|
165 |
+
if joining_type in [ord('R'), ord('D')]:
|
166 |
+
ok = True
|
167 |
+
break
|
168 |
+
return ok
|
169 |
+
|
170 |
+
if cp_value == 0x200d:
|
171 |
+
|
172 |
+
if pos > 0:
|
173 |
+
if _combining_class(ord(label[pos - 1])) == _virama_combining_class:
|
174 |
+
return True
|
175 |
+
return False
|
176 |
+
|
177 |
+
else:
|
178 |
+
|
179 |
+
return False
|
180 |
+
|
181 |
+
|
182 |
+
def valid_contexto(label: str, pos: int, exception: bool = False) -> bool:
|
183 |
+
cp_value = ord(label[pos])
|
184 |
+
|
185 |
+
if cp_value == 0x00b7:
|
186 |
+
if 0 < pos < len(label)-1:
|
187 |
+
if ord(label[pos - 1]) == 0x006c and ord(label[pos + 1]) == 0x006c:
|
188 |
+
return True
|
189 |
+
return False
|
190 |
+
|
191 |
+
elif cp_value == 0x0375:
|
192 |
+
if pos < len(label)-1 and len(label) > 1:
|
193 |
+
return _is_script(label[pos + 1], 'Greek')
|
194 |
+
return False
|
195 |
+
|
196 |
+
elif cp_value == 0x05f3 or cp_value == 0x05f4:
|
197 |
+
if pos > 0:
|
198 |
+
return _is_script(label[pos - 1], 'Hebrew')
|
199 |
+
return False
|
200 |
+
|
201 |
+
elif cp_value == 0x30fb:
|
202 |
+
for cp in label:
|
203 |
+
if cp == '\u30fb':
|
204 |
+
continue
|
205 |
+
if _is_script(cp, 'Hiragana') or _is_script(cp, 'Katakana') or _is_script(cp, 'Han'):
|
206 |
+
return True
|
207 |
+
return False
|
208 |
+
|
209 |
+
elif 0x660 <= cp_value <= 0x669:
|
210 |
+
for cp in label:
|
211 |
+
if 0x6f0 <= ord(cp) <= 0x06f9:
|
212 |
+
return False
|
213 |
+
return True
|
214 |
+
|
215 |
+
elif 0x6f0 <= cp_value <= 0x6f9:
|
216 |
+
for cp in label:
|
217 |
+
if 0x660 <= ord(cp) <= 0x0669:
|
218 |
+
return False
|
219 |
+
return True
|
220 |
+
|
221 |
+
return False
|
222 |
+
|
223 |
+
|
224 |
+
def check_label(label: Union[str, bytes, bytearray]) -> None:
|
225 |
+
if isinstance(label, (bytes, bytearray)):
|
226 |
+
label = label.decode('utf-8')
|
227 |
+
if len(label) == 0:
|
228 |
+
raise IDNAError('Empty Label')
|
229 |
+
|
230 |
+
check_nfc(label)
|
231 |
+
check_hyphen_ok(label)
|
232 |
+
check_initial_combiner(label)
|
233 |
+
|
234 |
+
for (pos, cp) in enumerate(label):
|
235 |
+
cp_value = ord(cp)
|
236 |
+
if intranges_contain(cp_value, idnadata.codepoint_classes['PVALID']):
|
237 |
+
continue
|
238 |
+
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTJ']):
|
239 |
+
try:
|
240 |
+
if not valid_contextj(label, pos):
|
241 |
+
raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format(
|
242 |
+
_unot(cp_value), pos+1, repr(label)))
|
243 |
+
except ValueError:
|
244 |
+
raise IDNAError('Unknown codepoint adjacent to joiner {} at position {} in {}'.format(
|
245 |
+
_unot(cp_value), pos+1, repr(label)))
|
246 |
+
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTO']):
|
247 |
+
if not valid_contexto(label, pos):
|
248 |
+
raise InvalidCodepointContext('Codepoint {} not allowed at position {} in {}'.format(_unot(cp_value), pos+1, repr(label)))
|
249 |
+
else:
|
250 |
+
raise InvalidCodepoint('Codepoint {} at position {} of {} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
|
251 |
+
|
252 |
+
check_bidi(label)
|
253 |
+
|
254 |
+
|
255 |
+
def alabel(label: str) -> bytes:
|
256 |
+
try:
|
257 |
+
label_bytes = label.encode('ascii')
|
258 |
+
ulabel(label_bytes)
|
259 |
+
if not valid_label_length(label_bytes):
|
260 |
+
raise IDNAError('Label too long')
|
261 |
+
return label_bytes
|
262 |
+
except UnicodeEncodeError:
|
263 |
+
pass
|
264 |
+
|
265 |
+
if not label:
|
266 |
+
raise IDNAError('No Input')
|
267 |
+
|
268 |
+
label = str(label)
|
269 |
+
check_label(label)
|
270 |
+
label_bytes = _punycode(label)
|
271 |
+
label_bytes = _alabel_prefix + label_bytes
|
272 |
+
|
273 |
+
if not valid_label_length(label_bytes):
|
274 |
+
raise IDNAError('Label too long')
|
275 |
+
|
276 |
+
return label_bytes
|
277 |
+
|
278 |
+
|
279 |
+
def ulabel(label: Union[str, bytes, bytearray]) -> str:
|
280 |
+
if not isinstance(label, (bytes, bytearray)):
|
281 |
+
try:
|
282 |
+
label_bytes = label.encode('ascii')
|
283 |
+
except UnicodeEncodeError:
|
284 |
+
check_label(label)
|
285 |
+
return label
|
286 |
+
else:
|
287 |
+
label_bytes = label
|
288 |
+
|
289 |
+
label_bytes = label_bytes.lower()
|
290 |
+
if label_bytes.startswith(_alabel_prefix):
|
291 |
+
label_bytes = label_bytes[len(_alabel_prefix):]
|
292 |
+
if not label_bytes:
|
293 |
+
raise IDNAError('Malformed A-label, no Punycode eligible content found')
|
294 |
+
if label_bytes.decode('ascii')[-1] == '-':
|
295 |
+
raise IDNAError('A-label must not end with a hyphen')
|
296 |
+
else:
|
297 |
+
check_label(label_bytes)
|
298 |
+
return label_bytes.decode('ascii')
|
299 |
+
|
300 |
+
try:
|
301 |
+
label = label_bytes.decode('punycode')
|
302 |
+
except UnicodeError:
|
303 |
+
raise IDNAError('Invalid A-label')
|
304 |
+
check_label(label)
|
305 |
+
return label
|
306 |
+
|
307 |
+
|
308 |
+
def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False) -> str:
|
309 |
+
"""Re-map the characters in the string according to UTS46 processing."""
|
310 |
+
from .uts46data import uts46data
|
311 |
+
output = ''
|
312 |
+
|
313 |
+
for pos, char in enumerate(domain):
|
314 |
+
code_point = ord(char)
|
315 |
+
try:
|
316 |
+
uts46row = uts46data[code_point if code_point < 256 else
|
317 |
+
bisect.bisect_left(uts46data, (code_point, 'Z')) - 1]
|
318 |
+
status = uts46row[1]
|
319 |
+
replacement = None # type: Optional[str]
|
320 |
+
if len(uts46row) == 3:
|
321 |
+
replacement = uts46row[2] # type: ignore
|
322 |
+
if (status == 'V' or
|
323 |
+
(status == 'D' and not transitional) or
|
324 |
+
(status == '3' and not std3_rules and replacement is None)):
|
325 |
+
output += char
|
326 |
+
elif replacement is not None and (status == 'M' or
|
327 |
+
(status == '3' and not std3_rules) or
|
328 |
+
(status == 'D' and transitional)):
|
329 |
+
output += replacement
|
330 |
+
elif status != 'I':
|
331 |
+
raise IndexError()
|
332 |
+
except IndexError:
|
333 |
+
raise InvalidCodepoint(
|
334 |
+
'Codepoint {} not allowed at position {} in {}'.format(
|
335 |
+
_unot(code_point), pos + 1, repr(domain)))
|
336 |
+
|
337 |
+
return unicodedata.normalize('NFC', output)
|
338 |
+
|
339 |
+
|
340 |
+
def encode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool = False, std3_rules: bool = False, transitional: bool = False) -> bytes:
|
341 |
+
if isinstance(s, (bytes, bytearray)):
|
342 |
+
s = s.decode('ascii')
|
343 |
+
if uts46:
|
344 |
+
s = uts46_remap(s, std3_rules, transitional)
|
345 |
+
trailing_dot = False
|
346 |
+
result = []
|
347 |
+
if strict:
|
348 |
+
labels = s.split('.')
|
349 |
+
else:
|
350 |
+
labels = _unicode_dots_re.split(s)
|
351 |
+
if not labels or labels == ['']:
|
352 |
+
raise IDNAError('Empty domain')
|
353 |
+
if labels[-1] == '':
|
354 |
+
del labels[-1]
|
355 |
+
trailing_dot = True
|
356 |
+
for label in labels:
|
357 |
+
s = alabel(label)
|
358 |
+
if s:
|
359 |
+
result.append(s)
|
360 |
+
else:
|
361 |
+
raise IDNAError('Empty label')
|
362 |
+
if trailing_dot:
|
363 |
+
result.append(b'')
|
364 |
+
s = b'.'.join(result)
|
365 |
+
if not valid_string_length(s, trailing_dot):
|
366 |
+
raise IDNAError('Domain too long')
|
367 |
+
return s
|
368 |
+
|
369 |
+
|
370 |
+
def decode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool = False, std3_rules: bool = False) -> str:
|
371 |
+
try:
|
372 |
+
if isinstance(s, (bytes, bytearray)):
|
373 |
+
s = s.decode('ascii')
|
374 |
+
except UnicodeDecodeError:
|
375 |
+
raise IDNAError('Invalid ASCII in A-label')
|
376 |
+
if uts46:
|
377 |
+
s = uts46_remap(s, std3_rules, False)
|
378 |
+
trailing_dot = False
|
379 |
+
result = []
|
380 |
+
if not strict:
|
381 |
+
labels = _unicode_dots_re.split(s)
|
382 |
+
else:
|
383 |
+
labels = s.split('.')
|
384 |
+
if not labels or labels == ['']:
|
385 |
+
raise IDNAError('Empty domain')
|
386 |
+
if not labels[-1]:
|
387 |
+
del labels[-1]
|
388 |
+
trailing_dot = True
|
389 |
+
for label in labels:
|
390 |
+
s = ulabel(label)
|
391 |
+
if s:
|
392 |
+
result.append(s)
|
393 |
+
else:
|
394 |
+
raise IDNAError('Empty label')
|
395 |
+
if trailing_dot:
|
396 |
+
result.append('')
|
397 |
+
return '.'.join(result)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/idnadata.py
ADDED
@@ -0,0 +1,2137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is automatically generated by tools/idna-data
|
2 |
+
|
3 |
+
__version__ = '14.0.0'
|
4 |
+
scripts = {
|
5 |
+
'Greek': (
|
6 |
+
0x37000000374,
|
7 |
+
0x37500000378,
|
8 |
+
0x37a0000037e,
|
9 |
+
0x37f00000380,
|
10 |
+
0x38400000385,
|
11 |
+
0x38600000387,
|
12 |
+
0x3880000038b,
|
13 |
+
0x38c0000038d,
|
14 |
+
0x38e000003a2,
|
15 |
+
0x3a3000003e2,
|
16 |
+
0x3f000000400,
|
17 |
+
0x1d2600001d2b,
|
18 |
+
0x1d5d00001d62,
|
19 |
+
0x1d6600001d6b,
|
20 |
+
0x1dbf00001dc0,
|
21 |
+
0x1f0000001f16,
|
22 |
+
0x1f1800001f1e,
|
23 |
+
0x1f2000001f46,
|
24 |
+
0x1f4800001f4e,
|
25 |
+
0x1f5000001f58,
|
26 |
+
0x1f5900001f5a,
|
27 |
+
0x1f5b00001f5c,
|
28 |
+
0x1f5d00001f5e,
|
29 |
+
0x1f5f00001f7e,
|
30 |
+
0x1f8000001fb5,
|
31 |
+
0x1fb600001fc5,
|
32 |
+
0x1fc600001fd4,
|
33 |
+
0x1fd600001fdc,
|
34 |
+
0x1fdd00001ff0,
|
35 |
+
0x1ff200001ff5,
|
36 |
+
0x1ff600001fff,
|
37 |
+
0x212600002127,
|
38 |
+
0xab650000ab66,
|
39 |
+
0x101400001018f,
|
40 |
+
0x101a0000101a1,
|
41 |
+
0x1d2000001d246,
|
42 |
+
),
|
43 |
+
'Han': (
|
44 |
+
0x2e8000002e9a,
|
45 |
+
0x2e9b00002ef4,
|
46 |
+
0x2f0000002fd6,
|
47 |
+
0x300500003006,
|
48 |
+
0x300700003008,
|
49 |
+
0x30210000302a,
|
50 |
+
0x30380000303c,
|
51 |
+
0x340000004dc0,
|
52 |
+
0x4e000000a000,
|
53 |
+
0xf9000000fa6e,
|
54 |
+
0xfa700000fada,
|
55 |
+
0x16fe200016fe4,
|
56 |
+
0x16ff000016ff2,
|
57 |
+
0x200000002a6e0,
|
58 |
+
0x2a7000002b739,
|
59 |
+
0x2b7400002b81e,
|
60 |
+
0x2b8200002cea2,
|
61 |
+
0x2ceb00002ebe1,
|
62 |
+
0x2f8000002fa1e,
|
63 |
+
0x300000003134b,
|
64 |
+
),
|
65 |
+
'Hebrew': (
|
66 |
+
0x591000005c8,
|
67 |
+
0x5d0000005eb,
|
68 |
+
0x5ef000005f5,
|
69 |
+
0xfb1d0000fb37,
|
70 |
+
0xfb380000fb3d,
|
71 |
+
0xfb3e0000fb3f,
|
72 |
+
0xfb400000fb42,
|
73 |
+
0xfb430000fb45,
|
74 |
+
0xfb460000fb50,
|
75 |
+
),
|
76 |
+
'Hiragana': (
|
77 |
+
0x304100003097,
|
78 |
+
0x309d000030a0,
|
79 |
+
0x1b0010001b120,
|
80 |
+
0x1b1500001b153,
|
81 |
+
0x1f2000001f201,
|
82 |
+
),
|
83 |
+
'Katakana': (
|
84 |
+
0x30a1000030fb,
|
85 |
+
0x30fd00003100,
|
86 |
+
0x31f000003200,
|
87 |
+
0x32d0000032ff,
|
88 |
+
0x330000003358,
|
89 |
+
0xff660000ff70,
|
90 |
+
0xff710000ff9e,
|
91 |
+
0x1aff00001aff4,
|
92 |
+
0x1aff50001affc,
|
93 |
+
0x1affd0001afff,
|
94 |
+
0x1b0000001b001,
|
95 |
+
0x1b1200001b123,
|
96 |
+
0x1b1640001b168,
|
97 |
+
),
|
98 |
+
}
|
99 |
+
joining_types = {
|
100 |
+
0x600: 85,
|
101 |
+
0x601: 85,
|
102 |
+
0x602: 85,
|
103 |
+
0x603: 85,
|
104 |
+
0x604: 85,
|
105 |
+
0x605: 85,
|
106 |
+
0x608: 85,
|
107 |
+
0x60b: 85,
|
108 |
+
0x620: 68,
|
109 |
+
0x621: 85,
|
110 |
+
0x622: 82,
|
111 |
+
0x623: 82,
|
112 |
+
0x624: 82,
|
113 |
+
0x625: 82,
|
114 |
+
0x626: 68,
|
115 |
+
0x627: 82,
|
116 |
+
0x628: 68,
|
117 |
+
0x629: 82,
|
118 |
+
0x62a: 68,
|
119 |
+
0x62b: 68,
|
120 |
+
0x62c: 68,
|
121 |
+
0x62d: 68,
|
122 |
+
0x62e: 68,
|
123 |
+
0x62f: 82,
|
124 |
+
0x630: 82,
|
125 |
+
0x631: 82,
|
126 |
+
0x632: 82,
|
127 |
+
0x633: 68,
|
128 |
+
0x634: 68,
|
129 |
+
0x635: 68,
|
130 |
+
0x636: 68,
|
131 |
+
0x637: 68,
|
132 |
+
0x638: 68,
|
133 |
+
0x639: 68,
|
134 |
+
0x63a: 68,
|
135 |
+
0x63b: 68,
|
136 |
+
0x63c: 68,
|
137 |
+
0x63d: 68,
|
138 |
+
0x63e: 68,
|
139 |
+
0x63f: 68,
|
140 |
+
0x640: 67,
|
141 |
+
0x641: 68,
|
142 |
+
0x642: 68,
|
143 |
+
0x643: 68,
|
144 |
+
0x644: 68,
|
145 |
+
0x645: 68,
|
146 |
+
0x646: 68,
|
147 |
+
0x647: 68,
|
148 |
+
0x648: 82,
|
149 |
+
0x649: 68,
|
150 |
+
0x64a: 68,
|
151 |
+
0x66e: 68,
|
152 |
+
0x66f: 68,
|
153 |
+
0x671: 82,
|
154 |
+
0x672: 82,
|
155 |
+
0x673: 82,
|
156 |
+
0x674: 85,
|
157 |
+
0x675: 82,
|
158 |
+
0x676: 82,
|
159 |
+
0x677: 82,
|
160 |
+
0x678: 68,
|
161 |
+
0x679: 68,
|
162 |
+
0x67a: 68,
|
163 |
+
0x67b: 68,
|
164 |
+
0x67c: 68,
|
165 |
+
0x67d: 68,
|
166 |
+
0x67e: 68,
|
167 |
+
0x67f: 68,
|
168 |
+
0x680: 68,
|
169 |
+
0x681: 68,
|
170 |
+
0x682: 68,
|
171 |
+
0x683: 68,
|
172 |
+
0x684: 68,
|
173 |
+
0x685: 68,
|
174 |
+
0x686: 68,
|
175 |
+
0x687: 68,
|
176 |
+
0x688: 82,
|
177 |
+
0x689: 82,
|
178 |
+
0x68a: 82,
|
179 |
+
0x68b: 82,
|
180 |
+
0x68c: 82,
|
181 |
+
0x68d: 82,
|
182 |
+
0x68e: 82,
|
183 |
+
0x68f: 82,
|
184 |
+
0x690: 82,
|
185 |
+
0x691: 82,
|
186 |
+
0x692: 82,
|
187 |
+
0x693: 82,
|
188 |
+
0x694: 82,
|
189 |
+
0x695: 82,
|
190 |
+
0x696: 82,
|
191 |
+
0x697: 82,
|
192 |
+
0x698: 82,
|
193 |
+
0x699: 82,
|
194 |
+
0x69a: 68,
|
195 |
+
0x69b: 68,
|
196 |
+
0x69c: 68,
|
197 |
+
0x69d: 68,
|
198 |
+
0x69e: 68,
|
199 |
+
0x69f: 68,
|
200 |
+
0x6a0: 68,
|
201 |
+
0x6a1: 68,
|
202 |
+
0x6a2: 68,
|
203 |
+
0x6a3: 68,
|
204 |
+
0x6a4: 68,
|
205 |
+
0x6a5: 68,
|
206 |
+
0x6a6: 68,
|
207 |
+
0x6a7: 68,
|
208 |
+
0x6a8: 68,
|
209 |
+
0x6a9: 68,
|
210 |
+
0x6aa: 68,
|
211 |
+
0x6ab: 68,
|
212 |
+
0x6ac: 68,
|
213 |
+
0x6ad: 68,
|
214 |
+
0x6ae: 68,
|
215 |
+
0x6af: 68,
|
216 |
+
0x6b0: 68,
|
217 |
+
0x6b1: 68,
|
218 |
+
0x6b2: 68,
|
219 |
+
0x6b3: 68,
|
220 |
+
0x6b4: 68,
|
221 |
+
0x6b5: 68,
|
222 |
+
0x6b6: 68,
|
223 |
+
0x6b7: 68,
|
224 |
+
0x6b8: 68,
|
225 |
+
0x6b9: 68,
|
226 |
+
0x6ba: 68,
|
227 |
+
0x6bb: 68,
|
228 |
+
0x6bc: 68,
|
229 |
+
0x6bd: 68,
|
230 |
+
0x6be: 68,
|
231 |
+
0x6bf: 68,
|
232 |
+
0x6c0: 82,
|
233 |
+
0x6c1: 68,
|
234 |
+
0x6c2: 68,
|
235 |
+
0x6c3: 82,
|
236 |
+
0x6c4: 82,
|
237 |
+
0x6c5: 82,
|
238 |
+
0x6c6: 82,
|
239 |
+
0x6c7: 82,
|
240 |
+
0x6c8: 82,
|
241 |
+
0x6c9: 82,
|
242 |
+
0x6ca: 82,
|
243 |
+
0x6cb: 82,
|
244 |
+
0x6cc: 68,
|
245 |
+
0x6cd: 82,
|
246 |
+
0x6ce: 68,
|
247 |
+
0x6cf: 82,
|
248 |
+
0x6d0: 68,
|
249 |
+
0x6d1: 68,
|
250 |
+
0x6d2: 82,
|
251 |
+
0x6d3: 82,
|
252 |
+
0x6d5: 82,
|
253 |
+
0x6dd: 85,
|
254 |
+
0x6ee: 82,
|
255 |
+
0x6ef: 82,
|
256 |
+
0x6fa: 68,
|
257 |
+
0x6fb: 68,
|
258 |
+
0x6fc: 68,
|
259 |
+
0x6ff: 68,
|
260 |
+
0x70f: 84,
|
261 |
+
0x710: 82,
|
262 |
+
0x712: 68,
|
263 |
+
0x713: 68,
|
264 |
+
0x714: 68,
|
265 |
+
0x715: 82,
|
266 |
+
0x716: 82,
|
267 |
+
0x717: 82,
|
268 |
+
0x718: 82,
|
269 |
+
0x719: 82,
|
270 |
+
0x71a: 68,
|
271 |
+
0x71b: 68,
|
272 |
+
0x71c: 68,
|
273 |
+
0x71d: 68,
|
274 |
+
0x71e: 82,
|
275 |
+
0x71f: 68,
|
276 |
+
0x720: 68,
|
277 |
+
0x721: 68,
|
278 |
+
0x722: 68,
|
279 |
+
0x723: 68,
|
280 |
+
0x724: 68,
|
281 |
+
0x725: 68,
|
282 |
+
0x726: 68,
|
283 |
+
0x727: 68,
|
284 |
+
0x728: 82,
|
285 |
+
0x729: 68,
|
286 |
+
0x72a: 82,
|
287 |
+
0x72b: 68,
|
288 |
+
0x72c: 82,
|
289 |
+
0x72d: 68,
|
290 |
+
0x72e: 68,
|
291 |
+
0x72f: 82,
|
292 |
+
0x74d: 82,
|
293 |
+
0x74e: 68,
|
294 |
+
0x74f: 68,
|
295 |
+
0x750: 68,
|
296 |
+
0x751: 68,
|
297 |
+
0x752: 68,
|
298 |
+
0x753: 68,
|
299 |
+
0x754: 68,
|
300 |
+
0x755: 68,
|
301 |
+
0x756: 68,
|
302 |
+
0x757: 68,
|
303 |
+
0x758: 68,
|
304 |
+
0x759: 82,
|
305 |
+
0x75a: 82,
|
306 |
+
0x75b: 82,
|
307 |
+
0x75c: 68,
|
308 |
+
0x75d: 68,
|
309 |
+
0x75e: 68,
|
310 |
+
0x75f: 68,
|
311 |
+
0x760: 68,
|
312 |
+
0x761: 68,
|
313 |
+
0x762: 68,
|
314 |
+
0x763: 68,
|
315 |
+
0x764: 68,
|
316 |
+
0x765: 68,
|
317 |
+
0x766: 68,
|
318 |
+
0x767: 68,
|
319 |
+
0x768: 68,
|
320 |
+
0x769: 68,
|
321 |
+
0x76a: 68,
|
322 |
+
0x76b: 82,
|
323 |
+
0x76c: 82,
|
324 |
+
0x76d: 68,
|
325 |
+
0x76e: 68,
|
326 |
+
0x76f: 68,
|
327 |
+
0x770: 68,
|
328 |
+
0x771: 82,
|
329 |
+
0x772: 68,
|
330 |
+
0x773: 82,
|
331 |
+
0x774: 82,
|
332 |
+
0x775: 68,
|
333 |
+
0x776: 68,
|
334 |
+
0x777: 68,
|
335 |
+
0x778: 82,
|
336 |
+
0x779: 82,
|
337 |
+
0x77a: 68,
|
338 |
+
0x77b: 68,
|
339 |
+
0x77c: 68,
|
340 |
+
0x77d: 68,
|
341 |
+
0x77e: 68,
|
342 |
+
0x77f: 68,
|
343 |
+
0x7ca: 68,
|
344 |
+
0x7cb: 68,
|
345 |
+
0x7cc: 68,
|
346 |
+
0x7cd: 68,
|
347 |
+
0x7ce: 68,
|
348 |
+
0x7cf: 68,
|
349 |
+
0x7d0: 68,
|
350 |
+
0x7d1: 68,
|
351 |
+
0x7d2: 68,
|
352 |
+
0x7d3: 68,
|
353 |
+
0x7d4: 68,
|
354 |
+
0x7d5: 68,
|
355 |
+
0x7d6: 68,
|
356 |
+
0x7d7: 68,
|
357 |
+
0x7d8: 68,
|
358 |
+
0x7d9: 68,
|
359 |
+
0x7da: 68,
|
360 |
+
0x7db: 68,
|
361 |
+
0x7dc: 68,
|
362 |
+
0x7dd: 68,
|
363 |
+
0x7de: 68,
|
364 |
+
0x7df: 68,
|
365 |
+
0x7e0: 68,
|
366 |
+
0x7e1: 68,
|
367 |
+
0x7e2: 68,
|
368 |
+
0x7e3: 68,
|
369 |
+
0x7e4: 68,
|
370 |
+
0x7e5: 68,
|
371 |
+
0x7e6: 68,
|
372 |
+
0x7e7: 68,
|
373 |
+
0x7e8: 68,
|
374 |
+
0x7e9: 68,
|
375 |
+
0x7ea: 68,
|
376 |
+
0x7fa: 67,
|
377 |
+
0x840: 82,
|
378 |
+
0x841: 68,
|
379 |
+
0x842: 68,
|
380 |
+
0x843: 68,
|
381 |
+
0x844: 68,
|
382 |
+
0x845: 68,
|
383 |
+
0x846: 82,
|
384 |
+
0x847: 82,
|
385 |
+
0x848: 68,
|
386 |
+
0x849: 82,
|
387 |
+
0x84a: 68,
|
388 |
+
0x84b: 68,
|
389 |
+
0x84c: 68,
|
390 |
+
0x84d: 68,
|
391 |
+
0x84e: 68,
|
392 |
+
0x84f: 68,
|
393 |
+
0x850: 68,
|
394 |
+
0x851: 68,
|
395 |
+
0x852: 68,
|
396 |
+
0x853: 68,
|
397 |
+
0x854: 82,
|
398 |
+
0x855: 68,
|
399 |
+
0x856: 82,
|
400 |
+
0x857: 82,
|
401 |
+
0x858: 82,
|
402 |
+
0x860: 68,
|
403 |
+
0x861: 85,
|
404 |
+
0x862: 68,
|
405 |
+
0x863: 68,
|
406 |
+
0x864: 68,
|
407 |
+
0x865: 68,
|
408 |
+
0x866: 85,
|
409 |
+
0x867: 82,
|
410 |
+
0x868: 68,
|
411 |
+
0x869: 82,
|
412 |
+
0x86a: 82,
|
413 |
+
0x870: 82,
|
414 |
+
0x871: 82,
|
415 |
+
0x872: 82,
|
416 |
+
0x873: 82,
|
417 |
+
0x874: 82,
|
418 |
+
0x875: 82,
|
419 |
+
0x876: 82,
|
420 |
+
0x877: 82,
|
421 |
+
0x878: 82,
|
422 |
+
0x879: 82,
|
423 |
+
0x87a: 82,
|
424 |
+
0x87b: 82,
|
425 |
+
0x87c: 82,
|
426 |
+
0x87d: 82,
|
427 |
+
0x87e: 82,
|
428 |
+
0x87f: 82,
|
429 |
+
0x880: 82,
|
430 |
+
0x881: 82,
|
431 |
+
0x882: 82,
|
432 |
+
0x883: 67,
|
433 |
+
0x884: 67,
|
434 |
+
0x885: 67,
|
435 |
+
0x886: 68,
|
436 |
+
0x887: 85,
|
437 |
+
0x888: 85,
|
438 |
+
0x889: 68,
|
439 |
+
0x88a: 68,
|
440 |
+
0x88b: 68,
|
441 |
+
0x88c: 68,
|
442 |
+
0x88d: 68,
|
443 |
+
0x88e: 82,
|
444 |
+
0x890: 85,
|
445 |
+
0x891: 85,
|
446 |
+
0x8a0: 68,
|
447 |
+
0x8a1: 68,
|
448 |
+
0x8a2: 68,
|
449 |
+
0x8a3: 68,
|
450 |
+
0x8a4: 68,
|
451 |
+
0x8a5: 68,
|
452 |
+
0x8a6: 68,
|
453 |
+
0x8a7: 68,
|
454 |
+
0x8a8: 68,
|
455 |
+
0x8a9: 68,
|
456 |
+
0x8aa: 82,
|
457 |
+
0x8ab: 82,
|
458 |
+
0x8ac: 82,
|
459 |
+
0x8ad: 85,
|
460 |
+
0x8ae: 82,
|
461 |
+
0x8af: 68,
|
462 |
+
0x8b0: 68,
|
463 |
+
0x8b1: 82,
|
464 |
+
0x8b2: 82,
|
465 |
+
0x8b3: 68,
|
466 |
+
0x8b4: 68,
|
467 |
+
0x8b5: 68,
|
468 |
+
0x8b6: 68,
|
469 |
+
0x8b7: 68,
|
470 |
+
0x8b8: 68,
|
471 |
+
0x8b9: 82,
|
472 |
+
0x8ba: 68,
|
473 |
+
0x8bb: 68,
|
474 |
+
0x8bc: 68,
|
475 |
+
0x8bd: 68,
|
476 |
+
0x8be: 68,
|
477 |
+
0x8bf: 68,
|
478 |
+
0x8c0: 68,
|
479 |
+
0x8c1: 68,
|
480 |
+
0x8c2: 68,
|
481 |
+
0x8c3: 68,
|
482 |
+
0x8c4: 68,
|
483 |
+
0x8c5: 68,
|
484 |
+
0x8c6: 68,
|
485 |
+
0x8c7: 68,
|
486 |
+
0x8c8: 68,
|
487 |
+
0x8e2: 85,
|
488 |
+
0x1806: 85,
|
489 |
+
0x1807: 68,
|
490 |
+
0x180a: 67,
|
491 |
+
0x180e: 85,
|
492 |
+
0x1820: 68,
|
493 |
+
0x1821: 68,
|
494 |
+
0x1822: 68,
|
495 |
+
0x1823: 68,
|
496 |
+
0x1824: 68,
|
497 |
+
0x1825: 68,
|
498 |
+
0x1826: 68,
|
499 |
+
0x1827: 68,
|
500 |
+
0x1828: 68,
|
501 |
+
0x1829: 68,
|
502 |
+
0x182a: 68,
|
503 |
+
0x182b: 68,
|
504 |
+
0x182c: 68,
|
505 |
+
0x182d: 68,
|
506 |
+
0x182e: 68,
|
507 |
+
0x182f: 68,
|
508 |
+
0x1830: 68,
|
509 |
+
0x1831: 68,
|
510 |
+
0x1832: 68,
|
511 |
+
0x1833: 68,
|
512 |
+
0x1834: 68,
|
513 |
+
0x1835: 68,
|
514 |
+
0x1836: 68,
|
515 |
+
0x1837: 68,
|
516 |
+
0x1838: 68,
|
517 |
+
0x1839: 68,
|
518 |
+
0x183a: 68,
|
519 |
+
0x183b: 68,
|
520 |
+
0x183c: 68,
|
521 |
+
0x183d: 68,
|
522 |
+
0x183e: 68,
|
523 |
+
0x183f: 68,
|
524 |
+
0x1840: 68,
|
525 |
+
0x1841: 68,
|
526 |
+
0x1842: 68,
|
527 |
+
0x1843: 68,
|
528 |
+
0x1844: 68,
|
529 |
+
0x1845: 68,
|
530 |
+
0x1846: 68,
|
531 |
+
0x1847: 68,
|
532 |
+
0x1848: 68,
|
533 |
+
0x1849: 68,
|
534 |
+
0x184a: 68,
|
535 |
+
0x184b: 68,
|
536 |
+
0x184c: 68,
|
537 |
+
0x184d: 68,
|
538 |
+
0x184e: 68,
|
539 |
+
0x184f: 68,
|
540 |
+
0x1850: 68,
|
541 |
+
0x1851: 68,
|
542 |
+
0x1852: 68,
|
543 |
+
0x1853: 68,
|
544 |
+
0x1854: 68,
|
545 |
+
0x1855: 68,
|
546 |
+
0x1856: 68,
|
547 |
+
0x1857: 68,
|
548 |
+
0x1858: 68,
|
549 |
+
0x1859: 68,
|
550 |
+
0x185a: 68,
|
551 |
+
0x185b: 68,
|
552 |
+
0x185c: 68,
|
553 |
+
0x185d: 68,
|
554 |
+
0x185e: 68,
|
555 |
+
0x185f: 68,
|
556 |
+
0x1860: 68,
|
557 |
+
0x1861: 68,
|
558 |
+
0x1862: 68,
|
559 |
+
0x1863: 68,
|
560 |
+
0x1864: 68,
|
561 |
+
0x1865: 68,
|
562 |
+
0x1866: 68,
|
563 |
+
0x1867: 68,
|
564 |
+
0x1868: 68,
|
565 |
+
0x1869: 68,
|
566 |
+
0x186a: 68,
|
567 |
+
0x186b: 68,
|
568 |
+
0x186c: 68,
|
569 |
+
0x186d: 68,
|
570 |
+
0x186e: 68,
|
571 |
+
0x186f: 68,
|
572 |
+
0x1870: 68,
|
573 |
+
0x1871: 68,
|
574 |
+
0x1872: 68,
|
575 |
+
0x1873: 68,
|
576 |
+
0x1874: 68,
|
577 |
+
0x1875: 68,
|
578 |
+
0x1876: 68,
|
579 |
+
0x1877: 68,
|
580 |
+
0x1878: 68,
|
581 |
+
0x1880: 85,
|
582 |
+
0x1881: 85,
|
583 |
+
0x1882: 85,
|
584 |
+
0x1883: 85,
|
585 |
+
0x1884: 85,
|
586 |
+
0x1885: 84,
|
587 |
+
0x1886: 84,
|
588 |
+
0x1887: 68,
|
589 |
+
0x1888: 68,
|
590 |
+
0x1889: 68,
|
591 |
+
0x188a: 68,
|
592 |
+
0x188b: 68,
|
593 |
+
0x188c: 68,
|
594 |
+
0x188d: 68,
|
595 |
+
0x188e: 68,
|
596 |
+
0x188f: 68,
|
597 |
+
0x1890: 68,
|
598 |
+
0x1891: 68,
|
599 |
+
0x1892: 68,
|
600 |
+
0x1893: 68,
|
601 |
+
0x1894: 68,
|
602 |
+
0x1895: 68,
|
603 |
+
0x1896: 68,
|
604 |
+
0x1897: 68,
|
605 |
+
0x1898: 68,
|
606 |
+
0x1899: 68,
|
607 |
+
0x189a: 68,
|
608 |
+
0x189b: 68,
|
609 |
+
0x189c: 68,
|
610 |
+
0x189d: 68,
|
611 |
+
0x189e: 68,
|
612 |
+
0x189f: 68,
|
613 |
+
0x18a0: 68,
|
614 |
+
0x18a1: 68,
|
615 |
+
0x18a2: 68,
|
616 |
+
0x18a3: 68,
|
617 |
+
0x18a4: 68,
|
618 |
+
0x18a5: 68,
|
619 |
+
0x18a6: 68,
|
620 |
+
0x18a7: 68,
|
621 |
+
0x18a8: 68,
|
622 |
+
0x18aa: 68,
|
623 |
+
0x200c: 85,
|
624 |
+
0x200d: 67,
|
625 |
+
0x202f: 85,
|
626 |
+
0x2066: 85,
|
627 |
+
0x2067: 85,
|
628 |
+
0x2068: 85,
|
629 |
+
0x2069: 85,
|
630 |
+
0xa840: 68,
|
631 |
+
0xa841: 68,
|
632 |
+
0xa842: 68,
|
633 |
+
0xa843: 68,
|
634 |
+
0xa844: 68,
|
635 |
+
0xa845: 68,
|
636 |
+
0xa846: 68,
|
637 |
+
0xa847: 68,
|
638 |
+
0xa848: 68,
|
639 |
+
0xa849: 68,
|
640 |
+
0xa84a: 68,
|
641 |
+
0xa84b: 68,
|
642 |
+
0xa84c: 68,
|
643 |
+
0xa84d: 68,
|
644 |
+
0xa84e: 68,
|
645 |
+
0xa84f: 68,
|
646 |
+
0xa850: 68,
|
647 |
+
0xa851: 68,
|
648 |
+
0xa852: 68,
|
649 |
+
0xa853: 68,
|
650 |
+
0xa854: 68,
|
651 |
+
0xa855: 68,
|
652 |
+
0xa856: 68,
|
653 |
+
0xa857: 68,
|
654 |
+
0xa858: 68,
|
655 |
+
0xa859: 68,
|
656 |
+
0xa85a: 68,
|
657 |
+
0xa85b: 68,
|
658 |
+
0xa85c: 68,
|
659 |
+
0xa85d: 68,
|
660 |
+
0xa85e: 68,
|
661 |
+
0xa85f: 68,
|
662 |
+
0xa860: 68,
|
663 |
+
0xa861: 68,
|
664 |
+
0xa862: 68,
|
665 |
+
0xa863: 68,
|
666 |
+
0xa864: 68,
|
667 |
+
0xa865: 68,
|
668 |
+
0xa866: 68,
|
669 |
+
0xa867: 68,
|
670 |
+
0xa868: 68,
|
671 |
+
0xa869: 68,
|
672 |
+
0xa86a: 68,
|
673 |
+
0xa86b: 68,
|
674 |
+
0xa86c: 68,
|
675 |
+
0xa86d: 68,
|
676 |
+
0xa86e: 68,
|
677 |
+
0xa86f: 68,
|
678 |
+
0xa870: 68,
|
679 |
+
0xa871: 68,
|
680 |
+
0xa872: 76,
|
681 |
+
0xa873: 85,
|
682 |
+
0x10ac0: 68,
|
683 |
+
0x10ac1: 68,
|
684 |
+
0x10ac2: 68,
|
685 |
+
0x10ac3: 68,
|
686 |
+
0x10ac4: 68,
|
687 |
+
0x10ac5: 82,
|
688 |
+
0x10ac6: 85,
|
689 |
+
0x10ac7: 82,
|
690 |
+
0x10ac8: 85,
|
691 |
+
0x10ac9: 82,
|
692 |
+
0x10aca: 82,
|
693 |
+
0x10acb: 85,
|
694 |
+
0x10acc: 85,
|
695 |
+
0x10acd: 76,
|
696 |
+
0x10ace: 82,
|
697 |
+
0x10acf: 82,
|
698 |
+
0x10ad0: 82,
|
699 |
+
0x10ad1: 82,
|
700 |
+
0x10ad2: 82,
|
701 |
+
0x10ad3: 68,
|
702 |
+
0x10ad4: 68,
|
703 |
+
0x10ad5: 68,
|
704 |
+
0x10ad6: 68,
|
705 |
+
0x10ad7: 76,
|
706 |
+
0x10ad8: 68,
|
707 |
+
0x10ad9: 68,
|
708 |
+
0x10ada: 68,
|
709 |
+
0x10adb: 68,
|
710 |
+
0x10adc: 68,
|
711 |
+
0x10add: 82,
|
712 |
+
0x10ade: 68,
|
713 |
+
0x10adf: 68,
|
714 |
+
0x10ae0: 68,
|
715 |
+
0x10ae1: 82,
|
716 |
+
0x10ae2: 85,
|
717 |
+
0x10ae3: 85,
|
718 |
+
0x10ae4: 82,
|
719 |
+
0x10aeb: 68,
|
720 |
+
0x10aec: 68,
|
721 |
+
0x10aed: 68,
|
722 |
+
0x10aee: 68,
|
723 |
+
0x10aef: 82,
|
724 |
+
0x10b80: 68,
|
725 |
+
0x10b81: 82,
|
726 |
+
0x10b82: 68,
|
727 |
+
0x10b83: 82,
|
728 |
+
0x10b84: 82,
|
729 |
+
0x10b85: 82,
|
730 |
+
0x10b86: 68,
|
731 |
+
0x10b87: 68,
|
732 |
+
0x10b88: 68,
|
733 |
+
0x10b89: 82,
|
734 |
+
0x10b8a: 68,
|
735 |
+
0x10b8b: 68,
|
736 |
+
0x10b8c: 82,
|
737 |
+
0x10b8d: 68,
|
738 |
+
0x10b8e: 82,
|
739 |
+
0x10b8f: 82,
|
740 |
+
0x10b90: 68,
|
741 |
+
0x10b91: 82,
|
742 |
+
0x10ba9: 82,
|
743 |
+
0x10baa: 82,
|
744 |
+
0x10bab: 82,
|
745 |
+
0x10bac: 82,
|
746 |
+
0x10bad: 68,
|
747 |
+
0x10bae: 68,
|
748 |
+
0x10baf: 85,
|
749 |
+
0x10d00: 76,
|
750 |
+
0x10d01: 68,
|
751 |
+
0x10d02: 68,
|
752 |
+
0x10d03: 68,
|
753 |
+
0x10d04: 68,
|
754 |
+
0x10d05: 68,
|
755 |
+
0x10d06: 68,
|
756 |
+
0x10d07: 68,
|
757 |
+
0x10d08: 68,
|
758 |
+
0x10d09: 68,
|
759 |
+
0x10d0a: 68,
|
760 |
+
0x10d0b: 68,
|
761 |
+
0x10d0c: 68,
|
762 |
+
0x10d0d: 68,
|
763 |
+
0x10d0e: 68,
|
764 |
+
0x10d0f: 68,
|
765 |
+
0x10d10: 68,
|
766 |
+
0x10d11: 68,
|
767 |
+
0x10d12: 68,
|
768 |
+
0x10d13: 68,
|
769 |
+
0x10d14: 68,
|
770 |
+
0x10d15: 68,
|
771 |
+
0x10d16: 68,
|
772 |
+
0x10d17: 68,
|
773 |
+
0x10d18: 68,
|
774 |
+
0x10d19: 68,
|
775 |
+
0x10d1a: 68,
|
776 |
+
0x10d1b: 68,
|
777 |
+
0x10d1c: 68,
|
778 |
+
0x10d1d: 68,
|
779 |
+
0x10d1e: 68,
|
780 |
+
0x10d1f: 68,
|
781 |
+
0x10d20: 68,
|
782 |
+
0x10d21: 68,
|
783 |
+
0x10d22: 82,
|
784 |
+
0x10d23: 68,
|
785 |
+
0x10f30: 68,
|
786 |
+
0x10f31: 68,
|
787 |
+
0x10f32: 68,
|
788 |
+
0x10f33: 82,
|
789 |
+
0x10f34: 68,
|
790 |
+
0x10f35: 68,
|
791 |
+
0x10f36: 68,
|
792 |
+
0x10f37: 68,
|
793 |
+
0x10f38: 68,
|
794 |
+
0x10f39: 68,
|
795 |
+
0x10f3a: 68,
|
796 |
+
0x10f3b: 68,
|
797 |
+
0x10f3c: 68,
|
798 |
+
0x10f3d: 68,
|
799 |
+
0x10f3e: 68,
|
800 |
+
0x10f3f: 68,
|
801 |
+
0x10f40: 68,
|
802 |
+
0x10f41: 68,
|
803 |
+
0x10f42: 68,
|
804 |
+
0x10f43: 68,
|
805 |
+
0x10f44: 68,
|
806 |
+
0x10f45: 85,
|
807 |
+
0x10f51: 68,
|
808 |
+
0x10f52: 68,
|
809 |
+
0x10f53: 68,
|
810 |
+
0x10f54: 82,
|
811 |
+
0x10f70: 68,
|
812 |
+
0x10f71: 68,
|
813 |
+
0x10f72: 68,
|
814 |
+
0x10f73: 68,
|
815 |
+
0x10f74: 82,
|
816 |
+
0x10f75: 82,
|
817 |
+
0x10f76: 68,
|
818 |
+
0x10f77: 68,
|
819 |
+
0x10f78: 68,
|
820 |
+
0x10f79: 68,
|
821 |
+
0x10f7a: 68,
|
822 |
+
0x10f7b: 68,
|
823 |
+
0x10f7c: 68,
|
824 |
+
0x10f7d: 68,
|
825 |
+
0x10f7e: 68,
|
826 |
+
0x10f7f: 68,
|
827 |
+
0x10f80: 68,
|
828 |
+
0x10f81: 68,
|
829 |
+
0x10fb0: 68,
|
830 |
+
0x10fb1: 85,
|
831 |
+
0x10fb2: 68,
|
832 |
+
0x10fb3: 68,
|
833 |
+
0x10fb4: 82,
|
834 |
+
0x10fb5: 82,
|
835 |
+
0x10fb6: 82,
|
836 |
+
0x10fb7: 85,
|
837 |
+
0x10fb8: 68,
|
838 |
+
0x10fb9: 82,
|
839 |
+
0x10fba: 82,
|
840 |
+
0x10fbb: 68,
|
841 |
+
0x10fbc: 68,
|
842 |
+
0x10fbd: 82,
|
843 |
+
0x10fbe: 68,
|
844 |
+
0x10fbf: 68,
|
845 |
+
0x10fc0: 85,
|
846 |
+
0x10fc1: 68,
|
847 |
+
0x10fc2: 82,
|
848 |
+
0x10fc3: 82,
|
849 |
+
0x10fc4: 68,
|
850 |
+
0x10fc5: 85,
|
851 |
+
0x10fc6: 85,
|
852 |
+
0x10fc7: 85,
|
853 |
+
0x10fc8: 85,
|
854 |
+
0x10fc9: 82,
|
855 |
+
0x10fca: 68,
|
856 |
+
0x10fcb: 76,
|
857 |
+
0x110bd: 85,
|
858 |
+
0x110cd: 85,
|
859 |
+
0x1e900: 68,
|
860 |
+
0x1e901: 68,
|
861 |
+
0x1e902: 68,
|
862 |
+
0x1e903: 68,
|
863 |
+
0x1e904: 68,
|
864 |
+
0x1e905: 68,
|
865 |
+
0x1e906: 68,
|
866 |
+
0x1e907: 68,
|
867 |
+
0x1e908: 68,
|
868 |
+
0x1e909: 68,
|
869 |
+
0x1e90a: 68,
|
870 |
+
0x1e90b: 68,
|
871 |
+
0x1e90c: 68,
|
872 |
+
0x1e90d: 68,
|
873 |
+
0x1e90e: 68,
|
874 |
+
0x1e90f: 68,
|
875 |
+
0x1e910: 68,
|
876 |
+
0x1e911: 68,
|
877 |
+
0x1e912: 68,
|
878 |
+
0x1e913: 68,
|
879 |
+
0x1e914: 68,
|
880 |
+
0x1e915: 68,
|
881 |
+
0x1e916: 68,
|
882 |
+
0x1e917: 68,
|
883 |
+
0x1e918: 68,
|
884 |
+
0x1e919: 68,
|
885 |
+
0x1e91a: 68,
|
886 |
+
0x1e91b: 68,
|
887 |
+
0x1e91c: 68,
|
888 |
+
0x1e91d: 68,
|
889 |
+
0x1e91e: 68,
|
890 |
+
0x1e91f: 68,
|
891 |
+
0x1e920: 68,
|
892 |
+
0x1e921: 68,
|
893 |
+
0x1e922: 68,
|
894 |
+
0x1e923: 68,
|
895 |
+
0x1e924: 68,
|
896 |
+
0x1e925: 68,
|
897 |
+
0x1e926: 68,
|
898 |
+
0x1e927: 68,
|
899 |
+
0x1e928: 68,
|
900 |
+
0x1e929: 68,
|
901 |
+
0x1e92a: 68,
|
902 |
+
0x1e92b: 68,
|
903 |
+
0x1e92c: 68,
|
904 |
+
0x1e92d: 68,
|
905 |
+
0x1e92e: 68,
|
906 |
+
0x1e92f: 68,
|
907 |
+
0x1e930: 68,
|
908 |
+
0x1e931: 68,
|
909 |
+
0x1e932: 68,
|
910 |
+
0x1e933: 68,
|
911 |
+
0x1e934: 68,
|
912 |
+
0x1e935: 68,
|
913 |
+
0x1e936: 68,
|
914 |
+
0x1e937: 68,
|
915 |
+
0x1e938: 68,
|
916 |
+
0x1e939: 68,
|
917 |
+
0x1e93a: 68,
|
918 |
+
0x1e93b: 68,
|
919 |
+
0x1e93c: 68,
|
920 |
+
0x1e93d: 68,
|
921 |
+
0x1e93e: 68,
|
922 |
+
0x1e93f: 68,
|
923 |
+
0x1e940: 68,
|
924 |
+
0x1e941: 68,
|
925 |
+
0x1e942: 68,
|
926 |
+
0x1e943: 68,
|
927 |
+
0x1e94b: 84,
|
928 |
+
}
|
929 |
+
codepoint_classes = {
|
930 |
+
'PVALID': (
|
931 |
+
0x2d0000002e,
|
932 |
+
0x300000003a,
|
933 |
+
0x610000007b,
|
934 |
+
0xdf000000f7,
|
935 |
+
0xf800000100,
|
936 |
+
0x10100000102,
|
937 |
+
0x10300000104,
|
938 |
+
0x10500000106,
|
939 |
+
0x10700000108,
|
940 |
+
0x1090000010a,
|
941 |
+
0x10b0000010c,
|
942 |
+
0x10d0000010e,
|
943 |
+
0x10f00000110,
|
944 |
+
0x11100000112,
|
945 |
+
0x11300000114,
|
946 |
+
0x11500000116,
|
947 |
+
0x11700000118,
|
948 |
+
0x1190000011a,
|
949 |
+
0x11b0000011c,
|
950 |
+
0x11d0000011e,
|
951 |
+
0x11f00000120,
|
952 |
+
0x12100000122,
|
953 |
+
0x12300000124,
|
954 |
+
0x12500000126,
|
955 |
+
0x12700000128,
|
956 |
+
0x1290000012a,
|
957 |
+
0x12b0000012c,
|
958 |
+
0x12d0000012e,
|
959 |
+
0x12f00000130,
|
960 |
+
0x13100000132,
|
961 |
+
0x13500000136,
|
962 |
+
0x13700000139,
|
963 |
+
0x13a0000013b,
|
964 |
+
0x13c0000013d,
|
965 |
+
0x13e0000013f,
|
966 |
+
0x14200000143,
|
967 |
+
0x14400000145,
|
968 |
+
0x14600000147,
|
969 |
+
0x14800000149,
|
970 |
+
0x14b0000014c,
|
971 |
+
0x14d0000014e,
|
972 |
+
0x14f00000150,
|
973 |
+
0x15100000152,
|
974 |
+
0x15300000154,
|
975 |
+
0x15500000156,
|
976 |
+
0x15700000158,
|
977 |
+
0x1590000015a,
|
978 |
+
0x15b0000015c,
|
979 |
+
0x15d0000015e,
|
980 |
+
0x15f00000160,
|
981 |
+
0x16100000162,
|
982 |
+
0x16300000164,
|
983 |
+
0x16500000166,
|
984 |
+
0x16700000168,
|
985 |
+
0x1690000016a,
|
986 |
+
0x16b0000016c,
|
987 |
+
0x16d0000016e,
|
988 |
+
0x16f00000170,
|
989 |
+
0x17100000172,
|
990 |
+
0x17300000174,
|
991 |
+
0x17500000176,
|
992 |
+
0x17700000178,
|
993 |
+
0x17a0000017b,
|
994 |
+
0x17c0000017d,
|
995 |
+
0x17e0000017f,
|
996 |
+
0x18000000181,
|
997 |
+
0x18300000184,
|
998 |
+
0x18500000186,
|
999 |
+
0x18800000189,
|
1000 |
+
0x18c0000018e,
|
1001 |
+
0x19200000193,
|
1002 |
+
0x19500000196,
|
1003 |
+
0x1990000019c,
|
1004 |
+
0x19e0000019f,
|
1005 |
+
0x1a1000001a2,
|
1006 |
+
0x1a3000001a4,
|
1007 |
+
0x1a5000001a6,
|
1008 |
+
0x1a8000001a9,
|
1009 |
+
0x1aa000001ac,
|
1010 |
+
0x1ad000001ae,
|
1011 |
+
0x1b0000001b1,
|
1012 |
+
0x1b4000001b5,
|
1013 |
+
0x1b6000001b7,
|
1014 |
+
0x1b9000001bc,
|
1015 |
+
0x1bd000001c4,
|
1016 |
+
0x1ce000001cf,
|
1017 |
+
0x1d0000001d1,
|
1018 |
+
0x1d2000001d3,
|
1019 |
+
0x1d4000001d5,
|
1020 |
+
0x1d6000001d7,
|
1021 |
+
0x1d8000001d9,
|
1022 |
+
0x1da000001db,
|
1023 |
+
0x1dc000001de,
|
1024 |
+
0x1df000001e0,
|
1025 |
+
0x1e1000001e2,
|
1026 |
+
0x1e3000001e4,
|
1027 |
+
0x1e5000001e6,
|
1028 |
+
0x1e7000001e8,
|
1029 |
+
0x1e9000001ea,
|
1030 |
+
0x1eb000001ec,
|
1031 |
+
0x1ed000001ee,
|
1032 |
+
0x1ef000001f1,
|
1033 |
+
0x1f5000001f6,
|
1034 |
+
0x1f9000001fa,
|
1035 |
+
0x1fb000001fc,
|
1036 |
+
0x1fd000001fe,
|
1037 |
+
0x1ff00000200,
|
1038 |
+
0x20100000202,
|
1039 |
+
0x20300000204,
|
1040 |
+
0x20500000206,
|
1041 |
+
0x20700000208,
|
1042 |
+
0x2090000020a,
|
1043 |
+
0x20b0000020c,
|
1044 |
+
0x20d0000020e,
|
1045 |
+
0x20f00000210,
|
1046 |
+
0x21100000212,
|
1047 |
+
0x21300000214,
|
1048 |
+
0x21500000216,
|
1049 |
+
0x21700000218,
|
1050 |
+
0x2190000021a,
|
1051 |
+
0x21b0000021c,
|
1052 |
+
0x21d0000021e,
|
1053 |
+
0x21f00000220,
|
1054 |
+
0x22100000222,
|
1055 |
+
0x22300000224,
|
1056 |
+
0x22500000226,
|
1057 |
+
0x22700000228,
|
1058 |
+
0x2290000022a,
|
1059 |
+
0x22b0000022c,
|
1060 |
+
0x22d0000022e,
|
1061 |
+
0x22f00000230,
|
1062 |
+
0x23100000232,
|
1063 |
+
0x2330000023a,
|
1064 |
+
0x23c0000023d,
|
1065 |
+
0x23f00000241,
|
1066 |
+
0x24200000243,
|
1067 |
+
0x24700000248,
|
1068 |
+
0x2490000024a,
|
1069 |
+
0x24b0000024c,
|
1070 |
+
0x24d0000024e,
|
1071 |
+
0x24f000002b0,
|
1072 |
+
0x2b9000002c2,
|
1073 |
+
0x2c6000002d2,
|
1074 |
+
0x2ec000002ed,
|
1075 |
+
0x2ee000002ef,
|
1076 |
+
0x30000000340,
|
1077 |
+
0x34200000343,
|
1078 |
+
0x3460000034f,
|
1079 |
+
0x35000000370,
|
1080 |
+
0x37100000372,
|
1081 |
+
0x37300000374,
|
1082 |
+
0x37700000378,
|
1083 |
+
0x37b0000037e,
|
1084 |
+
0x39000000391,
|
1085 |
+
0x3ac000003cf,
|
1086 |
+
0x3d7000003d8,
|
1087 |
+
0x3d9000003da,
|
1088 |
+
0x3db000003dc,
|
1089 |
+
0x3dd000003de,
|
1090 |
+
0x3df000003e0,
|
1091 |
+
0x3e1000003e2,
|
1092 |
+
0x3e3000003e4,
|
1093 |
+
0x3e5000003e6,
|
1094 |
+
0x3e7000003e8,
|
1095 |
+
0x3e9000003ea,
|
1096 |
+
0x3eb000003ec,
|
1097 |
+
0x3ed000003ee,
|
1098 |
+
0x3ef000003f0,
|
1099 |
+
0x3f3000003f4,
|
1100 |
+
0x3f8000003f9,
|
1101 |
+
0x3fb000003fd,
|
1102 |
+
0x43000000460,
|
1103 |
+
0x46100000462,
|
1104 |
+
0x46300000464,
|
1105 |
+
0x46500000466,
|
1106 |
+
0x46700000468,
|
1107 |
+
0x4690000046a,
|
1108 |
+
0x46b0000046c,
|
1109 |
+
0x46d0000046e,
|
1110 |
+
0x46f00000470,
|
1111 |
+
0x47100000472,
|
1112 |
+
0x47300000474,
|
1113 |
+
0x47500000476,
|
1114 |
+
0x47700000478,
|
1115 |
+
0x4790000047a,
|
1116 |
+
0x47b0000047c,
|
1117 |
+
0x47d0000047e,
|
1118 |
+
0x47f00000480,
|
1119 |
+
0x48100000482,
|
1120 |
+
0x48300000488,
|
1121 |
+
0x48b0000048c,
|
1122 |
+
0x48d0000048e,
|
1123 |
+
0x48f00000490,
|
1124 |
+
0x49100000492,
|
1125 |
+
0x49300000494,
|
1126 |
+
0x49500000496,
|
1127 |
+
0x49700000498,
|
1128 |
+
0x4990000049a,
|
1129 |
+
0x49b0000049c,
|
1130 |
+
0x49d0000049e,
|
1131 |
+
0x49f000004a0,
|
1132 |
+
0x4a1000004a2,
|
1133 |
+
0x4a3000004a4,
|
1134 |
+
0x4a5000004a6,
|
1135 |
+
0x4a7000004a8,
|
1136 |
+
0x4a9000004aa,
|
1137 |
+
0x4ab000004ac,
|
1138 |
+
0x4ad000004ae,
|
1139 |
+
0x4af000004b0,
|
1140 |
+
0x4b1000004b2,
|
1141 |
+
0x4b3000004b4,
|
1142 |
+
0x4b5000004b6,
|
1143 |
+
0x4b7000004b8,
|
1144 |
+
0x4b9000004ba,
|
1145 |
+
0x4bb000004bc,
|
1146 |
+
0x4bd000004be,
|
1147 |
+
0x4bf000004c0,
|
1148 |
+
0x4c2000004c3,
|
1149 |
+
0x4c4000004c5,
|
1150 |
+
0x4c6000004c7,
|
1151 |
+
0x4c8000004c9,
|
1152 |
+
0x4ca000004cb,
|
1153 |
+
0x4cc000004cd,
|
1154 |
+
0x4ce000004d0,
|
1155 |
+
0x4d1000004d2,
|
1156 |
+
0x4d3000004d4,
|
1157 |
+
0x4d5000004d6,
|
1158 |
+
0x4d7000004d8,
|
1159 |
+
0x4d9000004da,
|
1160 |
+
0x4db000004dc,
|
1161 |
+
0x4dd000004de,
|
1162 |
+
0x4df000004e0,
|
1163 |
+
0x4e1000004e2,
|
1164 |
+
0x4e3000004e4,
|
1165 |
+
0x4e5000004e6,
|
1166 |
+
0x4e7000004e8,
|
1167 |
+
0x4e9000004ea,
|
1168 |
+
0x4eb000004ec,
|
1169 |
+
0x4ed000004ee,
|
1170 |
+
0x4ef000004f0,
|
1171 |
+
0x4f1000004f2,
|
1172 |
+
0x4f3000004f4,
|
1173 |
+
0x4f5000004f6,
|
1174 |
+
0x4f7000004f8,
|
1175 |
+
0x4f9000004fa,
|
1176 |
+
0x4fb000004fc,
|
1177 |
+
0x4fd000004fe,
|
1178 |
+
0x4ff00000500,
|
1179 |
+
0x50100000502,
|
1180 |
+
0x50300000504,
|
1181 |
+
0x50500000506,
|
1182 |
+
0x50700000508,
|
1183 |
+
0x5090000050a,
|
1184 |
+
0x50b0000050c,
|
1185 |
+
0x50d0000050e,
|
1186 |
+
0x50f00000510,
|
1187 |
+
0x51100000512,
|
1188 |
+
0x51300000514,
|
1189 |
+
0x51500000516,
|
1190 |
+
0x51700000518,
|
1191 |
+
0x5190000051a,
|
1192 |
+
0x51b0000051c,
|
1193 |
+
0x51d0000051e,
|
1194 |
+
0x51f00000520,
|
1195 |
+
0x52100000522,
|
1196 |
+
0x52300000524,
|
1197 |
+
0x52500000526,
|
1198 |
+
0x52700000528,
|
1199 |
+
0x5290000052a,
|
1200 |
+
0x52b0000052c,
|
1201 |
+
0x52d0000052e,
|
1202 |
+
0x52f00000530,
|
1203 |
+
0x5590000055a,
|
1204 |
+
0x56000000587,
|
1205 |
+
0x58800000589,
|
1206 |
+
0x591000005be,
|
1207 |
+
0x5bf000005c0,
|
1208 |
+
0x5c1000005c3,
|
1209 |
+
0x5c4000005c6,
|
1210 |
+
0x5c7000005c8,
|
1211 |
+
0x5d0000005eb,
|
1212 |
+
0x5ef000005f3,
|
1213 |
+
0x6100000061b,
|
1214 |
+
0x62000000640,
|
1215 |
+
0x64100000660,
|
1216 |
+
0x66e00000675,
|
1217 |
+
0x679000006d4,
|
1218 |
+
0x6d5000006dd,
|
1219 |
+
0x6df000006e9,
|
1220 |
+
0x6ea000006f0,
|
1221 |
+
0x6fa00000700,
|
1222 |
+
0x7100000074b,
|
1223 |
+
0x74d000007b2,
|
1224 |
+
0x7c0000007f6,
|
1225 |
+
0x7fd000007fe,
|
1226 |
+
0x8000000082e,
|
1227 |
+
0x8400000085c,
|
1228 |
+
0x8600000086b,
|
1229 |
+
0x87000000888,
|
1230 |
+
0x8890000088f,
|
1231 |
+
0x898000008e2,
|
1232 |
+
0x8e300000958,
|
1233 |
+
0x96000000964,
|
1234 |
+
0x96600000970,
|
1235 |
+
0x97100000984,
|
1236 |
+
0x9850000098d,
|
1237 |
+
0x98f00000991,
|
1238 |
+
0x993000009a9,
|
1239 |
+
0x9aa000009b1,
|
1240 |
+
0x9b2000009b3,
|
1241 |
+
0x9b6000009ba,
|
1242 |
+
0x9bc000009c5,
|
1243 |
+
0x9c7000009c9,
|
1244 |
+
0x9cb000009cf,
|
1245 |
+
0x9d7000009d8,
|
1246 |
+
0x9e0000009e4,
|
1247 |
+
0x9e6000009f2,
|
1248 |
+
0x9fc000009fd,
|
1249 |
+
0x9fe000009ff,
|
1250 |
+
0xa0100000a04,
|
1251 |
+
0xa0500000a0b,
|
1252 |
+
0xa0f00000a11,
|
1253 |
+
0xa1300000a29,
|
1254 |
+
0xa2a00000a31,
|
1255 |
+
0xa3200000a33,
|
1256 |
+
0xa3500000a36,
|
1257 |
+
0xa3800000a3a,
|
1258 |
+
0xa3c00000a3d,
|
1259 |
+
0xa3e00000a43,
|
1260 |
+
0xa4700000a49,
|
1261 |
+
0xa4b00000a4e,
|
1262 |
+
0xa5100000a52,
|
1263 |
+
0xa5c00000a5d,
|
1264 |
+
0xa6600000a76,
|
1265 |
+
0xa8100000a84,
|
1266 |
+
0xa8500000a8e,
|
1267 |
+
0xa8f00000a92,
|
1268 |
+
0xa9300000aa9,
|
1269 |
+
0xaaa00000ab1,
|
1270 |
+
0xab200000ab4,
|
1271 |
+
0xab500000aba,
|
1272 |
+
0xabc00000ac6,
|
1273 |
+
0xac700000aca,
|
1274 |
+
0xacb00000ace,
|
1275 |
+
0xad000000ad1,
|
1276 |
+
0xae000000ae4,
|
1277 |
+
0xae600000af0,
|
1278 |
+
0xaf900000b00,
|
1279 |
+
0xb0100000b04,
|
1280 |
+
0xb0500000b0d,
|
1281 |
+
0xb0f00000b11,
|
1282 |
+
0xb1300000b29,
|
1283 |
+
0xb2a00000b31,
|
1284 |
+
0xb3200000b34,
|
1285 |
+
0xb3500000b3a,
|
1286 |
+
0xb3c00000b45,
|
1287 |
+
0xb4700000b49,
|
1288 |
+
0xb4b00000b4e,
|
1289 |
+
0xb5500000b58,
|
1290 |
+
0xb5f00000b64,
|
1291 |
+
0xb6600000b70,
|
1292 |
+
0xb7100000b72,
|
1293 |
+
0xb8200000b84,
|
1294 |
+
0xb8500000b8b,
|
1295 |
+
0xb8e00000b91,
|
1296 |
+
0xb9200000b96,
|
1297 |
+
0xb9900000b9b,
|
1298 |
+
0xb9c00000b9d,
|
1299 |
+
0xb9e00000ba0,
|
1300 |
+
0xba300000ba5,
|
1301 |
+
0xba800000bab,
|
1302 |
+
0xbae00000bba,
|
1303 |
+
0xbbe00000bc3,
|
1304 |
+
0xbc600000bc9,
|
1305 |
+
0xbca00000bce,
|
1306 |
+
0xbd000000bd1,
|
1307 |
+
0xbd700000bd8,
|
1308 |
+
0xbe600000bf0,
|
1309 |
+
0xc0000000c0d,
|
1310 |
+
0xc0e00000c11,
|
1311 |
+
0xc1200000c29,
|
1312 |
+
0xc2a00000c3a,
|
1313 |
+
0xc3c00000c45,
|
1314 |
+
0xc4600000c49,
|
1315 |
+
0xc4a00000c4e,
|
1316 |
+
0xc5500000c57,
|
1317 |
+
0xc5800000c5b,
|
1318 |
+
0xc5d00000c5e,
|
1319 |
+
0xc6000000c64,
|
1320 |
+
0xc6600000c70,
|
1321 |
+
0xc8000000c84,
|
1322 |
+
0xc8500000c8d,
|
1323 |
+
0xc8e00000c91,
|
1324 |
+
0xc9200000ca9,
|
1325 |
+
0xcaa00000cb4,
|
1326 |
+
0xcb500000cba,
|
1327 |
+
0xcbc00000cc5,
|
1328 |
+
0xcc600000cc9,
|
1329 |
+
0xcca00000cce,
|
1330 |
+
0xcd500000cd7,
|
1331 |
+
0xcdd00000cdf,
|
1332 |
+
0xce000000ce4,
|
1333 |
+
0xce600000cf0,
|
1334 |
+
0xcf100000cf3,
|
1335 |
+
0xd0000000d0d,
|
1336 |
+
0xd0e00000d11,
|
1337 |
+
0xd1200000d45,
|
1338 |
+
0xd4600000d49,
|
1339 |
+
0xd4a00000d4f,
|
1340 |
+
0xd5400000d58,
|
1341 |
+
0xd5f00000d64,
|
1342 |
+
0xd6600000d70,
|
1343 |
+
0xd7a00000d80,
|
1344 |
+
0xd8100000d84,
|
1345 |
+
0xd8500000d97,
|
1346 |
+
0xd9a00000db2,
|
1347 |
+
0xdb300000dbc,
|
1348 |
+
0xdbd00000dbe,
|
1349 |
+
0xdc000000dc7,
|
1350 |
+
0xdca00000dcb,
|
1351 |
+
0xdcf00000dd5,
|
1352 |
+
0xdd600000dd7,
|
1353 |
+
0xdd800000de0,
|
1354 |
+
0xde600000df0,
|
1355 |
+
0xdf200000df4,
|
1356 |
+
0xe0100000e33,
|
1357 |
+
0xe3400000e3b,
|
1358 |
+
0xe4000000e4f,
|
1359 |
+
0xe5000000e5a,
|
1360 |
+
0xe8100000e83,
|
1361 |
+
0xe8400000e85,
|
1362 |
+
0xe8600000e8b,
|
1363 |
+
0xe8c00000ea4,
|
1364 |
+
0xea500000ea6,
|
1365 |
+
0xea700000eb3,
|
1366 |
+
0xeb400000ebe,
|
1367 |
+
0xec000000ec5,
|
1368 |
+
0xec600000ec7,
|
1369 |
+
0xec800000ece,
|
1370 |
+
0xed000000eda,
|
1371 |
+
0xede00000ee0,
|
1372 |
+
0xf0000000f01,
|
1373 |
+
0xf0b00000f0c,
|
1374 |
+
0xf1800000f1a,
|
1375 |
+
0xf2000000f2a,
|
1376 |
+
0xf3500000f36,
|
1377 |
+
0xf3700000f38,
|
1378 |
+
0xf3900000f3a,
|
1379 |
+
0xf3e00000f43,
|
1380 |
+
0xf4400000f48,
|
1381 |
+
0xf4900000f4d,
|
1382 |
+
0xf4e00000f52,
|
1383 |
+
0xf5300000f57,
|
1384 |
+
0xf5800000f5c,
|
1385 |
+
0xf5d00000f69,
|
1386 |
+
0xf6a00000f6d,
|
1387 |
+
0xf7100000f73,
|
1388 |
+
0xf7400000f75,
|
1389 |
+
0xf7a00000f81,
|
1390 |
+
0xf8200000f85,
|
1391 |
+
0xf8600000f93,
|
1392 |
+
0xf9400000f98,
|
1393 |
+
0xf9900000f9d,
|
1394 |
+
0xf9e00000fa2,
|
1395 |
+
0xfa300000fa7,
|
1396 |
+
0xfa800000fac,
|
1397 |
+
0xfad00000fb9,
|
1398 |
+
0xfba00000fbd,
|
1399 |
+
0xfc600000fc7,
|
1400 |
+
0x10000000104a,
|
1401 |
+
0x10500000109e,
|
1402 |
+
0x10d0000010fb,
|
1403 |
+
0x10fd00001100,
|
1404 |
+
0x120000001249,
|
1405 |
+
0x124a0000124e,
|
1406 |
+
0x125000001257,
|
1407 |
+
0x125800001259,
|
1408 |
+
0x125a0000125e,
|
1409 |
+
0x126000001289,
|
1410 |
+
0x128a0000128e,
|
1411 |
+
0x1290000012b1,
|
1412 |
+
0x12b2000012b6,
|
1413 |
+
0x12b8000012bf,
|
1414 |
+
0x12c0000012c1,
|
1415 |
+
0x12c2000012c6,
|
1416 |
+
0x12c8000012d7,
|
1417 |
+
0x12d800001311,
|
1418 |
+
0x131200001316,
|
1419 |
+
0x13180000135b,
|
1420 |
+
0x135d00001360,
|
1421 |
+
0x138000001390,
|
1422 |
+
0x13a0000013f6,
|
1423 |
+
0x14010000166d,
|
1424 |
+
0x166f00001680,
|
1425 |
+
0x16810000169b,
|
1426 |
+
0x16a0000016eb,
|
1427 |
+
0x16f1000016f9,
|
1428 |
+
0x170000001716,
|
1429 |
+
0x171f00001735,
|
1430 |
+
0x174000001754,
|
1431 |
+
0x17600000176d,
|
1432 |
+
0x176e00001771,
|
1433 |
+
0x177200001774,
|
1434 |
+
0x1780000017b4,
|
1435 |
+
0x17b6000017d4,
|
1436 |
+
0x17d7000017d8,
|
1437 |
+
0x17dc000017de,
|
1438 |
+
0x17e0000017ea,
|
1439 |
+
0x18100000181a,
|
1440 |
+
0x182000001879,
|
1441 |
+
0x1880000018ab,
|
1442 |
+
0x18b0000018f6,
|
1443 |
+
0x19000000191f,
|
1444 |
+
0x19200000192c,
|
1445 |
+
0x19300000193c,
|
1446 |
+
0x19460000196e,
|
1447 |
+
0x197000001975,
|
1448 |
+
0x1980000019ac,
|
1449 |
+
0x19b0000019ca,
|
1450 |
+
0x19d0000019da,
|
1451 |
+
0x1a0000001a1c,
|
1452 |
+
0x1a2000001a5f,
|
1453 |
+
0x1a6000001a7d,
|
1454 |
+
0x1a7f00001a8a,
|
1455 |
+
0x1a9000001a9a,
|
1456 |
+
0x1aa700001aa8,
|
1457 |
+
0x1ab000001abe,
|
1458 |
+
0x1abf00001acf,
|
1459 |
+
0x1b0000001b4d,
|
1460 |
+
0x1b5000001b5a,
|
1461 |
+
0x1b6b00001b74,
|
1462 |
+
0x1b8000001bf4,
|
1463 |
+
0x1c0000001c38,
|
1464 |
+
0x1c4000001c4a,
|
1465 |
+
0x1c4d00001c7e,
|
1466 |
+
0x1cd000001cd3,
|
1467 |
+
0x1cd400001cfb,
|
1468 |
+
0x1d0000001d2c,
|
1469 |
+
0x1d2f00001d30,
|
1470 |
+
0x1d3b00001d3c,
|
1471 |
+
0x1d4e00001d4f,
|
1472 |
+
0x1d6b00001d78,
|
1473 |
+
0x1d7900001d9b,
|
1474 |
+
0x1dc000001e00,
|
1475 |
+
0x1e0100001e02,
|
1476 |
+
0x1e0300001e04,
|
1477 |
+
0x1e0500001e06,
|
1478 |
+
0x1e0700001e08,
|
1479 |
+
0x1e0900001e0a,
|
1480 |
+
0x1e0b00001e0c,
|
1481 |
+
0x1e0d00001e0e,
|
1482 |
+
0x1e0f00001e10,
|
1483 |
+
0x1e1100001e12,
|
1484 |
+
0x1e1300001e14,
|
1485 |
+
0x1e1500001e16,
|
1486 |
+
0x1e1700001e18,
|
1487 |
+
0x1e1900001e1a,
|
1488 |
+
0x1e1b00001e1c,
|
1489 |
+
0x1e1d00001e1e,
|
1490 |
+
0x1e1f00001e20,
|
1491 |
+
0x1e2100001e22,
|
1492 |
+
0x1e2300001e24,
|
1493 |
+
0x1e2500001e26,
|
1494 |
+
0x1e2700001e28,
|
1495 |
+
0x1e2900001e2a,
|
1496 |
+
0x1e2b00001e2c,
|
1497 |
+
0x1e2d00001e2e,
|
1498 |
+
0x1e2f00001e30,
|
1499 |
+
0x1e3100001e32,
|
1500 |
+
0x1e3300001e34,
|
1501 |
+
0x1e3500001e36,
|
1502 |
+
0x1e3700001e38,
|
1503 |
+
0x1e3900001e3a,
|
1504 |
+
0x1e3b00001e3c,
|
1505 |
+
0x1e3d00001e3e,
|
1506 |
+
0x1e3f00001e40,
|
1507 |
+
0x1e4100001e42,
|
1508 |
+
0x1e4300001e44,
|
1509 |
+
0x1e4500001e46,
|
1510 |
+
0x1e4700001e48,
|
1511 |
+
0x1e4900001e4a,
|
1512 |
+
0x1e4b00001e4c,
|
1513 |
+
0x1e4d00001e4e,
|
1514 |
+
0x1e4f00001e50,
|
1515 |
+
0x1e5100001e52,
|
1516 |
+
0x1e5300001e54,
|
1517 |
+
0x1e5500001e56,
|
1518 |
+
0x1e5700001e58,
|
1519 |
+
0x1e5900001e5a,
|
1520 |
+
0x1e5b00001e5c,
|
1521 |
+
0x1e5d00001e5e,
|
1522 |
+
0x1e5f00001e60,
|
1523 |
+
0x1e6100001e62,
|
1524 |
+
0x1e6300001e64,
|
1525 |
+
0x1e6500001e66,
|
1526 |
+
0x1e6700001e68,
|
1527 |
+
0x1e6900001e6a,
|
1528 |
+
0x1e6b00001e6c,
|
1529 |
+
0x1e6d00001e6e,
|
1530 |
+
0x1e6f00001e70,
|
1531 |
+
0x1e7100001e72,
|
1532 |
+
0x1e7300001e74,
|
1533 |
+
0x1e7500001e76,
|
1534 |
+
0x1e7700001e78,
|
1535 |
+
0x1e7900001e7a,
|
1536 |
+
0x1e7b00001e7c,
|
1537 |
+
0x1e7d00001e7e,
|
1538 |
+
0x1e7f00001e80,
|
1539 |
+
0x1e8100001e82,
|
1540 |
+
0x1e8300001e84,
|
1541 |
+
0x1e8500001e86,
|
1542 |
+
0x1e8700001e88,
|
1543 |
+
0x1e8900001e8a,
|
1544 |
+
0x1e8b00001e8c,
|
1545 |
+
0x1e8d00001e8e,
|
1546 |
+
0x1e8f00001e90,
|
1547 |
+
0x1e9100001e92,
|
1548 |
+
0x1e9300001e94,
|
1549 |
+
0x1e9500001e9a,
|
1550 |
+
0x1e9c00001e9e,
|
1551 |
+
0x1e9f00001ea0,
|
1552 |
+
0x1ea100001ea2,
|
1553 |
+
0x1ea300001ea4,
|
1554 |
+
0x1ea500001ea6,
|
1555 |
+
0x1ea700001ea8,
|
1556 |
+
0x1ea900001eaa,
|
1557 |
+
0x1eab00001eac,
|
1558 |
+
0x1ead00001eae,
|
1559 |
+
0x1eaf00001eb0,
|
1560 |
+
0x1eb100001eb2,
|
1561 |
+
0x1eb300001eb4,
|
1562 |
+
0x1eb500001eb6,
|
1563 |
+
0x1eb700001eb8,
|
1564 |
+
0x1eb900001eba,
|
1565 |
+
0x1ebb00001ebc,
|
1566 |
+
0x1ebd00001ebe,
|
1567 |
+
0x1ebf00001ec0,
|
1568 |
+
0x1ec100001ec2,
|
1569 |
+
0x1ec300001ec4,
|
1570 |
+
0x1ec500001ec6,
|
1571 |
+
0x1ec700001ec8,
|
1572 |
+
0x1ec900001eca,
|
1573 |
+
0x1ecb00001ecc,
|
1574 |
+
0x1ecd00001ece,
|
1575 |
+
0x1ecf00001ed0,
|
1576 |
+
0x1ed100001ed2,
|
1577 |
+
0x1ed300001ed4,
|
1578 |
+
0x1ed500001ed6,
|
1579 |
+
0x1ed700001ed8,
|
1580 |
+
0x1ed900001eda,
|
1581 |
+
0x1edb00001edc,
|
1582 |
+
0x1edd00001ede,
|
1583 |
+
0x1edf00001ee0,
|
1584 |
+
0x1ee100001ee2,
|
1585 |
+
0x1ee300001ee4,
|
1586 |
+
0x1ee500001ee6,
|
1587 |
+
0x1ee700001ee8,
|
1588 |
+
0x1ee900001eea,
|
1589 |
+
0x1eeb00001eec,
|
1590 |
+
0x1eed00001eee,
|
1591 |
+
0x1eef00001ef0,
|
1592 |
+
0x1ef100001ef2,
|
1593 |
+
0x1ef300001ef4,
|
1594 |
+
0x1ef500001ef6,
|
1595 |
+
0x1ef700001ef8,
|
1596 |
+
0x1ef900001efa,
|
1597 |
+
0x1efb00001efc,
|
1598 |
+
0x1efd00001efe,
|
1599 |
+
0x1eff00001f08,
|
1600 |
+
0x1f1000001f16,
|
1601 |
+
0x1f2000001f28,
|
1602 |
+
0x1f3000001f38,
|
1603 |
+
0x1f4000001f46,
|
1604 |
+
0x1f5000001f58,
|
1605 |
+
0x1f6000001f68,
|
1606 |
+
0x1f7000001f71,
|
1607 |
+
0x1f7200001f73,
|
1608 |
+
0x1f7400001f75,
|
1609 |
+
0x1f7600001f77,
|
1610 |
+
0x1f7800001f79,
|
1611 |
+
0x1f7a00001f7b,
|
1612 |
+
0x1f7c00001f7d,
|
1613 |
+
0x1fb000001fb2,
|
1614 |
+
0x1fb600001fb7,
|
1615 |
+
0x1fc600001fc7,
|
1616 |
+
0x1fd000001fd3,
|
1617 |
+
0x1fd600001fd8,
|
1618 |
+
0x1fe000001fe3,
|
1619 |
+
0x1fe400001fe8,
|
1620 |
+
0x1ff600001ff7,
|
1621 |
+
0x214e0000214f,
|
1622 |
+
0x218400002185,
|
1623 |
+
0x2c3000002c60,
|
1624 |
+
0x2c6100002c62,
|
1625 |
+
0x2c6500002c67,
|
1626 |
+
0x2c6800002c69,
|
1627 |
+
0x2c6a00002c6b,
|
1628 |
+
0x2c6c00002c6d,
|
1629 |
+
0x2c7100002c72,
|
1630 |
+
0x2c7300002c75,
|
1631 |
+
0x2c7600002c7c,
|
1632 |
+
0x2c8100002c82,
|
1633 |
+
0x2c8300002c84,
|
1634 |
+
0x2c8500002c86,
|
1635 |
+
0x2c8700002c88,
|
1636 |
+
0x2c8900002c8a,
|
1637 |
+
0x2c8b00002c8c,
|
1638 |
+
0x2c8d00002c8e,
|
1639 |
+
0x2c8f00002c90,
|
1640 |
+
0x2c9100002c92,
|
1641 |
+
0x2c9300002c94,
|
1642 |
+
0x2c9500002c96,
|
1643 |
+
0x2c9700002c98,
|
1644 |
+
0x2c9900002c9a,
|
1645 |
+
0x2c9b00002c9c,
|
1646 |
+
0x2c9d00002c9e,
|
1647 |
+
0x2c9f00002ca0,
|
1648 |
+
0x2ca100002ca2,
|
1649 |
+
0x2ca300002ca4,
|
1650 |
+
0x2ca500002ca6,
|
1651 |
+
0x2ca700002ca8,
|
1652 |
+
0x2ca900002caa,
|
1653 |
+
0x2cab00002cac,
|
1654 |
+
0x2cad00002cae,
|
1655 |
+
0x2caf00002cb0,
|
1656 |
+
0x2cb100002cb2,
|
1657 |
+
0x2cb300002cb4,
|
1658 |
+
0x2cb500002cb6,
|
1659 |
+
0x2cb700002cb8,
|
1660 |
+
0x2cb900002cba,
|
1661 |
+
0x2cbb00002cbc,
|
1662 |
+
0x2cbd00002cbe,
|
1663 |
+
0x2cbf00002cc0,
|
1664 |
+
0x2cc100002cc2,
|
1665 |
+
0x2cc300002cc4,
|
1666 |
+
0x2cc500002cc6,
|
1667 |
+
0x2cc700002cc8,
|
1668 |
+
0x2cc900002cca,
|
1669 |
+
0x2ccb00002ccc,
|
1670 |
+
0x2ccd00002cce,
|
1671 |
+
0x2ccf00002cd0,
|
1672 |
+
0x2cd100002cd2,
|
1673 |
+
0x2cd300002cd4,
|
1674 |
+
0x2cd500002cd6,
|
1675 |
+
0x2cd700002cd8,
|
1676 |
+
0x2cd900002cda,
|
1677 |
+
0x2cdb00002cdc,
|
1678 |
+
0x2cdd00002cde,
|
1679 |
+
0x2cdf00002ce0,
|
1680 |
+
0x2ce100002ce2,
|
1681 |
+
0x2ce300002ce5,
|
1682 |
+
0x2cec00002ced,
|
1683 |
+
0x2cee00002cf2,
|
1684 |
+
0x2cf300002cf4,
|
1685 |
+
0x2d0000002d26,
|
1686 |
+
0x2d2700002d28,
|
1687 |
+
0x2d2d00002d2e,
|
1688 |
+
0x2d3000002d68,
|
1689 |
+
0x2d7f00002d97,
|
1690 |
+
0x2da000002da7,
|
1691 |
+
0x2da800002daf,
|
1692 |
+
0x2db000002db7,
|
1693 |
+
0x2db800002dbf,
|
1694 |
+
0x2dc000002dc7,
|
1695 |
+
0x2dc800002dcf,
|
1696 |
+
0x2dd000002dd7,
|
1697 |
+
0x2dd800002ddf,
|
1698 |
+
0x2de000002e00,
|
1699 |
+
0x2e2f00002e30,
|
1700 |
+
0x300500003008,
|
1701 |
+
0x302a0000302e,
|
1702 |
+
0x303c0000303d,
|
1703 |
+
0x304100003097,
|
1704 |
+
0x30990000309b,
|
1705 |
+
0x309d0000309f,
|
1706 |
+
0x30a1000030fb,
|
1707 |
+
0x30fc000030ff,
|
1708 |
+
0x310500003130,
|
1709 |
+
0x31a0000031c0,
|
1710 |
+
0x31f000003200,
|
1711 |
+
0x340000004dc0,
|
1712 |
+
0x4e000000a48d,
|
1713 |
+
0xa4d00000a4fe,
|
1714 |
+
0xa5000000a60d,
|
1715 |
+
0xa6100000a62c,
|
1716 |
+
0xa6410000a642,
|
1717 |
+
0xa6430000a644,
|
1718 |
+
0xa6450000a646,
|
1719 |
+
0xa6470000a648,
|
1720 |
+
0xa6490000a64a,
|
1721 |
+
0xa64b0000a64c,
|
1722 |
+
0xa64d0000a64e,
|
1723 |
+
0xa64f0000a650,
|
1724 |
+
0xa6510000a652,
|
1725 |
+
0xa6530000a654,
|
1726 |
+
0xa6550000a656,
|
1727 |
+
0xa6570000a658,
|
1728 |
+
0xa6590000a65a,
|
1729 |
+
0xa65b0000a65c,
|
1730 |
+
0xa65d0000a65e,
|
1731 |
+
0xa65f0000a660,
|
1732 |
+
0xa6610000a662,
|
1733 |
+
0xa6630000a664,
|
1734 |
+
0xa6650000a666,
|
1735 |
+
0xa6670000a668,
|
1736 |
+
0xa6690000a66a,
|
1737 |
+
0xa66b0000a66c,
|
1738 |
+
0xa66d0000a670,
|
1739 |
+
0xa6740000a67e,
|
1740 |
+
0xa67f0000a680,
|
1741 |
+
0xa6810000a682,
|
1742 |
+
0xa6830000a684,
|
1743 |
+
0xa6850000a686,
|
1744 |
+
0xa6870000a688,
|
1745 |
+
0xa6890000a68a,
|
1746 |
+
0xa68b0000a68c,
|
1747 |
+
0xa68d0000a68e,
|
1748 |
+
0xa68f0000a690,
|
1749 |
+
0xa6910000a692,
|
1750 |
+
0xa6930000a694,
|
1751 |
+
0xa6950000a696,
|
1752 |
+
0xa6970000a698,
|
1753 |
+
0xa6990000a69a,
|
1754 |
+
0xa69b0000a69c,
|
1755 |
+
0xa69e0000a6e6,
|
1756 |
+
0xa6f00000a6f2,
|
1757 |
+
0xa7170000a720,
|
1758 |
+
0xa7230000a724,
|
1759 |
+
0xa7250000a726,
|
1760 |
+
0xa7270000a728,
|
1761 |
+
0xa7290000a72a,
|
1762 |
+
0xa72b0000a72c,
|
1763 |
+
0xa72d0000a72e,
|
1764 |
+
0xa72f0000a732,
|
1765 |
+
0xa7330000a734,
|
1766 |
+
0xa7350000a736,
|
1767 |
+
0xa7370000a738,
|
1768 |
+
0xa7390000a73a,
|
1769 |
+
0xa73b0000a73c,
|
1770 |
+
0xa73d0000a73e,
|
1771 |
+
0xa73f0000a740,
|
1772 |
+
0xa7410000a742,
|
1773 |
+
0xa7430000a744,
|
1774 |
+
0xa7450000a746,
|
1775 |
+
0xa7470000a748,
|
1776 |
+
0xa7490000a74a,
|
1777 |
+
0xa74b0000a74c,
|
1778 |
+
0xa74d0000a74e,
|
1779 |
+
0xa74f0000a750,
|
1780 |
+
0xa7510000a752,
|
1781 |
+
0xa7530000a754,
|
1782 |
+
0xa7550000a756,
|
1783 |
+
0xa7570000a758,
|
1784 |
+
0xa7590000a75a,
|
1785 |
+
0xa75b0000a75c,
|
1786 |
+
0xa75d0000a75e,
|
1787 |
+
0xa75f0000a760,
|
1788 |
+
0xa7610000a762,
|
1789 |
+
0xa7630000a764,
|
1790 |
+
0xa7650000a766,
|
1791 |
+
0xa7670000a768,
|
1792 |
+
0xa7690000a76a,
|
1793 |
+
0xa76b0000a76c,
|
1794 |
+
0xa76d0000a76e,
|
1795 |
+
0xa76f0000a770,
|
1796 |
+
0xa7710000a779,
|
1797 |
+
0xa77a0000a77b,
|
1798 |
+
0xa77c0000a77d,
|
1799 |
+
0xa77f0000a780,
|
1800 |
+
0xa7810000a782,
|
1801 |
+
0xa7830000a784,
|
1802 |
+
0xa7850000a786,
|
1803 |
+
0xa7870000a789,
|
1804 |
+
0xa78c0000a78d,
|
1805 |
+
0xa78e0000a790,
|
1806 |
+
0xa7910000a792,
|
1807 |
+
0xa7930000a796,
|
1808 |
+
0xa7970000a798,
|
1809 |
+
0xa7990000a79a,
|
1810 |
+
0xa79b0000a79c,
|
1811 |
+
0xa79d0000a79e,
|
1812 |
+
0xa79f0000a7a0,
|
1813 |
+
0xa7a10000a7a2,
|
1814 |
+
0xa7a30000a7a4,
|
1815 |
+
0xa7a50000a7a6,
|
1816 |
+
0xa7a70000a7a8,
|
1817 |
+
0xa7a90000a7aa,
|
1818 |
+
0xa7af0000a7b0,
|
1819 |
+
0xa7b50000a7b6,
|
1820 |
+
0xa7b70000a7b8,
|
1821 |
+
0xa7b90000a7ba,
|
1822 |
+
0xa7bb0000a7bc,
|
1823 |
+
0xa7bd0000a7be,
|
1824 |
+
0xa7bf0000a7c0,
|
1825 |
+
0xa7c10000a7c2,
|
1826 |
+
0xa7c30000a7c4,
|
1827 |
+
0xa7c80000a7c9,
|
1828 |
+
0xa7ca0000a7cb,
|
1829 |
+
0xa7d10000a7d2,
|
1830 |
+
0xa7d30000a7d4,
|
1831 |
+
0xa7d50000a7d6,
|
1832 |
+
0xa7d70000a7d8,
|
1833 |
+
0xa7d90000a7da,
|
1834 |
+
0xa7f20000a7f5,
|
1835 |
+
0xa7f60000a7f8,
|
1836 |
+
0xa7fa0000a828,
|
1837 |
+
0xa82c0000a82d,
|
1838 |
+
0xa8400000a874,
|
1839 |
+
0xa8800000a8c6,
|
1840 |
+
0xa8d00000a8da,
|
1841 |
+
0xa8e00000a8f8,
|
1842 |
+
0xa8fb0000a8fc,
|
1843 |
+
0xa8fd0000a92e,
|
1844 |
+
0xa9300000a954,
|
1845 |
+
0xa9800000a9c1,
|
1846 |
+
0xa9cf0000a9da,
|
1847 |
+
0xa9e00000a9ff,
|
1848 |
+
0xaa000000aa37,
|
1849 |
+
0xaa400000aa4e,
|
1850 |
+
0xaa500000aa5a,
|
1851 |
+
0xaa600000aa77,
|
1852 |
+
0xaa7a0000aac3,
|
1853 |
+
0xaadb0000aade,
|
1854 |
+
0xaae00000aaf0,
|
1855 |
+
0xaaf20000aaf7,
|
1856 |
+
0xab010000ab07,
|
1857 |
+
0xab090000ab0f,
|
1858 |
+
0xab110000ab17,
|
1859 |
+
0xab200000ab27,
|
1860 |
+
0xab280000ab2f,
|
1861 |
+
0xab300000ab5b,
|
1862 |
+
0xab600000ab6a,
|
1863 |
+
0xabc00000abeb,
|
1864 |
+
0xabec0000abee,
|
1865 |
+
0xabf00000abfa,
|
1866 |
+
0xac000000d7a4,
|
1867 |
+
0xfa0e0000fa10,
|
1868 |
+
0xfa110000fa12,
|
1869 |
+
0xfa130000fa15,
|
1870 |
+
0xfa1f0000fa20,
|
1871 |
+
0xfa210000fa22,
|
1872 |
+
0xfa230000fa25,
|
1873 |
+
0xfa270000fa2a,
|
1874 |
+
0xfb1e0000fb1f,
|
1875 |
+
0xfe200000fe30,
|
1876 |
+
0xfe730000fe74,
|
1877 |
+
0x100000001000c,
|
1878 |
+
0x1000d00010027,
|
1879 |
+
0x100280001003b,
|
1880 |
+
0x1003c0001003e,
|
1881 |
+
0x1003f0001004e,
|
1882 |
+
0x100500001005e,
|
1883 |
+
0x10080000100fb,
|
1884 |
+
0x101fd000101fe,
|
1885 |
+
0x102800001029d,
|
1886 |
+
0x102a0000102d1,
|
1887 |
+
0x102e0000102e1,
|
1888 |
+
0x1030000010320,
|
1889 |
+
0x1032d00010341,
|
1890 |
+
0x103420001034a,
|
1891 |
+
0x103500001037b,
|
1892 |
+
0x103800001039e,
|
1893 |
+
0x103a0000103c4,
|
1894 |
+
0x103c8000103d0,
|
1895 |
+
0x104280001049e,
|
1896 |
+
0x104a0000104aa,
|
1897 |
+
0x104d8000104fc,
|
1898 |
+
0x1050000010528,
|
1899 |
+
0x1053000010564,
|
1900 |
+
0x10597000105a2,
|
1901 |
+
0x105a3000105b2,
|
1902 |
+
0x105b3000105ba,
|
1903 |
+
0x105bb000105bd,
|
1904 |
+
0x1060000010737,
|
1905 |
+
0x1074000010756,
|
1906 |
+
0x1076000010768,
|
1907 |
+
0x1078000010786,
|
1908 |
+
0x10787000107b1,
|
1909 |
+
0x107b2000107bb,
|
1910 |
+
0x1080000010806,
|
1911 |
+
0x1080800010809,
|
1912 |
+
0x1080a00010836,
|
1913 |
+
0x1083700010839,
|
1914 |
+
0x1083c0001083d,
|
1915 |
+
0x1083f00010856,
|
1916 |
+
0x1086000010877,
|
1917 |
+
0x108800001089f,
|
1918 |
+
0x108e0000108f3,
|
1919 |
+
0x108f4000108f6,
|
1920 |
+
0x1090000010916,
|
1921 |
+
0x109200001093a,
|
1922 |
+
0x10980000109b8,
|
1923 |
+
0x109be000109c0,
|
1924 |
+
0x10a0000010a04,
|
1925 |
+
0x10a0500010a07,
|
1926 |
+
0x10a0c00010a14,
|
1927 |
+
0x10a1500010a18,
|
1928 |
+
0x10a1900010a36,
|
1929 |
+
0x10a3800010a3b,
|
1930 |
+
0x10a3f00010a40,
|
1931 |
+
0x10a6000010a7d,
|
1932 |
+
0x10a8000010a9d,
|
1933 |
+
0x10ac000010ac8,
|
1934 |
+
0x10ac900010ae7,
|
1935 |
+
0x10b0000010b36,
|
1936 |
+
0x10b4000010b56,
|
1937 |
+
0x10b6000010b73,
|
1938 |
+
0x10b8000010b92,
|
1939 |
+
0x10c0000010c49,
|
1940 |
+
0x10cc000010cf3,
|
1941 |
+
0x10d0000010d28,
|
1942 |
+
0x10d3000010d3a,
|
1943 |
+
0x10e8000010eaa,
|
1944 |
+
0x10eab00010ead,
|
1945 |
+
0x10eb000010eb2,
|
1946 |
+
0x10f0000010f1d,
|
1947 |
+
0x10f2700010f28,
|
1948 |
+
0x10f3000010f51,
|
1949 |
+
0x10f7000010f86,
|
1950 |
+
0x10fb000010fc5,
|
1951 |
+
0x10fe000010ff7,
|
1952 |
+
0x1100000011047,
|
1953 |
+
0x1106600011076,
|
1954 |
+
0x1107f000110bb,
|
1955 |
+
0x110c2000110c3,
|
1956 |
+
0x110d0000110e9,
|
1957 |
+
0x110f0000110fa,
|
1958 |
+
0x1110000011135,
|
1959 |
+
0x1113600011140,
|
1960 |
+
0x1114400011148,
|
1961 |
+
0x1115000011174,
|
1962 |
+
0x1117600011177,
|
1963 |
+
0x11180000111c5,
|
1964 |
+
0x111c9000111cd,
|
1965 |
+
0x111ce000111db,
|
1966 |
+
0x111dc000111dd,
|
1967 |
+
0x1120000011212,
|
1968 |
+
0x1121300011238,
|
1969 |
+
0x1123e0001123f,
|
1970 |
+
0x1128000011287,
|
1971 |
+
0x1128800011289,
|
1972 |
+
0x1128a0001128e,
|
1973 |
+
0x1128f0001129e,
|
1974 |
+
0x1129f000112a9,
|
1975 |
+
0x112b0000112eb,
|
1976 |
+
0x112f0000112fa,
|
1977 |
+
0x1130000011304,
|
1978 |
+
0x113050001130d,
|
1979 |
+
0x1130f00011311,
|
1980 |
+
0x1131300011329,
|
1981 |
+
0x1132a00011331,
|
1982 |
+
0x1133200011334,
|
1983 |
+
0x113350001133a,
|
1984 |
+
0x1133b00011345,
|
1985 |
+
0x1134700011349,
|
1986 |
+
0x1134b0001134e,
|
1987 |
+
0x1135000011351,
|
1988 |
+
0x1135700011358,
|
1989 |
+
0x1135d00011364,
|
1990 |
+
0x113660001136d,
|
1991 |
+
0x1137000011375,
|
1992 |
+
0x114000001144b,
|
1993 |
+
0x114500001145a,
|
1994 |
+
0x1145e00011462,
|
1995 |
+
0x11480000114c6,
|
1996 |
+
0x114c7000114c8,
|
1997 |
+
0x114d0000114da,
|
1998 |
+
0x11580000115b6,
|
1999 |
+
0x115b8000115c1,
|
2000 |
+
0x115d8000115de,
|
2001 |
+
0x1160000011641,
|
2002 |
+
0x1164400011645,
|
2003 |
+
0x116500001165a,
|
2004 |
+
0x11680000116b9,
|
2005 |
+
0x116c0000116ca,
|
2006 |
+
0x117000001171b,
|
2007 |
+
0x1171d0001172c,
|
2008 |
+
0x117300001173a,
|
2009 |
+
0x1174000011747,
|
2010 |
+
0x118000001183b,
|
2011 |
+
0x118c0000118ea,
|
2012 |
+
0x118ff00011907,
|
2013 |
+
0x119090001190a,
|
2014 |
+
0x1190c00011914,
|
2015 |
+
0x1191500011917,
|
2016 |
+
0x1191800011936,
|
2017 |
+
0x1193700011939,
|
2018 |
+
0x1193b00011944,
|
2019 |
+
0x119500001195a,
|
2020 |
+
0x119a0000119a8,
|
2021 |
+
0x119aa000119d8,
|
2022 |
+
0x119da000119e2,
|
2023 |
+
0x119e3000119e5,
|
2024 |
+
0x11a0000011a3f,
|
2025 |
+
0x11a4700011a48,
|
2026 |
+
0x11a5000011a9a,
|
2027 |
+
0x11a9d00011a9e,
|
2028 |
+
0x11ab000011af9,
|
2029 |
+
0x11c0000011c09,
|
2030 |
+
0x11c0a00011c37,
|
2031 |
+
0x11c3800011c41,
|
2032 |
+
0x11c5000011c5a,
|
2033 |
+
0x11c7200011c90,
|
2034 |
+
0x11c9200011ca8,
|
2035 |
+
0x11ca900011cb7,
|
2036 |
+
0x11d0000011d07,
|
2037 |
+
0x11d0800011d0a,
|
2038 |
+
0x11d0b00011d37,
|
2039 |
+
0x11d3a00011d3b,
|
2040 |
+
0x11d3c00011d3e,
|
2041 |
+
0x11d3f00011d48,
|
2042 |
+
0x11d5000011d5a,
|
2043 |
+
0x11d6000011d66,
|
2044 |
+
0x11d6700011d69,
|
2045 |
+
0x11d6a00011d8f,
|
2046 |
+
0x11d9000011d92,
|
2047 |
+
0x11d9300011d99,
|
2048 |
+
0x11da000011daa,
|
2049 |
+
0x11ee000011ef7,
|
2050 |
+
0x11fb000011fb1,
|
2051 |
+
0x120000001239a,
|
2052 |
+
0x1248000012544,
|
2053 |
+
0x12f9000012ff1,
|
2054 |
+
0x130000001342f,
|
2055 |
+
0x1440000014647,
|
2056 |
+
0x1680000016a39,
|
2057 |
+
0x16a4000016a5f,
|
2058 |
+
0x16a6000016a6a,
|
2059 |
+
0x16a7000016abf,
|
2060 |
+
0x16ac000016aca,
|
2061 |
+
0x16ad000016aee,
|
2062 |
+
0x16af000016af5,
|
2063 |
+
0x16b0000016b37,
|
2064 |
+
0x16b4000016b44,
|
2065 |
+
0x16b5000016b5a,
|
2066 |
+
0x16b6300016b78,
|
2067 |
+
0x16b7d00016b90,
|
2068 |
+
0x16e6000016e80,
|
2069 |
+
0x16f0000016f4b,
|
2070 |
+
0x16f4f00016f88,
|
2071 |
+
0x16f8f00016fa0,
|
2072 |
+
0x16fe000016fe2,
|
2073 |
+
0x16fe300016fe5,
|
2074 |
+
0x16ff000016ff2,
|
2075 |
+
0x17000000187f8,
|
2076 |
+
0x1880000018cd6,
|
2077 |
+
0x18d0000018d09,
|
2078 |
+
0x1aff00001aff4,
|
2079 |
+
0x1aff50001affc,
|
2080 |
+
0x1affd0001afff,
|
2081 |
+
0x1b0000001b123,
|
2082 |
+
0x1b1500001b153,
|
2083 |
+
0x1b1640001b168,
|
2084 |
+
0x1b1700001b2fc,
|
2085 |
+
0x1bc000001bc6b,
|
2086 |
+
0x1bc700001bc7d,
|
2087 |
+
0x1bc800001bc89,
|
2088 |
+
0x1bc900001bc9a,
|
2089 |
+
0x1bc9d0001bc9f,
|
2090 |
+
0x1cf000001cf2e,
|
2091 |
+
0x1cf300001cf47,
|
2092 |
+
0x1da000001da37,
|
2093 |
+
0x1da3b0001da6d,
|
2094 |
+
0x1da750001da76,
|
2095 |
+
0x1da840001da85,
|
2096 |
+
0x1da9b0001daa0,
|
2097 |
+
0x1daa10001dab0,
|
2098 |
+
0x1df000001df1f,
|
2099 |
+
0x1e0000001e007,
|
2100 |
+
0x1e0080001e019,
|
2101 |
+
0x1e01b0001e022,
|
2102 |
+
0x1e0230001e025,
|
2103 |
+
0x1e0260001e02b,
|
2104 |
+
0x1e1000001e12d,
|
2105 |
+
0x1e1300001e13e,
|
2106 |
+
0x1e1400001e14a,
|
2107 |
+
0x1e14e0001e14f,
|
2108 |
+
0x1e2900001e2af,
|
2109 |
+
0x1e2c00001e2fa,
|
2110 |
+
0x1e7e00001e7e7,
|
2111 |
+
0x1e7e80001e7ec,
|
2112 |
+
0x1e7ed0001e7ef,
|
2113 |
+
0x1e7f00001e7ff,
|
2114 |
+
0x1e8000001e8c5,
|
2115 |
+
0x1e8d00001e8d7,
|
2116 |
+
0x1e9220001e94c,
|
2117 |
+
0x1e9500001e95a,
|
2118 |
+
0x1fbf00001fbfa,
|
2119 |
+
0x200000002a6e0,
|
2120 |
+
0x2a7000002b739,
|
2121 |
+
0x2b7400002b81e,
|
2122 |
+
0x2b8200002cea2,
|
2123 |
+
0x2ceb00002ebe1,
|
2124 |
+
0x300000003134b,
|
2125 |
+
),
|
2126 |
+
'CONTEXTJ': (
|
2127 |
+
0x200c0000200e,
|
2128 |
+
),
|
2129 |
+
'CONTEXTO': (
|
2130 |
+
0xb7000000b8,
|
2131 |
+
0x37500000376,
|
2132 |
+
0x5f3000005f5,
|
2133 |
+
0x6600000066a,
|
2134 |
+
0x6f0000006fa,
|
2135 |
+
0x30fb000030fc,
|
2136 |
+
),
|
2137 |
+
}
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/intranges.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Given a list of integers, made up of (hopefully) a small number of long runs
|
3 |
+
of consecutive integers, compute a representation of the form
|
4 |
+
((start1, end1), (start2, end2) ...). Then answer the question "was x present
|
5 |
+
in the original list?" in time O(log(# runs)).
|
6 |
+
"""
|
7 |
+
|
8 |
+
import bisect
|
9 |
+
from typing import List, Tuple
|
10 |
+
|
11 |
+
def intranges_from_list(list_: List[int]) -> Tuple[int, ...]:
|
12 |
+
"""Represent a list of integers as a sequence of ranges:
|
13 |
+
((start_0, end_0), (start_1, end_1), ...), such that the original
|
14 |
+
integers are exactly those x such that start_i <= x < end_i for some i.
|
15 |
+
|
16 |
+
Ranges are encoded as single integers (start << 32 | end), not as tuples.
|
17 |
+
"""
|
18 |
+
|
19 |
+
sorted_list = sorted(list_)
|
20 |
+
ranges = []
|
21 |
+
last_write = -1
|
22 |
+
for i in range(len(sorted_list)):
|
23 |
+
if i+1 < len(sorted_list):
|
24 |
+
if sorted_list[i] == sorted_list[i+1]-1:
|
25 |
+
continue
|
26 |
+
current_range = sorted_list[last_write+1:i+1]
|
27 |
+
ranges.append(_encode_range(current_range[0], current_range[-1] + 1))
|
28 |
+
last_write = i
|
29 |
+
|
30 |
+
return tuple(ranges)
|
31 |
+
|
32 |
+
def _encode_range(start: int, end: int) -> int:
|
33 |
+
return (start << 32) | end
|
34 |
+
|
35 |
+
def _decode_range(r: int) -> Tuple[int, int]:
|
36 |
+
return (r >> 32), (r & ((1 << 32) - 1))
|
37 |
+
|
38 |
+
|
39 |
+
def intranges_contain(int_: int, ranges: Tuple[int, ...]) -> bool:
|
40 |
+
"""Determine if `int_` falls into one of the ranges in `ranges`."""
|
41 |
+
tuple_ = _encode_range(int_, 0)
|
42 |
+
pos = bisect.bisect_left(ranges, tuple_)
|
43 |
+
# we could be immediately ahead of a tuple (start, end)
|
44 |
+
# with start < int_ <= end
|
45 |
+
if pos > 0:
|
46 |
+
left, right = _decode_range(ranges[pos-1])
|
47 |
+
if left <= int_ < right:
|
48 |
+
return True
|
49 |
+
# or we could be immediately behind a tuple (int_, end)
|
50 |
+
if pos < len(ranges):
|
51 |
+
left, _ = _decode_range(ranges[pos])
|
52 |
+
if left == int_:
|
53 |
+
return True
|
54 |
+
return False
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/package_data.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
__version__ = '3.3'
|
2 |
+
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/idna/uts46data.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__init__.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more
|
3 |
+
"""
|
4 |
+
from __future__ import absolute_import
|
5 |
+
|
6 |
+
# Set default logging handler to avoid "No handler found" warnings.
|
7 |
+
import logging
|
8 |
+
import warnings
|
9 |
+
from logging import NullHandler
|
10 |
+
|
11 |
+
from . import exceptions
|
12 |
+
from ._version import __version__
|
13 |
+
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
|
14 |
+
from .filepost import encode_multipart_formdata
|
15 |
+
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
|
16 |
+
from .response import HTTPResponse
|
17 |
+
from .util.request import make_headers
|
18 |
+
from .util.retry import Retry
|
19 |
+
from .util.timeout import Timeout
|
20 |
+
from .util.url import get_host
|
21 |
+
|
22 |
+
__author__ = "Andrey Petrov ([email protected])"
|
23 |
+
__license__ = "MIT"
|
24 |
+
__version__ = __version__
|
25 |
+
|
26 |
+
__all__ = (
|
27 |
+
"HTTPConnectionPool",
|
28 |
+
"HTTPSConnectionPool",
|
29 |
+
"PoolManager",
|
30 |
+
"ProxyManager",
|
31 |
+
"HTTPResponse",
|
32 |
+
"Retry",
|
33 |
+
"Timeout",
|
34 |
+
"add_stderr_logger",
|
35 |
+
"connection_from_url",
|
36 |
+
"disable_warnings",
|
37 |
+
"encode_multipart_formdata",
|
38 |
+
"get_host",
|
39 |
+
"make_headers",
|
40 |
+
"proxy_from_url",
|
41 |
+
)
|
42 |
+
|
43 |
+
logging.getLogger(__name__).addHandler(NullHandler())
|
44 |
+
|
45 |
+
|
46 |
+
def add_stderr_logger(level=logging.DEBUG):
|
47 |
+
"""
|
48 |
+
Helper for quickly adding a StreamHandler to the logger. Useful for
|
49 |
+
debugging.
|
50 |
+
|
51 |
+
Returns the handler after adding it.
|
52 |
+
"""
|
53 |
+
# This method needs to be in this __init__.py to get the __name__ correct
|
54 |
+
# even if urllib3 is vendored within another package.
|
55 |
+
logger = logging.getLogger(__name__)
|
56 |
+
handler = logging.StreamHandler()
|
57 |
+
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s"))
|
58 |
+
logger.addHandler(handler)
|
59 |
+
logger.setLevel(level)
|
60 |
+
logger.debug("Added a stderr logging handler to logger: %s", __name__)
|
61 |
+
return handler
|
62 |
+
|
63 |
+
|
64 |
+
# ... Clean up.
|
65 |
+
del NullHandler
|
66 |
+
|
67 |
+
|
68 |
+
# All warning filters *must* be appended unless you're really certain that they
|
69 |
+
# shouldn't be: otherwise, it's very hard for users to use most Python
|
70 |
+
# mechanisms to silence them.
|
71 |
+
# SecurityWarning's always go off by default.
|
72 |
+
warnings.simplefilter("always", exceptions.SecurityWarning, append=True)
|
73 |
+
# SubjectAltNameWarning's should go off once per host
|
74 |
+
warnings.simplefilter("default", exceptions.SubjectAltNameWarning, append=True)
|
75 |
+
# InsecurePlatformWarning's don't vary between requests, so we keep it default.
|
76 |
+
warnings.simplefilter("default", exceptions.InsecurePlatformWarning, append=True)
|
77 |
+
# SNIMissingWarnings should go off only once.
|
78 |
+
warnings.simplefilter("default", exceptions.SNIMissingWarning, append=True)
|
79 |
+
|
80 |
+
|
81 |
+
def disable_warnings(category=exceptions.HTTPWarning):
|
82 |
+
"""
|
83 |
+
Helper for quickly disabling all urllib3 warnings.
|
84 |
+
"""
|
85 |
+
warnings.simplefilter("ignore", category)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (2.19 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/_collections.cpython-310.pyc
ADDED
Binary file (11.4 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/_version.cpython-310.pyc
ADDED
Binary file (214 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/connection.cpython-310.pyc
ADDED
Binary file (13.6 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/connectionpool.cpython-310.pyc
ADDED
Binary file (25.5 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/exceptions.cpython-310.pyc
ADDED
Binary file (11 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/fields.cpython-310.pyc
ADDED
Binary file (8.18 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/filepost.cpython-310.pyc
ADDED
Binary file (2.75 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/poolmanager.cpython-310.pyc
ADDED
Binary file (15.3 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/request.cpython-310.pyc
ADDED
Binary file (5.63 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/__pycache__/response.cpython-310.pyc
ADDED
Binary file (20.9 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import absolute_import
|
2 |
+
|
3 |
+
try:
|
4 |
+
from collections.abc import Mapping, MutableMapping
|
5 |
+
except ImportError:
|
6 |
+
from collections import Mapping, MutableMapping
|
7 |
+
try:
|
8 |
+
from threading import RLock
|
9 |
+
except ImportError: # Platform-specific: No threads available
|
10 |
+
|
11 |
+
class RLock:
|
12 |
+
def __enter__(self):
|
13 |
+
pass
|
14 |
+
|
15 |
+
def __exit__(self, exc_type, exc_value, traceback):
|
16 |
+
pass
|
17 |
+
|
18 |
+
|
19 |
+
from collections import OrderedDict
|
20 |
+
|
21 |
+
from .exceptions import InvalidHeader
|
22 |
+
from .packages import six
|
23 |
+
from .packages.six import iterkeys, itervalues
|
24 |
+
|
25 |
+
__all__ = ["RecentlyUsedContainer", "HTTPHeaderDict"]
|
26 |
+
|
27 |
+
|
28 |
+
_Null = object()
|
29 |
+
|
30 |
+
|
31 |
+
class RecentlyUsedContainer(MutableMapping):
|
32 |
+
"""
|
33 |
+
Provides a thread-safe dict-like container which maintains up to
|
34 |
+
``maxsize`` keys while throwing away the least-recently-used keys beyond
|
35 |
+
``maxsize``.
|
36 |
+
|
37 |
+
:param maxsize:
|
38 |
+
Maximum number of recent elements to retain.
|
39 |
+
|
40 |
+
:param dispose_func:
|
41 |
+
Every time an item is evicted from the container,
|
42 |
+
``dispose_func(value)`` is called. Callback which will get called
|
43 |
+
"""
|
44 |
+
|
45 |
+
ContainerCls = OrderedDict
|
46 |
+
|
47 |
+
def __init__(self, maxsize=10, dispose_func=None):
|
48 |
+
self._maxsize = maxsize
|
49 |
+
self.dispose_func = dispose_func
|
50 |
+
|
51 |
+
self._container = self.ContainerCls()
|
52 |
+
self.lock = RLock()
|
53 |
+
|
54 |
+
def __getitem__(self, key):
|
55 |
+
# Re-insert the item, moving it to the end of the eviction line.
|
56 |
+
with self.lock:
|
57 |
+
item = self._container.pop(key)
|
58 |
+
self._container[key] = item
|
59 |
+
return item
|
60 |
+
|
61 |
+
def __setitem__(self, key, value):
|
62 |
+
evicted_value = _Null
|
63 |
+
with self.lock:
|
64 |
+
# Possibly evict the existing value of 'key'
|
65 |
+
evicted_value = self._container.get(key, _Null)
|
66 |
+
self._container[key] = value
|
67 |
+
|
68 |
+
# If we didn't evict an existing value, we might have to evict the
|
69 |
+
# least recently used item from the beginning of the container.
|
70 |
+
if len(self._container) > self._maxsize:
|
71 |
+
_key, evicted_value = self._container.popitem(last=False)
|
72 |
+
|
73 |
+
if self.dispose_func and evicted_value is not _Null:
|
74 |
+
self.dispose_func(evicted_value)
|
75 |
+
|
76 |
+
def __delitem__(self, key):
|
77 |
+
with self.lock:
|
78 |
+
value = self._container.pop(key)
|
79 |
+
|
80 |
+
if self.dispose_func:
|
81 |
+
self.dispose_func(value)
|
82 |
+
|
83 |
+
def __len__(self):
|
84 |
+
with self.lock:
|
85 |
+
return len(self._container)
|
86 |
+
|
87 |
+
def __iter__(self):
|
88 |
+
raise NotImplementedError(
|
89 |
+
"Iteration over this class is unlikely to be threadsafe."
|
90 |
+
)
|
91 |
+
|
92 |
+
def clear(self):
|
93 |
+
with self.lock:
|
94 |
+
# Copy pointers to all values, then wipe the mapping
|
95 |
+
values = list(itervalues(self._container))
|
96 |
+
self._container.clear()
|
97 |
+
|
98 |
+
if self.dispose_func:
|
99 |
+
for value in values:
|
100 |
+
self.dispose_func(value)
|
101 |
+
|
102 |
+
def keys(self):
|
103 |
+
with self.lock:
|
104 |
+
return list(iterkeys(self._container))
|
105 |
+
|
106 |
+
|
107 |
+
class HTTPHeaderDict(MutableMapping):
|
108 |
+
"""
|
109 |
+
:param headers:
|
110 |
+
An iterable of field-value pairs. Must not contain multiple field names
|
111 |
+
when compared case-insensitively.
|
112 |
+
|
113 |
+
:param kwargs:
|
114 |
+
Additional field-value pairs to pass in to ``dict.update``.
|
115 |
+
|
116 |
+
A ``dict`` like container for storing HTTP Headers.
|
117 |
+
|
118 |
+
Field names are stored and compared case-insensitively in compliance with
|
119 |
+
RFC 7230. Iteration provides the first case-sensitive key seen for each
|
120 |
+
case-insensitive pair.
|
121 |
+
|
122 |
+
Using ``__setitem__`` syntax overwrites fields that compare equal
|
123 |
+
case-insensitively in order to maintain ``dict``'s api. For fields that
|
124 |
+
compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
|
125 |
+
in a loop.
|
126 |
+
|
127 |
+
If multiple fields that are equal case-insensitively are passed to the
|
128 |
+
constructor or ``.update``, the behavior is undefined and some will be
|
129 |
+
lost.
|
130 |
+
|
131 |
+
>>> headers = HTTPHeaderDict()
|
132 |
+
>>> headers.add('Set-Cookie', 'foo=bar')
|
133 |
+
>>> headers.add('set-cookie', 'baz=quxx')
|
134 |
+
>>> headers['content-length'] = '7'
|
135 |
+
>>> headers['SET-cookie']
|
136 |
+
'foo=bar, baz=quxx'
|
137 |
+
>>> headers['Content-Length']
|
138 |
+
'7'
|
139 |
+
"""
|
140 |
+
|
141 |
+
def __init__(self, headers=None, **kwargs):
|
142 |
+
super(HTTPHeaderDict, self).__init__()
|
143 |
+
self._container = OrderedDict()
|
144 |
+
if headers is not None:
|
145 |
+
if isinstance(headers, HTTPHeaderDict):
|
146 |
+
self._copy_from(headers)
|
147 |
+
else:
|
148 |
+
self.extend(headers)
|
149 |
+
if kwargs:
|
150 |
+
self.extend(kwargs)
|
151 |
+
|
152 |
+
def __setitem__(self, key, val):
|
153 |
+
self._container[key.lower()] = [key, val]
|
154 |
+
return self._container[key.lower()]
|
155 |
+
|
156 |
+
def __getitem__(self, key):
|
157 |
+
val = self._container[key.lower()]
|
158 |
+
return ", ".join(val[1:])
|
159 |
+
|
160 |
+
def __delitem__(self, key):
|
161 |
+
del self._container[key.lower()]
|
162 |
+
|
163 |
+
def __contains__(self, key):
|
164 |
+
return key.lower() in self._container
|
165 |
+
|
166 |
+
def __eq__(self, other):
|
167 |
+
if not isinstance(other, Mapping) and not hasattr(other, "keys"):
|
168 |
+
return False
|
169 |
+
if not isinstance(other, type(self)):
|
170 |
+
other = type(self)(other)
|
171 |
+
return dict((k.lower(), v) for k, v in self.itermerged()) == dict(
|
172 |
+
(k.lower(), v) for k, v in other.itermerged()
|
173 |
+
)
|
174 |
+
|
175 |
+
def __ne__(self, other):
|
176 |
+
return not self.__eq__(other)
|
177 |
+
|
178 |
+
if six.PY2: # Python 2
|
179 |
+
iterkeys = MutableMapping.iterkeys
|
180 |
+
itervalues = MutableMapping.itervalues
|
181 |
+
|
182 |
+
__marker = object()
|
183 |
+
|
184 |
+
def __len__(self):
|
185 |
+
return len(self._container)
|
186 |
+
|
187 |
+
def __iter__(self):
|
188 |
+
# Only provide the originally cased names
|
189 |
+
for vals in self._container.values():
|
190 |
+
yield vals[0]
|
191 |
+
|
192 |
+
def pop(self, key, default=__marker):
|
193 |
+
"""D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
194 |
+
If key is not found, d is returned if given, otherwise KeyError is raised.
|
195 |
+
"""
|
196 |
+
# Using the MutableMapping function directly fails due to the private marker.
|
197 |
+
# Using ordinary dict.pop would expose the internal structures.
|
198 |
+
# So let's reinvent the wheel.
|
199 |
+
try:
|
200 |
+
value = self[key]
|
201 |
+
except KeyError:
|
202 |
+
if default is self.__marker:
|
203 |
+
raise
|
204 |
+
return default
|
205 |
+
else:
|
206 |
+
del self[key]
|
207 |
+
return value
|
208 |
+
|
209 |
+
def discard(self, key):
|
210 |
+
try:
|
211 |
+
del self[key]
|
212 |
+
except KeyError:
|
213 |
+
pass
|
214 |
+
|
215 |
+
def add(self, key, val):
|
216 |
+
"""Adds a (name, value) pair, doesn't overwrite the value if it already
|
217 |
+
exists.
|
218 |
+
|
219 |
+
>>> headers = HTTPHeaderDict(foo='bar')
|
220 |
+
>>> headers.add('Foo', 'baz')
|
221 |
+
>>> headers['foo']
|
222 |
+
'bar, baz'
|
223 |
+
"""
|
224 |
+
key_lower = key.lower()
|
225 |
+
new_vals = [key, val]
|
226 |
+
# Keep the common case aka no item present as fast as possible
|
227 |
+
vals = self._container.setdefault(key_lower, new_vals)
|
228 |
+
if new_vals is not vals:
|
229 |
+
vals.append(val)
|
230 |
+
|
231 |
+
def extend(self, *args, **kwargs):
|
232 |
+
"""Generic import function for any type of header-like object.
|
233 |
+
Adapted version of MutableMapping.update in order to insert items
|
234 |
+
with self.add instead of self.__setitem__
|
235 |
+
"""
|
236 |
+
if len(args) > 1:
|
237 |
+
raise TypeError(
|
238 |
+
"extend() takes at most 1 positional "
|
239 |
+
"arguments ({0} given)".format(len(args))
|
240 |
+
)
|
241 |
+
other = args[0] if len(args) >= 1 else ()
|
242 |
+
|
243 |
+
if isinstance(other, HTTPHeaderDict):
|
244 |
+
for key, val in other.iteritems():
|
245 |
+
self.add(key, val)
|
246 |
+
elif isinstance(other, Mapping):
|
247 |
+
for key in other:
|
248 |
+
self.add(key, other[key])
|
249 |
+
elif hasattr(other, "keys"):
|
250 |
+
for key in other.keys():
|
251 |
+
self.add(key, other[key])
|
252 |
+
else:
|
253 |
+
for key, value in other:
|
254 |
+
self.add(key, value)
|
255 |
+
|
256 |
+
for key, value in kwargs.items():
|
257 |
+
self.add(key, value)
|
258 |
+
|
259 |
+
def getlist(self, key, default=__marker):
|
260 |
+
"""Returns a list of all the values for the named field. Returns an
|
261 |
+
empty list if the key doesn't exist."""
|
262 |
+
try:
|
263 |
+
vals = self._container[key.lower()]
|
264 |
+
except KeyError:
|
265 |
+
if default is self.__marker:
|
266 |
+
return []
|
267 |
+
return default
|
268 |
+
else:
|
269 |
+
return vals[1:]
|
270 |
+
|
271 |
+
def _prepare_for_method_change(self):
|
272 |
+
"""
|
273 |
+
Remove content-specific header fields before changing the request
|
274 |
+
method to GET or HEAD according to RFC 9110, Section 15.4.
|
275 |
+
"""
|
276 |
+
content_specific_headers = [
|
277 |
+
"Content-Encoding",
|
278 |
+
"Content-Language",
|
279 |
+
"Content-Location",
|
280 |
+
"Content-Type",
|
281 |
+
"Content-Length",
|
282 |
+
"Digest",
|
283 |
+
"Last-Modified",
|
284 |
+
]
|
285 |
+
for header in content_specific_headers:
|
286 |
+
self.discard(header)
|
287 |
+
return self
|
288 |
+
|
289 |
+
# Backwards compatibility for httplib
|
290 |
+
getheaders = getlist
|
291 |
+
getallmatchingheaders = getlist
|
292 |
+
iget = getlist
|
293 |
+
|
294 |
+
# Backwards compatibility for http.cookiejar
|
295 |
+
get_all = getlist
|
296 |
+
|
297 |
+
def __repr__(self):
|
298 |
+
return "%s(%s)" % (type(self).__name__, dict(self.itermerged()))
|
299 |
+
|
300 |
+
def _copy_from(self, other):
|
301 |
+
for key in other:
|
302 |
+
val = other.getlist(key)
|
303 |
+
if isinstance(val, list):
|
304 |
+
# Don't need to convert tuples
|
305 |
+
val = list(val)
|
306 |
+
self._container[key.lower()] = [key] + val
|
307 |
+
|
308 |
+
def copy(self):
|
309 |
+
clone = type(self)()
|
310 |
+
clone._copy_from(self)
|
311 |
+
return clone
|
312 |
+
|
313 |
+
def iteritems(self):
|
314 |
+
"""Iterate over all header lines, including duplicate ones."""
|
315 |
+
for key in self:
|
316 |
+
vals = self._container[key.lower()]
|
317 |
+
for val in vals[1:]:
|
318 |
+
yield vals[0], val
|
319 |
+
|
320 |
+
def itermerged(self):
|
321 |
+
"""Iterate over all headers, merging duplicate ones together."""
|
322 |
+
for key in self:
|
323 |
+
val = self._container[key.lower()]
|
324 |
+
yield val[0], ", ".join(val[1:])
|
325 |
+
|
326 |
+
def items(self):
|
327 |
+
return list(self.iteritems())
|
328 |
+
|
329 |
+
@classmethod
|
330 |
+
def from_httplib(cls, message): # Python 2
|
331 |
+
"""Read headers from a Python 2 httplib message object."""
|
332 |
+
# python2.7 does not expose a proper API for exporting multiheaders
|
333 |
+
# efficiently. This function re-reads raw lines from the message
|
334 |
+
# object and extracts the multiheaders properly.
|
335 |
+
obs_fold_continued_leaders = (" ", "\t")
|
336 |
+
headers = []
|
337 |
+
|
338 |
+
for line in message.headers:
|
339 |
+
if line.startswith(obs_fold_continued_leaders):
|
340 |
+
if not headers:
|
341 |
+
# We received a header line that starts with OWS as described
|
342 |
+
# in RFC-7230 S3.2.4. This indicates a multiline header, but
|
343 |
+
# there exists no previous header to which we can attach it.
|
344 |
+
raise InvalidHeader(
|
345 |
+
"Header continuation with no previous header: %s" % line
|
346 |
+
)
|
347 |
+
else:
|
348 |
+
key, value = headers[-1]
|
349 |
+
headers[-1] = (key, value + " " + line.strip())
|
350 |
+
continue
|
351 |
+
|
352 |
+
key, value = line.split(":", 1)
|
353 |
+
headers.append((key, value.strip()))
|
354 |
+
|
355 |
+
return cls(headers)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/connection.py
ADDED
@@ -0,0 +1,569 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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olute_import
|
2 |
+
|
3 |
+
import datetime
|
4 |
+
import logging
|
5 |
+
import os
|
6 |
+
import re
|
7 |
+
import socket
|
8 |
+
import warnings
|
9 |
+
from socket import error as SocketError
|
10 |
+
from socket import timeout as SocketTimeout
|
11 |
+
|
12 |
+
from .packages import six
|
13 |
+
from .packages.six.moves.http_client import HTTPConnection as _HTTPConnection
|
14 |
+
from .packages.six.moves.http_client import HTTPException # noqa: F401
|
15 |
+
from .util.proxy import create_proxy_ssl_context
|
16 |
+
|
17 |
+
try: # Compiled with SSL?
|
18 |
+
import ssl
|
19 |
+
|
20 |
+
BaseSSLError = ssl.SSLError
|
21 |
+
except (ImportError, AttributeError): # Platform-specific: No SSL.
|
22 |
+
ssl = None
|
23 |
+
|
24 |
+
class BaseSSLError(BaseException):
|
25 |
+
pass
|
26 |
+
|
27 |
+
|
28 |
+
try:
|
29 |
+
# Python 3: not a no-op, we're adding this to the namespace so it can be imported.
|
30 |
+
ConnectionError = ConnectionError
|
31 |
+
except NameError:
|
32 |
+
# Python 2
|
33 |
+
class ConnectionError(Exception):
|
34 |
+
pass
|
35 |
+
|
36 |
+
|
37 |
+
try: # Python 3:
|
38 |
+
# Not a no-op, we're adding this to the namespace so it can be imported.
|
39 |
+
BrokenPipeError = BrokenPipeError
|
40 |
+
except NameError: # Python 2:
|
41 |
+
|
42 |
+
class BrokenPipeError(Exception):
|
43 |
+
pass
|
44 |
+
|
45 |
+
|
46 |
+
from ._collections import HTTPHeaderDict # noqa (historical, removed in v2)
|
47 |
+
from ._version import __version__
|
48 |
+
from .exceptions import (
|
49 |
+
ConnectTimeoutError,
|
50 |
+
NewConnectionError,
|
51 |
+
SubjectAltNameWarning,
|
52 |
+
SystemTimeWarning,
|
53 |
+
)
|
54 |
+
from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection
|
55 |
+
from .util.ssl_ import (
|
56 |
+
assert_fingerprint,
|
57 |
+
create_urllib3_context,
|
58 |
+
is_ipaddress,
|
59 |
+
resolve_cert_reqs,
|
60 |
+
resolve_ssl_version,
|
61 |
+
ssl_wrap_socket,
|
62 |
+
)
|
63 |
+
from .util.ssl_match_hostname import CertificateError, match_hostname
|
64 |
+
|
65 |
+
log = logging.getLogger(__name__)
|
66 |
+
|
67 |
+
port_by_scheme = {"http": 80, "https": 443}
|
68 |
+
|
69 |
+
# When it comes time to update this value as a part of regular maintenance
|
70 |
+
# (ie test_recent_date is failing) update it to ~6 months before the current date.
|
71 |
+
RECENT_DATE = datetime.date(2020, 7, 1)
|
72 |
+
|
73 |
+
_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")
|
74 |
+
|
75 |
+
|
76 |
+
class HTTPConnection(_HTTPConnection, object):
|
77 |
+
"""
|
78 |
+
Based on :class:`http.client.HTTPConnection` but provides an extra constructor
|
79 |
+
backwards-compatibility layer between older and newer Pythons.
|
80 |
+
|
81 |
+
Additional keyword parameters are used to configure attributes of the connection.
|
82 |
+
Accepted parameters include:
|
83 |
+
|
84 |
+
- ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
|
85 |
+
- ``source_address``: Set the source address for the current connection.
|
86 |
+
- ``socket_options``: Set specific options on the underlying socket. If not specified, then
|
87 |
+
defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
|
88 |
+
Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.
|
89 |
+
|
90 |
+
For example, if you wish to enable TCP Keep Alive in addition to the defaults,
|
91 |
+
you might pass:
|
92 |
+
|
93 |
+
.. code-block:: python
|
94 |
+
|
95 |
+
HTTPConnection.default_socket_options + [
|
96 |
+
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
|
97 |
+
]
|
98 |
+
|
99 |
+
Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
|
100 |
+
"""
|
101 |
+
|
102 |
+
default_port = port_by_scheme["http"]
|
103 |
+
|
104 |
+
#: Disable Nagle's algorithm by default.
|
105 |
+
#: ``[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]``
|
106 |
+
default_socket_options = [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]
|
107 |
+
|
108 |
+
#: Whether this connection verifies the host's certificate.
|
109 |
+
is_verified = False
|
110 |
+
|
111 |
+
#: Whether this proxy connection (if used) verifies the proxy host's
|
112 |
+
#: certificate.
|
113 |
+
proxy_is_verified = None
|
114 |
+
|
115 |
+
def __init__(self, *args, **kw):
|
116 |
+
if not six.PY2:
|
117 |
+
kw.pop("strict", None)
|
118 |
+
|
119 |
+
# Pre-set source_address.
|
120 |
+
self.source_address = kw.get("source_address")
|
121 |
+
|
122 |
+
#: The socket options provided by the user. If no options are
|
123 |
+
#: provided, we use the default options.
|
124 |
+
self.socket_options = kw.pop("socket_options", self.default_socket_options)
|
125 |
+
|
126 |
+
# Proxy options provided by the user.
|
127 |
+
self.proxy = kw.pop("proxy", None)
|
128 |
+
self.proxy_config = kw.pop("proxy_config", None)
|
129 |
+
|
130 |
+
_HTTPConnection.__init__(self, *args, **kw)
|
131 |
+
|
132 |
+
@property
|
133 |
+
def host(self):
|
134 |
+
"""
|
135 |
+
Getter method to remove any trailing dots that indicate the hostname is an FQDN.
|
136 |
+
|
137 |
+
In general, SSL certificates don't include the trailing dot indicating a
|
138 |
+
fully-qualified domain name, and thus, they don't validate properly when
|
139 |
+
checked against a domain name that includes the dot. In addition, some
|
140 |
+
servers may not expect to receive the trailing dot when provided.
|
141 |
+
|
142 |
+
However, the hostname with trailing dot is critical to DNS resolution; doing a
|
143 |
+
lookup with the trailing dot will properly only resolve the appropriate FQDN,
|
144 |
+
whereas a lookup without a trailing dot will search the system's search domain
|
145 |
+
list. Thus, it's important to keep the original host around for use only in
|
146 |
+
those cases where it's appropriate (i.e., when doing DNS lookup to establish the
|
147 |
+
actual TCP connection across which we're going to send HTTP requests).
|
148 |
+
"""
|
149 |
+
return self._dns_host.rstrip(".")
|
150 |
+
|
151 |
+
@host.setter
|
152 |
+
def host(self, value):
|
153 |
+
"""
|
154 |
+
Setter for the `host` property.
|
155 |
+
|
156 |
+
We assume that only urllib3 uses the _dns_host attribute; httplib itself
|
157 |
+
only uses `host`, and it seems reasonable that other libraries follow suit.
|
158 |
+
"""
|
159 |
+
self._dns_host = value
|
160 |
+
|
161 |
+
def _new_conn(self):
|
162 |
+
"""Establish a socket connection and set nodelay settings on it.
|
163 |
+
|
164 |
+
:return: New socket connection.
|
165 |
+
"""
|
166 |
+
extra_kw = {}
|
167 |
+
if self.source_address:
|
168 |
+
extra_kw["source_address"] = self.source_address
|
169 |
+
|
170 |
+
if self.socket_options:
|
171 |
+
extra_kw["socket_options"] = self.socket_options
|
172 |
+
|
173 |
+
try:
|
174 |
+
conn = connection.create_connection(
|
175 |
+
(self._dns_host, self.port), self.timeout, **extra_kw
|
176 |
+
)
|
177 |
+
|
178 |
+
except SocketTimeout:
|
179 |
+
raise ConnectTimeoutError(
|
180 |
+
self,
|
181 |
+
"Connection to %s timed out. (connect timeout=%s)"
|
182 |
+
% (self.host, self.timeout),
|
183 |
+
)
|
184 |
+
|
185 |
+
except SocketError as e:
|
186 |
+
raise NewConnectionError(
|
187 |
+
self, "Failed to establish a new connection: %s" % e
|
188 |
+
)
|
189 |
+
|
190 |
+
return conn
|
191 |
+
|
192 |
+
def _is_using_tunnel(self):
|
193 |
+
# Google App Engine's httplib does not define _tunnel_host
|
194 |
+
return getattr(self, "_tunnel_host", None)
|
195 |
+
|
196 |
+
def _prepare_conn(self, conn):
|
197 |
+
self.sock = conn
|
198 |
+
if self._is_using_tunnel():
|
199 |
+
# TODO: Fix tunnel so it doesn't depend on self.sock state.
|
200 |
+
self._tunnel()
|
201 |
+
# Mark this connection as not reusable
|
202 |
+
self.auto_open = 0
|
203 |
+
|
204 |
+
def connect(self):
|
205 |
+
conn = self._new_conn()
|
206 |
+
self._prepare_conn(conn)
|
207 |
+
|
208 |
+
def putrequest(self, method, url, *args, **kwargs):
|
209 |
+
""" """
|
210 |
+
# Empty docstring because the indentation of CPython's implementation
|
211 |
+
# is broken but we don't want this method in our documentation.
|
212 |
+
match = _CONTAINS_CONTROL_CHAR_RE.search(method)
|
213 |
+
if match:
|
214 |
+
raise ValueError(
|
215 |
+
"Method cannot contain non-token characters %r (found at least %r)"
|
216 |
+
% (method, match.group())
|
217 |
+
)
|
218 |
+
|
219 |
+
return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
|
220 |
+
|
221 |
+
def putheader(self, header, *values):
|
222 |
+
""" """
|
223 |
+
if not any(isinstance(v, str) and v == SKIP_HEADER for v in values):
|
224 |
+
_HTTPConnection.putheader(self, header, *values)
|
225 |
+
elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS:
|
226 |
+
raise ValueError(
|
227 |
+
"urllib3.util.SKIP_HEADER only supports '%s'"
|
228 |
+
% ("', '".join(map(str.title, sorted(SKIPPABLE_HEADERS))),)
|
229 |
+
)
|
230 |
+
|
231 |
+
def request(self, method, url, body=None, headers=None):
|
232 |
+
if headers is None:
|
233 |
+
headers = {}
|
234 |
+
else:
|
235 |
+
# Avoid modifying the headers passed into .request()
|
236 |
+
headers = headers.copy()
|
237 |
+
if "user-agent" not in (six.ensure_str(k.lower()) for k in headers):
|
238 |
+
headers["User-Agent"] = _get_default_user_agent()
|
239 |
+
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
|
240 |
+
|
241 |
+
def request_chunked(self, method, url, body=None, headers=None):
|
242 |
+
"""
|
243 |
+
Alternative to the common request method, which sends the
|
244 |
+
body with chunked encoding and not as one block
|
245 |
+
"""
|
246 |
+
headers = headers or {}
|
247 |
+
header_keys = set([six.ensure_str(k.lower()) for k in headers])
|
248 |
+
skip_accept_encoding = "accept-encoding" in header_keys
|
249 |
+
skip_host = "host" in header_keys
|
250 |
+
self.putrequest(
|
251 |
+
method, url, skip_accept_encoding=skip_accept_encoding, skip_host=skip_host
|
252 |
+
)
|
253 |
+
if "user-agent" not in header_keys:
|
254 |
+
self.putheader("User-Agent", _get_default_user_agent())
|
255 |
+
for header, value in headers.items():
|
256 |
+
self.putheader(header, value)
|
257 |
+
if "transfer-encoding" not in header_keys:
|
258 |
+
self.putheader("Transfer-Encoding", "chunked")
|
259 |
+
self.endheaders()
|
260 |
+
|
261 |
+
if body is not None:
|
262 |
+
stringish_types = six.string_types + (bytes,)
|
263 |
+
if isinstance(body, stringish_types):
|
264 |
+
body = (body,)
|
265 |
+
for chunk in body:
|
266 |
+
if not chunk:
|
267 |
+
continue
|
268 |
+
if not isinstance(chunk, bytes):
|
269 |
+
chunk = chunk.encode("utf8")
|
270 |
+
len_str = hex(len(chunk))[2:]
|
271 |
+
to_send = bytearray(len_str.encode())
|
272 |
+
to_send += b"\r\n"
|
273 |
+
to_send += chunk
|
274 |
+
to_send += b"\r\n"
|
275 |
+
self.send(to_send)
|
276 |
+
|
277 |
+
# After the if clause, to always have a closed body
|
278 |
+
self.send(b"0\r\n\r\n")
|
279 |
+
|
280 |
+
|
281 |
+
class HTTPSConnection(HTTPConnection):
|
282 |
+
"""
|
283 |
+
Many of the parameters to this constructor are passed to the underlying SSL
|
284 |
+
socket by means of :py:func:`urllib3.util.ssl_wrap_socket`.
|
285 |
+
"""
|
286 |
+
|
287 |
+
default_port = port_by_scheme["https"]
|
288 |
+
|
289 |
+
cert_reqs = None
|
290 |
+
ca_certs = None
|
291 |
+
ca_cert_dir = None
|
292 |
+
ca_cert_data = None
|
293 |
+
ssl_version = None
|
294 |
+
assert_fingerprint = None
|
295 |
+
tls_in_tls_required = False
|
296 |
+
|
297 |
+
def __init__(
|
298 |
+
self,
|
299 |
+
host,
|
300 |
+
port=None,
|
301 |
+
key_file=None,
|
302 |
+
cert_file=None,
|
303 |
+
key_password=None,
|
304 |
+
strict=None,
|
305 |
+
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
306 |
+
ssl_context=None,
|
307 |
+
server_hostname=None,
|
308 |
+
**kw
|
309 |
+
):
|
310 |
+
|
311 |
+
HTTPConnection.__init__(self, host, port, strict=strict, timeout=timeout, **kw)
|
312 |
+
|
313 |
+
self.key_file = key_file
|
314 |
+
self.cert_file = cert_file
|
315 |
+
self.key_password = key_password
|
316 |
+
self.ssl_context = ssl_context
|
317 |
+
self.server_hostname = server_hostname
|
318 |
+
|
319 |
+
# Required property for Google AppEngine 1.9.0 which otherwise causes
|
320 |
+
# HTTPS requests to go out as HTTP. (See Issue #356)
|
321 |
+
self._protocol = "https"
|
322 |
+
|
323 |
+
def set_cert(
|
324 |
+
self,
|
325 |
+
key_file=None,
|
326 |
+
cert_file=None,
|
327 |
+
cert_reqs=None,
|
328 |
+
key_password=None,
|
329 |
+
ca_certs=None,
|
330 |
+
assert_hostname=None,
|
331 |
+
assert_fingerprint=None,
|
332 |
+
ca_cert_dir=None,
|
333 |
+
ca_cert_data=None,
|
334 |
+
):
|
335 |
+
"""
|
336 |
+
This method should only be called once, before the connection is used.
|
337 |
+
"""
|
338 |
+
# If cert_reqs is not provided we'll assume CERT_REQUIRED unless we also
|
339 |
+
# have an SSLContext object in which case we'll use its verify_mode.
|
340 |
+
if cert_reqs is None:
|
341 |
+
if self.ssl_context is not None:
|
342 |
+
cert_reqs = self.ssl_context.verify_mode
|
343 |
+
else:
|
344 |
+
cert_reqs = resolve_cert_reqs(None)
|
345 |
+
|
346 |
+
self.key_file = key_file
|
347 |
+
self.cert_file = cert_file
|
348 |
+
self.cert_reqs = cert_reqs
|
349 |
+
self.key_password = key_password
|
350 |
+
self.assert_hostname = assert_hostname
|
351 |
+
self.assert_fingerprint = assert_fingerprint
|
352 |
+
self.ca_certs = ca_certs and os.path.expanduser(ca_certs)
|
353 |
+
self.ca_cert_dir = ca_cert_dir and os.path.expanduser(ca_cert_dir)
|
354 |
+
self.ca_cert_data = ca_cert_data
|
355 |
+
|
356 |
+
def connect(self):
|
357 |
+
# Add certificate verification
|
358 |
+
conn = self._new_conn()
|
359 |
+
hostname = self.host
|
360 |
+
tls_in_tls = False
|
361 |
+
|
362 |
+
if self._is_using_tunnel():
|
363 |
+
if self.tls_in_tls_required:
|
364 |
+
conn = self._connect_tls_proxy(hostname, conn)
|
365 |
+
tls_in_tls = True
|
366 |
+
|
367 |
+
self.sock = conn
|
368 |
+
|
369 |
+
# Calls self._set_hostport(), so self.host is
|
370 |
+
# self._tunnel_host below.
|
371 |
+
self._tunnel()
|
372 |
+
# Mark this connection as not reusable
|
373 |
+
self.auto_open = 0
|
374 |
+
|
375 |
+
# Override the host with the one we're requesting data from.
|
376 |
+
hostname = self._tunnel_host
|
377 |
+
|
378 |
+
server_hostname = hostname
|
379 |
+
if self.server_hostname is not None:
|
380 |
+
server_hostname = self.server_hostname
|
381 |
+
|
382 |
+
is_time_off = datetime.date.today() < RECENT_DATE
|
383 |
+
if is_time_off:
|
384 |
+
warnings.warn(
|
385 |
+
(
|
386 |
+
"System time is way off (before {0}). This will probably "
|
387 |
+
"lead to SSL verification errors"
|
388 |
+
).format(RECENT_DATE),
|
389 |
+
SystemTimeWarning,
|
390 |
+
)
|
391 |
+
|
392 |
+
# Wrap socket using verification with the root certs in
|
393 |
+
# trusted_root_certs
|
394 |
+
default_ssl_context = False
|
395 |
+
if self.ssl_context is None:
|
396 |
+
default_ssl_context = True
|
397 |
+
self.ssl_context = create_urllib3_context(
|
398 |
+
ssl_version=resolve_ssl_version(self.ssl_version),
|
399 |
+
cert_reqs=resolve_cert_reqs(self.cert_reqs),
|
400 |
+
)
|
401 |
+
|
402 |
+
context = self.ssl_context
|
403 |
+
context.verify_mode = resolve_cert_reqs(self.cert_reqs)
|
404 |
+
|
405 |
+
# Try to load OS default certs if none are given.
|
406 |
+
# Works well on Windows (requires Python3.4+)
|
407 |
+
if (
|
408 |
+
not self.ca_certs
|
409 |
+
and not self.ca_cert_dir
|
410 |
+
and not self.ca_cert_data
|
411 |
+
and default_ssl_context
|
412 |
+
and hasattr(context, "load_default_certs")
|
413 |
+
):
|
414 |
+
context.load_default_certs()
|
415 |
+
|
416 |
+
self.sock = ssl_wrap_socket(
|
417 |
+
sock=conn,
|
418 |
+
keyfile=self.key_file,
|
419 |
+
certfile=self.cert_file,
|
420 |
+
key_password=self.key_password,
|
421 |
+
ca_certs=self.ca_certs,
|
422 |
+
ca_cert_dir=self.ca_cert_dir,
|
423 |
+
ca_cert_data=self.ca_cert_data,
|
424 |
+
server_hostname=server_hostname,
|
425 |
+
ssl_context=context,
|
426 |
+
tls_in_tls=tls_in_tls,
|
427 |
+
)
|
428 |
+
|
429 |
+
# If we're using all defaults and the connection
|
430 |
+
# is TLSv1 or TLSv1.1 we throw a DeprecationWarning
|
431 |
+
# for the host.
|
432 |
+
if (
|
433 |
+
default_ssl_context
|
434 |
+
and self.ssl_version is None
|
435 |
+
and hasattr(self.sock, "version")
|
436 |
+
and self.sock.version() in {"TLSv1", "TLSv1.1"}
|
437 |
+
):
|
438 |
+
warnings.warn(
|
439 |
+
"Negotiating TLSv1/TLSv1.1 by default is deprecated "
|
440 |
+
"and will be disabled in urllib3 v2.0.0. Connecting to "
|
441 |
+
"'%s' with '%s' can be enabled by explicitly opting-in "
|
442 |
+
"with 'ssl_version'" % (self.host, self.sock.version()),
|
443 |
+
DeprecationWarning,
|
444 |
+
)
|
445 |
+
|
446 |
+
if self.assert_fingerprint:
|
447 |
+
assert_fingerprint(
|
448 |
+
self.sock.getpeercert(binary_form=True), self.assert_fingerprint
|
449 |
+
)
|
450 |
+
elif (
|
451 |
+
context.verify_mode != ssl.CERT_NONE
|
452 |
+
and not getattr(context, "check_hostname", False)
|
453 |
+
and self.assert_hostname is not False
|
454 |
+
):
|
455 |
+
# While urllib3 attempts to always turn off hostname matching from
|
456 |
+
# the TLS library, this cannot always be done. So we check whether
|
457 |
+
# the TLS Library still thinks it's matching hostnames.
|
458 |
+
cert = self.sock.getpeercert()
|
459 |
+
if not cert.get("subjectAltName", ()):
|
460 |
+
warnings.warn(
|
461 |
+
(
|
462 |
+
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
|
463 |
+
"`commonName` for now. This feature is being removed by major browsers and "
|
464 |
+
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
|
465 |
+
"for details.)".format(hostname)
|
466 |
+
),
|
467 |
+
SubjectAltNameWarning,
|
468 |
+
)
|
469 |
+
_match_hostname(cert, self.assert_hostname or server_hostname)
|
470 |
+
|
471 |
+
self.is_verified = (
|
472 |
+
context.verify_mode == ssl.CERT_REQUIRED
|
473 |
+
or self.assert_fingerprint is not None
|
474 |
+
)
|
475 |
+
|
476 |
+
def _connect_tls_proxy(self, hostname, conn):
|
477 |
+
"""
|
478 |
+
Establish a TLS connection to the proxy using the provided SSL context.
|
479 |
+
"""
|
480 |
+
proxy_config = self.proxy_config
|
481 |
+
ssl_context = proxy_config.ssl_context
|
482 |
+
if ssl_context:
|
483 |
+
# If the user provided a proxy context, we assume CA and client
|
484 |
+
# certificates have already been set
|
485 |
+
return ssl_wrap_socket(
|
486 |
+
sock=conn,
|
487 |
+
server_hostname=hostname,
|
488 |
+
ssl_context=ssl_context,
|
489 |
+
)
|
490 |
+
|
491 |
+
ssl_context = create_proxy_ssl_context(
|
492 |
+
self.ssl_version,
|
493 |
+
self.cert_reqs,
|
494 |
+
self.ca_certs,
|
495 |
+
self.ca_cert_dir,
|
496 |
+
self.ca_cert_data,
|
497 |
+
)
|
498 |
+
|
499 |
+
# If no cert was provided, use only the default options for server
|
500 |
+
# certificate validation
|
501 |
+
socket = ssl_wrap_socket(
|
502 |
+
sock=conn,
|
503 |
+
ca_certs=self.ca_certs,
|
504 |
+
ca_cert_dir=self.ca_cert_dir,
|
505 |
+
ca_cert_data=self.ca_cert_data,
|
506 |
+
server_hostname=hostname,
|
507 |
+
ssl_context=ssl_context,
|
508 |
+
)
|
509 |
+
|
510 |
+
if ssl_context.verify_mode != ssl.CERT_NONE and not getattr(
|
511 |
+
ssl_context, "check_hostname", False
|
512 |
+
):
|
513 |
+
# While urllib3 attempts to always turn off hostname matching from
|
514 |
+
# the TLS library, this cannot always be done. So we check whether
|
515 |
+
# the TLS Library still thinks it's matching hostnames.
|
516 |
+
cert = socket.getpeercert()
|
517 |
+
if not cert.get("subjectAltName", ()):
|
518 |
+
warnings.warn(
|
519 |
+
(
|
520 |
+
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
|
521 |
+
"`commonName` for now. This feature is being removed by major browsers and "
|
522 |
+
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
|
523 |
+
"for details.)".format(hostname)
|
524 |
+
),
|
525 |
+
SubjectAltNameWarning,
|
526 |
+
)
|
527 |
+
_match_hostname(cert, hostname)
|
528 |
+
|
529 |
+
self.proxy_is_verified = ssl_context.verify_mode == ssl.CERT_REQUIRED
|
530 |
+
return socket
|
531 |
+
|
532 |
+
|
533 |
+
def _match_hostname(cert, asserted_hostname):
|
534 |
+
# Our upstream implementation of ssl.match_hostname()
|
535 |
+
# only applies this normalization to IP addresses so it doesn't
|
536 |
+
# match DNS SANs so we do the same thing!
|
537 |
+
stripped_hostname = asserted_hostname.strip("u[]")
|
538 |
+
if is_ipaddress(stripped_hostname):
|
539 |
+
asserted_hostname = stripped_hostname
|
540 |
+
|
541 |
+
try:
|
542 |
+
match_hostname(cert, asserted_hostname)
|
543 |
+
except CertificateError as e:
|
544 |
+
log.warning(
|
545 |
+
"Certificate did not match expected hostname: %s. Certificate: %s",
|
546 |
+
asserted_hostname,
|
547 |
+
cert,
|
548 |
+
)
|
549 |
+
# Add cert to exception and reraise so client code can inspect
|
550 |
+
# the cert when catching the exception, if they want to
|
551 |
+
e._peer_cert = cert
|
552 |
+
raise
|
553 |
+
|
554 |
+
|
555 |
+
def _get_default_user_agent():
|
556 |
+
return "python-urllib3/%s" % __version__
|
557 |
+
|
558 |
+
|
559 |
+
class DummyConnection(object):
|
560 |
+
"""Used to detect a failed ConnectionCls import."""
|
561 |
+
|
562 |
+
pass
|
563 |
+
|
564 |
+
|
565 |
+
if not ssl:
|
566 |
+
HTTPSConnection = DummyConnection # noqa: F811
|
567 |
+
|
568 |
+
|
569 |
+
VerifiedH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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import absolute_import
|
2 |
+
|
3 |
+
import errno
|
4 |
+
import logging
|
5 |
+
import re
|
6 |
+
import socket
|
7 |
+
import sys
|
8 |
+
import warnings
|
9 |
+
from socket import error as SocketError
|
10 |
+
from socket import timeout as SocketTimeout
|
11 |
+
|
12 |
+
from ._collections import HTTPHeaderDict
|
13 |
+
from .connection import (
|
14 |
+
BaseSSLError,
|
15 |
+
BrokenPipeError,
|
16 |
+
DummyConnection,
|
17 |
+
HTTPConnection,
|
18 |
+
HTTPException,
|
19 |
+
HTTPSConnection,
|
20 |
+
VerifiedHTTPSConnection,
|
21 |
+
port_by_scheme,
|
22 |
+
)
|
23 |
+
from .exceptions import (
|
24 |
+
ClosedPoolError,
|
25 |
+
EmptyPoolError,
|
26 |
+
HeaderParsingError,
|
27 |
+
HostChangedError,
|
28 |
+
InsecureRequestWarning,
|
29 |
+
LocationValueError,
|
30 |
+
MaxRetryError,
|
31 |
+
NewConnectionError,
|
32 |
+
ProtocolError,
|
33 |
+
ProxyError,
|
34 |
+
ReadTimeoutError,
|
35 |
+
SSLError,
|
36 |
+
TimeoutError,
|
37 |
+
)
|
38 |
+
from .packages import six
|
39 |
+
from .packages.six.moves import queue
|
40 |
+
from .request import RequestMethods
|
41 |
+
from .response import HTTPResponse
|
42 |
+
from .util.connection import is_connection_dropped
|
43 |
+
from .util.proxy import connection_requires_http_tunnel
|
44 |
+
from .util.queue import LifoQueue
|
45 |
+
from .util.request import set_file_position
|
46 |
+
from .util.response import assert_header_parsing
|
47 |
+
from .util.retry import Retry
|
48 |
+
from .util.ssl_match_hostname import CertificateError
|
49 |
+
from .util.timeout import Timeout
|
50 |
+
from .util.url import Url, _encode_target
|
51 |
+
from .util.url import _normalize_host as normalize_host
|
52 |
+
from .util.url import get_host, parse_url
|
53 |
+
|
54 |
+
xrange = six.moves.xrange
|
55 |
+
|
56 |
+
log = logging.getLogger(__name__)
|
57 |
+
|
58 |
+
_Default = object()
|
59 |
+
|
60 |
+
|
61 |
+
# Pool objects
|
62 |
+
class ConnectionPool(object):
|
63 |
+
"""
|
64 |
+
Base class for all connection pools, such as
|
65 |
+
:class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
|
66 |
+
|
67 |
+
.. note::
|
68 |
+
ConnectionPool.urlopen() does not normalize or percent-encode target URIs
|
69 |
+
which is useful if your target server doesn't support percent-encoded
|
70 |
+
target URIs.
|
71 |
+
"""
|
72 |
+
|
73 |
+
scheme = None
|
74 |
+
QueueCls = LifoQueue
|
75 |
+
|
76 |
+
def __init__(self, host, port=None):
|
77 |
+
if not host:
|
78 |
+
raise LocationValueError("No host specified.")
|
79 |
+
|
80 |
+
self.host = _normalize_host(host, scheme=self.scheme)
|
81 |
+
self._proxy_host = host.lower()
|
82 |
+
self.port = port
|
83 |
+
|
84 |
+
def __str__(self):
|
85 |
+
return "%s(host=%r, port=%r)" % (type(self).__name__, self.host, self.port)
|
86 |
+
|
87 |
+
def __enter__(self):
|
88 |
+
return self
|
89 |
+
|
90 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
91 |
+
self.close()
|
92 |
+
# Return False to re-raise any potential exceptions
|
93 |
+
return False
|
94 |
+
|
95 |
+
def close(self):
|
96 |
+
"""
|
97 |
+
Close all pooled connections and disable the pool.
|
98 |
+
"""
|
99 |
+
pass
|
100 |
+
|
101 |
+
|
102 |
+
# This is taken from http://hg.python.org/cpython/file/7aaba721ebc0/Lib/socket.py#l252
|
103 |
+
_blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
|
104 |
+
|
105 |
+
|
106 |
+
class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
107 |
+
"""
|
108 |
+
Thread-safe connection pool for one host.
|
109 |
+
|
110 |
+
:param host:
|
111 |
+
Host used for this HTTP Connection (e.g. "localhost"), passed into
|
112 |
+
:class:`http.client.HTTPConnection`.
|
113 |
+
|
114 |
+
:param port:
|
115 |
+
Port used for this HTTP Connection (None is equivalent to 80), passed
|
116 |
+
into :class:`http.client.HTTPConnection`.
|
117 |
+
|
118 |
+
:param strict:
|
119 |
+
Causes BadStatusLine to be raised if the status line can't be parsed
|
120 |
+
as a valid HTTP/1.0 or 1.1 status line, passed into
|
121 |
+
:class:`http.client.HTTPConnection`.
|
122 |
+
|
123 |
+
.. note::
|
124 |
+
Only works in Python 2. This parameter is ignored in Python 3.
|
125 |
+
|
126 |
+
:param timeout:
|
127 |
+
Socket timeout in seconds for each individual connection. This can
|
128 |
+
be a float or integer, which sets the timeout for the HTTP request,
|
129 |
+
or an instance of :class:`urllib3.util.Timeout` which gives you more
|
130 |
+
fine-grained control over request timeouts. After the constructor has
|
131 |
+
been parsed, this is always a `urllib3.util.Timeout` object.
|
132 |
+
|
133 |
+
:param maxsize:
|
134 |
+
Number of connections to save that can be reused. More than 1 is useful
|
135 |
+
in multithreaded situations. If ``block`` is set to False, more
|
136 |
+
connections will be created but they will not be saved once they've
|
137 |
+
been used.
|
138 |
+
|
139 |
+
:param block:
|
140 |
+
If set to True, no more than ``maxsize`` connections will be used at
|
141 |
+
a time. When no free connections are available, the call will block
|
142 |
+
until a connection has been released. This is a useful side effect for
|
143 |
+
particular multithreaded situations where one does not want to use more
|
144 |
+
than maxsize connections per host to prevent flooding.
|
145 |
+
|
146 |
+
:param headers:
|
147 |
+
Headers to include with all requests, unless other headers are given
|
148 |
+
explicitly.
|
149 |
+
|
150 |
+
:param retries:
|
151 |
+
Retry configuration to use by default with requests in this pool.
|
152 |
+
|
153 |
+
:param _proxy:
|
154 |
+
Parsed proxy URL, should not be used directly, instead, see
|
155 |
+
:class:`urllib3.ProxyManager`
|
156 |
+
|
157 |
+
:param _proxy_headers:
|
158 |
+
A dictionary with proxy headers, should not be used directly,
|
159 |
+
instead, see :class:`urllib3.ProxyManager`
|
160 |
+
|
161 |
+
:param \\**conn_kw:
|
162 |
+
Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
|
163 |
+
:class:`urllib3.connection.HTTPSConnection` instances.
|
164 |
+
"""
|
165 |
+
|
166 |
+
scheme = "http"
|
167 |
+
ConnectionCls = HTTPConnection
|
168 |
+
ResponseCls = HTTPResponse
|
169 |
+
|
170 |
+
def __init__(
|
171 |
+
self,
|
172 |
+
host,
|
173 |
+
port=None,
|
174 |
+
strict=False,
|
175 |
+
timeout=Timeout.DEFAULT_TIMEOUT,
|
176 |
+
maxsize=1,
|
177 |
+
block=False,
|
178 |
+
headers=None,
|
179 |
+
retries=None,
|
180 |
+
_proxy=None,
|
181 |
+
_proxy_headers=None,
|
182 |
+
_proxy_config=None,
|
183 |
+
**conn_kw
|
184 |
+
):
|
185 |
+
ConnectionPool.__init__(self, host, port)
|
186 |
+
RequestMethods.__init__(self, headers)
|
187 |
+
|
188 |
+
self.strict = strict
|
189 |
+
|
190 |
+
if not isinstance(timeout, Timeout):
|
191 |
+
timeout = Timeout.from_float(timeout)
|
192 |
+
|
193 |
+
if retries is None:
|
194 |
+
retries = Retry.DEFAULT
|
195 |
+
|
196 |
+
self.timeout = timeout
|
197 |
+
self.retries = retries
|
198 |
+
|
199 |
+
self.pool = self.QueueCls(maxsize)
|
200 |
+
self.block = block
|
201 |
+
|
202 |
+
self.proxy = _proxy
|
203 |
+
self.proxy_headers = _proxy_headers or {}
|
204 |
+
self.proxy_config = _proxy_config
|
205 |
+
|
206 |
+
# Fill the queue up so that doing get() on it will block properly
|
207 |
+
for _ in xrange(maxsize):
|
208 |
+
self.pool.put(None)
|
209 |
+
|
210 |
+
# These are mostly for testing and debugging purposes.
|
211 |
+
self.num_connections = 0
|
212 |
+
self.num_requests = 0
|
213 |
+
self.conn_kw = conn_kw
|
214 |
+
|
215 |
+
if self.proxy:
|
216 |
+
# Enable Nagle's algorithm for proxies, to avoid packet fragmentation.
|
217 |
+
# We cannot know if the user has added default socket options, so we cannot replace the
|
218 |
+
# list.
|
219 |
+
self.conn_kw.setdefault("socket_options", [])
|
220 |
+
|
221 |
+
self.conn_kw["proxy"] = self.proxy
|
222 |
+
self.conn_kw["proxy_config"] = self.proxy_config
|
223 |
+
|
224 |
+
def _new_conn(self):
|
225 |
+
"""
|
226 |
+
Return a fresh :class:`HTTPConnection`.
|
227 |
+
"""
|
228 |
+
self.num_connections += 1
|
229 |
+
log.debug(
|
230 |
+
"Starting new HTTP connection (%d): %s:%s",
|
231 |
+
self.num_connections,
|
232 |
+
self.host,
|
233 |
+
self.port or "80",
|
234 |
+
)
|
235 |
+
|
236 |
+
conn = self.ConnectionCls(
|
237 |
+
host=self.host,
|
238 |
+
port=self.port,
|
239 |
+
timeout=self.timeout.connect_timeout,
|
240 |
+
strict=self.strict,
|
241 |
+
**self.conn_kw
|
242 |
+
)
|
243 |
+
return conn
|
244 |
+
|
245 |
+
def _get_conn(self, timeout=None):
|
246 |
+
"""
|
247 |
+
Get a connection. Will return a pooled connection if one is available.
|
248 |
+
|
249 |
+
If no connections are available and :prop:`.block` is ``False``, then a
|
250 |
+
fresh connection is returned.
|
251 |
+
|
252 |
+
:param timeout:
|
253 |
+
Seconds to wait before giving up and raising
|
254 |
+
:class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
|
255 |
+
:prop:`.block` is ``True``.
|
256 |
+
"""
|
257 |
+
conn = None
|
258 |
+
try:
|
259 |
+
conn = self.pool.get(block=self.block, timeout=timeout)
|
260 |
+
|
261 |
+
except AttributeError: # self.pool is None
|
262 |
+
raise ClosedPoolError(self, "Pool is closed.")
|
263 |
+
|
264 |
+
except queue.Empty:
|
265 |
+
if self.block:
|
266 |
+
raise EmptyPoolError(
|
267 |
+
self,
|
268 |
+
"Pool reached maximum size and no more connections are allowed.",
|
269 |
+
)
|
270 |
+
pass # Oh well, we'll create a new connection then
|
271 |
+
|
272 |
+
# If this is a persistent connection, check if it got disconnected
|
273 |
+
if conn and is_connection_dropped(conn):
|
274 |
+
log.debug("Resetting dropped connection: %s", self.host)
|
275 |
+
conn.close()
|
276 |
+
if getattr(conn, "auto_open", 1) == 0:
|
277 |
+
# This is a proxied connection that has been mutated by
|
278 |
+
# http.client._tunnel() and cannot be reused (since it would
|
279 |
+
# attempt to bypass the proxy)
|
280 |
+
conn = None
|
281 |
+
|
282 |
+
return conn or self._new_conn()
|
283 |
+
|
284 |
+
def _put_conn(self, conn):
|
285 |
+
"""
|
286 |
+
Put a connection back into the pool.
|
287 |
+
|
288 |
+
:param conn:
|
289 |
+
Connection object for the current host and port as returned by
|
290 |
+
:meth:`._new_conn` or :meth:`._get_conn`.
|
291 |
+
|
292 |
+
If the pool is already full, the connection is closed and discarded
|
293 |
+
because we exceeded maxsize. If connections are discarded frequently,
|
294 |
+
then maxsize should be increased.
|
295 |
+
|
296 |
+
If the pool is closed, then the connection will be closed and discarded.
|
297 |
+
"""
|
298 |
+
try:
|
299 |
+
self.pool.put(conn, block=False)
|
300 |
+
return # Everything is dandy, done.
|
301 |
+
except AttributeError:
|
302 |
+
# self.pool is None.
|
303 |
+
pass
|
304 |
+
except queue.Full:
|
305 |
+
# This should never happen if self.block == True
|
306 |
+
log.warning(
|
307 |
+
"Connection pool is full, discarding connection: %s. Connection pool size: %s",
|
308 |
+
self.host,
|
309 |
+
self.pool.qsize(),
|
310 |
+
)
|
311 |
+
# Connection never got put back into the pool, close it.
|
312 |
+
if conn:
|
313 |
+
conn.close()
|
314 |
+
|
315 |
+
def _validate_conn(self, conn):
|
316 |
+
"""
|
317 |
+
Called right before a request is made, after the socket is created.
|
318 |
+
"""
|
319 |
+
pass
|
320 |
+
|
321 |
+
def _prepare_proxy(self, conn):
|
322 |
+
# Nothing to do for HTTP connections.
|
323 |
+
pass
|
324 |
+
|
325 |
+
def _get_timeout(self, timeout):
|
326 |
+
"""Helper that always returns a :class:`urllib3.util.Timeout`"""
|
327 |
+
if timeout is _Default:
|
328 |
+
return self.timeout.clone()
|
329 |
+
|
330 |
+
if isinstance(timeout, Timeout):
|
331 |
+
return timeout.clone()
|
332 |
+
else:
|
333 |
+
# User passed us an int/float. This is for backwards compatibility,
|
334 |
+
# can be removed later
|
335 |
+
return Timeout.from_float(timeout)
|
336 |
+
|
337 |
+
def _raise_timeout(self, err, url, timeout_value):
|
338 |
+
"""Is the error actually a timeout? Will raise a ReadTimeout or pass"""
|
339 |
+
|
340 |
+
if isinstance(err, SocketTimeout):
|
341 |
+
raise ReadTimeoutError(
|
342 |
+
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
343 |
+
)
|
344 |
+
|
345 |
+
# See the above comment about EAGAIN in Python 3. In Python 2 we have
|
346 |
+
# to specifically catch it and throw the timeout error
|
347 |
+
if hasattr(err, "errno") and err.errno in _blocking_errnos:
|
348 |
+
raise ReadTimeoutError(
|
349 |
+
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
350 |
+
)
|
351 |
+
|
352 |
+
# Catch possible read timeouts thrown as SSL errors. If not the
|
353 |
+
# case, rethrow the original. We need to do this because of:
|
354 |
+
# http://bugs.python.org/issue10272
|
355 |
+
if "timed out" in str(err) or "did not complete (read)" in str(
|
356 |
+
err
|
357 |
+
): # Python < 2.7.4
|
358 |
+
raise ReadTimeoutError(
|
359 |
+
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
360 |
+
)
|
361 |
+
|
362 |
+
def _make_request(
|
363 |
+
self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
|
364 |
+
):
|
365 |
+
"""
|
366 |
+
Perform a request on a given urllib connection object taken from our
|
367 |
+
pool.
|
368 |
+
|
369 |
+
:param conn:
|
370 |
+
a connection from one of our connection pools
|
371 |
+
|
372 |
+
:param timeout:
|
373 |
+
Socket timeout in seconds for the request. This can be a
|
374 |
+
float or integer, which will set the same timeout value for
|
375 |
+
the socket connect and the socket read, or an instance of
|
376 |
+
:class:`urllib3.util.Timeout`, which gives you more fine-grained
|
377 |
+
control over your timeouts.
|
378 |
+
"""
|
379 |
+
self.num_requests += 1
|
380 |
+
|
381 |
+
timeout_obj = self._get_timeout(timeout)
|
382 |
+
timeout_obj.start_connect()
|
383 |
+
conn.timeout = timeout_obj.connect_timeout
|
384 |
+
|
385 |
+
# Trigger any extra validation we need to do.
|
386 |
+
try:
|
387 |
+
self._validate_conn(conn)
|
388 |
+
except (SocketTimeout, BaseSSLError) as e:
|
389 |
+
# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
|
390 |
+
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
|
391 |
+
raise
|
392 |
+
|
393 |
+
# conn.request() calls http.client.*.request, not the method in
|
394 |
+
# urllib3.request. It also calls makefile (recv) on the socket.
|
395 |
+
try:
|
396 |
+
if chunked:
|
397 |
+
conn.request_chunked(method, url, **httplib_request_kw)
|
398 |
+
else:
|
399 |
+
conn.request(method, url, **httplib_request_kw)
|
400 |
+
|
401 |
+
# We are swallowing BrokenPipeError (errno.EPIPE) since the server is
|
402 |
+
# legitimately able to close the connection after sending a valid response.
|
403 |
+
# With this behaviour, the received response is still readable.
|
404 |
+
except BrokenPipeError:
|
405 |
+
# Python 3
|
406 |
+
pass
|
407 |
+
except IOError as e:
|
408 |
+
# Python 2 and macOS/Linux
|
409 |
+
# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS
|
410 |
+
# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
|
411 |
+
if e.errno not in {
|
412 |
+
errno.EPIPE,
|
413 |
+
errno.ESHUTDOWN,
|
414 |
+
errno.EPROTOTYPE,
|
415 |
+
}:
|
416 |
+
raise
|
417 |
+
|
418 |
+
# Reset the timeout for the recv() on the socket
|
419 |
+
read_timeout = timeout_obj.read_timeout
|
420 |
+
|
421 |
+
# App Engine doesn't have a sock attr
|
422 |
+
if getattr(conn, "sock", None):
|
423 |
+
# In Python 3 socket.py will catch EAGAIN and return None when you
|
424 |
+
# try and read into the file pointer created by http.client, which
|
425 |
+
# instead raises a BadStatusLine exception. Instead of catching
|
426 |
+
# the exception and assuming all BadStatusLine exceptions are read
|
427 |
+
# timeouts, check for a zero timeout before making the request.
|
428 |
+
if read_timeout == 0:
|
429 |
+
raise ReadTimeoutError(
|
430 |
+
self, url, "Read timed out. (read timeout=%s)" % read_timeout
|
431 |
+
)
|
432 |
+
if read_timeout is Timeout.DEFAULT_TIMEOUT:
|
433 |
+
conn.sock.settimeout(socket.getdefaulttimeout())
|
434 |
+
else: # None or a value
|
435 |
+
conn.sock.settimeout(read_timeout)
|
436 |
+
|
437 |
+
# Receive the response from the server
|
438 |
+
try:
|
439 |
+
try:
|
440 |
+
# Python 2.7, use buffering of HTTP responses
|
441 |
+
httplib_response = conn.getresponse(buffering=True)
|
442 |
+
except TypeError:
|
443 |
+
# Python 3
|
444 |
+
try:
|
445 |
+
httplib_response = conn.getresponse()
|
446 |
+
except BaseException as e:
|
447 |
+
# Remove the TypeError from the exception chain in
|
448 |
+
# Python 3 (including for exceptions like SystemExit).
|
449 |
+
# Otherwise it looks like a bug in the code.
|
450 |
+
six.raise_from(e, None)
|
451 |
+
except (SocketTimeout, BaseSSLError, SocketError) as e:
|
452 |
+
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
|
453 |
+
raise
|
454 |
+
|
455 |
+
# AppEngine doesn't have a version attr.
|
456 |
+
http_version = getattr(conn, "_http_vsn_str", "HTTP/?")
|
457 |
+
log.debug(
|
458 |
+
'%s://%s:%s "%s %s %s" %s %s',
|
459 |
+
self.scheme,
|
460 |
+
self.host,
|
461 |
+
self.port,
|
462 |
+
method,
|
463 |
+
url,
|
464 |
+
http_version,
|
465 |
+
httplib_response.status,
|
466 |
+
httplib_response.length,
|
467 |
+
)
|
468 |
+
|
469 |
+
try:
|
470 |
+
assert_header_parsing(httplib_response.msg)
|
471 |
+
except (HeaderParsingError, TypeError) as hpe: # Platform-specific: Python 3
|
472 |
+
log.warning(
|
473 |
+
"Failed to parse headers (url=%s): %s",
|
474 |
+
self._absolute_url(url),
|
475 |
+
hpe,
|
476 |
+
exc_info=True,
|
477 |
+
)
|
478 |
+
|
479 |
+
return httplib_response
|
480 |
+
|
481 |
+
def _absolute_url(self, path):
|
482 |
+
return Url(scheme=self.scheme, host=self.host, port=self.port, path=path).url
|
483 |
+
|
484 |
+
def close(self):
|
485 |
+
"""
|
486 |
+
Close all pooled connections and disable the pool.
|
487 |
+
"""
|
488 |
+
if self.pool is None:
|
489 |
+
return
|
490 |
+
# Disable access to the pool
|
491 |
+
old_pool, self.pool = self.pool, None
|
492 |
+
|
493 |
+
try:
|
494 |
+
while True:
|
495 |
+
conn = old_pool.get(block=False)
|
496 |
+
if conn:
|
497 |
+
conn.close()
|
498 |
+
|
499 |
+
except queue.Empty:
|
500 |
+
pass # Done.
|
501 |
+
|
502 |
+
def is_same_host(self, url):
|
503 |
+
"""
|
504 |
+
Check if the given ``url`` is a member of the same host as this
|
505 |
+
connection pool.
|
506 |
+
"""
|
507 |
+
if url.startswith("/"):
|
508 |
+
return True
|
509 |
+
|
510 |
+
# TODO: Add optional support for socket.gethostbyname checking.
|
511 |
+
scheme, host, port = get_host(url)
|
512 |
+
if host is not None:
|
513 |
+
host = _normalize_host(host, scheme=scheme)
|
514 |
+
|
515 |
+
# Use explicit default port for comparison when none is given
|
516 |
+
if self.port and not port:
|
517 |
+
port = port_by_scheme.get(scheme)
|
518 |
+
elif not self.port and port == port_by_scheme.get(scheme):
|
519 |
+
port = None
|
520 |
+
|
521 |
+
return (scheme, host, port) == (self.scheme, self.host, self.port)
|
522 |
+
|
523 |
+
def urlopen(
|
524 |
+
self,
|
525 |
+
method,
|
526 |
+
url,
|
527 |
+
body=None,
|
528 |
+
headers=None,
|
529 |
+
retries=None,
|
530 |
+
redirect=True,
|
531 |
+
assert_same_host=True,
|
532 |
+
timeout=_Default,
|
533 |
+
pool_timeout=None,
|
534 |
+
release_conn=None,
|
535 |
+
chunked=False,
|
536 |
+
body_pos=None,
|
537 |
+
**response_kw
|
538 |
+
):
|
539 |
+
"""
|
540 |
+
Get a connection from the pool and perform an HTTP request. This is the
|
541 |
+
lowest level call for making a request, so you'll need to specify all
|
542 |
+
the raw details.
|
543 |
+
|
544 |
+
.. note::
|
545 |
+
|
546 |
+
More commonly, it's appropriate to use a convenience method provided
|
547 |
+
by :class:`.RequestMethods`, such as :meth:`request`.
|
548 |
+
|
549 |
+
.. note::
|
550 |
+
|
551 |
+
`release_conn` will only behave as expected if
|
552 |
+
`preload_content=False` because we want to make
|
553 |
+
`preload_content=False` the default behaviour someday soon without
|
554 |
+
breaking backwards compatibility.
|
555 |
+
|
556 |
+
:param method:
|
557 |
+
HTTP request method (such as GET, POST, PUT, etc.)
|
558 |
+
|
559 |
+
:param url:
|
560 |
+
The URL to perform the request on.
|
561 |
+
|
562 |
+
:param body:
|
563 |
+
Data to send in the request body, either :class:`str`, :class:`bytes`,
|
564 |
+
an iterable of :class:`str`/:class:`bytes`, or a file-like object.
|
565 |
+
|
566 |
+
:param headers:
|
567 |
+
Dictionary of custom headers to send, such as User-Agent,
|
568 |
+
If-None-Match, etc. If None, pool headers are used. If provided,
|
569 |
+
these headers completely replace any pool-specific headers.
|
570 |
+
|
571 |
+
:param retries:
|
572 |
+
Configure the number of retries to allow before raising a
|
573 |
+
:class:`~urllib3.exceptions.MaxRetryError` exception.
|
574 |
+
|
575 |
+
Pass ``None`` to retry until you receive a response. Pass a
|
576 |
+
:class:`~urllib3.util.retry.Retry` object for fine-grained control
|
577 |
+
over different types of retries.
|
578 |
+
Pass an integer number to retry connection errors that many times,
|
579 |
+
but no other types of errors. Pass zero to never retry.
|
580 |
+
|
581 |
+
If ``False``, then retries are disabled and any exception is raised
|
582 |
+
immediately. Also, instead of raising a MaxRetryError on redirects,
|
583 |
+
the redirect response will be returned.
|
584 |
+
|
585 |
+
:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
|
586 |
+
|
587 |
+
:param redirect:
|
588 |
+
If True, automatically handle redirects (status codes 301, 302,
|
589 |
+
303, 307, 308). Each redirect counts as a retry. Disabling retries
|
590 |
+
will disable redirect, too.
|
591 |
+
|
592 |
+
:param assert_same_host:
|
593 |
+
If ``True``, will make sure that the host of the pool requests is
|
594 |
+
consistent else will raise HostChangedError. When ``False``, you can
|
595 |
+
use the pool on an HTTP proxy and request foreign hosts.
|
596 |
+
|
597 |
+
:param timeout:
|
598 |
+
If specified, overrides the default timeout for this one
|
599 |
+
request. It may be a float (in seconds) or an instance of
|
600 |
+
:class:`urllib3.util.Timeout`.
|
601 |
+
|
602 |
+
:param pool_timeout:
|
603 |
+
If set and the pool is set to block=True, then this method will
|
604 |
+
block for ``pool_timeout`` seconds and raise EmptyPoolError if no
|
605 |
+
connection is available within the time period.
|
606 |
+
|
607 |
+
:param release_conn:
|
608 |
+
If False, then the urlopen call will not release the connection
|
609 |
+
back into the pool once a response is received (but will release if
|
610 |
+
you read the entire contents of the response such as when
|
611 |
+
`preload_content=True`). This is useful if you're not preloading
|
612 |
+
the response's content immediately. You will need to call
|
613 |
+
``r.release_conn()`` on the response ``r`` to return the connection
|
614 |
+
back into the pool. If None, it takes the value of
|
615 |
+
``response_kw.get('preload_content', True)``.
|
616 |
+
|
617 |
+
:param chunked:
|
618 |
+
If True, urllib3 will send the body using chunked transfer
|
619 |
+
encoding. Otherwise, urllib3 will send the body using the standard
|
620 |
+
content-length form. Defaults to False.
|
621 |
+
|
622 |
+
:param int body_pos:
|
623 |
+
Position to seek to in file-like body in the event of a retry or
|
624 |
+
redirect. Typically this won't need to be set because urllib3 will
|
625 |
+
auto-populate the value when needed.
|
626 |
+
|
627 |
+
:param \\**response_kw:
|
628 |
+
Additional parameters are passed to
|
629 |
+
:meth:`urllib3.response.HTTPResponse.from_httplib`
|
630 |
+
"""
|
631 |
+
|
632 |
+
parsed_url = parse_url(url)
|
633 |
+
destination_scheme = parsed_url.scheme
|
634 |
+
|
635 |
+
if headers is None:
|
636 |
+
headers = self.headers
|
637 |
+
|
638 |
+
if not isinstance(retries, Retry):
|
639 |
+
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
|
640 |
+
|
641 |
+
if release_conn is None:
|
642 |
+
release_conn = response_kw.get("preload_content", True)
|
643 |
+
|
644 |
+
# Check host
|
645 |
+
if assert_same_host and not self.is_same_host(url):
|
646 |
+
raise HostChangedError(self, url, retries)
|
647 |
+
|
648 |
+
# Ensure that the URL we're connecting to is properly encoded
|
649 |
+
if url.startswith("/"):
|
650 |
+
url = six.ensure_str(_encode_target(url))
|
651 |
+
else:
|
652 |
+
url = six.ensure_str(parsed_url.url)
|
653 |
+
|
654 |
+
conn = None
|
655 |
+
|
656 |
+
# Track whether `conn` needs to be released before
|
657 |
+
# returning/raising/recursing. Update this variable if necessary, and
|
658 |
+
# leave `release_conn` constant throughout the function. That way, if
|
659 |
+
# the function recurses, the original value of `release_conn` will be
|
660 |
+
# passed down into the recursive call, and its value will be respected.
|
661 |
+
#
|
662 |
+
# See issue #651 [1] for details.
|
663 |
+
#
|
664 |
+
# [1] <https://github.com/urllib3/urllib3/issues/651>
|
665 |
+
release_this_conn = release_conn
|
666 |
+
|
667 |
+
http_tunnel_required = connection_requires_http_tunnel(
|
668 |
+
self.proxy, self.proxy_config, destination_scheme
|
669 |
+
)
|
670 |
+
|
671 |
+
# Merge the proxy headers. Only done when not using HTTP CONNECT. We
|
672 |
+
# have to copy the headers dict so we can safely change it without those
|
673 |
+
# changes being reflected in anyone else's copy.
|
674 |
+
if not http_tunnel_required:
|
675 |
+
headers = headers.copy()
|
676 |
+
headers.update(self.proxy_headers)
|
677 |
+
|
678 |
+
# Must keep the exception bound to a separate variable or else Python 3
|
679 |
+
# complains about UnboundLocalError.
|
680 |
+
err = None
|
681 |
+
|
682 |
+
# Keep track of whether we cleanly exited the except block. This
|
683 |
+
# ensures we do proper cleanup in finally.
|
684 |
+
clean_exit = False
|
685 |
+
|
686 |
+
# Rewind body position, if needed. Record current position
|
687 |
+
# for future rewinds in the event of a redirect/retry.
|
688 |
+
body_pos = set_file_position(body, body_pos)
|
689 |
+
|
690 |
+
try:
|
691 |
+
# Request a connection from the queue.
|
692 |
+
timeout_obj = self._get_timeout(timeout)
|
693 |
+
conn = self._get_conn(timeout=pool_timeout)
|
694 |
+
|
695 |
+
conn.timeout = timeout_obj.connect_timeout
|
696 |
+
|
697 |
+
is_new_proxy_conn = self.proxy is not None and not getattr(
|
698 |
+
conn, "sock", None
|
699 |
+
)
|
700 |
+
if is_new_proxy_conn and http_tunnel_required:
|
701 |
+
self._prepare_proxy(conn)
|
702 |
+
|
703 |
+
# Make the request on the httplib connection object.
|
704 |
+
httplib_response = self._make_request(
|
705 |
+
conn,
|
706 |
+
method,
|
707 |
+
url,
|
708 |
+
timeout=timeout_obj,
|
709 |
+
body=body,
|
710 |
+
headers=headers,
|
711 |
+
chunked=chunked,
|
712 |
+
)
|
713 |
+
|
714 |
+
# If we're going to release the connection in ``finally:``, then
|
715 |
+
# the response doesn't need to know about the connection. Otherwise
|
716 |
+
# it will also try to release it and we'll have a double-release
|
717 |
+
# mess.
|
718 |
+
response_conn = conn if not release_conn else None
|
719 |
+
|
720 |
+
# Pass method to Response for length checking
|
721 |
+
response_kw["request_method"] = method
|
722 |
+
|
723 |
+
# Import httplib's response into our own wrapper object
|
724 |
+
response = self.ResponseCls.from_httplib(
|
725 |
+
httplib_response,
|
726 |
+
pool=self,
|
727 |
+
connection=response_conn,
|
728 |
+
retries=retries,
|
729 |
+
**response_kw
|
730 |
+
)
|
731 |
+
|
732 |
+
# Everything went great!
|
733 |
+
clean_exit = True
|
734 |
+
|
735 |
+
except EmptyPoolError:
|
736 |
+
# Didn't get a connection from the pool, no need to clean up
|
737 |
+
clean_exit = True
|
738 |
+
release_this_conn = False
|
739 |
+
raise
|
740 |
+
|
741 |
+
except (
|
742 |
+
TimeoutError,
|
743 |
+
HTTPException,
|
744 |
+
SocketError,
|
745 |
+
ProtocolError,
|
746 |
+
BaseSSLError,
|
747 |
+
SSLError,
|
748 |
+
CertificateError,
|
749 |
+
) as e:
|
750 |
+
# Discard the connection for these exceptions. It will be
|
751 |
+
# replaced during the next _get_conn() call.
|
752 |
+
clean_exit = False
|
753 |
+
|
754 |
+
def _is_ssl_error_message_from_http_proxy(ssl_error):
|
755 |
+
# We're trying to detect the message 'WRONG_VERSION_NUMBER' but
|
756 |
+
# SSLErrors are kinda all over the place when it comes to the message,
|
757 |
+
# so we try to cover our bases here!
|
758 |
+
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
|
759 |
+
return (
|
760 |
+
"wrong version number" in message or "unknown protocol" in message
|
761 |
+
)
|
762 |
+
|
763 |
+
# Try to detect a common user error with proxies which is to
|
764 |
+
# set an HTTP proxy to be HTTPS when it should be 'http://'
|
765 |
+
# (ie {'http': 'http://proxy', 'https': 'https://proxy'})
|
766 |
+
# Instead we add a nice error message and point to a URL.
|
767 |
+
if (
|
768 |
+
isinstance(e, BaseSSLError)
|
769 |
+
and self.proxy
|
770 |
+
and _is_ssl_error_message_from_http_proxy(e)
|
771 |
+
):
|
772 |
+
e = ProxyError(
|
773 |
+
"Your proxy appears to only use HTTP and not HTTPS, "
|
774 |
+
"try changing your proxy URL to be HTTP. See: "
|
775 |
+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
776 |
+
"#https-proxy-error-http-proxy",
|
777 |
+
SSLError(e),
|
778 |
+
)
|
779 |
+
elif isinstance(e, (BaseSSLError, CertificateError)):
|
780 |
+
e = SSLError(e)
|
781 |
+
elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
|
782 |
+
e = ProxyError("Cannot connect to proxy.", e)
|
783 |
+
elif isinstance(e, (SocketError, HTTPException)):
|
784 |
+
e = ProtocolError("Connection aborted.", e)
|
785 |
+
|
786 |
+
retries = retries.increment(
|
787 |
+
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
|
788 |
+
)
|
789 |
+
retries.sleep()
|
790 |
+
|
791 |
+
# Keep track of the error for the retry warning.
|
792 |
+
err = e
|
793 |
+
|
794 |
+
finally:
|
795 |
+
if not clean_exit:
|
796 |
+
# We hit some kind of exception, handled or otherwise. We need
|
797 |
+
# to throw the connection away unless explicitly told not to.
|
798 |
+
# Close the connection, set the variable to None, and make sure
|
799 |
+
# we put the None back in the pool to avoid leaking it.
|
800 |
+
conn = conn and conn.close()
|
801 |
+
release_this_conn = True
|
802 |
+
|
803 |
+
if release_this_conn:
|
804 |
+
# Put the connection back to be reused. If the connection is
|
805 |
+
# expired then it will be None, which will get replaced with a
|
806 |
+
# fresh connection during _get_conn.
|
807 |
+
self._put_conn(conn)
|
808 |
+
|
809 |
+
if not conn:
|
810 |
+
# Try again
|
811 |
+
log.warning(
|
812 |
+
"Retrying (%r) after connection broken by '%r': %s", retries, err, url
|
813 |
+
)
|
814 |
+
return self.urlopen(
|
815 |
+
method,
|
816 |
+
url,
|
817 |
+
body,
|
818 |
+
headers,
|
819 |
+
retries,
|
820 |
+
redirect,
|
821 |
+
assert_same_host,
|
822 |
+
timeout=timeout,
|
823 |
+
pool_timeout=pool_timeout,
|
824 |
+
release_conn=release_conn,
|
825 |
+
chunked=chunked,
|
826 |
+
body_pos=body_pos,
|
827 |
+
**response_kw
|
828 |
+
)
|
829 |
+
|
830 |
+
# Handle redirect?
|
831 |
+
redirect_location = redirect and response.get_redirect_location()
|
832 |
+
if redirect_location:
|
833 |
+
if response.status == 303:
|
834 |
+
# Change the method according to RFC 9110, Section 15.4.4.
|
835 |
+
method = "GET"
|
836 |
+
# And lose the body not to transfer anything sensitive.
|
837 |
+
body = None
|
838 |
+
headers = HTTPHeaderDict(headers)._prepare_for_method_change()
|
839 |
+
|
840 |
+
try:
|
841 |
+
retries = retries.increment(method, url, response=response, _pool=self)
|
842 |
+
except MaxRetryError:
|
843 |
+
if retries.raise_on_redirect:
|
844 |
+
response.drain_conn()
|
845 |
+
raise
|
846 |
+
return response
|
847 |
+
|
848 |
+
response.drain_conn()
|
849 |
+
retries.sleep_for_retry(response)
|
850 |
+
log.debug("Redirecting %s -> %s", url, redirect_location)
|
851 |
+
return self.urlopen(
|
852 |
+
method,
|
853 |
+
redirect_location,
|
854 |
+
body,
|
855 |
+
headers,
|
856 |
+
retries=retries,
|
857 |
+
redirect=redirect,
|
858 |
+
assert_same_host=assert_same_host,
|
859 |
+
timeout=timeout,
|
860 |
+
pool_timeout=pool_timeout,
|
861 |
+
release_conn=release_conn,
|
862 |
+
chunked=chunked,
|
863 |
+
body_pos=body_pos,
|
864 |
+
**response_kw
|
865 |
+
)
|
866 |
+
|
867 |
+
# Check if we should retry the HTTP response.
|
868 |
+
has_retry_after = bool(response.getheader("Retry-After"))
|
869 |
+
if retries.is_retry(method, response.status, has_retry_after):
|
870 |
+
try:
|
871 |
+
retries = retries.increment(method, url, response=response, _pool=self)
|
872 |
+
except MaxRetryError:
|
873 |
+
if retries.raise_on_status:
|
874 |
+
response.drain_conn()
|
875 |
+
raise
|
876 |
+
return response
|
877 |
+
|
878 |
+
response.drain_conn()
|
879 |
+
retries.sleep(response)
|
880 |
+
log.debug("Retry: %s", url)
|
881 |
+
return self.urlopen(
|
882 |
+
method,
|
883 |
+
url,
|
884 |
+
body,
|
885 |
+
headers,
|
886 |
+
retries=retries,
|
887 |
+
redirect=redirect,
|
888 |
+
assert_same_host=assert_same_host,
|
889 |
+
timeout=timeout,
|
890 |
+
pool_timeout=pool_timeout,
|
891 |
+
release_conn=release_conn,
|
892 |
+
chunked=chunked,
|
893 |
+
body_pos=body_pos,
|
894 |
+
**response_kw
|
895 |
+
)
|
896 |
+
|
897 |
+
return response
|
898 |
+
|
899 |
+
|
900 |
+
class HTTPSConnectionPool(HTTPConnectionPool):
|
901 |
+
"""
|
902 |
+
Same as :class:`.HTTPConnectionPool`, but HTTPS.
|
903 |
+
|
904 |
+
:class:`.HTTPSConnection` uses one of ``assert_fingerprint``,
|
905 |
+
``assert_hostname`` and ``host`` in this order to verify connections.
|
906 |
+
If ``assert_hostname`` is False, no verification is done.
|
907 |
+
|
908 |
+
The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs``,
|
909 |
+
``ca_cert_dir``, ``ssl_version``, ``key_password`` are only used if :mod:`ssl`
|
910 |
+
is available and are fed into :meth:`urllib3.util.ssl_wrap_socket` to upgrade
|
911 |
+
the connection socket into an SSL socket.
|
912 |
+
"""
|
913 |
+
|
914 |
+
scheme = "https"
|
915 |
+
ConnectionCls = HTTPSConnection
|
916 |
+
|
917 |
+
def __init__(
|
918 |
+
self,
|
919 |
+
host,
|
920 |
+
port=None,
|
921 |
+
strict=False,
|
922 |
+
timeout=Timeout.DEFAULT_TIMEOUT,
|
923 |
+
maxsize=1,
|
924 |
+
block=False,
|
925 |
+
headers=None,
|
926 |
+
retries=None,
|
927 |
+
_proxy=None,
|
928 |
+
_proxy_headers=None,
|
929 |
+
key_file=None,
|
930 |
+
cert_file=None,
|
931 |
+
cert_reqs=None,
|
932 |
+
key_password=None,
|
933 |
+
ca_certs=None,
|
934 |
+
ssl_version=None,
|
935 |
+
assert_hostname=None,
|
936 |
+
assert_fingerprint=None,
|
937 |
+
ca_cert_dir=None,
|
938 |
+
**conn_kw
|
939 |
+
):
|
940 |
+
|
941 |
+
HTTPConnectionPool.__init__(
|
942 |
+
self,
|
943 |
+
host,
|
944 |
+
port,
|
945 |
+
strict,
|
946 |
+
timeout,
|
947 |
+
maxsize,
|
948 |
+
block,
|
949 |
+
headers,
|
950 |
+
retries,
|
951 |
+
_proxy,
|
952 |
+
_proxy_headers,
|
953 |
+
**conn_kw
|
954 |
+
)
|
955 |
+
|
956 |
+
self.key_file = key_file
|
957 |
+
self.cert_file = cert_file
|
958 |
+
self.cert_reqs = cert_reqs
|
959 |
+
self.key_password = key_password
|
960 |
+
self.ca_certs = ca_certs
|
961 |
+
self.ca_cert_dir = ca_cert_dir
|
962 |
+
self.ssl_version = ssl_version
|
963 |
+
self.assert_hostname = assert_hostname
|
964 |
+
self.assert_fingerprint = assert_fingerprint
|
965 |
+
|
966 |
+
def _prepare_conn(self, conn):
|
967 |
+
"""
|
968 |
+
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket`
|
969 |
+
and establish the tunnel if proxy is used.
|
970 |
+
"""
|
971 |
+
|
972 |
+
if isinstance(conn, VerifiedHTTPSConnection):
|
973 |
+
conn.set_cert(
|
974 |
+
key_file=self.key_file,
|
975 |
+
key_password=self.key_password,
|
976 |
+
cert_file=self.cert_file,
|
977 |
+
cert_reqs=self.cert_reqs,
|
978 |
+
ca_certs=self.ca_certs,
|
979 |
+
ca_cert_dir=self.ca_cert_dir,
|
980 |
+
assert_hostname=self.assert_hostname,
|
981 |
+
assert_fingerprint=self.assert_fingerprint,
|
982 |
+
)
|
983 |
+
conn.ssl_version = self.ssl_version
|
984 |
+
return conn
|
985 |
+
|
986 |
+
def _prepare_proxy(self, conn):
|
987 |
+
"""
|
988 |
+
Establishes a tunnel connection through HTTP CONNECT.
|
989 |
+
|
990 |
+
Tunnel connection is established early because otherwise httplib would
|
991 |
+
improperly set Host: header to proxy's IP:port.
|
992 |
+
"""
|
993 |
+
|
994 |
+
conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
|
995 |
+
|
996 |
+
if self.proxy.scheme == "https":
|
997 |
+
conn.tls_in_tls_required = True
|
998 |
+
|
999 |
+
conn.connect()
|
1000 |
+
|
1001 |
+
def _new_conn(self):
|
1002 |
+
"""
|
1003 |
+
Return a fresh :class:`http.client.HTTPSConnection`.
|
1004 |
+
"""
|
1005 |
+
self.num_connections += 1
|
1006 |
+
log.debug(
|
1007 |
+
"Starting new HTTPS connection (%d): %s:%s",
|
1008 |
+
self.num_connections,
|
1009 |
+
self.host,
|
1010 |
+
self.port or "443",
|
1011 |
+
)
|
1012 |
+
|
1013 |
+
if not self.ConnectionCls or self.ConnectionCls is DummyConnection:
|
1014 |
+
raise SSLError(
|
1015 |
+
"Can't connect to HTTPS URL because the SSL module is not available."
|
1016 |
+
)
|
1017 |
+
|
1018 |
+
actual_host = self.host
|
1019 |
+
actual_port = self.port
|
1020 |
+
if self.proxy is not None:
|
1021 |
+
actual_host = self.proxy.host
|
1022 |
+
actual_port = self.proxy.port
|
1023 |
+
|
1024 |
+
conn = self.ConnectionCls(
|
1025 |
+
host=actual_host,
|
1026 |
+
port=actual_port,
|
1027 |
+
timeout=self.timeout.connect_timeout,
|
1028 |
+
strict=self.strict,
|
1029 |
+
cert_file=self.cert_file,
|
1030 |
+
key_file=self.key_file,
|
1031 |
+
key_password=self.key_password,
|
1032 |
+
**self.conn_kw
|
1033 |
+
)
|
1034 |
+
|
1035 |
+
return self._prepare_conn(conn)
|
1036 |
+
|
1037 |
+
def _validate_conn(self, conn):
|
1038 |
+
"""
|
1039 |
+
Called right before a request is made, after the socket is created.
|
1040 |
+
"""
|
1041 |
+
super(HTTPSConnectionPool, self)._validate_conn(conn)
|
1042 |
+
|
1043 |
+
# Force connect early to allow us to validate the connection.
|
1044 |
+
if not getattr(conn, "sock", None): # AppEngine might not have `.sock`
|
1045 |
+
conn.connect()
|
1046 |
+
|
1047 |
+
if not conn.is_verified:
|
1048 |
+
warnings.warn(
|
1049 |
+
(
|
1050 |
+
"Unverified HTTPS request is being made to host '%s'. "
|
1051 |
+
"Adding certificate verification is strongly advised. See: "
|
1052 |
+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
1053 |
+
"#ssl-warnings" % conn.host
|
1054 |
+
),
|
1055 |
+
InsecureRequestWarning,
|
1056 |
+
)
|
1057 |
+
|
1058 |
+
if getattr(conn, "proxy_is_verified", None) is False:
|
1059 |
+
warnings.warn(
|
1060 |
+
(
|
1061 |
+
"Unverified HTTPS connection done to an HTTPS proxy. "
|
1062 |
+
"Adding certificate verification is strongly advised. See: "
|
1063 |
+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
1064 |
+
"#ssl-warnings"
|
1065 |
+
),
|
1066 |
+
InsecureRequestWarning,
|
1067 |
+
)
|
1068 |
+
|
1069 |
+
|
1070 |
+
def connection_from_url(url, **kw):
|
1071 |
+
"""
|
1072 |
+
Given a url, return an :class:`.ConnectionPool` instance of its host.
|
1073 |
+
|
1074 |
+
This is a shortcut for not having to parse out the scheme, host, and port
|
1075 |
+
of the url before creating an :class:`.ConnectionPool` instance.
|
1076 |
+
|
1077 |
+
:param url:
|
1078 |
+
Absolute URL string that must include the scheme. Port is optional.
|
1079 |
+
|
1080 |
+
:param \\**kw:
|
1081 |
+
Passes additional parameters to the constructor of the appropriate
|
1082 |
+
:class:`.ConnectionPool`. Useful for specifying things like
|
1083 |
+
timeout, maxsize, headers, etc.
|
1084 |
+
|
1085 |
+
Example::
|
1086 |
+
|
1087 |
+
>>> conn = connection_from_url('http://google.com/')
|
1088 |
+
>>> r = conn.request('GET', '/')
|
1089 |
+
"""
|
1090 |
+
scheme, host, port = get_host(url)
|
1091 |
+
port = port or port_by_scheme.get(scheme, 80)
|
1092 |
+
if scheme == "https":
|
1093 |
+
return HTTPSConnectionPool(host, port=port, **kw)
|
1094 |
+
else:
|
1095 |
+
return HTTPConnectionPool(host, port=port, **kw)
|
1096 |
+
|
1097 |
+
|
1098 |
+
def _normalize_host(host, scheme):
|
1099 |
+
"""
|
1100 |
+
Normalize hosts for comparisons and use with sockets.
|
1101 |
+
"""
|
1102 |
+
|
1103 |
+
host = normalize_host(host, scheme)
|
1104 |
+
|
1105 |
+
# httplib doesn't like it when we include brackets in IPv6 addresses
|
1106 |
+
# Specifically, if we include brackets but also pass the port then
|
1107 |
+
# httplib crazily doubles up the square brackets on the Host header.
|
1108 |
+
# Instead, we need to make sure we never pass ``None`` as the port.
|
1109 |
+
# However, for backward compatibility reasons we can't actually
|
1110 |
+
# *assert* that. See http://bugs.python.org/issue28539
|
1111 |
+
if host.startswith("[") and host.endswith("]"):
|
1112 |
+
host = host[1:-1]
|
1113 |
+
return host
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
This module provides means to detect the App Engine environment.
|
3 |
+
"""
|
4 |
+
|
5 |
+
import os
|
6 |
+
|
7 |
+
|
8 |
+
def is_appengine():
|
9 |
+
return is_local_appengine() or is_prod_appengine()
|
10 |
+
|
11 |
+
|
12 |
+
def is_appengine_sandbox():
|
13 |
+
"""Reports if the app is running in the first generation sandbox.
|
14 |
+
|
15 |
+
The second generation runtimes are technically still in a sandbox, but it
|
16 |
+
is much less restrictive, so generally you shouldn't need to check for it.
|
17 |
+
see https://cloud.google.com/appengine/docs/standard/runtimes
|
18 |
+
"""
|
19 |
+
return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27"
|
20 |
+
|
21 |
+
|
22 |
+
def is_local_appengine():
|
23 |
+
return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
|
24 |
+
"SERVER_SOFTWARE", ""
|
25 |
+
).startswith("Development/")
|
26 |
+
|
27 |
+
|
28 |
+
def is_prod_appengine():
|
29 |
+
return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
|
30 |
+
"SERVER_SOFTWARE", ""
|
31 |
+
).startswith("Google App Engine/")
|
32 |
+
|
33 |
+
|
34 |
+
def is_prod_appengine_mvms():
|
35 |
+
"""Deprecated."""
|
36 |
+
return False
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (217 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__pycache__/bindings.cpython-310.pyc
ADDED
Binary file (10.7 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__pycache__/low_level.cpython-310.pyc
ADDED
Binary file (9.1 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py
ADDED
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Low-level helpers for the SecureTransport bindings.
|
3 |
+
|
4 |
+
These are Python functions that are not directly related to the high-level APIs
|
5 |
+
but are necessary to get them to work. They include a whole bunch of low-level
|
6 |
+
CoreFoundation messing about and memory management. The concerns in this module
|
7 |
+
are almost entirely about trying to avoid memory leaks and providing
|
8 |
+
appropriate and useful assistance to the higher-level code.
|
9 |
+
"""
|
10 |
+
import base64
|
11 |
+
import ctypes
|
12 |
+
import itertools
|
13 |
+
import os
|
14 |
+
import re
|
15 |
+
import ssl
|
16 |
+
import struct
|
17 |
+
import tempfile
|
18 |
+
|
19 |
+
from .bindings import CFConst, CoreFoundation, Security
|
20 |
+
|
21 |
+
# This regular expression is used to grab PEM data out of a PEM bundle.
|
22 |
+
_PEM_CERTS_RE = re.compile(
|
23 |
+
b"-----BEGIN CERTIFICATE-----\n(.*?)\n-----END CERTIFICATE-----", re.DOTALL
|
24 |
+
)
|
25 |
+
|
26 |
+
|
27 |
+
def _cf_data_from_bytes(bytestring):
|
28 |
+
"""
|
29 |
+
Given a bytestring, create a CFData object from it. This CFData object must
|
30 |
+
be CFReleased by the caller.
|
31 |
+
"""
|
32 |
+
return CoreFoundation.CFDataCreate(
|
33 |
+
CoreFoundation.kCFAllocatorDefault, bytestring, len(bytestring)
|
34 |
+
)
|
35 |
+
|
36 |
+
|
37 |
+
def _cf_dictionary_from_tuples(tuples):
|
38 |
+
"""
|
39 |
+
Given a list of Python tuples, create an associated CFDictionary.
|
40 |
+
"""
|
41 |
+
dictionary_size = len(tuples)
|
42 |
+
|
43 |
+
# We need to get the dictionary keys and values out in the same order.
|
44 |
+
keys = (t[0] for t in tuples)
|
45 |
+
values = (t[1] for t in tuples)
|
46 |
+
cf_keys = (CoreFoundation.CFTypeRef * dictionary_size)(*keys)
|
47 |
+
cf_values = (CoreFoundation.CFTypeRef * dictionary_size)(*values)
|
48 |
+
|
49 |
+
return CoreFoundation.CFDictionaryCreate(
|
50 |
+
CoreFoundation.kCFAllocatorDefault,
|
51 |
+
cf_keys,
|
52 |
+
cf_values,
|
53 |
+
dictionary_size,
|
54 |
+
CoreFoundation.kCFTypeDictionaryKeyCallBacks,
|
55 |
+
CoreFoundation.kCFTypeDictionaryValueCallBacks,
|
56 |
+
)
|
57 |
+
|
58 |
+
|
59 |
+
def _cfstr(py_bstr):
|
60 |
+
"""
|
61 |
+
Given a Python binary data, create a CFString.
|
62 |
+
The string must be CFReleased by the caller.
|
63 |
+
"""
|
64 |
+
c_str = ctypes.c_char_p(py_bstr)
|
65 |
+
cf_str = CoreFoundation.CFStringCreateWithCString(
|
66 |
+
CoreFoundation.kCFAllocatorDefault,
|
67 |
+
c_str,
|
68 |
+
CFConst.kCFStringEncodingUTF8,
|
69 |
+
)
|
70 |
+
return cf_str
|
71 |
+
|
72 |
+
|
73 |
+
def _create_cfstring_array(lst):
|
74 |
+
"""
|
75 |
+
Given a list of Python binary data, create an associated CFMutableArray.
|
76 |
+
The array must be CFReleased by the caller.
|
77 |
+
|
78 |
+
Raises an ssl.SSLError on failure.
|
79 |
+
"""
|
80 |
+
cf_arr = None
|
81 |
+
try:
|
82 |
+
cf_arr = CoreFoundation.CFArrayCreateMutable(
|
83 |
+
CoreFoundation.kCFAllocatorDefault,
|
84 |
+
0,
|
85 |
+
ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
|
86 |
+
)
|
87 |
+
if not cf_arr:
|
88 |
+
raise MemoryError("Unable to allocate memory!")
|
89 |
+
for item in lst:
|
90 |
+
cf_str = _cfstr(item)
|
91 |
+
if not cf_str:
|
92 |
+
raise MemoryError("Unable to allocate memory!")
|
93 |
+
try:
|
94 |
+
CoreFoundation.CFArrayAppendValue(cf_arr, cf_str)
|
95 |
+
finally:
|
96 |
+
CoreFoundation.CFRelease(cf_str)
|
97 |
+
except BaseException as e:
|
98 |
+
if cf_arr:
|
99 |
+
CoreFoundation.CFRelease(cf_arr)
|
100 |
+
raise ssl.SSLError("Unable to allocate array: %s" % (e,))
|
101 |
+
return cf_arr
|
102 |
+
|
103 |
+
|
104 |
+
def _cf_string_to_unicode(value):
|
105 |
+
"""
|
106 |
+
Creates a Unicode string from a CFString object. Used entirely for error
|
107 |
+
reporting.
|
108 |
+
|
109 |
+
Yes, it annoys me quite a lot that this function is this complex.
|
110 |
+
"""
|
111 |
+
value_as_void_p = ctypes.cast(value, ctypes.POINTER(ctypes.c_void_p))
|
112 |
+
|
113 |
+
string = CoreFoundation.CFStringGetCStringPtr(
|
114 |
+
value_as_void_p, CFConst.kCFStringEncodingUTF8
|
115 |
+
)
|
116 |
+
if string is None:
|
117 |
+
buffer = ctypes.create_string_buffer(1024)
|
118 |
+
result = CoreFoundation.CFStringGetCString(
|
119 |
+
value_as_void_p, buffer, 1024, CFConst.kCFStringEncodingUTF8
|
120 |
+
)
|
121 |
+
if not result:
|
122 |
+
raise OSError("Error copying C string from CFStringRef")
|
123 |
+
string = buffer.value
|
124 |
+
if string is not None:
|
125 |
+
string = string.decode("utf-8")
|
126 |
+
return string
|
127 |
+
|
128 |
+
|
129 |
+
def _assert_no_error(error, exception_class=None):
|
130 |
+
"""
|
131 |
+
Checks the return code and throws an exception if there is an error to
|
132 |
+
report
|
133 |
+
"""
|
134 |
+
if error == 0:
|
135 |
+
return
|
136 |
+
|
137 |
+
cf_error_string = Security.SecCopyErrorMessageString(error, None)
|
138 |
+
output = _cf_string_to_unicode(cf_error_string)
|
139 |
+
CoreFoundation.CFRelease(cf_error_string)
|
140 |
+
|
141 |
+
if output is None or output == u"":
|
142 |
+
output = u"OSStatus %s" % error
|
143 |
+
|
144 |
+
if exception_class is None:
|
145 |
+
exception_class = ssl.SSLError
|
146 |
+
|
147 |
+
raise exception_class(output)
|
148 |
+
|
149 |
+
|
150 |
+
def _cert_array_from_pem(pem_bundle):
|
151 |
+
"""
|
152 |
+
Given a bundle of certs in PEM format, turns them into a CFArray of certs
|
153 |
+
that can be used to validate a cert chain.
|
154 |
+
"""
|
155 |
+
# Normalize the PEM bundle's line endings.
|
156 |
+
pem_bundle = pem_bundle.replace(b"\r\n", b"\n")
|
157 |
+
|
158 |
+
der_certs = [
|
159 |
+
base64.b64decode(match.group(1)) for match in _PEM_CERTS_RE.finditer(pem_bundle)
|
160 |
+
]
|
161 |
+
if not der_certs:
|
162 |
+
raise ssl.SSLError("No root certificates specified")
|
163 |
+
|
164 |
+
cert_array = CoreFoundation.CFArrayCreateMutable(
|
165 |
+
CoreFoundation.kCFAllocatorDefault,
|
166 |
+
0,
|
167 |
+
ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
|
168 |
+
)
|
169 |
+
if not cert_array:
|
170 |
+
raise ssl.SSLError("Unable to allocate memory!")
|
171 |
+
|
172 |
+
try:
|
173 |
+
for der_bytes in der_certs:
|
174 |
+
certdata = _cf_data_from_bytes(der_bytes)
|
175 |
+
if not certdata:
|
176 |
+
raise ssl.SSLError("Unable to allocate memory!")
|
177 |
+
cert = Security.SecCertificateCreateWithData(
|
178 |
+
CoreFoundation.kCFAllocatorDefault, certdata
|
179 |
+
)
|
180 |
+
CoreFoundation.CFRelease(certdata)
|
181 |
+
if not cert:
|
182 |
+
raise ssl.SSLError("Unable to build cert object!")
|
183 |
+
|
184 |
+
CoreFoundation.CFArrayAppendValue(cert_array, cert)
|
185 |
+
CoreFoundation.CFRelease(cert)
|
186 |
+
except Exception:
|
187 |
+
# We need to free the array before the exception bubbles further.
|
188 |
+
# We only want to do that if an error occurs: otherwise, the caller
|
189 |
+
# should free.
|
190 |
+
CoreFoundation.CFRelease(cert_array)
|
191 |
+
raise
|
192 |
+
|
193 |
+
return cert_array
|
194 |
+
|
195 |
+
|
196 |
+
def _is_cert(item):
|
197 |
+
"""
|
198 |
+
Returns True if a given CFTypeRef is a certificate.
|
199 |
+
"""
|
200 |
+
expected = Security.SecCertificateGetTypeID()
|
201 |
+
return CoreFoundation.CFGetTypeID(item) == expected
|
202 |
+
|
203 |
+
|
204 |
+
def _is_identity(item):
|
205 |
+
"""
|
206 |
+
Returns True if a given CFTypeRef is an identity.
|
207 |
+
"""
|
208 |
+
expected = Security.SecIdentityGetTypeID()
|
209 |
+
return CoreFoundation.CFGetTypeID(item) == expected
|
210 |
+
|
211 |
+
|
212 |
+
def _temporary_keychain():
|
213 |
+
"""
|
214 |
+
This function creates a temporary Mac keychain that we can use to work with
|
215 |
+
credentials. This keychain uses a one-time password and a temporary file to
|
216 |
+
store the data. We expect to have one keychain per socket. The returned
|
217 |
+
SecKeychainRef must be freed by the caller, including calling
|
218 |
+
SecKeychainDelete.
|
219 |
+
|
220 |
+
Returns a tuple of the SecKeychainRef and the path to the temporary
|
221 |
+
directory that contains it.
|
222 |
+
"""
|
223 |
+
# Unfortunately, SecKeychainCreate requires a path to a keychain. This
|
224 |
+
# means we cannot use mkstemp to use a generic temporary file. Instead,
|
225 |
+
# we're going to create a temporary directory and a filename to use there.
|
226 |
+
# This filename will be 8 random bytes expanded into base64. We also need
|
227 |
+
# some random bytes to password-protect the keychain we're creating, so we
|
228 |
+
# ask for 40 random bytes.
|
229 |
+
random_bytes = os.urandom(40)
|
230 |
+
filename = base64.b16encode(random_bytes[:8]).decode("utf-8")
|
231 |
+
password = base64.b16encode(random_bytes[8:]) # Must be valid UTF-8
|
232 |
+
tempdirectory = tempfile.mkdtemp()
|
233 |
+
|
234 |
+
keychain_path = os.path.join(tempdirectory, filename).encode("utf-8")
|
235 |
+
|
236 |
+
# We now want to create the keychain itself.
|
237 |
+
keychain = Security.SecKeychainRef()
|
238 |
+
status = Security.SecKeychainCreate(
|
239 |
+
keychain_path, len(password), password, False, None, ctypes.byref(keychain)
|
240 |
+
)
|
241 |
+
_assert_no_error(status)
|
242 |
+
|
243 |
+
# Having created the keychain, we want to pass it off to the caller.
|
244 |
+
return keychain, tempdirectory
|
245 |
+
|
246 |
+
|
247 |
+
def _load_items_from_file(keychain, path):
|
248 |
+
"""
|
249 |
+
Given a single file, loads all the trust objects from it into arrays and
|
250 |
+
the keychain.
|
251 |
+
Returns a tuple of lists: the first list is a list of identities, the
|
252 |
+
second a list of certs.
|
253 |
+
"""
|
254 |
+
certificates = []
|
255 |
+
identities = []
|
256 |
+
result_array = None
|
257 |
+
|
258 |
+
with open(path, "rb") as f:
|
259 |
+
raw_filedata = f.read()
|
260 |
+
|
261 |
+
try:
|
262 |
+
filedata = CoreFoundation.CFDataCreate(
|
263 |
+
CoreFoundation.kCFAllocatorDefault, raw_filedata, len(raw_filedata)
|
264 |
+
)
|
265 |
+
result_array = CoreFoundation.CFArrayRef()
|
266 |
+
result = Security.SecItemImport(
|
267 |
+
filedata, # cert data
|
268 |
+
None, # Filename, leaving it out for now
|
269 |
+
None, # What the type of the file is, we don't care
|
270 |
+
None, # what's in the file, we don't care
|
271 |
+
0, # import flags
|
272 |
+
None, # key params, can include passphrase in the future
|
273 |
+
keychain, # The keychain to insert into
|
274 |
+
ctypes.byref(result_array), # Results
|
275 |
+
)
|
276 |
+
_assert_no_error(result)
|
277 |
+
|
278 |
+
# A CFArray is not very useful to us as an intermediary
|
279 |
+
# representation, so we are going to extract the objects we want
|
280 |
+
# and then free the array. We don't need to keep hold of keys: the
|
281 |
+
# keychain already has them!
|
282 |
+
result_count = CoreFoundation.CFArrayGetCount(result_array)
|
283 |
+
for index in range(result_count):
|
284 |
+
item = CoreFoundation.CFArrayGetValueAtIndex(result_array, index)
|
285 |
+
item = ctypes.cast(item, CoreFoundation.CFTypeRef)
|
286 |
+
|
287 |
+
if _is_cert(item):
|
288 |
+
CoreFoundation.CFRetain(item)
|
289 |
+
certificates.append(item)
|
290 |
+
elif _is_identity(item):
|
291 |
+
CoreFoundation.CFRetain(item)
|
292 |
+
identities.append(item)
|
293 |
+
finally:
|
294 |
+
if result_array:
|
295 |
+
CoreFoundation.CFRelease(result_array)
|
296 |
+
|
297 |
+
CoreFoundation.CFRelease(filedata)
|
298 |
+
|
299 |
+
return (identities, certificates)
|
300 |
+
|
301 |
+
|
302 |
+
def _load_client_cert_chain(keychain, *paths):
|
303 |
+
"""
|
304 |
+
Load certificates and maybe keys from a number of files. Has the end goal
|
305 |
+
of returning a CFArray containing one SecIdentityRef, and then zero or more
|
306 |
+
SecCertificateRef objects, suitable for use as a client certificate trust
|
307 |
+
chain.
|
308 |
+
"""
|
309 |
+
# Ok, the strategy.
|
310 |
+
#
|
311 |
+
# This relies on knowing that macOS will not give you a SecIdentityRef
|
312 |
+
# unless you have imported a key into a keychain. This is a somewhat
|
313 |
+
# artificial limitation of macOS (for example, it doesn't necessarily
|
314 |
+
# affect iOS), but there is nothing inside Security.framework that lets you
|
315 |
+
# get a SecIdentityRef without having a key in a keychain.
|
316 |
+
#
|
317 |
+
# So the policy here is we take all the files and iterate them in order.
|
318 |
+
# Each one will use SecItemImport to have one or more objects loaded from
|
319 |
+
# it. We will also point at a keychain that macOS can use to work with the
|
320 |
+
# private key.
|
321 |
+
#
|
322 |
+
# Once we have all the objects, we'll check what we actually have. If we
|
323 |
+
# already have a SecIdentityRef in hand, fab: we'll use that. Otherwise,
|
324 |
+
# we'll take the first certificate (which we assume to be our leaf) and
|
325 |
+
# ask the keychain to give us a SecIdentityRef with that cert's associated
|
326 |
+
# key.
|
327 |
+
#
|
328 |
+
# We'll then return a CFArray containing the trust chain: one
|
329 |
+
# SecIdentityRef and then zero-or-more SecCertificateRef objects. The
|
330 |
+
# responsibility for freeing this CFArray will be with the caller. This
|
331 |
+
# CFArray must remain alive for the entire connection, so in practice it
|
332 |
+
# will be stored with a single SSLSocket, along with the reference to the
|
333 |
+
# keychain.
|
334 |
+
certificates = []
|
335 |
+
identities = []
|
336 |
+
|
337 |
+
# Filter out bad paths.
|
338 |
+
paths = (path for path in paths if path)
|
339 |
+
|
340 |
+
try:
|
341 |
+
for file_path in paths:
|
342 |
+
new_identities, new_certs = _load_items_from_file(keychain, file_path)
|
343 |
+
identities.extend(new_identities)
|
344 |
+
certificates.extend(new_certs)
|
345 |
+
|
346 |
+
# Ok, we have everything. The question is: do we have an identity? If
|
347 |
+
# not, we want to grab one from the first cert we have.
|
348 |
+
if not identities:
|
349 |
+
new_identity = Security.SecIdentityRef()
|
350 |
+
status = Security.SecIdentityCreateWithCertificate(
|
351 |
+
keychain, certificates[0], ctypes.byref(new_identity)
|
352 |
+
)
|
353 |
+
_assert_no_error(status)
|
354 |
+
identities.append(new_identity)
|
355 |
+
|
356 |
+
# We now want to release the original certificate, as we no longer
|
357 |
+
# need it.
|
358 |
+
CoreFoundation.CFRelease(certificates.pop(0))
|
359 |
+
|
360 |
+
# We now need to build a new CFArray that holds the trust chain.
|
361 |
+
trust_chain = CoreFoundation.CFArrayCreateMutable(
|
362 |
+
CoreFoundation.kCFAllocatorDefault,
|
363 |
+
0,
|
364 |
+
ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
|
365 |
+
)
|
366 |
+
for item in itertools.chain(identities, certificates):
|
367 |
+
# ArrayAppendValue does a CFRetain on the item. That's fine,
|
368 |
+
# because the finally block will release our other refs to them.
|
369 |
+
CoreFoundation.CFArrayAppendValue(trust_chain, item)
|
370 |
+
|
371 |
+
return trust_chain
|
372 |
+
finally:
|
373 |
+
for obj in itertools.chain(identities, certificates):
|
374 |
+
CoreFoundation.CFRelease(obj)
|
375 |
+
|
376 |
+
|
377 |
+
TLS_PROTOCOL_VERSIONS = {
|
378 |
+
"SSLv2": (0, 2),
|
379 |
+
"SSLv3": (3, 0),
|
380 |
+
"TLSv1": (3, 1),
|
381 |
+
"TLSv1.1": (3, 2),
|
382 |
+
"TLSv1.2": (3, 3),
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
def _build_tls_unknown_ca_alert(version):
|
387 |
+
"""
|
388 |
+
Builds a TLS alert record for an unknown CA.
|
389 |
+
"""
|
390 |
+
ver_maj, ver_min = TLS_PROTOCOL_VERSIONS[version]
|
391 |
+
severity_fatal = 0x02
|
392 |
+
description_unknown_ca = 0x30
|
393 |
+
msg = struct.pack(">BB", severity_fatal, description_unknown_ca)
|
394 |
+
msg_len = len(msg)
|
395 |
+
record_type_alert = 0x15
|
396 |
+
record = struct.pack(">BBBH", record_type_alert, ver_maj, ver_min, msg_len) + msg
|
397 |
+
return record
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/contrib/appengine.py
ADDED
@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
This module provides a pool manager that uses Google App Engine's
|
3 |
+
`URLFetch Service <https://cloud.google.com/appengine/docs/python/urlfetch>`_.
|
4 |
+
|
5 |
+
Example usage::
|
6 |
+
|
7 |
+
from pip._vendor.urllib3 import PoolManager
|
8 |
+
from pip._vendor.urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox
|
9 |
+
|
10 |
+
if is_appengine_sandbox():
|
11 |
+
# AppEngineManager uses AppEngine's URLFetch API behind the scenes
|
12 |
+
http = AppEngineManager()
|
13 |
+
else:
|
14 |
+
# PoolManager uses a socket-level API behind the scenes
|
15 |
+
http = PoolManager()
|
16 |
+
|
17 |
+
r = http.request('GET', 'https://google.com/')
|
18 |
+
|
19 |
+
There are `limitations <https://cloud.google.com/appengine/docs/python/\
|
20 |
+
urlfetch/#Python_Quotas_and_limits>`_ to the URLFetch service and it may not be
|
21 |
+
the best choice for your application. There are three options for using
|
22 |
+
urllib3 on Google App Engine:
|
23 |
+
|
24 |
+
1. You can use :class:`AppEngineManager` with URLFetch. URLFetch is
|
25 |
+
cost-effective in many circumstances as long as your usage is within the
|
26 |
+
limitations.
|
27 |
+
2. You can use a normal :class:`~urllib3.PoolManager` by enabling sockets.
|
28 |
+
Sockets also have `limitations and restrictions
|
29 |
+
<https://cloud.google.com/appengine/docs/python/sockets/\
|
30 |
+
#limitations-and-restrictions>`_ and have a lower free quota than URLFetch.
|
31 |
+
To use sockets, be sure to specify the following in your ``app.yaml``::
|
32 |
+
|
33 |
+
env_variables:
|
34 |
+
GAE_USE_SOCKETS_HTTPLIB : 'true'
|
35 |
+
|
36 |
+
3. If you are using `App Engine Flexible
|
37 |
+
<https://cloud.google.com/appengine/docs/flexible/>`_, you can use the standard
|
38 |
+
:class:`PoolManager` without any configuration or special environment variables.
|
39 |
+
"""
|
40 |
+
|
41 |
+
from __future__ import absolute_import
|
42 |
+
|
43 |
+
import io
|
44 |
+
import logging
|
45 |
+
import warnings
|
46 |
+
|
47 |
+
from ..exceptions import (
|
48 |
+
HTTPError,
|
49 |
+
HTTPWarning,
|
50 |
+
MaxRetryError,
|
51 |
+
ProtocolError,
|
52 |
+
SSLError,
|
53 |
+
TimeoutError,
|
54 |
+
)
|
55 |
+
from ..packages.six.moves.urllib.parse import urljoin
|
56 |
+
from ..request import RequestMethods
|
57 |
+
from ..response import HTTPResponse
|
58 |
+
from ..util.retry import Retry
|
59 |
+
from ..util.timeout import Timeout
|
60 |
+
from . import _appengine_environ
|
61 |
+
|
62 |
+
try:
|
63 |
+
from google.appengine.api import urlfetch
|
64 |
+
except ImportError:
|
65 |
+
urlfetch = None
|
66 |
+
|
67 |
+
|
68 |
+
log = logging.getLogger(__name__)
|
69 |
+
|
70 |
+
|
71 |
+
class AppEnginePlatformWarning(HTTPWarning):
|
72 |
+
pass
|
73 |
+
|
74 |
+
|
75 |
+
class AppEnginePlatformError(HTTPError):
|
76 |
+
pass
|
77 |
+
|
78 |
+
|
79 |
+
class AppEngineManager(RequestMethods):
|
80 |
+
"""
|
81 |
+
Connection manager for Google App Engine sandbox applications.
|
82 |
+
|
83 |
+
This manager uses the URLFetch service directly instead of using the
|
84 |
+
emulated httplib, and is subject to URLFetch limitations as described in
|
85 |
+
the App Engine documentation `here
|
86 |
+
<https://cloud.google.com/appengine/docs/python/urlfetch>`_.
|
87 |
+
|
88 |
+
Notably it will raise an :class:`AppEnginePlatformError` if:
|
89 |
+
* URLFetch is not available.
|
90 |
+
* If you attempt to use this on App Engine Flexible, as full socket
|
91 |
+
support is available.
|
92 |
+
* If a request size is more than 10 megabytes.
|
93 |
+
* If a response size is more than 32 megabytes.
|
94 |
+
* If you use an unsupported request method such as OPTIONS.
|
95 |
+
|
96 |
+
Beyond those cases, it will raise normal urllib3 errors.
|
97 |
+
"""
|
98 |
+
|
99 |
+
def __init__(
|
100 |
+
self,
|
101 |
+
headers=None,
|
102 |
+
retries=None,
|
103 |
+
validate_certificate=True,
|
104 |
+
urlfetch_retries=True,
|
105 |
+
):
|
106 |
+
if not urlfetch:
|
107 |
+
raise AppEnginePlatformError(
|
108 |
+
"URLFetch is not available in this environment."
|
109 |
+
)
|
110 |
+
|
111 |
+
warnings.warn(
|
112 |
+
"urllib3 is using URLFetch on Google App Engine sandbox instead "
|
113 |
+
"of sockets. To use sockets directly instead of URLFetch see "
|
114 |
+
"https://urllib3.readthedocs.io/en/1.26.x/reference/urllib3.contrib.html.",
|
115 |
+
AppEnginePlatformWarning,
|
116 |
+
)
|
117 |
+
|
118 |
+
RequestMethods.__init__(self, headers)
|
119 |
+
self.validate_certificate = validate_certificate
|
120 |
+
self.urlfetch_retries = urlfetch_retries
|
121 |
+
|
122 |
+
self.retries = retries or Retry.DEFAULT
|
123 |
+
|
124 |
+
def __enter__(self):
|
125 |
+
return self
|
126 |
+
|
127 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
128 |
+
# Return False to re-raise any potential exceptions
|
129 |
+
return False
|
130 |
+
|
131 |
+
def urlopen(
|
132 |
+
self,
|
133 |
+
method,
|
134 |
+
url,
|
135 |
+
body=None,
|
136 |
+
headers=None,
|
137 |
+
retries=None,
|
138 |
+
redirect=True,
|
139 |
+
timeout=Timeout.DEFAULT_TIMEOUT,
|
140 |
+
**response_kw
|
141 |
+
):
|
142 |
+
|
143 |
+
retries = self._get_retries(retries, redirect)
|
144 |
+
|
145 |
+
try:
|
146 |
+
follow_redirects = redirect and retries.redirect != 0 and retries.total
|
147 |
+
response = urlfetch.fetch(
|
148 |
+
url,
|
149 |
+
payload=body,
|
150 |
+
method=method,
|
151 |
+
headers=headers or {},
|
152 |
+
allow_truncated=False,
|
153 |
+
follow_redirects=self.urlfetch_retries and follow_redirects,
|
154 |
+
deadline=self._get_absolute_timeout(timeout),
|
155 |
+
validate_certificate=self.validate_certificate,
|
156 |
+
)
|
157 |
+
except urlfetch.DeadlineExceededError as e:
|
158 |
+
raise TimeoutError(self, e)
|
159 |
+
|
160 |
+
except urlfetch.InvalidURLError as e:
|
161 |
+
if "too large" in str(e):
|
162 |
+
raise AppEnginePlatformError(
|
163 |
+
"URLFetch request too large, URLFetch only "
|
164 |
+
"supports requests up to 10mb in size.",
|
165 |
+
e,
|
166 |
+
)
|
167 |
+
raise ProtocolError(e)
|
168 |
+
|
169 |
+
except urlfetch.DownloadError as e:
|
170 |
+
if "Too many redirects" in str(e):
|
171 |
+
raise MaxRetryError(self, url, reason=e)
|
172 |
+
raise ProtocolError(e)
|
173 |
+
|
174 |
+
except urlfetch.ResponseTooLargeError as e:
|
175 |
+
raise AppEnginePlatformError(
|
176 |
+
"URLFetch response too large, URLFetch only supports"
|
177 |
+
"responses up to 32mb in size.",
|
178 |
+
e,
|
179 |
+
)
|
180 |
+
|
181 |
+
except urlfetch.SSLCertificateError as e:
|
182 |
+
raise SSLError(e)
|
183 |
+
|
184 |
+
except urlfetch.InvalidMethodError as e:
|
185 |
+
raise AppEnginePlatformError(
|
186 |
+
"URLFetch does not support method: %s" % method, e
|
187 |
+
)
|
188 |
+
|
189 |
+
http_response = self._urlfetch_response_to_http_response(
|
190 |
+
response, retries=retries, **response_kw
|
191 |
+
)
|
192 |
+
|
193 |
+
# Handle redirect?
|
194 |
+
redirect_location = redirect and http_response.get_redirect_location()
|
195 |
+
if redirect_location:
|
196 |
+
# Check for redirect response
|
197 |
+
if self.urlfetch_retries and retries.raise_on_redirect:
|
198 |
+
raise MaxRetryError(self, url, "too many redirects")
|
199 |
+
else:
|
200 |
+
if http_response.status == 303:
|
201 |
+
method = "GET"
|
202 |
+
|
203 |
+
try:
|
204 |
+
retries = retries.increment(
|
205 |
+
method, url, response=http_response, _pool=self
|
206 |
+
)
|
207 |
+
except MaxRetryError:
|
208 |
+
if retries.raise_on_redirect:
|
209 |
+
raise MaxRetryError(self, url, "too many redirects")
|
210 |
+
return http_response
|
211 |
+
|
212 |
+
retries.sleep_for_retry(http_response)
|
213 |
+
log.debug("Redirecting %s -> %s", url, redirect_location)
|
214 |
+
redirect_url = urljoin(url, redirect_location)
|
215 |
+
return self.urlopen(
|
216 |
+
method,
|
217 |
+
redirect_url,
|
218 |
+
body,
|
219 |
+
headers,
|
220 |
+
retries=retries,
|
221 |
+
redirect=redirect,
|
222 |
+
timeout=timeout,
|
223 |
+
**response_kw
|
224 |
+
)
|
225 |
+
|
226 |
+
# Check if we should retry the HTTP response.
|
227 |
+
has_retry_after = bool(http_response.getheader("Retry-After"))
|
228 |
+
if retries.is_retry(method, http_response.status, has_retry_after):
|
229 |
+
retries = retries.increment(method, url, response=http_response, _pool=self)
|
230 |
+
log.debug("Retry: %s", url)
|
231 |
+
retries.sleep(http_response)
|
232 |
+
return self.urlopen(
|
233 |
+
method,
|
234 |
+
url,
|
235 |
+
body=body,
|
236 |
+
headers=headers,
|
237 |
+
retries=retries,
|
238 |
+
redirect=redirect,
|
239 |
+
timeout=timeout,
|
240 |
+
**response_kw
|
241 |
+
)
|
242 |
+
|
243 |
+
return http_response
|
244 |
+
|
245 |
+
def _urlfetch_response_to_http_response(self, urlfetch_resp, **response_kw):
|
246 |
+
|
247 |
+
if is_prod_appengine():
|
248 |
+
# Production GAE handles deflate encoding automatically, but does
|
249 |
+
# not remove the encoding header.
|
250 |
+
content_encoding = urlfetch_resp.headers.get("content-encoding")
|
251 |
+
|
252 |
+
if content_encoding == "deflate":
|
253 |
+
del urlfetch_resp.headers["content-encoding"]
|
254 |
+
|
255 |
+
transfer_encoding = urlfetch_resp.headers.get("transfer-encoding")
|
256 |
+
# We have a full response's content,
|
257 |
+
# so let's make sure we don't report ourselves as chunked data.
|
258 |
+
if transfer_encoding == "chunked":
|
259 |
+
encodings = transfer_encoding.split(",")
|
260 |
+
encodings.remove("chunked")
|
261 |
+
urlfetch_resp.headers["transfer-encoding"] = ",".join(encodings)
|
262 |
+
|
263 |
+
original_response = HTTPResponse(
|
264 |
+
# In order for decoding to work, we must present the content as
|
265 |
+
# a file-like object.
|
266 |
+
body=io.BytesIO(urlfetch_resp.content),
|
267 |
+
msg=urlfetch_resp.header_msg,
|
268 |
+
headers=urlfetch_resp.headers,
|
269 |
+
status=urlfetch_resp.status_code,
|
270 |
+
**response_kw
|
271 |
+
)
|
272 |
+
|
273 |
+
return HTTPResponse(
|
274 |
+
body=io.BytesIO(urlfetch_resp.content),
|
275 |
+
headers=urlfetch_resp.headers,
|
276 |
+
status=urlfetch_resp.status_code,
|
277 |
+
original_response=original_response,
|
278 |
+
**response_kw
|
279 |
+
)
|
280 |
+
|
281 |
+
def _get_absolute_timeout(self, timeout):
|
282 |
+
if timeout is Timeout.DEFAULT_TIMEOUT:
|
283 |
+
return None # Defer to URLFetch's default.
|
284 |
+
if isinstance(timeout, Timeout):
|
285 |
+
if timeout._read is not None or timeout._connect is not None:
|
286 |
+
warnings.warn(
|
287 |
+
"URLFetch does not support granular timeout settings, "
|
288 |
+
"reverting to total or default URLFetch timeout.",
|
289 |
+
AppEnginePlatformWarning,
|
290 |
+
)
|
291 |
+
return timeout.total
|
292 |
+
return timeout
|
293 |
+
|
294 |
+
def _get_retries(self, retries, redirect):
|
295 |
+
if not isinstance(retries, Retry):
|
296 |
+
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
|
297 |
+
|
298 |
+
if retries.connect or retries.read or retries.redirect:
|
299 |
+
warnings.warn(
|
300 |
+
"URLFetch only supports total retries and does not "
|
301 |
+
"recognize connect, read, or redirect retry parameters.",
|
302 |
+
AppEnginePlatformWarning,
|
303 |
+
)
|
304 |
+
|
305 |
+
return retries
|
306 |
+
|
307 |
+
|
308 |
+
# Alias methods from _appengine_environ to maintain public API interface.
|
309 |
+
|
310 |
+
is_appengine = _appengine_environ.is_appengine
|
311 |
+
is_appengine_sandbox = _appengine_environ.is_appengine_sandbox
|
312 |
+
is_local_appengine = _appengine_environ.is_local_appengine
|
313 |
+
is_prod_appengine = _appengine_environ.is_prod_appengine
|
314 |
+
is_prod_appengine_mvms = _appengine_environ.is_prod_appengine_mvms
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/exceptions.py
ADDED
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import absolute_import
|
2 |
+
|
3 |
+
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
|
4 |
+
|
5 |
+
# Base Exceptions
|
6 |
+
|
7 |
+
|
8 |
+
class HTTPError(Exception):
|
9 |
+
"""Base exception used by this module."""
|
10 |
+
|
11 |
+
pass
|
12 |
+
|
13 |
+
|
14 |
+
class HTTPWarning(Warning):
|
15 |
+
"""Base warning used by this module."""
|
16 |
+
|
17 |
+
pass
|
18 |
+
|
19 |
+
|
20 |
+
class PoolError(HTTPError):
|
21 |
+
"""Base exception for errors caused within a pool."""
|
22 |
+
|
23 |
+
def __init__(self, pool, message):
|
24 |
+
self.pool = pool
|
25 |
+
HTTPError.__init__(self, "%s: %s" % (pool, message))
|
26 |
+
|
27 |
+
def __reduce__(self):
|
28 |
+
# For pickling purposes.
|
29 |
+
return self.__class__, (None, None)
|
30 |
+
|
31 |
+
|
32 |
+
class RequestError(PoolError):
|
33 |
+
"""Base exception for PoolErrors that have associated URLs."""
|
34 |
+
|
35 |
+
def __init__(self, pool, url, message):
|
36 |
+
self.url = url
|
37 |
+
PoolError.__init__(self, pool, message)
|
38 |
+
|
39 |
+
def __reduce__(self):
|
40 |
+
# For pickling purposes.
|
41 |
+
return self.__class__, (None, self.url, None)
|
42 |
+
|
43 |
+
|
44 |
+
class SSLError(HTTPError):
|
45 |
+
"""Raised when SSL certificate fails in an HTTPS connection."""
|
46 |
+
|
47 |
+
pass
|
48 |
+
|
49 |
+
|
50 |
+
class ProxyError(HTTPError):
|
51 |
+
"""Raised when the connection to a proxy fails."""
|
52 |
+
|
53 |
+
def __init__(self, message, error, *args):
|
54 |
+
super(ProxyError, self).__init__(message, error, *args)
|
55 |
+
self.original_error = error
|
56 |
+
|
57 |
+
|
58 |
+
class DecodeError(HTTPError):
|
59 |
+
"""Raised when automatic decoding based on Content-Type fails."""
|
60 |
+
|
61 |
+
pass
|
62 |
+
|
63 |
+
|
64 |
+
class ProtocolError(HTTPError):
|
65 |
+
"""Raised when something unexpected happens mid-request/response."""
|
66 |
+
|
67 |
+
pass
|
68 |
+
|
69 |
+
|
70 |
+
#: Renamed to ProtocolError but aliased for backwards compatibility.
|
71 |
+
ConnectionError = ProtocolError
|
72 |
+
|
73 |
+
|
74 |
+
# Leaf Exceptions
|
75 |
+
|
76 |
+
|
77 |
+
class MaxRetryError(RequestError):
|
78 |
+
"""Raised when the maximum number of retries is exceeded.
|
79 |
+
|
80 |
+
:param pool: The connection pool
|
81 |
+
:type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
|
82 |
+
:param string url: The requested Url
|
83 |
+
:param exceptions.Exception reason: The underlying error
|
84 |
+
|
85 |
+
"""
|
86 |
+
|
87 |
+
def __init__(self, pool, url, reason=None):
|
88 |
+
self.reason = reason
|
89 |
+
|
90 |
+
message = "Max retries exceeded with url: %s (Caused by %r)" % (url, reason)
|
91 |
+
|
92 |
+
RequestError.__init__(self, pool, url, message)
|
93 |
+
|
94 |
+
|
95 |
+
class HostChangedError(RequestError):
|
96 |
+
"""Raised when an existing pool gets a request for a foreign host."""
|
97 |
+
|
98 |
+
def __init__(self, pool, url, retries=3):
|
99 |
+
message = "Tried to open a foreign host with url: %s" % url
|
100 |
+
RequestError.__init__(self, pool, url, message)
|
101 |
+
self.retries = retries
|
102 |
+
|
103 |
+
|
104 |
+
class TimeoutStateError(HTTPError):
|
105 |
+
"""Raised when passing an invalid state to a timeout"""
|
106 |
+
|
107 |
+
pass
|
108 |
+
|
109 |
+
|
110 |
+
class TimeoutError(HTTPError):
|
111 |
+
"""Raised when a socket timeout error occurs.
|
112 |
+
|
113 |
+
Catching this error will catch both :exc:`ReadTimeoutErrors
|
114 |
+
<ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
|
115 |
+
"""
|
116 |
+
|
117 |
+
pass
|
118 |
+
|
119 |
+
|
120 |
+
class ReadTimeoutError(TimeoutError, RequestError):
|
121 |
+
"""Raised when a socket timeout occurs while receiving data from a server"""
|
122 |
+
|
123 |
+
pass
|
124 |
+
|
125 |
+
|
126 |
+
# This timeout error does not have a URL attached and needs to inherit from the
|
127 |
+
# base HTTPError
|
128 |
+
class ConnectTimeoutError(TimeoutError):
|
129 |
+
"""Raised when a socket timeout occurs while connecting to a server"""
|
130 |
+
|
131 |
+
pass
|
132 |
+
|
133 |
+
|
134 |
+
class NewConnectionError(ConnectTimeoutError, PoolError):
|
135 |
+
"""Raised when we fail to establish a new connection. Usually ECONNREFUSED."""
|
136 |
+
|
137 |
+
pass
|
138 |
+
|
139 |
+
|
140 |
+
class EmptyPoolError(PoolError):
|
141 |
+
"""Raised when a pool runs out of connections and no more are allowed."""
|
142 |
+
|
143 |
+
pass
|
144 |
+
|
145 |
+
|
146 |
+
class ClosedPoolError(PoolError):
|
147 |
+
"""Raised when a request enters a pool after the pool has been closed."""
|
148 |
+
|
149 |
+
pass
|
150 |
+
|
151 |
+
|
152 |
+
class LocationValueError(ValueError, HTTPError):
|
153 |
+
"""Raised when there is something wrong with a given URL input."""
|
154 |
+
|
155 |
+
pass
|
156 |
+
|
157 |
+
|
158 |
+
class LocationParseError(LocationValueError):
|
159 |
+
"""Raised when get_host or similar fails to parse the URL input."""
|
160 |
+
|
161 |
+
def __init__(self, location):
|
162 |
+
message = "Failed to parse: %s" % location
|
163 |
+
HTTPError.__init__(self, message)
|
164 |
+
|
165 |
+
self.location = location
|
166 |
+
|
167 |
+
|
168 |
+
class URLSchemeUnknown(LocationValueError):
|
169 |
+
"""Raised when a URL input has an unsupported scheme."""
|
170 |
+
|
171 |
+
def __init__(self, scheme):
|
172 |
+
message = "Not supported URL scheme %s" % scheme
|
173 |
+
super(URLSchemeUnknown, self).__init__(message)
|
174 |
+
|
175 |
+
self.scheme = scheme
|
176 |
+
|
177 |
+
|
178 |
+
class ResponseError(HTTPError):
|
179 |
+
"""Used as a container for an error reason supplied in a MaxRetryError."""
|
180 |
+
|
181 |
+
GENERIC_ERROR = "too many error responses"
|
182 |
+
SPECIFIC_ERROR = "too many {status_code} error responses"
|
183 |
+
|
184 |
+
|
185 |
+
class SecurityWarning(HTTPWarning):
|
186 |
+
"""Warned when performing security reducing actions"""
|
187 |
+
|
188 |
+
pass
|
189 |
+
|
190 |
+
|
191 |
+
class SubjectAltNameWarning(SecurityWarning):
|
192 |
+
"""Warned when connecting to a host with a certificate missing a SAN."""
|
193 |
+
|
194 |
+
pass
|
195 |
+
|
196 |
+
|
197 |
+
class InsecureRequestWarning(SecurityWarning):
|
198 |
+
"""Warned when making an unverified HTTPS request."""
|
199 |
+
|
200 |
+
pass
|
201 |
+
|
202 |
+
|
203 |
+
class SystemTimeWarning(SecurityWarning):
|
204 |
+
"""Warned when system time is suspected to be wrong"""
|
205 |
+
|
206 |
+
pass
|
207 |
+
|
208 |
+
|
209 |
+
class InsecurePlatformWarning(SecurityWarning):
|
210 |
+
"""Warned when certain TLS/SSL configuration is not available on a platform."""
|
211 |
+
|
212 |
+
pass
|
213 |
+
|
214 |
+
|
215 |
+
class SNIMissingWarning(HTTPWarning):
|
216 |
+
"""Warned when making a HTTPS request without SNI available."""
|
217 |
+
|
218 |
+
pass
|
219 |
+
|
220 |
+
|
221 |
+
class DependencyWarning(HTTPWarning):
|
222 |
+
"""
|
223 |
+
Warned when an attempt is made to import a module with missing optional
|
224 |
+
dependencies.
|
225 |
+
"""
|
226 |
+
|
227 |
+
pass
|
228 |
+
|
229 |
+
|
230 |
+
class ResponseNotChunked(ProtocolError, ValueError):
|
231 |
+
"""Response needs to be chunked in order to read it as chunks."""
|
232 |
+
|
233 |
+
pass
|
234 |
+
|
235 |
+
|
236 |
+
class BodyNotHttplibCompatible(HTTPError):
|
237 |
+
"""
|
238 |
+
Body should be :class:`http.client.HTTPResponse` like
|
239 |
+
(have an fp attribute which returns raw chunks) for read_chunked().
|
240 |
+
"""
|
241 |
+
|
242 |
+
pass
|
243 |
+
|
244 |
+
|
245 |
+
class IncompleteRead(HTTPError, httplib_IncompleteRead):
|
246 |
+
"""
|
247 |
+
Response length doesn't match expected Content-Length
|
248 |
+
|
249 |
+
Subclass of :class:`http.client.IncompleteRead` to allow int value
|
250 |
+
for ``partial`` to avoid creating large objects on streamed reads.
|
251 |
+
"""
|
252 |
+
|
253 |
+
def __init__(self, partial, expected):
|
254 |
+
super(IncompleteRead, self).__init__(partial, expected)
|
255 |
+
|
256 |
+
def __repr__(self):
|
257 |
+
return "IncompleteRead(%i bytes read, %i more expected)" % (
|
258 |
+
self.partial,
|
259 |
+
self.expected,
|
260 |
+
)
|
261 |
+
|
262 |
+
|
263 |
+
class InvalidChunkLength(HTTPError, httplib_IncompleteRead):
|
264 |
+
"""Invalid chunk length in a chunked response."""
|
265 |
+
|
266 |
+
def __init__(self, response, length):
|
267 |
+
super(InvalidChunkLength, self).__init__(
|
268 |
+
response.tell(), response.length_remaining
|
269 |
+
)
|
270 |
+
self.response = response
|
271 |
+
self.length = length
|
272 |
+
|
273 |
+
def __repr__(self):
|
274 |
+
return "InvalidChunkLength(got length %r, %i bytes read)" % (
|
275 |
+
self.length,
|
276 |
+
self.partial,
|
277 |
+
)
|
278 |
+
|
279 |
+
|
280 |
+
class InvalidHeader(HTTPError):
|
281 |
+
"""The header provided was somehow invalid."""
|
282 |
+
|
283 |
+
pass
|
284 |
+
|
285 |
+
|
286 |
+
class ProxySchemeUnknown(AssertionError, URLSchemeUnknown):
|
287 |
+
"""ProxyManager does not support the supplied scheme"""
|
288 |
+
|
289 |
+
# TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
|
290 |
+
|
291 |
+
def __init__(self, scheme):
|
292 |
+
# 'localhost' is here because our URL parser parses
|
293 |
+
# localhost:8080 -> scheme=localhost, remove if we fix this.
|
294 |
+
if scheme == "localhost":
|
295 |
+
scheme = None
|
296 |
+
if scheme is None:
|
297 |
+
message = "Proxy URL had no scheme, should start with http:// or https://"
|
298 |
+
else:
|
299 |
+
message = (
|
300 |
+
"Proxy URL had unsupported scheme %s, should use http:// or https://"
|
301 |
+
% scheme
|
302 |
+
)
|
303 |
+
super(ProxySchemeUnknown, self).__init__(message)
|
304 |
+
|
305 |
+
|
306 |
+
class ProxySchemeUnsupported(ValueError):
|
307 |
+
"""Fetching HTTPS resources through HTTPS proxies is unsupported"""
|
308 |
+
|
309 |
+
pass
|
310 |
+
|
311 |
+
|
312 |
+
class HeaderParsingError(HTTPError):
|
313 |
+
"""Raised by assert_header_parsing, but we convert it to a log.warning statement."""
|
314 |
+
|
315 |
+
def __init__(self, defects, unparsed_data):
|
316 |
+
message = "%s, unparsed data: %r" % (defects or "Unknown", unparsed_data)
|
317 |
+
super(HeaderParsingError, self).__init__(message)
|
318 |
+
|
319 |
+
|
320 |
+
class UnrewindableBodyError(HTTPError):
|
321 |
+
"""urllib3 encountered an error when trying to rewind a body"""
|
322 |
+
|
323 |
+
pass
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/__init__.py
ADDED
File without changes
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (201 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/__pycache__/six.cpython-310.pyc
ADDED
Binary file (27.7 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py
ADDED
File without changes
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (211 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/__pycache__/makefile.cpython-310.pyc
ADDED
Binary file (1.31 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
backports.makefile
|
4 |
+
~~~~~~~~~~~~~~~~~~
|
5 |
+
|
6 |
+
Backports the Python 3 ``socket.makefile`` method for use with anything that
|
7 |
+
wants to create a "fake" socket object.
|
8 |
+
"""
|
9 |
+
import io
|
10 |
+
from socket import SocketIO
|
11 |
+
|
12 |
+
|
13 |
+
def backport_makefile(
|
14 |
+
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
|
15 |
+
):
|
16 |
+
"""
|
17 |
+
Backport of ``socket.makefile`` from Python 3.5.
|
18 |
+
"""
|
19 |
+
if not set(mode) <= {"r", "w", "b"}:
|
20 |
+
raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,))
|
21 |
+
writing = "w" in mode
|
22 |
+
reading = "r" in mode or not writing
|
23 |
+
assert reading or writing
|
24 |
+
binary = "b" in mode
|
25 |
+
rawmode = ""
|
26 |
+
if reading:
|
27 |
+
rawmode += "r"
|
28 |
+
if writing:
|
29 |
+
rawmode += "w"
|
30 |
+
raw = SocketIO(self, rawmode)
|
31 |
+
self._makefile_refs += 1
|
32 |
+
if buffering is None:
|
33 |
+
buffering = -1
|
34 |
+
if buffering < 0:
|
35 |
+
buffering = io.DEFAULT_BUFFER_SIZE
|
36 |
+
if buffering == 0:
|
37 |
+
if not binary:
|
38 |
+
raise ValueError("unbuffered streams must be binary")
|
39 |
+
return raw
|
40 |
+
if reading and writing:
|
41 |
+
buffer = io.BufferedRWPair(raw, raw, buffering)
|
42 |
+
elif reading:
|
43 |
+
buffer = io.BufferedReader(raw, buffering)
|
44 |
+
else:
|
45 |
+
assert writing
|
46 |
+
buffer = io.BufferedWriter(raw, buffering)
|
47 |
+
if binary:
|
48 |
+
return buffer
|
49 |
+
text = io.TextIOWrapper(buffer, encoding, errors, newline)
|
50 |
+
text.mode = mode
|
51 |
+
return text
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/packages/six.py
ADDED
@@ -0,0 +1,1077 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) 2010-2020 Benjamin Peterson
|
2 |
+
#
|
3 |
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
# of this software and associated documentation files (the "Software"), to deal
|
5 |
+
# in the Software without restriction, including without limitation the rights
|
6 |
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
# copies of the Software, and to permit persons to whom the Software is
|
8 |
+
# furnished to do so, subject to the following conditions:
|
9 |
+
#
|
10 |
+
# The above copyright notice and this permission notice shall be included in all
|
11 |
+
# copies or substantial portions of the Software.
|
12 |
+
#
|
13 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19 |
+
# SOFTWARE.
|
20 |
+
|
21 |
+
"""Utilities for writing code that runs on Python 2 and 3"""
|
22 |
+
|
23 |
+
from __future__ import absolute_import
|
24 |
+
|
25 |
+
import functools
|
26 |
+
import itertools
|
27 |
+
import operator
|
28 |
+
import sys
|
29 |
+
import types
|
30 |
+
|
31 |
+
__author__ = "Benjamin Peterson <[email protected]>"
|
32 |
+
__version__ = "1.16.0"
|
33 |
+
|
34 |
+
|
35 |
+
# Useful for very coarse version differentiation.
|
36 |
+
PY2 = sys.version_info[0] == 2
|
37 |
+
PY3 = sys.version_info[0] == 3
|
38 |
+
PY34 = sys.version_info[0:2] >= (3, 4)
|
39 |
+
|
40 |
+
if PY3:
|
41 |
+
string_types = (str,)
|
42 |
+
integer_types = (int,)
|
43 |
+
class_types = (type,)
|
44 |
+
text_type = str
|
45 |
+
binary_type = bytes
|
46 |
+
|
47 |
+
MAXSIZE = sys.maxsize
|
48 |
+
else:
|
49 |
+
string_types = (basestring,)
|
50 |
+
integer_types = (int, long)
|
51 |
+
class_types = (type, types.ClassType)
|
52 |
+
text_type = unicode
|
53 |
+
binary_type = str
|
54 |
+
|
55 |
+
if sys.platform.startswith("java"):
|
56 |
+
# Jython always uses 32 bits.
|
57 |
+
MAXSIZE = int((1 << 31) - 1)
|
58 |
+
else:
|
59 |
+
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
|
60 |
+
class X(object):
|
61 |
+
def __len__(self):
|
62 |
+
return 1 << 31
|
63 |
+
|
64 |
+
try:
|
65 |
+
len(X())
|
66 |
+
except OverflowError:
|
67 |
+
# 32-bit
|
68 |
+
MAXSIZE = int((1 << 31) - 1)
|
69 |
+
else:
|
70 |
+
# 64-bit
|
71 |
+
MAXSIZE = int((1 << 63) - 1)
|
72 |
+
del X
|
73 |
+
|
74 |
+
if PY34:
|
75 |
+
from importlib.util import spec_from_loader
|
76 |
+
else:
|
77 |
+
spec_from_loader = None
|
78 |
+
|
79 |
+
|
80 |
+
def _add_doc(func, doc):
|
81 |
+
"""Add documentation to a function."""
|
82 |
+
func.__doc__ = doc
|
83 |
+
|
84 |
+
|
85 |
+
def _import_module(name):
|
86 |
+
"""Import module, returning the module after the last dot."""
|
87 |
+
__import__(name)
|
88 |
+
return sys.modules[name]
|
89 |
+
|
90 |
+
|
91 |
+
class _LazyDescr(object):
|
92 |
+
def __init__(self, name):
|
93 |
+
self.name = name
|
94 |
+
|
95 |
+
def __get__(self, obj, tp):
|
96 |
+
result = self._resolve()
|
97 |
+
setattr(obj, self.name, result) # Invokes __set__.
|
98 |
+
try:
|
99 |
+
# This is a bit ugly, but it avoids running this again by
|
100 |
+
# removing this descriptor.
|
101 |
+
delattr(obj.__class__, self.name)
|
102 |
+
except AttributeError:
|
103 |
+
pass
|
104 |
+
return result
|
105 |
+
|
106 |
+
|
107 |
+
class MovedModule(_LazyDescr):
|
108 |
+
def __init__(self, name, old, new=None):
|
109 |
+
super(MovedModule, self).__init__(name)
|
110 |
+
if PY3:
|
111 |
+
if new is None:
|
112 |
+
new = name
|
113 |
+
self.mod = new
|
114 |
+
else:
|
115 |
+
self.mod = old
|
116 |
+
|
117 |
+
def _resolve(self):
|
118 |
+
return _import_module(self.mod)
|
119 |
+
|
120 |
+
def __getattr__(self, attr):
|
121 |
+
_module = self._resolve()
|
122 |
+
value = getattr(_module, attr)
|
123 |
+
setattr(self, attr, value)
|
124 |
+
return value
|
125 |
+
|
126 |
+
|
127 |
+
class _LazyModule(types.ModuleType):
|
128 |
+
def __init__(self, name):
|
129 |
+
super(_LazyModule, self).__init__(name)
|
130 |
+
self.__doc__ = self.__class__.__doc__
|
131 |
+
|
132 |
+
def __dir__(self):
|
133 |
+
attrs = ["__doc__", "__name__"]
|
134 |
+
attrs += [attr.name for attr in self._moved_attributes]
|
135 |
+
return attrs
|
136 |
+
|
137 |
+
# Subclasses should override this
|
138 |
+
_moved_attributes = []
|
139 |
+
|
140 |
+
|
141 |
+
class MovedAttribute(_LazyDescr):
|
142 |
+
def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
|
143 |
+
super(MovedAttribute, self).__init__(name)
|
144 |
+
if PY3:
|
145 |
+
if new_mod is None:
|
146 |
+
new_mod = name
|
147 |
+
self.mod = new_mod
|
148 |
+
if new_attr is None:
|
149 |
+
if old_attr is None:
|
150 |
+
new_attr = name
|
151 |
+
else:
|
152 |
+
new_attr = old_attr
|
153 |
+
self.attr = new_attr
|
154 |
+
else:
|
155 |
+
self.mod = old_mod
|
156 |
+
if old_attr is None:
|
157 |
+
old_attr = name
|
158 |
+
self.attr = old_attr
|
159 |
+
|
160 |
+
def _resolve(self):
|
161 |
+
module = _import_module(self.mod)
|
162 |
+
return getattr(module, self.attr)
|
163 |
+
|
164 |
+
|
165 |
+
class _SixMetaPathImporter(object):
|
166 |
+
|
167 |
+
"""
|
168 |
+
A meta path importer to import six.moves and its submodules.
|
169 |
+
|
170 |
+
This class implements a PEP302 finder and loader. It should be compatible
|
171 |
+
with Python 2.5 and all existing versions of Python3
|
172 |
+
"""
|
173 |
+
|
174 |
+
def __init__(self, six_module_name):
|
175 |
+
self.name = six_module_name
|
176 |
+
self.known_modules = {}
|
177 |
+
|
178 |
+
def _add_module(self, mod, *fullnames):
|
179 |
+
for fullname in fullnames:
|
180 |
+
self.known_modules[self.name + "." + fullname] = mod
|
181 |
+
|
182 |
+
def _get_module(self, fullname):
|
183 |
+
return self.known_modules[self.name + "." + fullname]
|
184 |
+
|
185 |
+
def find_module(self, fullname, path=None):
|
186 |
+
if fullname in self.known_modules:
|
187 |
+
return self
|
188 |
+
return None
|
189 |
+
|
190 |
+
def find_spec(self, fullname, path, target=None):
|
191 |
+
if fullname in self.known_modules:
|
192 |
+
return spec_from_loader(fullname, self)
|
193 |
+
return None
|
194 |
+
|
195 |
+
def __get_module(self, fullname):
|
196 |
+
try:
|
197 |
+
return self.known_modules[fullname]
|
198 |
+
except KeyError:
|
199 |
+
raise ImportError("This loader does not know module " + fullname)
|
200 |
+
|
201 |
+
def load_module(self, fullname):
|
202 |
+
try:
|
203 |
+
# in case of a reload
|
204 |
+
return sys.modules[fullname]
|
205 |
+
except KeyError:
|
206 |
+
pass
|
207 |
+
mod = self.__get_module(fullname)
|
208 |
+
if isinstance(mod, MovedModule):
|
209 |
+
mod = mod._resolve()
|
210 |
+
else:
|
211 |
+
mod.__loader__ = self
|
212 |
+
sys.modules[fullname] = mod
|
213 |
+
return mod
|
214 |
+
|
215 |
+
def is_package(self, fullname):
|
216 |
+
"""
|
217 |
+
Return true, if the named module is a package.
|
218 |
+
|
219 |
+
We need this method to get correct spec objects with
|
220 |
+
Python 3.4 (see PEP451)
|
221 |
+
"""
|
222 |
+
return hasattr(self.__get_module(fullname), "__path__")
|
223 |
+
|
224 |
+
def get_code(self, fullname):
|
225 |
+
"""Return None
|
226 |
+
|
227 |
+
Required, if is_package is implemented"""
|
228 |
+
self.__get_module(fullname) # eventually raises ImportError
|
229 |
+
return None
|
230 |
+
|
231 |
+
get_source = get_code # same as get_code
|
232 |
+
|
233 |
+
def create_module(self, spec):
|
234 |
+
return self.load_module(spec.name)
|
235 |
+
|
236 |
+
def exec_module(self, module):
|
237 |
+
pass
|
238 |
+
|
239 |
+
|
240 |
+
_importer = _SixMetaPathImporter(__name__)
|
241 |
+
|
242 |
+
|
243 |
+
class _MovedItems(_LazyModule):
|
244 |
+
|
245 |
+
"""Lazy loading of moved objects"""
|
246 |
+
|
247 |
+
__path__ = [] # mark as package
|
248 |
+
|
249 |
+
|
250 |
+
_moved_attributes = [
|
251 |
+
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
|
252 |
+
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
|
253 |
+
MovedAttribute(
|
254 |
+
"filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"
|
255 |
+
),
|
256 |
+
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
|
257 |
+
MovedAttribute("intern", "__builtin__", "sys"),
|
258 |
+
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
|
259 |
+
MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
|
260 |
+
MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
|
261 |
+
MovedAttribute("getoutput", "commands", "subprocess"),
|
262 |
+
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
|
263 |
+
MovedAttribute(
|
264 |
+
"reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"
|
265 |
+
),
|
266 |
+
MovedAttribute("reduce", "__builtin__", "functools"),
|
267 |
+
MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
|
268 |
+
MovedAttribute("StringIO", "StringIO", "io"),
|
269 |
+
MovedAttribute("UserDict", "UserDict", "collections"),
|
270 |
+
MovedAttribute("UserList", "UserList", "collections"),
|
271 |
+
MovedAttribute("UserString", "UserString", "collections"),
|
272 |
+
MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
|
273 |
+
MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
|
274 |
+
MovedAttribute(
|
275 |
+
"zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"
|
276 |
+
),
|
277 |
+
MovedModule("builtins", "__builtin__"),
|
278 |
+
MovedModule("configparser", "ConfigParser"),
|
279 |
+
MovedModule(
|
280 |
+
"collections_abc",
|
281 |
+
"collections",
|
282 |
+
"collections.abc" if sys.version_info >= (3, 3) else "collections",
|
283 |
+
),
|
284 |
+
MovedModule("copyreg", "copy_reg"),
|
285 |
+
MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
|
286 |
+
MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"),
|
287 |
+
MovedModule(
|
288 |
+
"_dummy_thread",
|
289 |
+
"dummy_thread",
|
290 |
+
"_dummy_thread" if sys.version_info < (3, 9) else "_thread",
|
291 |
+
),
|
292 |
+
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
|
293 |
+
MovedModule("http_cookies", "Cookie", "http.cookies"),
|
294 |
+
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
|
295 |
+
MovedModule("html_parser", "HTMLParser", "html.parser"),
|
296 |
+
MovedModule("http_client", "httplib", "http.client"),
|
297 |
+
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
|
298 |
+
MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"),
|
299 |
+
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
|
300 |
+
MovedModule(
|
301 |
+
"email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"
|
302 |
+
),
|
303 |
+
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
|
304 |
+
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
|
305 |
+
MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
|
306 |
+
MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
|
307 |
+
MovedModule("cPickle", "cPickle", "pickle"),
|
308 |
+
MovedModule("queue", "Queue"),
|
309 |
+
MovedModule("reprlib", "repr"),
|
310 |
+
MovedModule("socketserver", "SocketServer"),
|
311 |
+
MovedModule("_thread", "thread", "_thread"),
|
312 |
+
MovedModule("tkinter", "Tkinter"),
|
313 |
+
MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
|
314 |
+
MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
|
315 |
+
MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
|
316 |
+
MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
|
317 |
+
MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
|
318 |
+
MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
|
319 |
+
MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
|
320 |
+
MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
|
321 |
+
MovedModule("tkinter_colorchooser", "tkColorChooser", "tkinter.colorchooser"),
|
322 |
+
MovedModule("tkinter_commondialog", "tkCommonDialog", "tkinter.commondialog"),
|
323 |
+
MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
|
324 |
+
MovedModule("tkinter_font", "tkFont", "tkinter.font"),
|
325 |
+
MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
|
326 |
+
MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", "tkinter.simpledialog"),
|
327 |
+
MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
|
328 |
+
MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
|
329 |
+
MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
|
330 |
+
MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
|
331 |
+
MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
|
332 |
+
MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
|
333 |
+
]
|
334 |
+
# Add windows specific modules.
|
335 |
+
if sys.platform == "win32":
|
336 |
+
_moved_attributes += [
|
337 |
+
MovedModule("winreg", "_winreg"),
|
338 |
+
]
|
339 |
+
|
340 |
+
for attr in _moved_attributes:
|
341 |
+
setattr(_MovedItems, attr.name, attr)
|
342 |
+
if isinstance(attr, MovedModule):
|
343 |
+
_importer._add_module(attr, "moves." + attr.name)
|
344 |
+
del attr
|
345 |
+
|
346 |
+
_MovedItems._moved_attributes = _moved_attributes
|
347 |
+
|
348 |
+
moves = _MovedItems(__name__ + ".moves")
|
349 |
+
_importer._add_module(moves, "moves")
|
350 |
+
|
351 |
+
|
352 |
+
class Module_six_moves_urllib_parse(_LazyModule):
|
353 |
+
|
354 |
+
"""Lazy loading of moved objects in six.moves.urllib_parse"""
|
355 |
+
|
356 |
+
|
357 |
+
_urllib_parse_moved_attributes = [
|
358 |
+
MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
|
359 |
+
MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
|
360 |
+
MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
|
361 |
+
MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
|
362 |
+
MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
|
363 |
+
MovedAttribute("urljoin", "urlparse", "urllib.parse"),
|
364 |
+
MovedAttribute("urlparse", "urlparse", "urllib.parse"),
|
365 |
+
MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
|
366 |
+
MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
|
367 |
+
MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
|
368 |
+
MovedAttribute("quote", "urllib", "urllib.parse"),
|
369 |
+
MovedAttribute("quote_plus", "urllib", "urllib.parse"),
|
370 |
+
MovedAttribute("unquote", "urllib", "urllib.parse"),
|
371 |
+
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
|
372 |
+
MovedAttribute(
|
373 |
+
"unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"
|
374 |
+
),
|
375 |
+
MovedAttribute("urlencode", "urllib", "urllib.parse"),
|
376 |
+
MovedAttribute("splitquery", "urllib", "urllib.parse"),
|
377 |
+
MovedAttribute("splittag", "urllib", "urllib.parse"),
|
378 |
+
MovedAttribute("splituser", "urllib", "urllib.parse"),
|
379 |
+
MovedAttribute("splitvalue", "urllib", "urllib.parse"),
|
380 |
+
MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
|
381 |
+
MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
|
382 |
+
MovedAttribute("uses_params", "urlparse", "urllib.parse"),
|
383 |
+
MovedAttribute("uses_query", "urlparse", "urllib.parse"),
|
384 |
+
MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
|
385 |
+
]
|
386 |
+
for attr in _urllib_parse_moved_attributes:
|
387 |
+
setattr(Module_six_moves_urllib_parse, attr.name, attr)
|
388 |
+
del attr
|
389 |
+
|
390 |
+
Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
|
391 |
+
|
392 |
+
_importer._add_module(
|
393 |
+
Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
|
394 |
+
"moves.urllib_parse",
|
395 |
+
"moves.urllib.parse",
|
396 |
+
)
|
397 |
+
|
398 |
+
|
399 |
+
class Module_six_moves_urllib_error(_LazyModule):
|
400 |
+
|
401 |
+
"""Lazy loading of moved objects in six.moves.urllib_error"""
|
402 |
+
|
403 |
+
|
404 |
+
_urllib_error_moved_attributes = [
|
405 |
+
MovedAttribute("URLError", "urllib2", "urllib.error"),
|
406 |
+
MovedAttribute("HTTPError", "urllib2", "urllib.error"),
|
407 |
+
MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
|
408 |
+
]
|
409 |
+
for attr in _urllib_error_moved_attributes:
|
410 |
+
setattr(Module_six_moves_urllib_error, attr.name, attr)
|
411 |
+
del attr
|
412 |
+
|
413 |
+
Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
|
414 |
+
|
415 |
+
_importer._add_module(
|
416 |
+
Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
|
417 |
+
"moves.urllib_error",
|
418 |
+
"moves.urllib.error",
|
419 |
+
)
|
420 |
+
|
421 |
+
|
422 |
+
class Module_six_moves_urllib_request(_LazyModule):
|
423 |
+
|
424 |
+
"""Lazy loading of moved objects in six.moves.urllib_request"""
|
425 |
+
|
426 |
+
|
427 |
+
_urllib_request_moved_attributes = [
|
428 |
+
MovedAttribute("urlopen", "urllib2", "urllib.request"),
|
429 |
+
MovedAttribute("install_opener", "urllib2", "urllib.request"),
|
430 |
+
MovedAttribute("build_opener", "urllib2", "urllib.request"),
|
431 |
+
MovedAttribute("pathname2url", "urllib", "urllib.request"),
|
432 |
+
MovedAttribute("url2pathname", "urllib", "urllib.request"),
|
433 |
+
MovedAttribute("getproxies", "urllib", "urllib.request"),
|
434 |
+
MovedAttribute("Request", "urllib2", "urllib.request"),
|
435 |
+
MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
|
436 |
+
MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
|
437 |
+
MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
|
438 |
+
MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
|
439 |
+
MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
|
440 |
+
MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
|
441 |
+
MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
|
442 |
+
MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
|
443 |
+
MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
|
444 |
+
MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
|
445 |
+
MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
|
446 |
+
MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
|
447 |
+
MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
|
448 |
+
MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
|
449 |
+
MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
|
450 |
+
MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
|
451 |
+
MovedAttribute("FileHandler", "urllib2", "urllib.request"),
|
452 |
+
MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
|
453 |
+
MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
|
454 |
+
MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
|
455 |
+
MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
|
456 |
+
MovedAttribute("urlretrieve", "urllib", "urllib.request"),
|
457 |
+
MovedAttribute("urlcleanup", "urllib", "urllib.request"),
|
458 |
+
MovedAttribute("URLopener", "urllib", "urllib.request"),
|
459 |
+
MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
|
460 |
+
MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
|
461 |
+
MovedAttribute("parse_http_list", "urllib2", "urllib.request"),
|
462 |
+
MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"),
|
463 |
+
]
|
464 |
+
for attr in _urllib_request_moved_attributes:
|
465 |
+
setattr(Module_six_moves_urllib_request, attr.name, attr)
|
466 |
+
del attr
|
467 |
+
|
468 |
+
Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
|
469 |
+
|
470 |
+
_importer._add_module(
|
471 |
+
Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
|
472 |
+
"moves.urllib_request",
|
473 |
+
"moves.urllib.request",
|
474 |
+
)
|
475 |
+
|
476 |
+
|
477 |
+
class Module_six_moves_urllib_response(_LazyModule):
|
478 |
+
|
479 |
+
"""Lazy loading of moved objects in six.moves.urllib_response"""
|
480 |
+
|
481 |
+
|
482 |
+
_urllib_response_moved_attributes = [
|
483 |
+
MovedAttribute("addbase", "urllib", "urllib.response"),
|
484 |
+
MovedAttribute("addclosehook", "urllib", "urllib.response"),
|
485 |
+
MovedAttribute("addinfo", "urllib", "urllib.response"),
|
486 |
+
MovedAttribute("addinfourl", "urllib", "urllib.response"),
|
487 |
+
]
|
488 |
+
for attr in _urllib_response_moved_attributes:
|
489 |
+
setattr(Module_six_moves_urllib_response, attr.name, attr)
|
490 |
+
del attr
|
491 |
+
|
492 |
+
Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
|
493 |
+
|
494 |
+
_importer._add_module(
|
495 |
+
Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
|
496 |
+
"moves.urllib_response",
|
497 |
+
"moves.urllib.response",
|
498 |
+
)
|
499 |
+
|
500 |
+
|
501 |
+
class Module_six_moves_urllib_robotparser(_LazyModule):
|
502 |
+
|
503 |
+
"""Lazy loading of moved objects in six.moves.urllib_robotparser"""
|
504 |
+
|
505 |
+
|
506 |
+
_urllib_robotparser_moved_attributes = [
|
507 |
+
MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
|
508 |
+
]
|
509 |
+
for attr in _urllib_robotparser_moved_attributes:
|
510 |
+
setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
|
511 |
+
del attr
|
512 |
+
|
513 |
+
Module_six_moves_urllib_robotparser._moved_attributes = (
|
514 |
+
_urllib_robotparser_moved_attributes
|
515 |
+
)
|
516 |
+
|
517 |
+
_importer._add_module(
|
518 |
+
Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
|
519 |
+
"moves.urllib_robotparser",
|
520 |
+
"moves.urllib.robotparser",
|
521 |
+
)
|
522 |
+
|
523 |
+
|
524 |
+
class Module_six_moves_urllib(types.ModuleType):
|
525 |
+
|
526 |
+
"""Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
|
527 |
+
|
528 |
+
__path__ = [] # mark as package
|
529 |
+
parse = _importer._get_module("moves.urllib_parse")
|
530 |
+
error = _importer._get_module("moves.urllib_error")
|
531 |
+
request = _importer._get_module("moves.urllib_request")
|
532 |
+
response = _importer._get_module("moves.urllib_response")
|
533 |
+
robotparser = _importer._get_module("moves.urllib_robotparser")
|
534 |
+
|
535 |
+
def __dir__(self):
|
536 |
+
return ["parse", "error", "request", "response", "robotparser"]
|
537 |
+
|
538 |
+
|
539 |
+
_importer._add_module(
|
540 |
+
Module_six_moves_urllib(__name__ + ".moves.urllib"), "moves.urllib"
|
541 |
+
)
|
542 |
+
|
543 |
+
|
544 |
+
def add_move(move):
|
545 |
+
"""Add an item to six.moves."""
|
546 |
+
setattr(_MovedItems, move.name, move)
|
547 |
+
|
548 |
+
|
549 |
+
def remove_move(name):
|
550 |
+
"""Remove item from six.moves."""
|
551 |
+
try:
|
552 |
+
delattr(_MovedItems, name)
|
553 |
+
except AttributeError:
|
554 |
+
try:
|
555 |
+
del moves.__dict__[name]
|
556 |
+
except KeyError:
|
557 |
+
raise AttributeError("no such move, %r" % (name,))
|
558 |
+
|
559 |
+
|
560 |
+
if PY3:
|
561 |
+
_meth_func = "__func__"
|
562 |
+
_meth_self = "__self__"
|
563 |
+
|
564 |
+
_func_closure = "__closure__"
|
565 |
+
_func_code = "__code__"
|
566 |
+
_func_defaults = "__defaults__"
|
567 |
+
_func_globals = "__globals__"
|
568 |
+
else:
|
569 |
+
_meth_func = "im_func"
|
570 |
+
_meth_self = "im_self"
|
571 |
+
|
572 |
+
_func_closure = "func_closure"
|
573 |
+
_func_code = "func_code"
|
574 |
+
_func_defaults = "func_defaults"
|
575 |
+
_func_globals = "func_globals"
|
576 |
+
|
577 |
+
|
578 |
+
try:
|
579 |
+
advance_iterator = next
|
580 |
+
except NameError:
|
581 |
+
|
582 |
+
def advance_iterator(it):
|
583 |
+
return it.next()
|
584 |
+
|
585 |
+
|
586 |
+
next = advance_iterator
|
587 |
+
|
588 |
+
|
589 |
+
try:
|
590 |
+
callable = callable
|
591 |
+
except NameError:
|
592 |
+
|
593 |
+
def callable(obj):
|
594 |
+
return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
|
595 |
+
|
596 |
+
|
597 |
+
if PY3:
|
598 |
+
|
599 |
+
def get_unbound_function(unbound):
|
600 |
+
return unbound
|
601 |
+
|
602 |
+
create_bound_method = types.MethodType
|
603 |
+
|
604 |
+
def create_unbound_method(func, cls):
|
605 |
+
return func
|
606 |
+
|
607 |
+
Iterator = object
|
608 |
+
else:
|
609 |
+
|
610 |
+
def get_unbound_function(unbound):
|
611 |
+
return unbound.im_func
|
612 |
+
|
613 |
+
def create_bound_method(func, obj):
|
614 |
+
return types.MethodType(func, obj, obj.__class__)
|
615 |
+
|
616 |
+
def create_unbound_method(func, cls):
|
617 |
+
return types.MethodType(func, None, cls)
|
618 |
+
|
619 |
+
class Iterator(object):
|
620 |
+
def next(self):
|
621 |
+
return type(self).__next__(self)
|
622 |
+
|
623 |
+
callable = callable
|
624 |
+
_add_doc(
|
625 |
+
get_unbound_function, """Get the function out of a possibly unbound function"""
|
626 |
+
)
|
627 |
+
|
628 |
+
|
629 |
+
get_method_function = operator.attrgetter(_meth_func)
|
630 |
+
get_method_self = operator.attrgetter(_meth_self)
|
631 |
+
get_function_closure = operator.attrgetter(_func_closure)
|
632 |
+
get_function_code = operator.attrgetter(_func_code)
|
633 |
+
get_function_defaults = operator.attrgetter(_func_defaults)
|
634 |
+
get_function_globals = operator.attrgetter(_func_globals)
|
635 |
+
|
636 |
+
|
637 |
+
if PY3:
|
638 |
+
|
639 |
+
def iterkeys(d, **kw):
|
640 |
+
return iter(d.keys(**kw))
|
641 |
+
|
642 |
+
def itervalues(d, **kw):
|
643 |
+
return iter(d.values(**kw))
|
644 |
+
|
645 |
+
def iteritems(d, **kw):
|
646 |
+
return iter(d.items(**kw))
|
647 |
+
|
648 |
+
def iterlists(d, **kw):
|
649 |
+
return iter(d.lists(**kw))
|
650 |
+
|
651 |
+
viewkeys = operator.methodcaller("keys")
|
652 |
+
|
653 |
+
viewvalues = operator.methodcaller("values")
|
654 |
+
|
655 |
+
viewitems = operator.methodcaller("items")
|
656 |
+
else:
|
657 |
+
|
658 |
+
def iterkeys(d, **kw):
|
659 |
+
return d.iterkeys(**kw)
|
660 |
+
|
661 |
+
def itervalues(d, **kw):
|
662 |
+
return d.itervalues(**kw)
|
663 |
+
|
664 |
+
def iteritems(d, **kw):
|
665 |
+
return d.iteritems(**kw)
|
666 |
+
|
667 |
+
def iterlists(d, **kw):
|
668 |
+
return d.iterlists(**kw)
|
669 |
+
|
670 |
+
viewkeys = operator.methodcaller("viewkeys")
|
671 |
+
|
672 |
+
viewvalues = operator.methodcaller("viewvalues")
|
673 |
+
|
674 |
+
viewitems = operator.methodcaller("viewitems")
|
675 |
+
|
676 |
+
_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
|
677 |
+
_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
|
678 |
+
_add_doc(iteritems, "Return an iterator over the (key, value) pairs of a dictionary.")
|
679 |
+
_add_doc(
|
680 |
+
iterlists, "Return an iterator over the (key, [values]) pairs of a dictionary."
|
681 |
+
)
|
682 |
+
|
683 |
+
|
684 |
+
if PY3:
|
685 |
+
|
686 |
+
def b(s):
|
687 |
+
return s.encode("latin-1")
|
688 |
+
|
689 |
+
def u(s):
|
690 |
+
return s
|
691 |
+
|
692 |
+
unichr = chr
|
693 |
+
import struct
|
694 |
+
|
695 |
+
int2byte = struct.Struct(">B").pack
|
696 |
+
del struct
|
697 |
+
byte2int = operator.itemgetter(0)
|
698 |
+
indexbytes = operator.getitem
|
699 |
+
iterbytes = iter
|
700 |
+
import io
|
701 |
+
|
702 |
+
StringIO = io.StringIO
|
703 |
+
BytesIO = io.BytesIO
|
704 |
+
del io
|
705 |
+
_assertCountEqual = "assertCountEqual"
|
706 |
+
if sys.version_info[1] <= 1:
|
707 |
+
_assertRaisesRegex = "assertRaisesRegexp"
|
708 |
+
_assertRegex = "assertRegexpMatches"
|
709 |
+
_assertNotRegex = "assertNotRegexpMatches"
|
710 |
+
else:
|
711 |
+
_assertRaisesRegex = "assertRaisesRegex"
|
712 |
+
_assertRegex = "assertRegex"
|
713 |
+
_assertNotRegex = "assertNotRegex"
|
714 |
+
else:
|
715 |
+
|
716 |
+
def b(s):
|
717 |
+
return s
|
718 |
+
|
719 |
+
# Workaround for standalone backslash
|
720 |
+
|
721 |
+
def u(s):
|
722 |
+
return unicode(s.replace(r"\\", r"\\\\"), "unicode_escape")
|
723 |
+
|
724 |
+
unichr = unichr
|
725 |
+
int2byte = chr
|
726 |
+
|
727 |
+
def byte2int(bs):
|
728 |
+
return ord(bs[0])
|
729 |
+
|
730 |
+
def indexbytes(buf, i):
|
731 |
+
return ord(buf[i])
|
732 |
+
|
733 |
+
iterbytes = functools.partial(itertools.imap, ord)
|
734 |
+
import StringIO
|
735 |
+
|
736 |
+
StringIO = BytesIO = StringIO.StringIO
|
737 |
+
_assertCountEqual = "assertItemsEqual"
|
738 |
+
_assertRaisesRegex = "assertRaisesRegexp"
|
739 |
+
_assertRegex = "assertRegexpMatches"
|
740 |
+
_assertNotRegex = "assertNotRegexpMatches"
|
741 |
+
_add_doc(b, """Byte literal""")
|
742 |
+
_add_doc(u, """Text literal""")
|
743 |
+
|
744 |
+
|
745 |
+
def assertCountEqual(self, *args, **kwargs):
|
746 |
+
return getattr(self, _assertCountEqual)(*args, **kwargs)
|
747 |
+
|
748 |
+
|
749 |
+
def assertRaisesRegex(self, *args, **kwargs):
|
750 |
+
return getattr(self, _assertRaisesRegex)(*args, **kwargs)
|
751 |
+
|
752 |
+
|
753 |
+
def assertRegex(self, *args, **kwargs):
|
754 |
+
return getattr(self, _assertRegex)(*args, **kwargs)
|
755 |
+
|
756 |
+
|
757 |
+
def assertNotRegex(self, *args, **kwargs):
|
758 |
+
return getattr(self, _assertNotRegex)(*args, **kwargs)
|
759 |
+
|
760 |
+
|
761 |
+
if PY3:
|
762 |
+
exec_ = getattr(moves.builtins, "exec")
|
763 |
+
|
764 |
+
def reraise(tp, value, tb=None):
|
765 |
+
try:
|
766 |
+
if value is None:
|
767 |
+
value = tp()
|
768 |
+
if value.__traceback__ is not tb:
|
769 |
+
raise value.with_traceback(tb)
|
770 |
+
raise value
|
771 |
+
finally:
|
772 |
+
value = None
|
773 |
+
tb = None
|
774 |
+
|
775 |
+
|
776 |
+
else:
|
777 |
+
|
778 |
+
def exec_(_code_, _globs_=None, _locs_=None):
|
779 |
+
"""Execute code in a namespace."""
|
780 |
+
if _globs_ is None:
|
781 |
+
frame = sys._getframe(1)
|
782 |
+
_globs_ = frame.f_globals
|
783 |
+
if _locs_ is None:
|
784 |
+
_locs_ = frame.f_locals
|
785 |
+
del frame
|
786 |
+
elif _locs_ is None:
|
787 |
+
_locs_ = _globs_
|
788 |
+
exec ("""exec _code_ in _globs_, _locs_""")
|
789 |
+
|
790 |
+
exec_(
|
791 |
+
"""def reraise(tp, value, tb=None):
|
792 |
+
try:
|
793 |
+
raise tp, value, tb
|
794 |
+
finally:
|
795 |
+
tb = None
|
796 |
+
"""
|
797 |
+
)
|
798 |
+
|
799 |
+
|
800 |
+
if sys.version_info[:2] > (3,):
|
801 |
+
exec_(
|
802 |
+
"""def raise_from(value, from_value):
|
803 |
+
try:
|
804 |
+
raise value from from_value
|
805 |
+
finally:
|
806 |
+
value = None
|
807 |
+
"""
|
808 |
+
)
|
809 |
+
else:
|
810 |
+
|
811 |
+
def raise_from(value, from_value):
|
812 |
+
raise value
|
813 |
+
|
814 |
+
|
815 |
+
print_ = getattr(moves.builtins, "print", None)
|
816 |
+
if print_ is None:
|
817 |
+
|
818 |
+
def print_(*args, **kwargs):
|
819 |
+
"""The new-style print function for Python 2.4 and 2.5."""
|
820 |
+
fp = kwargs.pop("file", sys.stdout)
|
821 |
+
if fp is None:
|
822 |
+
return
|
823 |
+
|
824 |
+
def write(data):
|
825 |
+
if not isinstance(data, basestring):
|
826 |
+
data = str(data)
|
827 |
+
# If the file has an encoding, encode unicode with it.
|
828 |
+
if (
|
829 |
+
isinstance(fp, file)
|
830 |
+
and isinstance(data, unicode)
|
831 |
+
and fp.encoding is not None
|
832 |
+
):
|
833 |
+
errors = getattr(fp, "errors", None)
|
834 |
+
if errors is None:
|
835 |
+
errors = "strict"
|
836 |
+
data = data.encode(fp.encoding, errors)
|
837 |
+
fp.write(data)
|
838 |
+
|
839 |
+
want_unicode = False
|
840 |
+
sep = kwargs.pop("sep", None)
|
841 |
+
if sep is not None:
|
842 |
+
if isinstance(sep, unicode):
|
843 |
+
want_unicode = True
|
844 |
+
elif not isinstance(sep, str):
|
845 |
+
raise TypeError("sep must be None or a string")
|
846 |
+
end = kwargs.pop("end", None)
|
847 |
+
if end is not None:
|
848 |
+
if isinstance(end, unicode):
|
849 |
+
want_unicode = True
|
850 |
+
elif not isinstance(end, str):
|
851 |
+
raise TypeError("end must be None or a string")
|
852 |
+
if kwargs:
|
853 |
+
raise TypeError("invalid keyword arguments to print()")
|
854 |
+
if not want_unicode:
|
855 |
+
for arg in args:
|
856 |
+
if isinstance(arg, unicode):
|
857 |
+
want_unicode = True
|
858 |
+
break
|
859 |
+
if want_unicode:
|
860 |
+
newline = unicode("\n")
|
861 |
+
space = unicode(" ")
|
862 |
+
else:
|
863 |
+
newline = "\n"
|
864 |
+
space = " "
|
865 |
+
if sep is None:
|
866 |
+
sep = space
|
867 |
+
if end is None:
|
868 |
+
end = newline
|
869 |
+
for i, arg in enumerate(args):
|
870 |
+
if i:
|
871 |
+
write(sep)
|
872 |
+
write(arg)
|
873 |
+
write(end)
|
874 |
+
|
875 |
+
|
876 |
+
if sys.version_info[:2] < (3, 3):
|
877 |
+
_print = print_
|
878 |
+
|
879 |
+
def print_(*args, **kwargs):
|
880 |
+
fp = kwargs.get("file", sys.stdout)
|
881 |
+
flush = kwargs.pop("flush", False)
|
882 |
+
_print(*args, **kwargs)
|
883 |
+
if flush and fp is not None:
|
884 |
+
fp.flush()
|
885 |
+
|
886 |
+
|
887 |
+
_add_doc(reraise, """Reraise an exception.""")
|
888 |
+
|
889 |
+
if sys.version_info[0:2] < (3, 4):
|
890 |
+
# This does exactly the same what the :func:`py3:functools.update_wrapper`
|
891 |
+
# function does on Python versions after 3.2. It sets the ``__wrapped__``
|
892 |
+
# attribute on ``wrapper`` object and it doesn't raise an error if any of
|
893 |
+
# the attributes mentioned in ``assigned`` and ``updated`` are missing on
|
894 |
+
# ``wrapped`` object.
|
895 |
+
def _update_wrapper(
|
896 |
+
wrapper,
|
897 |
+
wrapped,
|
898 |
+
assigned=functools.WRAPPER_ASSIGNMENTS,
|
899 |
+
updated=functools.WRAPPER_UPDATES,
|
900 |
+
):
|
901 |
+
for attr in assigned:
|
902 |
+
try:
|
903 |
+
value = getattr(wrapped, attr)
|
904 |
+
except AttributeError:
|
905 |
+
continue
|
906 |
+
else:
|
907 |
+
setattr(wrapper, attr, value)
|
908 |
+
for attr in updated:
|
909 |
+
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
|
910 |
+
wrapper.__wrapped__ = wrapped
|
911 |
+
return wrapper
|
912 |
+
|
913 |
+
_update_wrapper.__doc__ = functools.update_wrapper.__doc__
|
914 |
+
|
915 |
+
def wraps(
|
916 |
+
wrapped,
|
917 |
+
assigned=functools.WRAPPER_ASSIGNMENTS,
|
918 |
+
updated=functools.WRAPPER_UPDATES,
|
919 |
+
):
|
920 |
+
return functools.partial(
|
921 |
+
_update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated
|
922 |
+
)
|
923 |
+
|
924 |
+
wraps.__doc__ = functools.wraps.__doc__
|
925 |
+
|
926 |
+
else:
|
927 |
+
wraps = functools.wraps
|
928 |
+
|
929 |
+
|
930 |
+
def with_metaclass(meta, *bases):
|
931 |
+
"""Create a base class with a metaclass."""
|
932 |
+
# This requires a bit of explanation: the basic idea is to make a dummy
|
933 |
+
# metaclass for one level of class instantiation that replaces itself with
|
934 |
+
# the actual metaclass.
|
935 |
+
class metaclass(type):
|
936 |
+
def __new__(cls, name, this_bases, d):
|
937 |
+
if sys.version_info[:2] >= (3, 7):
|
938 |
+
# This version introduced PEP 560 that requires a bit
|
939 |
+
# of extra care (we mimic what is done by __build_class__).
|
940 |
+
resolved_bases = types.resolve_bases(bases)
|
941 |
+
if resolved_bases is not bases:
|
942 |
+
d["__orig_bases__"] = bases
|
943 |
+
else:
|
944 |
+
resolved_bases = bases
|
945 |
+
return meta(name, resolved_bases, d)
|
946 |
+
|
947 |
+
@classmethod
|
948 |
+
def __prepare__(cls, name, this_bases):
|
949 |
+
return meta.__prepare__(name, bases)
|
950 |
+
|
951 |
+
return type.__new__(metaclass, "temporary_class", (), {})
|
952 |
+
|
953 |
+
|
954 |
+
def add_metaclass(metaclass):
|
955 |
+
"""Class decorator for creating a class with a metaclass."""
|
956 |
+
|
957 |
+
def wrapper(cls):
|
958 |
+
orig_vars = cls.__dict__.copy()
|
959 |
+
slots = orig_vars.get("__slots__")
|
960 |
+
if slots is not None:
|
961 |
+
if isinstance(slots, str):
|
962 |
+
slots = [slots]
|
963 |
+
for slots_var in slots:
|
964 |
+
orig_vars.pop(slots_var)
|
965 |
+
orig_vars.pop("__dict__", None)
|
966 |
+
orig_vars.pop("__weakref__", None)
|
967 |
+
if hasattr(cls, "__qualname__"):
|
968 |
+
orig_vars["__qualname__"] = cls.__qualname__
|
969 |
+
return metaclass(cls.__name__, cls.__bases__, orig_vars)
|
970 |
+
|
971 |
+
return wrapper
|
972 |
+
|
973 |
+
|
974 |
+
def ensure_binary(s, encoding="utf-8", errors="strict"):
|
975 |
+
"""Coerce **s** to six.binary_type.
|
976 |
+
|
977 |
+
For Python 2:
|
978 |
+
- `unicode` -> encoded to `str`
|
979 |
+
- `str` -> `str`
|
980 |
+
|
981 |
+
For Python 3:
|
982 |
+
- `str` -> encoded to `bytes`
|
983 |
+
- `bytes` -> `bytes`
|
984 |
+
"""
|
985 |
+
if isinstance(s, binary_type):
|
986 |
+
return s
|
987 |
+
if isinstance(s, text_type):
|
988 |
+
return s.encode(encoding, errors)
|
989 |
+
raise TypeError("not expecting type '%s'" % type(s))
|
990 |
+
|
991 |
+
|
992 |
+
def ensure_str(s, encoding="utf-8", errors="strict"):
|
993 |
+
"""Coerce *s* to `str`.
|
994 |
+
|
995 |
+
For Python 2:
|
996 |
+
- `unicode` -> encoded to `str`
|
997 |
+
- `str` -> `str`
|
998 |
+
|
999 |
+
For Python 3:
|
1000 |
+
- `str` -> `str`
|
1001 |
+
- `bytes` -> decoded to `str`
|
1002 |
+
"""
|
1003 |
+
# Optimization: Fast return for the common case.
|
1004 |
+
if type(s) is str:
|
1005 |
+
return s
|
1006 |
+
if PY2 and isinstance(s, text_type):
|
1007 |
+
return s.encode(encoding, errors)
|
1008 |
+
elif PY3 and isinstance(s, binary_type):
|
1009 |
+
return s.decode(encoding, errors)
|
1010 |
+
elif not isinstance(s, (text_type, binary_type)):
|
1011 |
+
raise TypeError("not expecting type '%s'" % type(s))
|
1012 |
+
return s
|
1013 |
+
|
1014 |
+
|
1015 |
+
def ensure_text(s, encoding="utf-8", errors="strict"):
|
1016 |
+
"""Coerce *s* to six.text_type.
|
1017 |
+
|
1018 |
+
For Python 2:
|
1019 |
+
- `unicode` -> `unicode`
|
1020 |
+
- `str` -> `unicode`
|
1021 |
+
|
1022 |
+
For Python 3:
|
1023 |
+
- `str` -> `str`
|
1024 |
+
- `bytes` -> decoded to `str`
|
1025 |
+
"""
|
1026 |
+
if isinstance(s, binary_type):
|
1027 |
+
return s.decode(encoding, errors)
|
1028 |
+
elif isinstance(s, text_type):
|
1029 |
+
return s
|
1030 |
+
else:
|
1031 |
+
raise TypeError("not expecting type '%s'" % type(s))
|
1032 |
+
|
1033 |
+
|
1034 |
+
def python_2_unicode_compatible(klass):
|
1035 |
+
"""
|
1036 |
+
A class decorator that defines __unicode__ and __str__ methods under Python 2.
|
1037 |
+
Under Python 3 it does nothing.
|
1038 |
+
|
1039 |
+
To support Python 2 and 3 with a single code base, define a __str__ method
|
1040 |
+
returning text and apply this decorator to the class.
|
1041 |
+
"""
|
1042 |
+
if PY2:
|
1043 |
+
if "__str__" not in klass.__dict__:
|
1044 |
+
raise ValueError(
|
1045 |
+
"@python_2_unicode_compatible cannot be applied "
|
1046 |
+
"to %s because it doesn't define __str__()." % klass.__name__
|
1047 |
+
)
|
1048 |
+
klass.__unicode__ = klass.__str__
|
1049 |
+
klass.__str__ = lambda self: self.__unicode__().encode("utf-8")
|
1050 |
+
return klass
|
1051 |
+
|
1052 |
+
|
1053 |
+
# Complete the moves implementation.
|
1054 |
+
# This code is at the end of this module to speed up module loading.
|
1055 |
+
# Turn this module into a package.
|
1056 |
+
__path__ = [] # required for PEP 302 and PEP 451
|
1057 |
+
__package__ = __name__ # see PEP 366 @ReservedAssignment
|
1058 |
+
if globals().get("__spec__") is not None:
|
1059 |
+
__spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable
|
1060 |
+
# Remove other six meta path importers, since they cause problems. This can
|
1061 |
+
# happen if six is removed from sys.modules and then reloaded. (Setuptools does
|
1062 |
+
# this for some reason.)
|
1063 |
+
if sys.meta_path:
|
1064 |
+
for i, importer in enumerate(sys.meta_path):
|
1065 |
+
# Here's some real nastiness: Another "instance" of the six module might
|
1066 |
+
# be floating around. Therefore, we can't use isinstance() to check for
|
1067 |
+
# the six meta path importer, since the other six instance will have
|
1068 |
+
# inserted an importer with different class.
|
1069 |
+
if (
|
1070 |
+
type(importer).__name__ == "_SixMetaPathImporter"
|
1071 |
+
and importer.name == __name__
|
1072 |
+
):
|
1073 |
+
del sys.meta_path[i]
|
1074 |
+
break
|
1075 |
+
del i, importer
|
1076 |
+
# Finally, add the importer to the meta path import hook.
|
1077 |
+
sys.meta_path.append(_importer)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/poolmanager.py
ADDED
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, RecentlyUsedContainer
|
8 |
+
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme
|
9 |
+
from .exceptions import (
|
10 |
+
LocationValueError,
|
11 |
+
MaxRetryError,
|
12 |
+
ProxySchemeUnknown,
|
13 |
+
ProxySchemeUnsupported,
|
14 |
+
URLSchemeUnknown,
|
15 |
+
)
|
16 |
+
from .packages import six
|
17 |
+
from .packages.six.moves.urllib.parse import urljoin
|
18 |
+
from .request import RequestMethods
|
19 |
+
from .util.proxy import connection_requires_http_tunnel
|
20 |
+
from .util.retry import Retry
|
21 |
+
from .util.url import parse_url
|
22 |
+
|
23 |
+
__all__ = ["PoolManager", "ProxyManager", "proxy_from_url"]
|
24 |
+
|
25 |
+
|
26 |
+
log = logging.getLogger(__name__)
|
27 |
+
|
28 |
+
SSL_KEYWORDS = (
|
29 |
+
"key_file",
|
30 |
+
"cert_file",
|
31 |
+
"cert_reqs",
|
32 |
+
"ca_certs",
|
33 |
+
"ssl_version",
|
34 |
+
"ca_cert_dir",
|
35 |
+
"ssl_context",
|
36 |
+
"key_password",
|
37 |
+
)
|
38 |
+
|
39 |
+
# All known keyword arguments that could be provided to the pool manager, its
|
40 |
+
# pools, or the underlying connections. This is used to construct a pool key.
|
41 |
+
_key_fields = (
|
42 |
+
"key_scheme", # str
|
43 |
+
"key_host", # str
|
44 |
+
"key_port", # int
|
45 |
+
"key_timeout", # int or float or Timeout
|
46 |
+
"key_retries", # int or Retry
|
47 |
+
"key_strict", # bool
|
48 |
+
"key_block", # bool
|
49 |
+
"key_source_address", # str
|
50 |
+
"key_key_file", # str
|
51 |
+
"key_key_password", # str
|
52 |
+
"key_cert_file", # str
|
53 |
+
"key_cert_reqs", # str
|
54 |
+
"key_ca_certs", # str
|
55 |
+
"key_ssl_version", # str
|
56 |
+
"key_ca_cert_dir", # str
|
57 |
+
"key_ssl_context", # instance of ssl.SSLContext or urllib3.util.ssl_.SSLContext
|
58 |
+
"key_maxsize", # int
|
59 |
+
"key_headers", # dict
|
60 |
+
"key__proxy", # parsed proxy url
|
61 |
+
"key__proxy_headers", # dict
|
62 |
+
"key__proxy_config", # class
|
63 |
+
"key_socket_options", # list of (level (int), optname (int), value (int or str)) tuples
|
64 |
+
"key__socks_options", # dict
|
65 |
+
"key_assert_hostname", # bool or string
|
66 |
+
"key_assert_fingerprint", # str
|
67 |
+
"key_server_hostname", # str
|
68 |
+
)
|
69 |
+
|
70 |
+
#: The namedtuple class used to construct keys for the connection pool.
|
71 |
+
#: All custom key schemes should include the fields in this key at a minimum.
|
72 |
+
PoolKey = collections.namedtuple("PoolKey", _key_fields)
|
73 |
+
|
74 |
+
_proxy_config_fields = ("ssl_context", "use_forwarding_for_https")
|
75 |
+
ProxyConfig = collections.namedtuple("ProxyConfig", _proxy_config_fields)
|
76 |
+
|
77 |
+
|
78 |
+
def _default_key_normalizer(key_class, request_context):
|
79 |
+
"""
|
80 |
+
Create a pool key out of a request context dictionary.
|
81 |
+
|
82 |
+
According to RFC 3986, both the scheme and host are case-insensitive.
|
83 |
+
Therefore, this function normalizes both before constructing the pool
|
84 |
+
key for an HTTPS request. If you wish to change this behaviour, provide
|
85 |
+
alternate callables to ``key_fn_by_scheme``.
|
86 |
+
|
87 |
+
:param key_class:
|
88 |
+
The class to use when constructing the key. This should be a namedtuple
|
89 |
+
with the ``scheme`` and ``host`` keys at a minimum.
|
90 |
+
:type key_class: namedtuple
|
91 |
+
:param request_context:
|
92 |
+
A dictionary-like object that contain the context for a request.
|
93 |
+
:type request_context: dict
|
94 |
+
|
95 |
+
:return: A namedtuple that can be used as a connection pool key.
|
96 |
+
:rtype: PoolKey
|
97 |
+
"""
|
98 |
+
# Since we mutate the dictionary, make a copy first
|
99 |
+
context = request_context.copy()
|
100 |
+
context["scheme"] = context["scheme"].lower()
|
101 |
+
context["host"] = context["host"].lower()
|
102 |
+
|
103 |
+
# These are both dictionaries and need to be transformed into frozensets
|
104 |
+
for key in ("headers", "_proxy_headers", "_socks_options"):
|
105 |
+
if key in context and context[key] is not None:
|
106 |
+
context[key] = frozenset(context[key].items())
|
107 |
+
|
108 |
+
# The socket_options key may be a list and needs to be transformed into a
|
109 |
+
# tuple.
|
110 |
+
socket_opts = context.get("socket_options")
|
111 |
+
if socket_opts is not None:
|
112 |
+
context["socket_options"] = tuple(socket_opts)
|
113 |
+
|
114 |
+
# Map the kwargs to the names in the namedtuple - this is necessary since
|
115 |
+
# namedtuples can't have fields starting with '_'.
|
116 |
+
for key in list(context.keys()):
|
117 |
+
context["key_" + key] = context.pop(key)
|
118 |
+
|
119 |
+
# Default to ``None`` for keys missing from the context
|
120 |
+
for field in key_class._fields:
|
121 |
+
if field not in context:
|
122 |
+
context[field] = None
|
123 |
+
|
124 |
+
return key_class(**context)
|
125 |
+
|
126 |
+
|
127 |
+
#: A dictionary that maps a scheme to a callable that creates a pool key.
|
128 |
+
#: This can be used to alter the way pool keys are constructed, if desired.
|
129 |
+
#: Each PoolManager makes a copy of this dictionary so they can be configured
|
130 |
+
#: globally here, or individually on the instance.
|
131 |
+
key_fn_by_scheme = {
|
132 |
+
"http": functools.partial(_default_key_normalizer, PoolKey),
|
133 |
+
"https": functools.partial(_default_key_normalizer, PoolKey),
|
134 |
+
}
|
135 |
+
|
136 |
+
pool_classes_by_scheme = {"http": HTTPConnectionPool, "https": HTTPSConnectionPool}
|
137 |
+
|
138 |
+
|
139 |
+
class PoolManager(RequestMethods):
|
140 |
+
"""
|
141 |
+
Allows for arbitrary requests while transparently keeping track of
|
142 |
+
necessary connection pools for you.
|
143 |
+
|
144 |
+
:param num_pools:
|
145 |
+
Number of connection pools to cache before discarding the least
|
146 |
+
recently used pool.
|
147 |
+
|
148 |
+
:param headers:
|
149 |
+
Headers to include with all requests, unless other headers are given
|
150 |
+
explicitly.
|
151 |
+
|
152 |
+
:param \\**connection_pool_kw:
|
153 |
+
Additional parameters are used to create fresh
|
154 |
+
:class:`urllib3.connectionpool.ConnectionPool` instances.
|
155 |
+
|
156 |
+
Example::
|
157 |
+
|
158 |
+
>>> manager = PoolManager(num_pools=2)
|
159 |
+
>>> r = manager.request('GET', 'http://google.com/')
|
160 |
+
>>> r = manager.request('GET', 'http://google.com/mail')
|
161 |
+
>>> r = manager.request('GET', 'http://yahoo.com/')
|
162 |
+
>>> len(manager.pools)
|
163 |
+
2
|
164 |
+
|
165 |
+
"""
|
166 |
+
|
167 |
+
proxy = None
|
168 |
+
proxy_config = None
|
169 |
+
|
170 |
+
def __init__(self, num_pools=10, headers=None, **connection_pool_kw):
|
171 |
+
RequestMethods.__init__(self, headers)
|
172 |
+
self.connection_pool_kw = connection_pool_kw
|
173 |
+
self.pools = RecentlyUsedContainer(num_pools, dispose_func=lambda p: p.close())
|
174 |
+
|
175 |
+
# Locally set the pool classes and keys so other PoolManagers can
|
176 |
+
# override them.
|
177 |
+
self.pool_classes_by_scheme = pool_classes_by_scheme
|
178 |
+
self.key_fn_by_scheme = key_fn_by_scheme.copy()
|
179 |
+
|
180 |
+
def __enter__(self):
|
181 |
+
return self
|
182 |
+
|
183 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
184 |
+
self.clear()
|
185 |
+
# Return False to re-raise any potential exceptions
|
186 |
+
return False
|
187 |
+
|
188 |
+
def _new_pool(self, scheme, host, port, request_context=None):
|
189 |
+
"""
|
190 |
+
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and
|
191 |
+
any additional pool keyword arguments.
|
192 |
+
|
193 |
+
If ``request_context`` is provided, it is provided as keyword arguments
|
194 |
+
to the pool class used. This method is used to actually create the
|
195 |
+
connection pools handed out by :meth:`connection_from_url` and
|
196 |
+
companion methods. It is intended to be overridden for customization.
|
197 |
+
"""
|
198 |
+
pool_cls = self.pool_classes_by_scheme[scheme]
|
199 |
+
if request_context is None:
|
200 |
+
request_context = self.connection_pool_kw.copy()
|
201 |
+
|
202 |
+
# Although the context has everything necessary to create the pool,
|
203 |
+
# this function has historically only used the scheme, host, and port
|
204 |
+
# in the positional args. When an API change is acceptable these can
|
205 |
+
# be removed.
|
206 |
+
for key in ("scheme", "host", "port"):
|
207 |
+
request_context.pop(key, None)
|
208 |
+
|
209 |
+
if scheme == "http":
|
210 |
+
for kw in SSL_KEYWORDS:
|
211 |
+
request_context.pop(kw, None)
|
212 |
+
|
213 |
+
return pool_cls(host, port, **request_context)
|
214 |
+
|
215 |
+
def clear(self):
|
216 |
+
"""
|
217 |
+
Empty our store of pools and direct them all to close.
|
218 |
+
|
219 |
+
This will not affect in-flight connections, but they will not be
|
220 |
+
re-used after completion.
|
221 |
+
"""
|
222 |
+
self.pools.clear()
|
223 |
+
|
224 |
+
def connection_from_host(self, host, port=None, scheme="http", pool_kwargs=None):
|
225 |
+
"""
|
226 |
+
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme.
|
227 |
+
|
228 |
+
If ``port`` isn't given, it will be derived from the ``scheme`` using
|
229 |
+
``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is
|
230 |
+
provided, it is merged with the instance's ``connection_pool_kw``
|
231 |
+
variable and used to create the new connection pool, if one is
|
232 |
+
needed.
|
233 |
+
"""
|
234 |
+
|
235 |
+
if not host:
|
236 |
+
raise LocationValueError("No host specified.")
|
237 |
+
|
238 |
+
request_context = self._merge_pool_kwargs(pool_kwargs)
|
239 |
+
request_context["scheme"] = scheme or "http"
|
240 |
+
if not port:
|
241 |
+
port = port_by_scheme.get(request_context["scheme"].lower(), 80)
|
242 |
+
request_context["port"] = port
|
243 |
+
request_context["host"] = host
|
244 |
+
|
245 |
+
return self.connection_from_context(request_context)
|
246 |
+
|
247 |
+
def connection_from_context(self, request_context):
|
248 |
+
"""
|
249 |
+
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context.
|
250 |
+
|
251 |
+
``request_context`` must at least contain the ``scheme`` key and its
|
252 |
+
value must be a key in ``key_fn_by_scheme`` instance variable.
|
253 |
+
"""
|
254 |
+
scheme = request_context["scheme"].lower()
|
255 |
+
pool_key_constructor = self.key_fn_by_scheme.get(scheme)
|
256 |
+
if not pool_key_constructor:
|
257 |
+
raise URLSchemeUnknown(scheme)
|
258 |
+
pool_key = pool_key_constructor(request_context)
|
259 |
+
|
260 |
+
return self.connection_from_pool_key(pool_key, request_context=request_context)
|
261 |
+
|
262 |
+
def connection_from_pool_key(self, pool_key, request_context=None):
|
263 |
+
"""
|
264 |
+
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key.
|
265 |
+
|
266 |
+
``pool_key`` should be a namedtuple that only contains immutable
|
267 |
+
objects. At a minimum it must have the ``scheme``, ``host``, and
|
268 |
+
``port`` fields.
|
269 |
+
"""
|
270 |
+
with self.pools.lock:
|
271 |
+
# If the scheme, host, or port doesn't match existing open
|
272 |
+
# connections, open a new ConnectionPool.
|
273 |
+
pool = self.pools.get(pool_key)
|
274 |
+
if pool:
|
275 |
+
return pool
|
276 |
+
|
277 |
+
# Make a fresh ConnectionPool of the desired type
|
278 |
+
scheme = request_context["scheme"]
|
279 |
+
host = request_context["host"]
|
280 |
+
port = request_context["port"]
|
281 |
+
pool = self._new_pool(scheme, host, port, request_context=request_context)
|
282 |
+
self.pools[pool_key] = pool
|
283 |
+
|
284 |
+
return pool
|
285 |
+
|
286 |
+
def connection_from_url(self, url, pool_kwargs=None):
|
287 |
+
"""
|
288 |
+
Similar to :func:`urllib3.connectionpool.connection_from_url`.
|
289 |
+
|
290 |
+
If ``pool_kwargs`` is not provided and a new pool needs to be
|
291 |
+
constructed, ``self.connection_pool_kw`` is used to initialize
|
292 |
+
the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs``
|
293 |
+
is provided, it is used instead. Note that if a new pool does not
|
294 |
+
need to be created for the request, the provided ``pool_kwargs`` are
|
295 |
+
not used.
|
296 |
+
"""
|
297 |
+
u = parse_url(url)
|
298 |
+
return self.connection_from_host(
|
299 |
+
u.host, port=u.port, scheme=u.scheme, pool_kwargs=pool_kwargs
|
300 |
+
)
|
301 |
+
|
302 |
+
def _merge_pool_kwargs(self, override):
|
303 |
+
"""
|
304 |
+
Merge a dictionary of override values for self.connection_pool_kw.
|
305 |
+
|
306 |
+
This does not modify self.connection_pool_kw and returns a new dict.
|
307 |
+
Any keys in the override dictionary with a value of ``None`` are
|
308 |
+
removed from the merged dictionary.
|
309 |
+
"""
|
310 |
+
base_pool_kwargs = self.connection_pool_kw.copy()
|
311 |
+
if override:
|
312 |
+
for key, value in override.items():
|
313 |
+
if value is None:
|
314 |
+
try:
|
315 |
+
del base_pool_kwargs[key]
|
316 |
+
except KeyError:
|
317 |
+
pass
|
318 |
+
else:
|
319 |
+
base_pool_kwargs[key] = value
|
320 |
+
return base_pool_kwargs
|
321 |
+
|
322 |
+
def _proxy_requires_url_absolute_form(self, parsed_url):
|
323 |
+
"""
|
324 |
+
Indicates if the proxy requires the complete destination URL in the
|
325 |
+
request. Normally this is only needed when not using an HTTP CONNECT
|
326 |
+
tunnel.
|
327 |
+
"""
|
328 |
+
if self.proxy is None:
|
329 |
+
return False
|
330 |
+
|
331 |
+
return not connection_requires_http_tunnel(
|
332 |
+
self.proxy, self.proxy_config, parsed_url.scheme
|
333 |
+
)
|
334 |
+
|
335 |
+
def _validate_proxy_scheme_url_selection(self, url_scheme):
|
336 |
+
"""
|
337 |
+
Validates that were not attempting to do TLS in TLS connections on
|
338 |
+
Python2 or with unsupported SSL implementations.
|
339 |
+
"""
|
340 |
+
if self.proxy is None or url_scheme != "https":
|
341 |
+
return
|
342 |
+
|
343 |
+
if self.proxy.scheme != "https":
|
344 |
+
return
|
345 |
+
|
346 |
+
if six.PY2 and not self.proxy_config.use_forwarding_for_https:
|
347 |
+
raise ProxySchemeUnsupported(
|
348 |
+
"Contacting HTTPS destinations through HTTPS proxies "
|
349 |
+
"'via CONNECT tunnels' is not supported in Python 2"
|
350 |
+
)
|
351 |
+
|
352 |
+
def urlopen(self, method, url, redirect=True, **kw):
|
353 |
+
"""
|
354 |
+
Same as :meth:`urllib3.HTTPConnectionPool.urlopen`
|
355 |
+
with custom cross-host redirect logic and only sends the request-uri
|
356 |
+
portion of the ``url``.
|
357 |
+
|
358 |
+
The given ``url`` parameter must be absolute, such that an appropriate
|
359 |
+
:class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
|
360 |
+
"""
|
361 |
+
u = parse_url(url)
|
362 |
+
self._validate_proxy_scheme_url_selection(u.scheme)
|
363 |
+
|
364 |
+
conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
|
365 |
+
|
366 |
+
kw["assert_same_host"] = False
|
367 |
+
kw["redirect"] = False
|
368 |
+
|
369 |
+
if "headers" not in kw:
|
370 |
+
kw["headers"] = self.headers.copy()
|
371 |
+
|
372 |
+
if self._proxy_requires_url_absolute_form(u):
|
373 |
+
response = conn.urlopen(method, url, **kw)
|
374 |
+
else:
|
375 |
+
response = conn.urlopen(method, u.request_uri, **kw)
|
376 |
+
|
377 |
+
redirect_location = redirect and response.get_redirect_location()
|
378 |
+
if not redirect_location:
|
379 |
+
return response
|
380 |
+
|
381 |
+
# Support relative URLs for redirecting.
|
382 |
+
redirect_location = urljoin(url, redirect_location)
|
383 |
+
|
384 |
+
if response.status == 303:
|
385 |
+
# Change the method according to RFC 9110, Section 15.4.4.
|
386 |
+
method = "GET"
|
387 |
+
# And lose the body not to transfer anything sensitive.
|
388 |
+
kw["body"] = None
|
389 |
+
kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change()
|
390 |
+
|
391 |
+
retries = kw.get("retries")
|
392 |
+
if not isinstance(retries, Retry):
|
393 |
+
retries = Retry.from_int(retries, redirect=redirect)
|
394 |
+
|
395 |
+
# Strip headers marked as unsafe to forward to the redirected location.
|
396 |
+
# Check remove_headers_on_redirect to avoid a potential network call within
|
397 |
+
# conn.is_same_host() which may use socket.gethostbyname() in the future.
|
398 |
+
if retries.remove_headers_on_redirect and not conn.is_same_host(
|
399 |
+
redirect_location
|
400 |
+
):
|
401 |
+
headers = list(six.iterkeys(kw["headers"]))
|
402 |
+
for header in headers:
|
403 |
+
if header.lower() in retries.remove_headers_on_redirect:
|
404 |
+
kw["headers"].pop(header, None)
|
405 |
+
|
406 |
+
try:
|
407 |
+
retries = retries.increment(method, url, response=response, _pool=conn)
|
408 |
+
except MaxRetryError:
|
409 |
+
if retries.raise_on_redirect:
|
410 |
+
response.drain_conn()
|
411 |
+
raise
|
412 |
+
return response
|
413 |
+
|
414 |
+
kw["retries"] = retries
|
415 |
+
kw["redirect"] = redirect
|
416 |
+
|
417 |
+
log.info("Redirecting %s -> %s", url, redirect_location)
|
418 |
+
|
419 |
+
response.drain_conn()
|
420 |
+
return self.urlopen(method, redirect_location, **kw)
|
421 |
+
|
422 |
+
|
423 |
+
class ProxyManager(PoolManager):
|
424 |
+
"""
|
425 |
+
Behaves just like :class:`PoolManager`, but sends all requests through
|
426 |
+
the defined proxy, using the CONNECT method for HTTPS URLs.
|
427 |
+
|
428 |
+
:param proxy_url:
|
429 |
+
The URL of the proxy to be used.
|
430 |
+
|
431 |
+
:param proxy_headers:
|
432 |
+
A dictionary containing headers that will be sent to the proxy. In case
|
433 |
+
of HTTP they are being sent with each request, while in the
|
434 |
+
HTTPS/CONNECT case they are sent only once. Could be used for proxy
|
435 |
+
authentication.
|
436 |
+
|
437 |
+
:param proxy_ssl_context:
|
438 |
+
The proxy SSL context is used to establish the TLS connection to the
|
439 |
+
proxy when using HTTPS proxies.
|
440 |
+
|
441 |
+
:param use_forwarding_for_https:
|
442 |
+
(Defaults to False) If set to True will forward requests to the HTTPS
|
443 |
+
proxy to be made on behalf of the client instead of creating a TLS
|
444 |
+
tunnel via the CONNECT method. **Enabling this flag means that request
|
445 |
+
and response headers and content will be visible from the HTTPS proxy**
|
446 |
+
whereas tunneling keeps request and response headers and content
|
447 |
+
private. IP address, target hostname, SNI, and port are always visible
|
448 |
+
to an HTTPS proxy even when this flag is disabled.
|
449 |
+
|
450 |
+
Example:
|
451 |
+
>>> proxy = urllib3.ProxyManager('http://localhost:3128/')
|
452 |
+
>>> r1 = proxy.request('GET', 'http://google.com/')
|
453 |
+
>>> r2 = proxy.request('GET', 'http://httpbin.org/')
|
454 |
+
>>> len(proxy.pools)
|
455 |
+
1
|
456 |
+
>>> r3 = proxy.request('GET', 'https://httpbin.org/')
|
457 |
+
>>> r4 = proxy.request('GET', 'https://twitter.com/')
|
458 |
+
>>> len(proxy.pools)
|
459 |
+
3
|
460 |
+
|
461 |
+
"""
|
462 |
+
|
463 |
+
def __init__(
|
464 |
+
self,
|
465 |
+
proxy_url,
|
466 |
+
num_pools=10,
|
467 |
+
headers=None,
|
468 |
+
proxy_headers=None,
|
469 |
+
proxy_ssl_context=None,
|
470 |
+
use_forwarding_for_https=False,
|
471 |
+
**connection_pool_kw
|
472 |
+
):
|
473 |
+
|
474 |
+
if isinstance(proxy_url, HTTPConnectionPool):
|
475 |
+
proxy_url = "%s://%s:%i" % (
|
476 |
+
proxy_url.scheme,
|
477 |
+
proxy_url.host,
|
478 |
+
proxy_url.port,
|
479 |
+
)
|
480 |
+
proxy = parse_url(proxy_url)
|
481 |
+
|
482 |
+
if proxy.scheme not in ("http", "https"):
|
483 |
+
raise ProxySchemeUnknown(proxy.scheme)
|
484 |
+
|
485 |
+
if not proxy.port:
|
486 |
+
port = port_by_scheme.get(proxy.scheme, 80)
|
487 |
+
proxy = proxy._replace(port=port)
|
488 |
+
|
489 |
+
self.proxy = proxy
|
490 |
+
self.proxy_headers = proxy_headers or {}
|
491 |
+
self.proxy_ssl_context = proxy_ssl_context
|
492 |
+
self.proxy_config = ProxyConfig(proxy_ssl_context, use_forwarding_for_https)
|
493 |
+
|
494 |
+
connection_pool_kw["_proxy"] = self.proxy
|
495 |
+
connection_pool_kw["_proxy_headers"] = self.proxy_headers
|
496 |
+
connection_pool_kw["_proxy_config"] = self.proxy_config
|
497 |
+
|
498 |
+
super(ProxyManager, self).__init__(num_pools, headers, **connection_pool_kw)
|
499 |
+
|
500 |
+
def connection_from_host(self, host, port=None, scheme="http", pool_kwargs=None):
|
501 |
+
if scheme == "https":
|
502 |
+
return super(ProxyManager, self).connection_from_host(
|
503 |
+
host, port, scheme, pool_kwargs=pool_kwargs
|
504 |
+
)
|
505 |
+
|
506 |
+
return super(ProxyManager, self).connection_from_host(
|
507 |
+
self.proxy.host, self.proxy.port, self.proxy.scheme, pool_kwargs=pool_kwargs
|
508 |
+
)
|
509 |
+
|
510 |
+
def _set_proxy_headers(self, url, headers=None):
|
511 |
+
"""
|
512 |
+
Sets headers needed by proxies: specifically, the Accept and Host
|
513 |
+
headers. Only sets headers not provided by the user.
|
514 |
+
"""
|
515 |
+
headers_ = {"Accept": "*/*"}
|
516 |
+
|
517 |
+
netloc = parse_url(url).netloc
|
518 |
+
if netloc:
|
519 |
+
headers_["Host"] = netloc
|
520 |
+
|
521 |
+
if headers:
|
522 |
+
headers_.update(headers)
|
523 |
+
return headers_
|
524 |
+
|
525 |
+
def urlopen(self, method, url, redirect=True, **kw):
|
526 |
+
"Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."
|
527 |
+
u = parse_url(url)
|
528 |
+
if not connection_requires_http_tunnel(self.proxy, self.proxy_config, u.scheme):
|
529 |
+
# For connections using HTTP CONNECT, httplib sets the necessary
|
530 |
+
# headers on the CONNECT to the proxy. If we're not using CONNECT,
|
531 |
+
# we'll definitely need to set 'Host' at the very least.
|
532 |
+
headers = kw.get("headers", self.headers)
|
533 |
+
kw["headers"] = self._set_proxy_headers(url, headers)
|
534 |
+
|
535 |
+
return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw)
|
536 |
+
|
537 |
+
|
538 |
+
def proxy_from_url(url, **kw):
|
539 |
+
return ProxyManager(proxy_url=url, **kw)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/request.py
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import absolute_import
|
2 |
+
|
3 |
+
from .filepost import encode_multipart_formdata
|
4 |
+
from .packages.six.moves.urllib.parse import urlencode
|
5 |
+
|
6 |
+
__all__ = ["RequestMethods"]
|
7 |
+
|
8 |
+
|
9 |
+
class RequestMethods(object):
|
10 |
+
"""
|
11 |
+
Convenience mixin for classes who implement a :meth:`urlopen` method, such
|
12 |
+
as :class:`urllib3.HTTPConnectionPool` and
|
13 |
+
:class:`urllib3.PoolManager`.
|
14 |
+
|
15 |
+
Provides behavior for making common types of HTTP request methods and
|
16 |
+
decides which type of request field encoding to use.
|
17 |
+
|
18 |
+
Specifically,
|
19 |
+
|
20 |
+
:meth:`.request_encode_url` is for sending requests whose fields are
|
21 |
+
encoded in the URL (such as GET, HEAD, DELETE).
|
22 |
+
|
23 |
+
:meth:`.request_encode_body` is for sending requests whose fields are
|
24 |
+
encoded in the *body* of the request using multipart or www-form-urlencoded
|
25 |
+
(such as for POST, PUT, PATCH).
|
26 |
+
|
27 |
+
:meth:`.request` is for making any kind of request, it will look up the
|
28 |
+
appropriate encoding format and use one of the above two methods to make
|
29 |
+
the request.
|
30 |
+
|
31 |
+
Initializer parameters:
|
32 |
+
|
33 |
+
:param headers:
|
34 |
+
Headers to include with all requests, unless other headers are given
|
35 |
+
explicitly.
|
36 |
+
"""
|
37 |
+
|
38 |
+
_encode_url_methods = {"DELETE", "GET", "HEAD", "OPTIONS"}
|
39 |
+
|
40 |
+
def __init__(self, headers=None):
|
41 |
+
self.headers = headers or {}
|
42 |
+
|
43 |
+
def urlopen(
|
44 |
+
self,
|
45 |
+
method,
|
46 |
+
url,
|
47 |
+
body=None,
|
48 |
+
headers=None,
|
49 |
+
encode_multipart=True,
|
50 |
+
multipart_boundary=None,
|
51 |
+
**kw
|
52 |
+
): # Abstract
|
53 |
+
raise NotImplementedError(
|
54 |
+
"Classes extending RequestMethods must implement "
|
55 |
+
"their own ``urlopen`` method."
|
56 |
+
)
|
57 |
+
|
58 |
+
def request(self, method, url, fields=None, headers=None, **urlopen_kw):
|
59 |
+
"""
|
60 |
+
Make a request using :meth:`urlopen` with the appropriate encoding of
|
61 |
+
``fields`` based on the ``method`` used.
|
62 |
+
|
63 |
+
This is a convenience method that requires the least amount of manual
|
64 |
+
effort. It can be used in most situations, while still having the
|
65 |
+
option to drop down to more specific methods when necessary, such as
|
66 |
+
:meth:`request_encode_url`, :meth:`request_encode_body`,
|
67 |
+
or even the lowest level :meth:`urlopen`.
|
68 |
+
"""
|
69 |
+
method = method.upper()
|
70 |
+
|
71 |
+
urlopen_kw["request_url"] = url
|
72 |
+
|
73 |
+
if method in self._encode_url_methods:
|
74 |
+
return self.request_encode_url(
|
75 |
+
method, url, fields=fields, headers=headers, **urlopen_kw
|
76 |
+
)
|
77 |
+
else:
|
78 |
+
return self.request_encode_body(
|
79 |
+
method, url, fields=fields, headers=headers, **urlopen_kw
|
80 |
+
)
|
81 |
+
|
82 |
+
def request_encode_url(self, method, url, fields=None, headers=None, **urlopen_kw):
|
83 |
+
"""
|
84 |
+
Make a request using :meth:`urlopen` with the ``fields`` encoded in
|
85 |
+
the url. This is useful for request methods like GET, HEAD, DELETE, etc.
|
86 |
+
"""
|
87 |
+
if headers is None:
|
88 |
+
headers = self.headers
|
89 |
+
|
90 |
+
extra_kw = {"headers": headers}
|
91 |
+
extra_kw.update(urlopen_kw)
|
92 |
+
|
93 |
+
if fields:
|
94 |
+
url += "?" + urlencode(fields)
|
95 |
+
|
96 |
+
return self.urlopen(method, url, **extra_kw)
|
97 |
+
|
98 |
+
def request_encode_body(
|
99 |
+
self,
|
100 |
+
method,
|
101 |
+
url,
|
102 |
+
fields=None,
|
103 |
+
headers=None,
|
104 |
+
encode_multipart=True,
|
105 |
+
multipart_boundary=None,
|
106 |
+
**urlopen_kw
|
107 |
+
):
|
108 |
+
"""
|
109 |
+
Make a request using :meth:`urlopen` with the ``fields`` encoded in
|
110 |
+
the body. This is useful for request methods like POST, PUT, PATCH, etc.
|
111 |
+
|
112 |
+
When ``encode_multipart=True`` (default), then
|
113 |
+
:func:`urllib3.encode_multipart_formdata` is used to encode
|
114 |
+
the payload with the appropriate content type. Otherwise
|
115 |
+
:func:`urllib.parse.urlencode` is used with the
|
116 |
+
'application/x-www-form-urlencoded' content type.
|
117 |
+
|
118 |
+
Multipart encoding must be used when posting files, and it's reasonably
|
119 |
+
safe to use it in other times too. However, it may break request
|
120 |
+
signing, such as with OAuth.
|
121 |
+
|
122 |
+
Supports an optional ``fields`` parameter of key/value strings AND
|
123 |
+
key/filetuple. A filetuple is a (filename, data, MIME type) tuple where
|
124 |
+
the MIME type is optional. For example::
|
125 |
+
|
126 |
+
fields = {
|
127 |
+
'foo': 'bar',
|
128 |
+
'fakefile': ('foofile.txt', 'contents of foofile'),
|
129 |
+
'realfile': ('barfile.txt', open('realfile').read()),
|
130 |
+
'typedfile': ('bazfile.bin', open('bazfile').read(),
|
131 |
+
'image/jpeg'),
|
132 |
+
'nonamefile': 'contents of nonamefile field',
|
133 |
+
}
|
134 |
+
|
135 |
+
When uploading a file, providing a filename (the first parameter of the
|
136 |
+
tuple) is optional but recommended to best mimic behavior of browsers.
|
137 |
+
|
138 |
+
Note that if ``headers`` are supplied, the 'Content-Type' header will
|
139 |
+
be overwritten because it depends on the dynamic random boundary string
|
140 |
+
which is used to compose the body of the request. The random boundary
|
141 |
+
string can be explicitly set with the ``multipart_boundary`` parameter.
|
142 |
+
"""
|
143 |
+
if headers is None:
|
144 |
+
headers = self.headers
|
145 |
+
|
146 |
+
extra_kw = {"headers": {}}
|
147 |
+
|
148 |
+
if fields:
|
149 |
+
if "body" in urlopen_kw:
|
150 |
+
raise TypeError(
|
151 |
+
"request got values for both 'fields' and 'body', can only specify one."
|
152 |
+
)
|
153 |
+
|
154 |
+
if encode_multipart:
|
155 |
+
body, content_type = encode_multipart_formdata(
|
156 |
+
fields, boundary=multipart_boundary
|
157 |
+
)
|
158 |
+
else:
|
159 |
+
body, content_type = (
|
160 |
+
urlencode(fields),
|
161 |
+
"application/x-www-form-urlencoded",
|
162 |
+
)
|
163 |
+
|
164 |
+
extra_kw["body"] = body
|
165 |
+
extra_kw["headers"] = {"Content-Type": content_type}
|
166 |
+
|
167 |
+
extra_kw["headers"].update(headers)
|
168 |
+
extra_kw.update(urlopen_kw)
|
169 |
+
|
170 |
+
return self.urlopen(method, url, **extra_kw)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/response.py
ADDED
@@ -0,0 +1,821 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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import absolute_import
|
2 |
+
|
3 |
+
import io
|
4 |
+
import logging
|
5 |
+
import zlib
|
6 |
+
from contextlib import contextmanager
|
7 |
+
from socket import error as SocketError
|
8 |
+
from socket import timeout as SocketTimeout
|
9 |
+
|
10 |
+
try:
|
11 |
+
import brotli
|
12 |
+
except ImportError:
|
13 |
+
brotli = None
|
14 |
+
|
15 |
+
from ._collections import HTTPHeaderDict
|
16 |
+
from .connection import BaseSSLError, HTTPException
|
17 |
+
from .exceptions import (
|
18 |
+
BodyNotHttplibCompatible,
|
19 |
+
DecodeError,
|
20 |
+
HTTPError,
|
21 |
+
IncompleteRead,
|
22 |
+
InvalidChunkLength,
|
23 |
+
InvalidHeader,
|
24 |
+
ProtocolError,
|
25 |
+
ReadTimeoutError,
|
26 |
+
ResponseNotChunked,
|
27 |
+
SSLError,
|
28 |
+
)
|
29 |
+
from .packages import six
|
30 |
+
from .util.response import is_fp_closed, is_response_to_head
|
31 |
+
|
32 |
+
log = logging.getLogger(__name__)
|
33 |
+
|
34 |
+
|
35 |
+
class DeflateDecoder(object):
|
36 |
+
def __init__(self):
|
37 |
+
self._first_try = True
|
38 |
+
self._data = b""
|
39 |
+
self._obj = zlib.decompressobj()
|
40 |
+
|
41 |
+
def __getattr__(self, name):
|
42 |
+
return getattr(self._obj, name)
|
43 |
+
|
44 |
+
def decompress(self, data):
|
45 |
+
if not data:
|
46 |
+
return data
|
47 |
+
|
48 |
+
if not self._first_try:
|
49 |
+
return self._obj.decompress(data)
|
50 |
+
|
51 |
+
self._data += data
|
52 |
+
try:
|
53 |
+
decompressed = self._obj.decompress(data)
|
54 |
+
if decompressed:
|
55 |
+
self._first_try = False
|
56 |
+
self._data = None
|
57 |
+
return decompressed
|
58 |
+
except zlib.error:
|
59 |
+
self._first_try = False
|
60 |
+
self._obj = zlib.decompressobj(-zlib.MAX_WBITS)
|
61 |
+
try:
|
62 |
+
return self.decompress(self._data)
|
63 |
+
finally:
|
64 |
+
self._data = None
|
65 |
+
|
66 |
+
|
67 |
+
class GzipDecoderState(object):
|
68 |
+
|
69 |
+
FIRST_MEMBER = 0
|
70 |
+
OTHER_MEMBERS = 1
|
71 |
+
SWALLOW_DATA = 2
|
72 |
+
|
73 |
+
|
74 |
+
class GzipDecoder(object):
|
75 |
+
def __init__(self):
|
76 |
+
self._obj = zlib.decompressobj(16 + zlib.MAX_WBITS)
|
77 |
+
self._state = GzipDecoderState.FIRST_MEMBER
|
78 |
+
|
79 |
+
def __getattr__(self, name):
|
80 |
+
return getattr(self._obj, name)
|
81 |
+
|
82 |
+
def decompress(self, data):
|
83 |
+
ret = bytearray()
|
84 |
+
if self._state == GzipDecoderState.SWALLOW_DATA or not data:
|
85 |
+
return bytes(ret)
|
86 |
+
while True:
|
87 |
+
try:
|
88 |
+
ret += self._obj.decompress(data)
|
89 |
+
except zlib.error:
|
90 |
+
previous_state = self._state
|
91 |
+
# Ignore data after the first error
|
92 |
+
self._state = GzipDecoderState.SWALLOW_DATA
|
93 |
+
if previous_state == GzipDecoderState.OTHER_MEMBERS:
|
94 |
+
# Allow trailing garbage acceptable in other gzip clients
|
95 |
+
return bytes(ret)
|
96 |
+
raise
|
97 |
+
data = self._obj.unused_data
|
98 |
+
if not data:
|
99 |
+
return bytes(ret)
|
100 |
+
self._state = GzipDecoderState.OTHER_MEMBERS
|
101 |
+
self._obj = zlib.decompressobj(16 + zlib.MAX_WBITS)
|
102 |
+
|
103 |
+
|
104 |
+
if brotli is not None:
|
105 |
+
|
106 |
+
class BrotliDecoder(object):
|
107 |
+
# Supports both 'brotlipy' and 'Brotli' packages
|
108 |
+
# since they share an import name. The top branches
|
109 |
+
# are for 'brotlipy' and bottom branches for 'Brotli'
|
110 |
+
def __init__(self):
|
111 |
+
self._obj = brotli.Decompressor()
|
112 |
+
if hasattr(self._obj, "decompress"):
|
113 |
+
self.decompress = self._obj.decompress
|
114 |
+
else:
|
115 |
+
self.decompress = self._obj.process
|
116 |
+
|
117 |
+
def flush(self):
|
118 |
+
if hasattr(self._obj, "flush"):
|
119 |
+
return self._obj.flush()
|
120 |
+
return b""
|
121 |
+
|
122 |
+
|
123 |
+
class MultiDecoder(object):
|
124 |
+
"""
|
125 |
+
From RFC7231:
|
126 |
+
If one or more encodings have been applied to a representation, the
|
127 |
+
sender that applied the encodings MUST generate a Content-Encoding
|
128 |
+
header field that lists the content codings in the order in which
|
129 |
+
they were applied.
|
130 |
+
"""
|
131 |
+
|
132 |
+
def __init__(self, modes):
|
133 |
+
self._decoders = [_get_decoder(m.strip()) for m in modes.split(",")]
|
134 |
+
|
135 |
+
def flush(self):
|
136 |
+
return self._decoders[0].flush()
|
137 |
+
|
138 |
+
def decompress(self, data):
|
139 |
+
for d in reversed(self._decoders):
|
140 |
+
data = d.decompress(data)
|
141 |
+
return data
|
142 |
+
|
143 |
+
|
144 |
+
def _get_decoder(mode):
|
145 |
+
if "," in mode:
|
146 |
+
return MultiDecoder(mode)
|
147 |
+
|
148 |
+
if mode == "gzip":
|
149 |
+
return GzipDecoder()
|
150 |
+
|
151 |
+
if brotli is not None and mode == "br":
|
152 |
+
return BrotliDecoder()
|
153 |
+
|
154 |
+
return DeflateDecoder()
|
155 |
+
|
156 |
+
|
157 |
+
class HTTPResponse(io.IOBase):
|
158 |
+
"""
|
159 |
+
HTTP Response container.
|
160 |
+
|
161 |
+
Backwards-compatible with :class:`http.client.HTTPResponse` but the response ``body`` is
|
162 |
+
loaded and decoded on-demand when the ``data`` property is accessed. This
|
163 |
+
class is also compatible with the Python standard library's :mod:`io`
|
164 |
+
module, and can hence be treated as a readable object in the context of that
|
165 |
+
framework.
|
166 |
+
|
167 |
+
Extra parameters for behaviour not present in :class:`http.client.HTTPResponse`:
|
168 |
+
|
169 |
+
:param preload_content:
|
170 |
+
If True, the response's body will be preloaded during construction.
|
171 |
+
|
172 |
+
:param decode_content:
|
173 |
+
If True, will attempt to decode the body based on the
|
174 |
+
'content-encoding' header.
|
175 |
+
|
176 |
+
:param original_response:
|
177 |
+
When this HTTPResponse wrapper is generated from an :class:`http.client.HTTPResponse`
|
178 |
+
object, it's convenient to include the original for debug purposes. It's
|
179 |
+
otherwise unused.
|
180 |
+
|
181 |
+
:param retries:
|
182 |
+
The retries contains the last :class:`~urllib3.util.retry.Retry` that
|
183 |
+
was used during the request.
|
184 |
+
|
185 |
+
:param enforce_content_length:
|
186 |
+
Enforce content length checking. Body returned by server must match
|
187 |
+
value of Content-Length header, if present. Otherwise, raise error.
|
188 |
+
"""
|
189 |
+
|
190 |
+
CONTENT_DECODERS = ["gzip", "deflate"]
|
191 |
+
if brotli is not None:
|
192 |
+
CONTENT_DECODERS += ["br"]
|
193 |
+
REDIRECT_STATUSES = [301, 302, 303, 307, 308]
|
194 |
+
|
195 |
+
def __init__(
|
196 |
+
self,
|
197 |
+
body="",
|
198 |
+
headers=None,
|
199 |
+
status=0,
|
200 |
+
version=0,
|
201 |
+
reason=None,
|
202 |
+
strict=0,
|
203 |
+
preload_content=True,
|
204 |
+
decode_content=True,
|
205 |
+
original_response=None,
|
206 |
+
pool=None,
|
207 |
+
connection=None,
|
208 |
+
msg=None,
|
209 |
+
retries=None,
|
210 |
+
enforce_content_length=False,
|
211 |
+
request_method=None,
|
212 |
+
request_url=None,
|
213 |
+
auto_close=True,
|
214 |
+
):
|
215 |
+
|
216 |
+
if isinstance(headers, HTTPHeaderDict):
|
217 |
+
self.headers = headers
|
218 |
+
else:
|
219 |
+
self.headers = HTTPHeaderDict(headers)
|
220 |
+
self.status = status
|
221 |
+
self.version = version
|
222 |
+
self.reason = reason
|
223 |
+
self.strict = strict
|
224 |
+
self.decode_content = decode_content
|
225 |
+
self.retries = retries
|
226 |
+
self.enforce_content_length = enforce_content_length
|
227 |
+
self.auto_close = auto_close
|
228 |
+
|
229 |
+
self._decoder = None
|
230 |
+
self._body = None
|
231 |
+
self._fp = None
|
232 |
+
self._original_response = original_response
|
233 |
+
self._fp_bytes_read = 0
|
234 |
+
self.msg = msg
|
235 |
+
self._request_url = request_url
|
236 |
+
|
237 |
+
if body and isinstance(body, (six.string_types, bytes)):
|
238 |
+
self._body = body
|
239 |
+
|
240 |
+
self._pool = pool
|
241 |
+
self._connection = connection
|
242 |
+
|
243 |
+
if hasattr(body, "read"):
|
244 |
+
self._fp = body
|
245 |
+
|
246 |
+
# Are we using the chunked-style of transfer encoding?
|
247 |
+
self.chunked = False
|
248 |
+
self.chunk_left = None
|
249 |
+
tr_enc = self.headers.get("transfer-encoding", "").lower()
|
250 |
+
# Don't incur the penalty of creating a list and then discarding it
|
251 |
+
encodings = (enc.strip() for enc in tr_enc.split(","))
|
252 |
+
if "chunked" in encodings:
|
253 |
+
self.chunked = True
|
254 |
+
|
255 |
+
# Determine length of response
|
256 |
+
self.length_remaining = self._init_length(request_method)
|
257 |
+
|
258 |
+
# If requested, preload the body.
|
259 |
+
if preload_content and not self._body:
|
260 |
+
self._body = self.read(decode_content=decode_content)
|
261 |
+
|
262 |
+
def get_redirect_location(self):
|
263 |
+
"""
|
264 |
+
Should we redirect and where to?
|
265 |
+
|
266 |
+
:returns: Truthy redirect location string if we got a redirect status
|
267 |
+
code and valid location. ``None`` if redirect status and no
|
268 |
+
location. ``False`` if not a redirect status code.
|
269 |
+
"""
|
270 |
+
if self.status in self.REDIRECT_STATUSES:
|
271 |
+
return self.headers.get("location")
|
272 |
+
|
273 |
+
return False
|
274 |
+
|
275 |
+
def release_conn(self):
|
276 |
+
if not self._pool or not self._connection:
|
277 |
+
return
|
278 |
+
|
279 |
+
self._pool._put_conn(self._connection)
|
280 |
+
self._connection = None
|
281 |
+
|
282 |
+
def drain_conn(self):
|
283 |
+
"""
|
284 |
+
Read and discard any remaining HTTP response data in the response connection.
|
285 |
+
|
286 |
+
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
|
287 |
+
"""
|
288 |
+
try:
|
289 |
+
self.read()
|
290 |
+
except (HTTPError, SocketError, BaseSSLError, HTTPException):
|
291 |
+
pass
|
292 |
+
|
293 |
+
@property
|
294 |
+
def data(self):
|
295 |
+
# For backwards-compat with earlier urllib3 0.4 and earlier.
|
296 |
+
if self._body:
|
297 |
+
return self._body
|
298 |
+
|
299 |
+
if self._fp:
|
300 |
+
return self.read(cache_content=True)
|
301 |
+
|
302 |
+
@property
|
303 |
+
def connection(self):
|
304 |
+
return self._connection
|
305 |
+
|
306 |
+
def isclosed(self):
|
307 |
+
return is_fp_closed(self._fp)
|
308 |
+
|
309 |
+
def tell(self):
|
310 |
+
"""
|
311 |
+
Obtain the number of bytes pulled over the wire so far. May differ from
|
312 |
+
the amount of content returned by :meth:``urllib3.response.HTTPResponse.read``
|
313 |
+
if bytes are encoded on the wire (e.g, compressed).
|
314 |
+
"""
|
315 |
+
return self._fp_bytes_read
|
316 |
+
|
317 |
+
def _init_length(self, request_method):
|
318 |
+
"""
|
319 |
+
Set initial length value for Response content if available.
|
320 |
+
"""
|
321 |
+
length = self.headers.get("content-length")
|
322 |
+
|
323 |
+
if length is not None:
|
324 |
+
if self.chunked:
|
325 |
+
# This Response will fail with an IncompleteRead if it can't be
|
326 |
+
# received as chunked. This method falls back to attempt reading
|
327 |
+
# the response before raising an exception.
|
328 |
+
log.warning(
|
329 |
+
"Received response with both Content-Length and "
|
330 |
+
"Transfer-Encoding set. This is expressly forbidden "
|
331 |
+
"by RFC 7230 sec 3.3.2. Ignoring Content-Length and "
|
332 |
+
"attempting to process response as Transfer-Encoding: "
|
333 |
+
"chunked."
|
334 |
+
)
|
335 |
+
return None
|
336 |
+
|
337 |
+
try:
|
338 |
+
# RFC 7230 section 3.3.2 specifies multiple content lengths can
|
339 |
+
# be sent in a single Content-Length header
|
340 |
+
# (e.g. Content-Length: 42, 42). This line ensures the values
|
341 |
+
# are all valid ints and that as long as the `set` length is 1,
|
342 |
+
# all values are the same. Otherwise, the header is invalid.
|
343 |
+
lengths = set([int(val) for val in length.split(",")])
|
344 |
+
if len(lengths) > 1:
|
345 |
+
raise InvalidHeader(
|
346 |
+
"Content-Length contained multiple "
|
347 |
+
"unmatching values (%s)" % length
|
348 |
+
)
|
349 |
+
length = lengths.pop()
|
350 |
+
except ValueError:
|
351 |
+
length = None
|
352 |
+
else:
|
353 |
+
if length < 0:
|
354 |
+
length = None
|
355 |
+
|
356 |
+
# Convert status to int for comparison
|
357 |
+
# In some cases, httplib returns a status of "_UNKNOWN"
|
358 |
+
try:
|
359 |
+
status = int(self.status)
|
360 |
+
except ValueError:
|
361 |
+
status = 0
|
362 |
+
|
363 |
+
# Check for responses that shouldn't include a body
|
364 |
+
if status in (204, 304) or 100 <= status < 200 or request_method == "HEAD":
|
365 |
+
length = 0
|
366 |
+
|
367 |
+
return length
|
368 |
+
|
369 |
+
def _init_decoder(self):
|
370 |
+
"""
|
371 |
+
Set-up the _decoder attribute if necessary.
|
372 |
+
"""
|
373 |
+
# Note: content-encoding value should be case-insensitive, per RFC 7230
|
374 |
+
# Section 3.2
|
375 |
+
content_encoding = self.headers.get("content-encoding", "").lower()
|
376 |
+
if self._decoder is None:
|
377 |
+
if content_encoding in self.CONTENT_DECODERS:
|
378 |
+
self._decoder = _get_decoder(content_encoding)
|
379 |
+
elif "," in content_encoding:
|
380 |
+
encodings = [
|
381 |
+
e.strip()
|
382 |
+
for e in content_encoding.split(",")
|
383 |
+
if e.strip() in self.CONTENT_DECODERS
|
384 |
+
]
|
385 |
+
if len(encodings):
|
386 |
+
self._decoder = _get_decoder(content_encoding)
|
387 |
+
|
388 |
+
DECODER_ERROR_CLASSES = (IOError, zlib.error)
|
389 |
+
if brotli is not None:
|
390 |
+
DECODER_ERROR_CLASSES += (brotli.error,)
|
391 |
+
|
392 |
+
def _decode(self, data, decode_content, flush_decoder):
|
393 |
+
"""
|
394 |
+
Decode the data passed in and potentially flush the decoder.
|
395 |
+
"""
|
396 |
+
if not decode_content:
|
397 |
+
return data
|
398 |
+
|
399 |
+
try:
|
400 |
+
if self._decoder:
|
401 |
+
data = self._decoder.decompress(data)
|
402 |
+
except self.DECODER_ERROR_CLASSES as e:
|
403 |
+
content_encoding = self.headers.get("content-encoding", "").lower()
|
404 |
+
raise DecodeError(
|
405 |
+
"Received response with content-encoding: %s, but "
|
406 |
+
"failed to decode it." % content_encoding,
|
407 |
+
e,
|
408 |
+
)
|
409 |
+
if flush_decoder:
|
410 |
+
data += self._flush_decoder()
|
411 |
+
|
412 |
+
return data
|
413 |
+
|
414 |
+
def _flush_decoder(self):
|
415 |
+
"""
|
416 |
+
Flushes the decoder. Should only be called if the decoder is actually
|
417 |
+
being used.
|
418 |
+
"""
|
419 |
+
if self._decoder:
|
420 |
+
buf = self._decoder.decompress(b"")
|
421 |
+
return buf + self._decoder.flush()
|
422 |
+
|
423 |
+
return b""
|
424 |
+
|
425 |
+
@contextmanager
|
426 |
+
def _error_catcher(self):
|
427 |
+
"""
|
428 |
+
Catch low-level python exceptions, instead re-raising urllib3
|
429 |
+
variants, so that low-level exceptions are not leaked in the
|
430 |
+
high-level api.
|
431 |
+
|
432 |
+
On exit, release the connection back to the pool.
|
433 |
+
"""
|
434 |
+
clean_exit = False
|
435 |
+
|
436 |
+
try:
|
437 |
+
try:
|
438 |
+
yield
|
439 |
+
|
440 |
+
except SocketTimeout:
|
441 |
+
# FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
|
442 |
+
# there is yet no clean way to get at it from this context.
|
443 |
+
raise ReadTimeoutError(self._pool, None, "Read timed out.")
|
444 |
+
|
445 |
+
except BaseSSLError as e:
|
446 |
+
# FIXME: Is there a better way to differentiate between SSLErrors?
|
447 |
+
if "read operation timed out" not in str(e):
|
448 |
+
# SSL errors related to framing/MAC get wrapped and reraised here
|
449 |
+
raise SSLError(e)
|
450 |
+
|
451 |
+
raise ReadTimeoutError(self._pool, None, "Read timed out.")
|
452 |
+
|
453 |
+
except (HTTPException, SocketError) as e:
|
454 |
+
# This includes IncompleteRead.
|
455 |
+
raise ProtocolError("Connection broken: %r" % e, e)
|
456 |
+
|
457 |
+
# If no exception is thrown, we should avoid cleaning up
|
458 |
+
# unnecessarily.
|
459 |
+
clean_exit = True
|
460 |
+
finally:
|
461 |
+
# If we didn't terminate cleanly, we need to throw away our
|
462 |
+
# connection.
|
463 |
+
if not clean_exit:
|
464 |
+
# The response may not be closed but we're not going to use it
|
465 |
+
# anymore so close it now to ensure that the connection is
|
466 |
+
# released back to the pool.
|
467 |
+
if self._original_response:
|
468 |
+
self._original_response.close()
|
469 |
+
|
470 |
+
# Closing the response may not actually be sufficient to close
|
471 |
+
# everything, so if we have a hold of the connection close that
|
472 |
+
# too.
|
473 |
+
if self._connection:
|
474 |
+
self._connection.close()
|
475 |
+
|
476 |
+
# If we hold the original response but it's closed now, we should
|
477 |
+
# return the connection back to the pool.
|
478 |
+
if self._original_response and self._original_response.isclosed():
|
479 |
+
self.release_conn()
|
480 |
+
|
481 |
+
def read(self, amt=None, decode_content=None, cache_content=False):
|
482 |
+
"""
|
483 |
+
Similar to :meth:`http.client.HTTPResponse.read`, but with two additional
|
484 |
+
parameters: ``decode_content`` and ``cache_content``.
|
485 |
+
|
486 |
+
:param amt:
|
487 |
+
How much of the content to read. If specified, caching is skipped
|
488 |
+
because it doesn't make sense to cache partial content as the full
|
489 |
+
response.
|
490 |
+
|
491 |
+
:param decode_content:
|
492 |
+
If True, will attempt to decode the body based on the
|
493 |
+
'content-encoding' header.
|
494 |
+
|
495 |
+
:param cache_content:
|
496 |
+
If True, will save the returned data such that the same result is
|
497 |
+
returned despite of the state of the underlying file object. This
|
498 |
+
is useful if you want the ``.data`` property to continue working
|
499 |
+
after having ``.read()`` the file object. (Overridden if ``amt`` is
|
500 |
+
set.)
|
501 |
+
"""
|
502 |
+
self._init_decoder()
|
503 |
+
if decode_content is None:
|
504 |
+
decode_content = self.decode_content
|
505 |
+
|
506 |
+
if self._fp is None:
|
507 |
+
return
|
508 |
+
|
509 |
+
flush_decoder = False
|
510 |
+
fp_closed = getattr(self._fp, "closed", False)
|
511 |
+
|
512 |
+
with self._error_catcher():
|
513 |
+
if amt is None:
|
514 |
+
# cStringIO doesn't like amt=None
|
515 |
+
data = self._fp.read() if not fp_closed else b""
|
516 |
+
flush_decoder = True
|
517 |
+
else:
|
518 |
+
cache_content = False
|
519 |
+
data = self._fp.read(amt) if not fp_closed else b""
|
520 |
+
if (
|
521 |
+
amt != 0 and not data
|
522 |
+
): # Platform-specific: Buggy versions of Python.
|
523 |
+
# Close the connection when no data is returned
|
524 |
+
#
|
525 |
+
# This is redundant to what httplib/http.client _should_
|
526 |
+
# already do. However, versions of python released before
|
527 |
+
# December 15, 2012 (http://bugs.python.org/issue16298) do
|
528 |
+
# not properly close the connection in all cases. There is
|
529 |
+
# no harm in redundantly calling close.
|
530 |
+
self._fp.close()
|
531 |
+
flush_decoder = True
|
532 |
+
if self.enforce_content_length and self.length_remaining not in (
|
533 |
+
0,
|
534 |
+
None,
|
535 |
+
):
|
536 |
+
# This is an edge case that httplib failed to cover due
|
537 |
+
# to concerns of backward compatibility. We're
|
538 |
+
# addressing it here to make sure IncompleteRead is
|
539 |
+
# raised during streaming, so all calls with incorrect
|
540 |
+
# Content-Length are caught.
|
541 |
+
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
|
542 |
+
|
543 |
+
if data:
|
544 |
+
self._fp_bytes_read += len(data)
|
545 |
+
if self.length_remaining is not None:
|
546 |
+
self.length_remaining -= len(data)
|
547 |
+
|
548 |
+
data = self._decode(data, decode_content, flush_decoder)
|
549 |
+
|
550 |
+
if cache_content:
|
551 |
+
self._body = data
|
552 |
+
|
553 |
+
return data
|
554 |
+
|
555 |
+
def stream(self, amt=2 ** 16, decode_content=None):
|
556 |
+
"""
|
557 |
+
A generator wrapper for the read() method. A call will block until
|
558 |
+
``amt`` bytes have been read from the connection or until the
|
559 |
+
connection is closed.
|
560 |
+
|
561 |
+
:param amt:
|
562 |
+
How much of the content to read. The generator will return up to
|
563 |
+
much data per iteration, but may return less. This is particularly
|
564 |
+
likely when using compressed data. However, the empty string will
|
565 |
+
never be returned.
|
566 |
+
|
567 |
+
:param decode_content:
|
568 |
+
If True, will attempt to decode the body based on the
|
569 |
+
'content-encoding' header.
|
570 |
+
"""
|
571 |
+
if self.chunked and self.supports_chunked_reads():
|
572 |
+
for line in self.read_chunked(amt, decode_content=decode_content):
|
573 |
+
yield line
|
574 |
+
else:
|
575 |
+
while not is_fp_closed(self._fp):
|
576 |
+
data = self.read(amt=amt, decode_content=decode_content)
|
577 |
+
|
578 |
+
if data:
|
579 |
+
yield data
|
580 |
+
|
581 |
+
@classmethod
|
582 |
+
def from_httplib(ResponseCls, r, **response_kw):
|
583 |
+
"""
|
584 |
+
Given an :class:`http.client.HTTPResponse` instance ``r``, return a
|
585 |
+
corresponding :class:`urllib3.response.HTTPResponse` object.
|
586 |
+
|
587 |
+
Remaining parameters are passed to the HTTPResponse constructor, along
|
588 |
+
with ``original_response=r``.
|
589 |
+
"""
|
590 |
+
headers = r.msg
|
591 |
+
|
592 |
+
if not isinstance(headers, HTTPHeaderDict):
|
593 |
+
if six.PY2:
|
594 |
+
# Python 2.7
|
595 |
+
headers = HTTPHeaderDict.from_httplib(headers)
|
596 |
+
else:
|
597 |
+
headers = HTTPHeaderDict(headers.items())
|
598 |
+
|
599 |
+
# HTTPResponse objects in Python 3 don't have a .strict attribute
|
600 |
+
strict = getattr(r, "strict", 0)
|
601 |
+
resp = ResponseCls(
|
602 |
+
body=r,
|
603 |
+
headers=headers,
|
604 |
+
status=r.status,
|
605 |
+
version=r.version,
|
606 |
+
reason=r.reason,
|
607 |
+
strict=strict,
|
608 |
+
original_response=r,
|
609 |
+
**response_kw
|
610 |
+
)
|
611 |
+
return resp
|
612 |
+
|
613 |
+
# Backwards-compatibility methods for http.client.HTTPResponse
|
614 |
+
def getheaders(self):
|
615 |
+
return self.headers
|
616 |
+
|
617 |
+
def getheader(self, name, default=None):
|
618 |
+
return self.headers.get(name, default)
|
619 |
+
|
620 |
+
# Backwards compatibility for http.cookiejar
|
621 |
+
def info(self):
|
622 |
+
return self.headers
|
623 |
+
|
624 |
+
# Overrides from io.IOBase
|
625 |
+
def close(self):
|
626 |
+
if not self.closed:
|
627 |
+
self._fp.close()
|
628 |
+
|
629 |
+
if self._connection:
|
630 |
+
self._connection.close()
|
631 |
+
|
632 |
+
if not self.auto_close:
|
633 |
+
io.IOBase.close(self)
|
634 |
+
|
635 |
+
@property
|
636 |
+
def closed(self):
|
637 |
+
if not self.auto_close:
|
638 |
+
return io.IOBase.closed.__get__(self)
|
639 |
+
elif self._fp is None:
|
640 |
+
return True
|
641 |
+
elif hasattr(self._fp, "isclosed"):
|
642 |
+
return self._fp.isclosed()
|
643 |
+
elif hasattr(self._fp, "closed"):
|
644 |
+
return self._fp.closed
|
645 |
+
else:
|
646 |
+
return True
|
647 |
+
|
648 |
+
def fileno(self):
|
649 |
+
if self._fp is None:
|
650 |
+
raise IOError("HTTPResponse has no file to get a fileno from")
|
651 |
+
elif hasattr(self._fp, "fileno"):
|
652 |
+
return self._fp.fileno()
|
653 |
+
else:
|
654 |
+
raise IOError(
|
655 |
+
"The file-like object this HTTPResponse is wrapped "
|
656 |
+
"around has no file descriptor"
|
657 |
+
)
|
658 |
+
|
659 |
+
def flush(self):
|
660 |
+
if (
|
661 |
+
self._fp is not None
|
662 |
+
and hasattr(self._fp, "flush")
|
663 |
+
and not getattr(self._fp, "closed", False)
|
664 |
+
):
|
665 |
+
return self._fp.flush()
|
666 |
+
|
667 |
+
def readable(self):
|
668 |
+
# This method is required for `io` module compatibility.
|
669 |
+
return True
|
670 |
+
|
671 |
+
def readinto(self, b):
|
672 |
+
# This method is required for `io` module compatibility.
|
673 |
+
temp = self.read(len(b))
|
674 |
+
if len(temp) == 0:
|
675 |
+
return 0
|
676 |
+
else:
|
677 |
+
b[: len(temp)] = temp
|
678 |
+
return len(temp)
|
679 |
+
|
680 |
+
def supports_chunked_reads(self):
|
681 |
+
"""
|
682 |
+
Checks if the underlying file-like object looks like a
|
683 |
+
:class:`http.client.HTTPResponse` object. We do this by testing for
|
684 |
+
the fp attribute. If it is present we assume it returns raw chunks as
|
685 |
+
processed by read_chunked().
|
686 |
+
"""
|
687 |
+
return hasattr(self._fp, "fp")
|
688 |
+
|
689 |
+
def _update_chunk_length(self):
|
690 |
+
# First, we'll figure out length of a chunk and then
|
691 |
+
# we'll try to read it from socket.
|
692 |
+
if self.chunk_left is not None:
|
693 |
+
return
|
694 |
+
line = self._fp.fp.readline()
|
695 |
+
line = line.split(b";", 1)[0]
|
696 |
+
try:
|
697 |
+
self.chunk_left = int(line, 16)
|
698 |
+
except ValueError:
|
699 |
+
# Invalid chunked protocol response, abort.
|
700 |
+
self.close()
|
701 |
+
raise InvalidChunkLength(self, line)
|
702 |
+
|
703 |
+
def _handle_chunk(self, amt):
|
704 |
+
returned_chunk = None
|
705 |
+
if amt is None:
|
706 |
+
chunk = self._fp._safe_read(self.chunk_left)
|
707 |
+
returned_chunk = chunk
|
708 |
+
self._fp._safe_read(2) # Toss the CRLF at the end of the chunk.
|
709 |
+
self.chunk_left = None
|
710 |
+
elif amt < self.chunk_left:
|
711 |
+
value = self._fp._safe_read(amt)
|
712 |
+
self.chunk_left = self.chunk_left - amt
|
713 |
+
returned_chunk = value
|
714 |
+
elif amt == self.chunk_left:
|
715 |
+
value = self._fp._safe_read(amt)
|
716 |
+
self._fp._safe_read(2) # Toss the CRLF at the end of the chunk.
|
717 |
+
self.chunk_left = None
|
718 |
+
returned_chunk = value
|
719 |
+
else: # amt > self.chunk_left
|
720 |
+
returned_chunk = self._fp._safe_read(self.chunk_left)
|
721 |
+
self._fp._safe_read(2) # Toss the CRLF at the end of the chunk.
|
722 |
+
self.chunk_left = None
|
723 |
+
return returned_chunk
|
724 |
+
|
725 |
+
def read_chunked(self, amt=None, decode_content=None):
|
726 |
+
"""
|
727 |
+
Similar to :meth:`HTTPResponse.read`, but with an additional
|
728 |
+
parameter: ``decode_content``.
|
729 |
+
|
730 |
+
:param amt:
|
731 |
+
How much of the content to read. If specified, caching is skipped
|
732 |
+
because it doesn't make sense to cache partial content as the full
|
733 |
+
response.
|
734 |
+
|
735 |
+
:param decode_content:
|
736 |
+
If True, will attempt to decode the body based on the
|
737 |
+
'content-encoding' header.
|
738 |
+
"""
|
739 |
+
self._init_decoder()
|
740 |
+
# FIXME: Rewrite this method and make it a class with a better structured logic.
|
741 |
+
if not self.chunked:
|
742 |
+
raise ResponseNotChunked(
|
743 |
+
"Response is not chunked. "
|
744 |
+
"Header 'transfer-encoding: chunked' is missing."
|
745 |
+
)
|
746 |
+
if not self.supports_chunked_reads():
|
747 |
+
raise BodyNotHttplibCompatible(
|
748 |
+
"Body should be http.client.HTTPResponse like. "
|
749 |
+
"It should have have an fp attribute which returns raw chunks."
|
750 |
+
)
|
751 |
+
|
752 |
+
with self._error_catcher():
|
753 |
+
# Don't bother reading the body of a HEAD request.
|
754 |
+
if self._original_response and is_response_to_head(self._original_response):
|
755 |
+
self._original_response.close()
|
756 |
+
return
|
757 |
+
|
758 |
+
# If a response is already read and closed
|
759 |
+
# then return immediately.
|
760 |
+
if self._fp.fp is None:
|
761 |
+
return
|
762 |
+
|
763 |
+
while True:
|
764 |
+
self._update_chunk_length()
|
765 |
+
if self.chunk_left == 0:
|
766 |
+
break
|
767 |
+
chunk = self._handle_chunk(amt)
|
768 |
+
decoded = self._decode(
|
769 |
+
chunk, decode_content=decode_content, flush_decoder=False
|
770 |
+
)
|
771 |
+
if decoded:
|
772 |
+
yield decoded
|
773 |
+
|
774 |
+
if decode_content:
|
775 |
+
# On CPython and PyPy, we should never need to flush the
|
776 |
+
# decoder. However, on Jython we *might* need to, so
|
777 |
+
# lets defensively do it anyway.
|
778 |
+
decoded = self._flush_decoder()
|
779 |
+
if decoded: # Platform-specific: Jython.
|
780 |
+
yield decoded
|
781 |
+
|
782 |
+
# Chunk content ends with \r\n: discard it.
|
783 |
+
while True:
|
784 |
+
line = self._fp.fp.readline()
|
785 |
+
if not line:
|
786 |
+
# Some sites may not end with '\r\n'.
|
787 |
+
break
|
788 |
+
if line == b"\r\n":
|
789 |
+
break
|
790 |
+
|
791 |
+
# We read everything; close the "file".
|
792 |
+
if self._original_response:
|
793 |
+
self._original_response.close()
|
794 |
+
|
795 |
+
def geturl(self):
|
796 |
+
"""
|
797 |
+
Returns the URL that was the source of this response.
|
798 |
+
If the request that generated this response redirected, this method
|
799 |
+
will return the final redirect location.
|
800 |
+
"""
|
801 |
+
if self.retries is not None and len(self.retries.history):
|
802 |
+
return self.retries.history[-1].redirect_location
|
803 |
+
else:
|
804 |
+
return self._request_url
|
805 |
+
|
806 |
+
def __iter__(self):
|
807 |
+
buffer = []
|
808 |
+
for chunk in self.stream(decode_content=True):
|
809 |
+
if b"\n" in chunk:
|
810 |
+
chunk = chunk.split(b"\n")
|
811 |
+
yield b"".join(buffer) + chunk[0] + b"\n"
|
812 |
+
for x in chunk[1:-1]:
|
813 |
+
yield x + b"\n"
|
814 |
+
if chunk[-1]:
|
815 |
+
buffer = [chunk[-1]]
|
816 |
+
else:
|
817 |
+
buffer = []
|
818 |
+
else:
|
819 |
+
buffer.append(chunk)
|
820 |
+
if buffer:
|
821 |
+
yield b"".join(buffer)
|
llmeval-env/lib/python3.10/site-packages/pip/_vendor/urllib3/util/__init__.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import absolute_import
|
2 |
+
|
3 |
+
# For backwards compatibility, provide imports that used to be here.
|
4 |
+
from .connection import is_connection_dropped
|
5 |
+
from .request import SKIP_HEADER, SKIPPABLE_HEADERS, make_headers
|
6 |
+
from .response import is_fp_closed
|
7 |
+
from .retry import Retry
|
8 |
+
from .ssl_ import (
|
9 |
+
ALPN_PROTOCOLS,
|
10 |
+
HAS_SNI,
|
11 |
+
IS_PYOPENSSL,
|
12 |
+
IS_SECURETRANSPORT,
|
13 |
+
PROTOCOL_TLS,
|
14 |
+
SSLContext,
|
15 |
+
assert_fingerprint,
|
16 |
+
resolve_cert_reqs,
|
17 |
+
resolve_ssl_version,
|
18 |
+
ssl_wrap_socket,
|
19 |
+
)
|
20 |
+
from .timeout import Timeout, current_time
|
21 |
+
from .url import Url, get_host, parse_url, split_first
|
22 |
+
from .wait import wait_for_read, wait_for_write
|
23 |
+
|
24 |
+
__all__ = (
|
25 |
+
"HAS_SNI",
|
26 |
+
"IS_PYOPENSSL",
|
27 |
+
"IS_SECURETRANSPORT",
|
28 |
+
"SSLContext",
|
29 |
+
"PROTOCOL_TLS",
|
30 |
+
"ALPN_PROTOCOLS",
|
31 |
+
"Retry",
|
32 |
+
"Timeout",
|
33 |
+
"Url",
|
34 |
+
"assert_fingerprint",
|
35 |
+
"current_time",
|
36 |
+
"is_connection_dropped",
|
37 |
+
"is_fp_closed",
|
38 |
+
"get_host",
|
39 |
+
"parse_url",
|
40 |
+
"make_headers",
|
41 |
+
"resolve_cert_reqs",
|
42 |
+
"resolve_ssl_version",
|
43 |
+
"split_first",
|
44 |
+
"ssl_wrap_socket",
|
45 |
+
"wait_for_read",
|
46 |
+
"wait_for_write",
|
47 |
+
"SKIP_HEADER",
|
48 |
+
"SKIPPABLE_HEADERS",
|
49 |
+
)
|