ZTWHHH commited on
Commit
4d3222f
·
verified ·
1 Parent(s): 280d421

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/__pycache__/parser.cpython-310.pyc +0 -0
  2. evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/__pycache__/shapes.cpython-310.pyc +0 -0
  3. evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/parser.py +322 -0
  4. evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/shapes.py +183 -0
  5. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/__main__.cpython-310.pyc +0 -0
  6. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/avar.cpython-310.pyc +0 -0
  7. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/avarPlanner.cpython-310.pyc +0 -0
  8. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/cff.cpython-310.pyc +0 -0
  9. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/interpolatableHelpers.cpython-310.pyc +0 -0
  10. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/interpolate_layout.cpython-310.pyc +0 -0
  11. evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/instancer/__pycache__/solver.cpython-310.pyc +0 -0
  12. evalkit_tf437/lib/python3.10/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/Index.DdudhzXc.js.gz +3 -0
  13. evalkit_tf437/lib/python3.10/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/r.H5fUPB2b.js.gz +3 -0
  14. evalkit_tf437/lib/python3.10/site-packages/httpx/__init__.py +105 -0
  15. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/__init__.cpython-310.pyc +0 -0
  16. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_api.cpython-310.pyc +0 -0
  17. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_auth.cpython-310.pyc +0 -0
  18. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_client.cpython-310.pyc +0 -0
  19. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_compat.cpython-310.pyc +0 -0
  20. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_config.cpython-310.pyc +0 -0
  21. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_multipart.cpython-310.pyc +0 -0
  22. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_types.cpython-310.pyc +0 -0
  23. evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_urlparse.cpython-310.pyc +0 -0
  24. evalkit_tf437/lib/python3.10/site-packages/httpx/_client.py +2065 -0
  25. evalkit_tf437/lib/python3.10/site-packages/httpx/_multipart.py +269 -0
  26. evalkit_tf437/lib/python3.10/site-packages/httpx/_transports/__pycache__/default.cpython-310.pyc +0 -0
  27. evalkit_tf437/lib/python3.10/site-packages/httpx/_transports/default.py +389 -0
  28. evalkit_tf437/lib/python3.10/site-packages/httpx/_transports/mock.py +43 -0
  29. evalkit_tf437/lib/python3.10/site-packages/importlib_metadata-8.5.0.dist-info/INSTALLER +1 -0
  30. evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/LICENSE.txt +59 -0
  31. evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/METADATA +50 -0
  32. evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/RECORD +11 -0
  33. evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/REQUESTED +0 -0
  34. evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/entry_points.txt +3 -0
  35. evalkit_tf437/lib/python3.10/site-packages/nvidia_nvjitlink_cu12-12.6.77.dist-info/REQUESTED +0 -0
  36. evalkit_tf437/lib/python3.10/site-packages/oauthlib-3.2.2.dist-info/INSTALLER +1 -0
  37. evalkit_tf437/lib/python3.10/site-packages/oauthlib-3.2.2.dist-info/REQUESTED +0 -0
  38. evalkit_tf437/lib/python3.10/site-packages/oauthlib-3.2.2.dist-info/top_level.txt +1 -0
  39. evalkit_tf437/lib/python3.10/site-packages/opencv_python-4.10.0.84.dist-info/top_level.txt +1 -0
  40. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/INSTALLER +1 -0
  41. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/LICENSE +3 -0
  42. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/LICENSE.APACHE +177 -0
  43. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/METADATA +102 -0
  44. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/RECORD +41 -0
  45. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/REQUESTED +0 -0
  46. evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/WHEEL +4 -0
  47. evalkit_tf437/lib/python3.10/site-packages/pygments/__main__.py +17 -0
  48. evalkit_tf437/lib/python3.10/site-packages/pygments/formatter.py +129 -0
  49. evalkit_tf437/lib/python3.10/site-packages/pygments/formatters/__pycache__/_mapping.cpython-310.pyc +0 -0
  50. evalkit_tf437/lib/python3.10/site-packages/pygments/formatters/__pycache__/bbcode.cpython-310.pyc +0 -0
evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/__pycache__/parser.cpython-310.pyc ADDED
Binary file (4.7 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/__pycache__/shapes.cpython-310.pyc ADDED
Binary file (6.39 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/parser.py ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SVG Path specification parser.
2
+ # This is an adaptation from 'svg.path' by Lennart Regebro (@regebro),
3
+ # modified so that the parser takes a FontTools Pen object instead of
4
+ # returning a list of svg.path Path objects.
5
+ # The original code can be found at:
6
+ # https://github.com/regebro/svg.path/blob/4f9b6e3/src/svg/path/parser.py
7
+ # Copyright (c) 2013-2014 Lennart Regebro
8
+ # License: MIT
9
+
10
+ from .arc import EllipticalArc
11
+ import re
12
+
13
+
14
+ COMMANDS = set("MmZzLlHhVvCcSsQqTtAa")
15
+ ARC_COMMANDS = set("Aa")
16
+ UPPERCASE = set("MZLHVCSQTA")
17
+
18
+ COMMAND_RE = re.compile("([MmZzLlHhVvCcSsQqTtAa])")
19
+
20
+ # https://www.w3.org/TR/css-syntax-3/#number-token-diagram
21
+ # but -6.e-5 will be tokenized as "-6" then "-5" and confuse parsing
22
+ FLOAT_RE = re.compile(
23
+ r"[-+]?" # optional sign
24
+ r"(?:"
25
+ r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][-+]?[0-9]+)?" # int/float
26
+ r"|"
27
+ r"(?:\.[0-9]+(?:[eE][-+]?[0-9]+)?)" # float with leading dot (e.g. '.42')
28
+ r")"
29
+ )
30
+ BOOL_RE = re.compile("^[01]")
31
+ SEPARATOR_RE = re.compile(f"[, \t]")
32
+
33
+
34
+ def _tokenize_path(pathdef):
35
+ arc_cmd = None
36
+ for x in COMMAND_RE.split(pathdef):
37
+ if x in COMMANDS:
38
+ arc_cmd = x if x in ARC_COMMANDS else None
39
+ yield x
40
+ continue
41
+
42
+ if arc_cmd:
43
+ try:
44
+ yield from _tokenize_arc_arguments(x)
45
+ except ValueError as e:
46
+ raise ValueError(f"Invalid arc command: '{arc_cmd}{x}'") from e
47
+ else:
48
+ for token in FLOAT_RE.findall(x):
49
+ yield token
50
+
51
+
52
+ ARC_ARGUMENT_TYPES = (
53
+ ("rx", FLOAT_RE),
54
+ ("ry", FLOAT_RE),
55
+ ("x-axis-rotation", FLOAT_RE),
56
+ ("large-arc-flag", BOOL_RE),
57
+ ("sweep-flag", BOOL_RE),
58
+ ("x", FLOAT_RE),
59
+ ("y", FLOAT_RE),
60
+ )
61
+
62
+
63
+ def _tokenize_arc_arguments(arcdef):
64
+ raw_args = [s for s in SEPARATOR_RE.split(arcdef) if s]
65
+ if not raw_args:
66
+ raise ValueError(f"Not enough arguments: '{arcdef}'")
67
+ raw_args.reverse()
68
+
69
+ i = 0
70
+ while raw_args:
71
+ arg = raw_args.pop()
72
+
73
+ name, pattern = ARC_ARGUMENT_TYPES[i]
74
+ match = pattern.search(arg)
75
+ if not match:
76
+ raise ValueError(f"Invalid argument for '{name}' parameter: {arg!r}")
77
+
78
+ j, k = match.span()
79
+ yield arg[j:k]
80
+ arg = arg[k:]
81
+
82
+ if arg:
83
+ raw_args.append(arg)
84
+
85
+ # wrap around every 7 consecutive arguments
86
+ if i == 6:
87
+ i = 0
88
+ else:
89
+ i += 1
90
+
91
+ if i != 0:
92
+ raise ValueError(f"Not enough arguments: '{arcdef}'")
93
+
94
+
95
+ def parse_path(pathdef, pen, current_pos=(0, 0), arc_class=EllipticalArc):
96
+ """Parse SVG path definition (i.e. "d" attribute of <path> elements)
97
+ and call a 'pen' object's moveTo, lineTo, curveTo, qCurveTo and closePath
98
+ methods.
99
+
100
+ If 'current_pos' (2-float tuple) is provided, the initial moveTo will
101
+ be relative to that instead being absolute.
102
+
103
+ If the pen has an "arcTo" method, it is called with the original values
104
+ of the elliptical arc curve commands:
105
+
106
+ .. code-block::
107
+
108
+ pen.arcTo(rx, ry, rotation, arc_large, arc_sweep, (x, y))
109
+
110
+ Otherwise, the arcs are approximated by series of cubic Bezier segments
111
+ ("curveTo"), one every 90 degrees.
112
+ """
113
+ # In the SVG specs, initial movetos are absolute, even if
114
+ # specified as 'm'. This is the default behavior here as well.
115
+ # But if you pass in a current_pos variable, the initial moveto
116
+ # will be relative to that current_pos. This is useful.
117
+ current_pos = complex(*current_pos)
118
+
119
+ elements = list(_tokenize_path(pathdef))
120
+ # Reverse for easy use of .pop()
121
+ elements.reverse()
122
+
123
+ start_pos = None
124
+ command = None
125
+ last_control = None
126
+
127
+ have_arcTo = hasattr(pen, "arcTo")
128
+
129
+ while elements:
130
+ if elements[-1] in COMMANDS:
131
+ # New command.
132
+ last_command = command # Used by S and T
133
+ command = elements.pop()
134
+ absolute = command in UPPERCASE
135
+ command = command.upper()
136
+ else:
137
+ # If this element starts with numbers, it is an implicit command
138
+ # and we don't change the command. Check that it's allowed:
139
+ if command is None:
140
+ raise ValueError(
141
+ "Unallowed implicit command in %s, position %s"
142
+ % (pathdef, len(pathdef.split()) - len(elements))
143
+ )
144
+ last_command = command # Used by S and T
145
+
146
+ if command == "M":
147
+ # Moveto command.
148
+ x = elements.pop()
149
+ y = elements.pop()
150
+ pos = float(x) + float(y) * 1j
151
+ if absolute:
152
+ current_pos = pos
153
+ else:
154
+ current_pos += pos
155
+
156
+ # M is not preceded by Z; it's an open subpath
157
+ if start_pos is not None:
158
+ pen.endPath()
159
+
160
+ pen.moveTo((current_pos.real, current_pos.imag))
161
+
162
+ # when M is called, reset start_pos
163
+ # This behavior of Z is defined in svg spec:
164
+ # http://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand
165
+ start_pos = current_pos
166
+
167
+ # Implicit moveto commands are treated as lineto commands.
168
+ # So we set command to lineto here, in case there are
169
+ # further implicit commands after this moveto.
170
+ command = "L"
171
+
172
+ elif command == "Z":
173
+ # Close path
174
+ if current_pos != start_pos:
175
+ pen.lineTo((start_pos.real, start_pos.imag))
176
+ pen.closePath()
177
+ current_pos = start_pos
178
+ start_pos = None
179
+ command = None # You can't have implicit commands after closing.
180
+
181
+ elif command == "L":
182
+ x = elements.pop()
183
+ y = elements.pop()
184
+ pos = float(x) + float(y) * 1j
185
+ if not absolute:
186
+ pos += current_pos
187
+ pen.lineTo((pos.real, pos.imag))
188
+ current_pos = pos
189
+
190
+ elif command == "H":
191
+ x = elements.pop()
192
+ pos = float(x) + current_pos.imag * 1j
193
+ if not absolute:
194
+ pos += current_pos.real
195
+ pen.lineTo((pos.real, pos.imag))
196
+ current_pos = pos
197
+
198
+ elif command == "V":
199
+ y = elements.pop()
200
+ pos = current_pos.real + float(y) * 1j
201
+ if not absolute:
202
+ pos += current_pos.imag * 1j
203
+ pen.lineTo((pos.real, pos.imag))
204
+ current_pos = pos
205
+
206
+ elif command == "C":
207
+ control1 = float(elements.pop()) + float(elements.pop()) * 1j
208
+ control2 = float(elements.pop()) + float(elements.pop()) * 1j
209
+ end = float(elements.pop()) + float(elements.pop()) * 1j
210
+
211
+ if not absolute:
212
+ control1 += current_pos
213
+ control2 += current_pos
214
+ end += current_pos
215
+
216
+ pen.curveTo(
217
+ (control1.real, control1.imag),
218
+ (control2.real, control2.imag),
219
+ (end.real, end.imag),
220
+ )
221
+ current_pos = end
222
+ last_control = control2
223
+
224
+ elif command == "S":
225
+ # Smooth curve. First control point is the "reflection" of
226
+ # the second control point in the previous path.
227
+
228
+ if last_command not in "CS":
229
+ # If there is no previous command or if the previous command
230
+ # was not an C, c, S or s, assume the first control point is
231
+ # coincident with the current point.
232
+ control1 = current_pos
233
+ else:
234
+ # The first control point is assumed to be the reflection of
235
+ # the second control point on the previous command relative
236
+ # to the current point.
237
+ control1 = current_pos + current_pos - last_control
238
+
239
+ control2 = float(elements.pop()) + float(elements.pop()) * 1j
240
+ end = float(elements.pop()) + float(elements.pop()) * 1j
241
+
242
+ if not absolute:
243
+ control2 += current_pos
244
+ end += current_pos
245
+
246
+ pen.curveTo(
247
+ (control1.real, control1.imag),
248
+ (control2.real, control2.imag),
249
+ (end.real, end.imag),
250
+ )
251
+ current_pos = end
252
+ last_control = control2
253
+
254
+ elif command == "Q":
255
+ control = float(elements.pop()) + float(elements.pop()) * 1j
256
+ end = float(elements.pop()) + float(elements.pop()) * 1j
257
+
258
+ if not absolute:
259
+ control += current_pos
260
+ end += current_pos
261
+
262
+ pen.qCurveTo((control.real, control.imag), (end.real, end.imag))
263
+ current_pos = end
264
+ last_control = control
265
+
266
+ elif command == "T":
267
+ # Smooth curve. Control point is the "reflection" of
268
+ # the second control point in the previous path.
269
+
270
+ if last_command not in "QT":
271
+ # If there is no previous command or if the previous command
272
+ # was not an Q, q, T or t, assume the first control point is
273
+ # coincident with the current point.
274
+ control = current_pos
275
+ else:
276
+ # The control point is assumed to be the reflection of
277
+ # the control point on the previous command relative
278
+ # to the current point.
279
+ control = current_pos + current_pos - last_control
280
+
281
+ end = float(elements.pop()) + float(elements.pop()) * 1j
282
+
283
+ if not absolute:
284
+ end += current_pos
285
+
286
+ pen.qCurveTo((control.real, control.imag), (end.real, end.imag))
287
+ current_pos = end
288
+ last_control = control
289
+
290
+ elif command == "A":
291
+ rx = abs(float(elements.pop()))
292
+ ry = abs(float(elements.pop()))
293
+ rotation = float(elements.pop())
294
+ arc_large = bool(int(elements.pop()))
295
+ arc_sweep = bool(int(elements.pop()))
296
+ end = float(elements.pop()) + float(elements.pop()) * 1j
297
+
298
+ if not absolute:
299
+ end += current_pos
300
+
301
+ # if the pen supports arcs, pass the values unchanged, otherwise
302
+ # approximate the arc with a series of cubic bezier curves
303
+ if have_arcTo:
304
+ pen.arcTo(
305
+ rx,
306
+ ry,
307
+ rotation,
308
+ arc_large,
309
+ arc_sweep,
310
+ (end.real, end.imag),
311
+ )
312
+ else:
313
+ arc = arc_class(
314
+ current_pos, rx, ry, rotation, arc_large, arc_sweep, end
315
+ )
316
+ arc.draw(pen)
317
+
318
+ current_pos = end
319
+
320
+ # no final Z command, it's an open path
321
+ if start_pos is not None:
322
+ pen.endPath()
evalkit_tf437/lib/python3.10/site-packages/fontTools/svgLib/path/shapes.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+
4
+ def _prefer_non_zero(*args):
5
+ for arg in args:
6
+ if arg != 0:
7
+ return arg
8
+ return 0.0
9
+
10
+
11
+ def _ntos(n):
12
+ # %f likes to add unnecessary 0's, %g isn't consistent about # decimals
13
+ return ("%.3f" % n).rstrip("0").rstrip(".")
14
+
15
+
16
+ def _strip_xml_ns(tag):
17
+ # ElementTree API doesn't provide a way to ignore XML namespaces in tags
18
+ # so we here strip them ourselves: cf. https://bugs.python.org/issue18304
19
+ return tag.split("}", 1)[1] if "}" in tag else tag
20
+
21
+
22
+ def _transform(raw_value):
23
+ # TODO assumes a 'matrix' transform.
24
+ # No other transform functions are supported at the moment.
25
+ # https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform
26
+ # start simple: if you aren't exactly matrix(...) then no love
27
+ match = re.match(r"matrix\((.*)\)", raw_value)
28
+ if not match:
29
+ raise NotImplementedError
30
+ matrix = tuple(float(p) for p in re.split(r"\s+|,", match.group(1)))
31
+ if len(matrix) != 6:
32
+ raise ValueError("wrong # of terms in %s" % raw_value)
33
+ return matrix
34
+
35
+
36
+ class PathBuilder(object):
37
+ def __init__(self):
38
+ self.paths = []
39
+ self.transforms = []
40
+
41
+ def _start_path(self, initial_path=""):
42
+ self.paths.append(initial_path)
43
+ self.transforms.append(None)
44
+
45
+ def _end_path(self):
46
+ self._add("z")
47
+
48
+ def _add(self, path_snippet):
49
+ path = self.paths[-1]
50
+ if path:
51
+ path += " " + path_snippet
52
+ else:
53
+ path = path_snippet
54
+ self.paths[-1] = path
55
+
56
+ def _move(self, c, x, y):
57
+ self._add("%s%s,%s" % (c, _ntos(x), _ntos(y)))
58
+
59
+ def M(self, x, y):
60
+ self._move("M", x, y)
61
+
62
+ def m(self, x, y):
63
+ self._move("m", x, y)
64
+
65
+ def _arc(self, c, rx, ry, x, y, large_arc):
66
+ self._add(
67
+ "%s%s,%s 0 %d 1 %s,%s"
68
+ % (c, _ntos(rx), _ntos(ry), large_arc, _ntos(x), _ntos(y))
69
+ )
70
+
71
+ def A(self, rx, ry, x, y, large_arc=0):
72
+ self._arc("A", rx, ry, x, y, large_arc)
73
+
74
+ def a(self, rx, ry, x, y, large_arc=0):
75
+ self._arc("a", rx, ry, x, y, large_arc)
76
+
77
+ def _vhline(self, c, x):
78
+ self._add("%s%s" % (c, _ntos(x)))
79
+
80
+ def H(self, x):
81
+ self._vhline("H", x)
82
+
83
+ def h(self, x):
84
+ self._vhline("h", x)
85
+
86
+ def V(self, y):
87
+ self._vhline("V", y)
88
+
89
+ def v(self, y):
90
+ self._vhline("v", y)
91
+
92
+ def _line(self, c, x, y):
93
+ self._add("%s%s,%s" % (c, _ntos(x), _ntos(y)))
94
+
95
+ def L(self, x, y):
96
+ self._line("L", x, y)
97
+
98
+ def l(self, x, y):
99
+ self._line("l", x, y)
100
+
101
+ def _parse_line(self, line):
102
+ x1 = float(line.attrib.get("x1", 0))
103
+ y1 = float(line.attrib.get("y1", 0))
104
+ x2 = float(line.attrib.get("x2", 0))
105
+ y2 = float(line.attrib.get("y2", 0))
106
+
107
+ self._start_path()
108
+ self.M(x1, y1)
109
+ self.L(x2, y2)
110
+
111
+ def _parse_rect(self, rect):
112
+ x = float(rect.attrib.get("x", 0))
113
+ y = float(rect.attrib.get("y", 0))
114
+ w = float(rect.attrib.get("width"))
115
+ h = float(rect.attrib.get("height"))
116
+ rx = float(rect.attrib.get("rx", 0))
117
+ ry = float(rect.attrib.get("ry", 0))
118
+
119
+ rx = _prefer_non_zero(rx, ry)
120
+ ry = _prefer_non_zero(ry, rx)
121
+ # TODO there are more rules for adjusting rx, ry
122
+
123
+ self._start_path()
124
+ self.M(x + rx, y)
125
+ self.H(x + w - rx)
126
+ if rx > 0:
127
+ self.A(rx, ry, x + w, y + ry)
128
+ self.V(y + h - ry)
129
+ if rx > 0:
130
+ self.A(rx, ry, x + w - rx, y + h)
131
+ self.H(x + rx)
132
+ if rx > 0:
133
+ self.A(rx, ry, x, y + h - ry)
134
+ self.V(y + ry)
135
+ if rx > 0:
136
+ self.A(rx, ry, x + rx, y)
137
+ self._end_path()
138
+
139
+ def _parse_path(self, path):
140
+ if "d" in path.attrib:
141
+ self._start_path(initial_path=path.attrib["d"])
142
+
143
+ def _parse_polygon(self, poly):
144
+ if "points" in poly.attrib:
145
+ self._start_path("M" + poly.attrib["points"])
146
+ self._end_path()
147
+
148
+ def _parse_polyline(self, poly):
149
+ if "points" in poly.attrib:
150
+ self._start_path("M" + poly.attrib["points"])
151
+
152
+ def _parse_circle(self, circle):
153
+ cx = float(circle.attrib.get("cx", 0))
154
+ cy = float(circle.attrib.get("cy", 0))
155
+ r = float(circle.attrib.get("r"))
156
+
157
+ # arc doesn't seem to like being a complete shape, draw two halves
158
+ self._start_path()
159
+ self.M(cx - r, cy)
160
+ self.A(r, r, cx + r, cy, large_arc=1)
161
+ self.A(r, r, cx - r, cy, large_arc=1)
162
+
163
+ def _parse_ellipse(self, ellipse):
164
+ cx = float(ellipse.attrib.get("cx", 0))
165
+ cy = float(ellipse.attrib.get("cy", 0))
166
+ rx = float(ellipse.attrib.get("rx"))
167
+ ry = float(ellipse.attrib.get("ry"))
168
+
169
+ # arc doesn't seem to like being a complete shape, draw two halves
170
+ self._start_path()
171
+ self.M(cx - rx, cy)
172
+ self.A(rx, ry, cx + rx, cy, large_arc=1)
173
+ self.A(rx, ry, cx - rx, cy, large_arc=1)
174
+
175
+ def add_path_from_element(self, el):
176
+ tag = _strip_xml_ns(el.tag)
177
+ parse_fn = getattr(self, "_parse_%s" % tag.lower(), None)
178
+ if not callable(parse_fn):
179
+ return False
180
+ parse_fn(el)
181
+ if "transform" in el.attrib:
182
+ self.transforms[-1] = _transform(el.attrib["transform"])
183
+ return True
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/__main__.cpython-310.pyc ADDED
Binary file (291 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/avar.cpython-310.pyc ADDED
Binary file (7.03 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/avarPlanner.cpython-310.pyc ADDED
Binary file (19.3 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/cff.cpython-310.pyc ADDED
Binary file (17 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/interpolatableHelpers.cpython-310.pyc ADDED
Binary file (12.5 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/__pycache__/interpolate_layout.cpython-310.pyc ADDED
Binary file (3.83 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/fontTools/varLib/instancer/__pycache__/solver.cpython-310.pyc ADDED
Binary file (3.27 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/Index.DdudhzXc.js.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:add155f13f945d752e981d49373bb7956903c347e5a955ef304c84e7db4ac593
3
+ size 30137
evalkit_tf437/lib/python3.10/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/r.H5fUPB2b.js.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5820b440acd4cdf1daf3212dcc23e98ddb5f3c37f29bfd378da52244fac569e1
3
+ size 1755
evalkit_tf437/lib/python3.10/site-packages/httpx/__init__.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .__version__ import __description__, __title__, __version__
2
+ from ._api import *
3
+ from ._auth import *
4
+ from ._client import *
5
+ from ._config import *
6
+ from ._content import *
7
+ from ._exceptions import *
8
+ from ._models import *
9
+ from ._status_codes import *
10
+ from ._transports import *
11
+ from ._types import *
12
+ from ._urls import *
13
+
14
+ try:
15
+ from ._main import main
16
+ except ImportError: # pragma: no cover
17
+
18
+ def main() -> None: # type: ignore
19
+ import sys
20
+
21
+ print(
22
+ "The httpx command line client could not run because the required "
23
+ "dependencies were not installed.\nMake sure you've installed "
24
+ "everything with: pip install 'httpx[cli]'"
25
+ )
26
+ sys.exit(1)
27
+
28
+
29
+ __all__ = [
30
+ "__description__",
31
+ "__title__",
32
+ "__version__",
33
+ "ASGITransport",
34
+ "AsyncBaseTransport",
35
+ "AsyncByteStream",
36
+ "AsyncClient",
37
+ "AsyncHTTPTransport",
38
+ "Auth",
39
+ "BaseTransport",
40
+ "BasicAuth",
41
+ "ByteStream",
42
+ "Client",
43
+ "CloseError",
44
+ "codes",
45
+ "ConnectError",
46
+ "ConnectTimeout",
47
+ "CookieConflict",
48
+ "Cookies",
49
+ "create_ssl_context",
50
+ "DecodingError",
51
+ "delete",
52
+ "DigestAuth",
53
+ "get",
54
+ "head",
55
+ "Headers",
56
+ "HTTPError",
57
+ "HTTPStatusError",
58
+ "HTTPTransport",
59
+ "InvalidURL",
60
+ "Limits",
61
+ "LocalProtocolError",
62
+ "main",
63
+ "MockTransport",
64
+ "NetRCAuth",
65
+ "NetworkError",
66
+ "options",
67
+ "patch",
68
+ "PoolTimeout",
69
+ "post",
70
+ "ProtocolError",
71
+ "Proxy",
72
+ "ProxyError",
73
+ "put",
74
+ "QueryParams",
75
+ "ReadError",
76
+ "ReadTimeout",
77
+ "RemoteProtocolError",
78
+ "request",
79
+ "Request",
80
+ "RequestError",
81
+ "RequestNotRead",
82
+ "Response",
83
+ "ResponseNotRead",
84
+ "stream",
85
+ "StreamClosed",
86
+ "StreamConsumed",
87
+ "StreamError",
88
+ "SyncByteStream",
89
+ "Timeout",
90
+ "TimeoutException",
91
+ "TooManyRedirects",
92
+ "TransportError",
93
+ "UnsupportedProtocol",
94
+ "URL",
95
+ "USE_CLIENT_DEFAULT",
96
+ "WriteError",
97
+ "WriteTimeout",
98
+ "WSGITransport",
99
+ ]
100
+
101
+
102
+ __locals = locals()
103
+ for __name in __all__:
104
+ if not __name.startswith("__"):
105
+ setattr(__locals[__name], "__module__", "httpx") # noqa
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.88 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_api.cpython-310.pyc ADDED
Binary file (8.16 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_auth.cpython-310.pyc ADDED
Binary file (10.6 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_client.cpython-310.pyc ADDED
Binary file (41.7 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_compat.cpython-310.pyc ADDED
Binary file (1.42 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_config.cpython-310.pyc ADDED
Binary file (10.1 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_multipart.cpython-310.pyc ADDED
Binary file (7.65 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_types.cpython-310.pyc ADDED
Binary file (3.13 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/__pycache__/_urlparse.cpython-310.pyc ADDED
Binary file (11 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/_client.py ADDED
@@ -0,0 +1,2065 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ import enum
5
+ import logging
6
+ import typing
7
+ import warnings
8
+ from contextlib import asynccontextmanager, contextmanager
9
+ from types import TracebackType
10
+
11
+ from .__version__ import __version__
12
+ from ._auth import Auth, BasicAuth, FunctionAuth
13
+ from ._config import (
14
+ DEFAULT_LIMITS,
15
+ DEFAULT_MAX_REDIRECTS,
16
+ DEFAULT_TIMEOUT_CONFIG,
17
+ Limits,
18
+ Proxy,
19
+ Timeout,
20
+ )
21
+ from ._decoders import SUPPORTED_DECODERS
22
+ from ._exceptions import (
23
+ InvalidURL,
24
+ RemoteProtocolError,
25
+ TooManyRedirects,
26
+ request_context,
27
+ )
28
+ from ._models import Cookies, Headers, Request, Response
29
+ from ._status_codes import codes
30
+ from ._transports.asgi import ASGITransport
31
+ from ._transports.base import AsyncBaseTransport, BaseTransport
32
+ from ._transports.default import AsyncHTTPTransport, HTTPTransport
33
+ from ._transports.wsgi import WSGITransport
34
+ from ._types import (
35
+ AsyncByteStream,
36
+ AuthTypes,
37
+ CertTypes,
38
+ CookieTypes,
39
+ HeaderTypes,
40
+ ProxiesTypes,
41
+ ProxyTypes,
42
+ QueryParamTypes,
43
+ RequestContent,
44
+ RequestData,
45
+ RequestExtensions,
46
+ RequestFiles,
47
+ SyncByteStream,
48
+ TimeoutTypes,
49
+ VerifyTypes,
50
+ )
51
+ from ._urls import URL, QueryParams
52
+ from ._utils import (
53
+ Timer,
54
+ URLPattern,
55
+ get_environment_proxies,
56
+ is_https_redirect,
57
+ same_origin,
58
+ )
59
+
60
+ __all__ = ["USE_CLIENT_DEFAULT", "AsyncClient", "Client"]
61
+
62
+ # The type annotation for @classmethod and context managers here follows PEP 484
63
+ # https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods
64
+ T = typing.TypeVar("T", bound="Client")
65
+ U = typing.TypeVar("U", bound="AsyncClient")
66
+
67
+
68
+ class UseClientDefault:
69
+ """
70
+ For some parameters such as `auth=...` and `timeout=...` we need to be able
71
+ to indicate the default "unset" state, in a way that is distinctly different
72
+ to using `None`.
73
+
74
+ The default "unset" state indicates that whatever default is set on the
75
+ client should be used. This is different to setting `None`, which
76
+ explicitly disables the parameter, possibly overriding a client default.
77
+
78
+ For example we use `timeout=USE_CLIENT_DEFAULT` in the `request()` signature.
79
+ Omitting the `timeout` parameter will send a request using whatever default
80
+ timeout has been configured on the client. Including `timeout=None` will
81
+ ensure no timeout is used.
82
+
83
+ Note that user code shouldn't need to use the `USE_CLIENT_DEFAULT` constant,
84
+ but it is used internally when a parameter is not included.
85
+ """
86
+
87
+
88
+ USE_CLIENT_DEFAULT = UseClientDefault()
89
+
90
+
91
+ logger = logging.getLogger("httpx")
92
+
93
+ USER_AGENT = f"python-httpx/{__version__}"
94
+ ACCEPT_ENCODING = ", ".join(
95
+ [key for key in SUPPORTED_DECODERS.keys() if key != "identity"]
96
+ )
97
+
98
+
99
+ class ClientState(enum.Enum):
100
+ # UNOPENED:
101
+ # The client has been instantiated, but has not been used to send a request,
102
+ # or been opened by entering the context of a `with` block.
103
+ UNOPENED = 1
104
+ # OPENED:
105
+ # The client has either sent a request, or is within a `with` block.
106
+ OPENED = 2
107
+ # CLOSED:
108
+ # The client has either exited the `with` block, or `close()` has
109
+ # been called explicitly.
110
+ CLOSED = 3
111
+
112
+
113
+ class BoundSyncStream(SyncByteStream):
114
+ """
115
+ A byte stream that is bound to a given response instance, and that
116
+ ensures the `response.elapsed` is set once the response is closed.
117
+ """
118
+
119
+ def __init__(
120
+ self, stream: SyncByteStream, response: Response, timer: Timer
121
+ ) -> None:
122
+ self._stream = stream
123
+ self._response = response
124
+ self._timer = timer
125
+
126
+ def __iter__(self) -> typing.Iterator[bytes]:
127
+ for chunk in self._stream:
128
+ yield chunk
129
+
130
+ def close(self) -> None:
131
+ seconds = self._timer.sync_elapsed()
132
+ self._response.elapsed = datetime.timedelta(seconds=seconds)
133
+ self._stream.close()
134
+
135
+
136
+ class BoundAsyncStream(AsyncByteStream):
137
+ """
138
+ An async byte stream that is bound to a given response instance, and that
139
+ ensures the `response.elapsed` is set once the response is closed.
140
+ """
141
+
142
+ def __init__(
143
+ self, stream: AsyncByteStream, response: Response, timer: Timer
144
+ ) -> None:
145
+ self._stream = stream
146
+ self._response = response
147
+ self._timer = timer
148
+
149
+ async def __aiter__(self) -> typing.AsyncIterator[bytes]:
150
+ async for chunk in self._stream:
151
+ yield chunk
152
+
153
+ async def aclose(self) -> None:
154
+ seconds = await self._timer.async_elapsed()
155
+ self._response.elapsed = datetime.timedelta(seconds=seconds)
156
+ await self._stream.aclose()
157
+
158
+
159
+ EventHook = typing.Callable[..., typing.Any]
160
+
161
+
162
+ class BaseClient:
163
+ def __init__(
164
+ self,
165
+ *,
166
+ auth: AuthTypes | None = None,
167
+ params: QueryParamTypes | None = None,
168
+ headers: HeaderTypes | None = None,
169
+ cookies: CookieTypes | None = None,
170
+ timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
171
+ follow_redirects: bool = False,
172
+ max_redirects: int = DEFAULT_MAX_REDIRECTS,
173
+ event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
174
+ base_url: URL | str = "",
175
+ trust_env: bool = True,
176
+ default_encoding: str | typing.Callable[[bytes], str] = "utf-8",
177
+ ) -> None:
178
+ event_hooks = {} if event_hooks is None else event_hooks
179
+
180
+ self._base_url = self._enforce_trailing_slash(URL(base_url))
181
+
182
+ self._auth = self._build_auth(auth)
183
+ self._params = QueryParams(params)
184
+ self.headers = Headers(headers)
185
+ self._cookies = Cookies(cookies)
186
+ self._timeout = Timeout(timeout)
187
+ self.follow_redirects = follow_redirects
188
+ self.max_redirects = max_redirects
189
+ self._event_hooks = {
190
+ "request": list(event_hooks.get("request", [])),
191
+ "response": list(event_hooks.get("response", [])),
192
+ }
193
+ self._trust_env = trust_env
194
+ self._default_encoding = default_encoding
195
+ self._state = ClientState.UNOPENED
196
+
197
+ @property
198
+ def is_closed(self) -> bool:
199
+ """
200
+ Check if the client being closed
201
+ """
202
+ return self._state == ClientState.CLOSED
203
+
204
+ @property
205
+ def trust_env(self) -> bool:
206
+ return self._trust_env
207
+
208
+ def _enforce_trailing_slash(self, url: URL) -> URL:
209
+ if url.raw_path.endswith(b"/"):
210
+ return url
211
+ return url.copy_with(raw_path=url.raw_path + b"/")
212
+
213
+ def _get_proxy_map(
214
+ self, proxies: ProxiesTypes | None, allow_env_proxies: bool
215
+ ) -> dict[str, Proxy | None]:
216
+ if proxies is None:
217
+ if allow_env_proxies:
218
+ return {
219
+ key: None if url is None else Proxy(url=url)
220
+ for key, url in get_environment_proxies().items()
221
+ }
222
+ return {}
223
+ if isinstance(proxies, dict):
224
+ new_proxies = {}
225
+ for key, value in proxies.items():
226
+ proxy = Proxy(url=value) if isinstance(value, (str, URL)) else value
227
+ new_proxies[str(key)] = proxy
228
+ return new_proxies
229
+ else:
230
+ proxy = Proxy(url=proxies) if isinstance(proxies, (str, URL)) else proxies
231
+ return {"all://": proxy}
232
+
233
+ @property
234
+ def timeout(self) -> Timeout:
235
+ return self._timeout
236
+
237
+ @timeout.setter
238
+ def timeout(self, timeout: TimeoutTypes) -> None:
239
+ self._timeout = Timeout(timeout)
240
+
241
+ @property
242
+ def event_hooks(self) -> dict[str, list[EventHook]]:
243
+ return self._event_hooks
244
+
245
+ @event_hooks.setter
246
+ def event_hooks(self, event_hooks: dict[str, list[EventHook]]) -> None:
247
+ self._event_hooks = {
248
+ "request": list(event_hooks.get("request", [])),
249
+ "response": list(event_hooks.get("response", [])),
250
+ }
251
+
252
+ @property
253
+ def auth(self) -> Auth | None:
254
+ """
255
+ Authentication class used when none is passed at the request-level.
256
+
257
+ See also [Authentication][0].
258
+
259
+ [0]: /quickstart/#authentication
260
+ """
261
+ return self._auth
262
+
263
+ @auth.setter
264
+ def auth(self, auth: AuthTypes) -> None:
265
+ self._auth = self._build_auth(auth)
266
+
267
+ @property
268
+ def base_url(self) -> URL:
269
+ """
270
+ Base URL to use when sending requests with relative URLs.
271
+ """
272
+ return self._base_url
273
+
274
+ @base_url.setter
275
+ def base_url(self, url: URL | str) -> None:
276
+ self._base_url = self._enforce_trailing_slash(URL(url))
277
+
278
+ @property
279
+ def headers(self) -> Headers:
280
+ """
281
+ HTTP headers to include when sending requests.
282
+ """
283
+ return self._headers
284
+
285
+ @headers.setter
286
+ def headers(self, headers: HeaderTypes) -> None:
287
+ client_headers = Headers(
288
+ {
289
+ b"Accept": b"*/*",
290
+ b"Accept-Encoding": ACCEPT_ENCODING.encode("ascii"),
291
+ b"Connection": b"keep-alive",
292
+ b"User-Agent": USER_AGENT.encode("ascii"),
293
+ }
294
+ )
295
+ client_headers.update(headers)
296
+ self._headers = client_headers
297
+
298
+ @property
299
+ def cookies(self) -> Cookies:
300
+ """
301
+ Cookie values to include when sending requests.
302
+ """
303
+ return self._cookies
304
+
305
+ @cookies.setter
306
+ def cookies(self, cookies: CookieTypes) -> None:
307
+ self._cookies = Cookies(cookies)
308
+
309
+ @property
310
+ def params(self) -> QueryParams:
311
+ """
312
+ Query parameters to include in the URL when sending requests.
313
+ """
314
+ return self._params
315
+
316
+ @params.setter
317
+ def params(self, params: QueryParamTypes) -> None:
318
+ self._params = QueryParams(params)
319
+
320
+ def build_request(
321
+ self,
322
+ method: str,
323
+ url: URL | str,
324
+ *,
325
+ content: RequestContent | None = None,
326
+ data: RequestData | None = None,
327
+ files: RequestFiles | None = None,
328
+ json: typing.Any | None = None,
329
+ params: QueryParamTypes | None = None,
330
+ headers: HeaderTypes | None = None,
331
+ cookies: CookieTypes | None = None,
332
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
333
+ extensions: RequestExtensions | None = None,
334
+ ) -> Request:
335
+ """
336
+ Build and return a request instance.
337
+
338
+ * The `params`, `headers` and `cookies` arguments
339
+ are merged with any values set on the client.
340
+ * The `url` argument is merged with any `base_url` set on the client.
341
+
342
+ See also: [Request instances][0]
343
+
344
+ [0]: /advanced/clients/#request-instances
345
+ """
346
+ url = self._merge_url(url)
347
+ headers = self._merge_headers(headers)
348
+ cookies = self._merge_cookies(cookies)
349
+ params = self._merge_queryparams(params)
350
+ extensions = {} if extensions is None else extensions
351
+ if "timeout" not in extensions:
352
+ timeout = (
353
+ self.timeout
354
+ if isinstance(timeout, UseClientDefault)
355
+ else Timeout(timeout)
356
+ )
357
+ extensions = dict(**extensions, timeout=timeout.as_dict())
358
+ return Request(
359
+ method,
360
+ url,
361
+ content=content,
362
+ data=data,
363
+ files=files,
364
+ json=json,
365
+ params=params,
366
+ headers=headers,
367
+ cookies=cookies,
368
+ extensions=extensions,
369
+ )
370
+
371
+ def _merge_url(self, url: URL | str) -> URL:
372
+ """
373
+ Merge a URL argument together with any 'base_url' on the client,
374
+ to create the URL used for the outgoing request.
375
+ """
376
+ merge_url = URL(url)
377
+ if merge_url.is_relative_url:
378
+ # To merge URLs we always append to the base URL. To get this
379
+ # behaviour correct we always ensure the base URL ends in a '/'
380
+ # separator, and strip any leading '/' from the merge URL.
381
+ #
382
+ # So, eg...
383
+ #
384
+ # >>> client = Client(base_url="https://www.example.com/subpath")
385
+ # >>> client.base_url
386
+ # URL('https://www.example.com/subpath/')
387
+ # >>> client.build_request("GET", "/path").url
388
+ # URL('https://www.example.com/subpath/path')
389
+ merge_raw_path = self.base_url.raw_path + merge_url.raw_path.lstrip(b"/")
390
+ return self.base_url.copy_with(raw_path=merge_raw_path)
391
+ return merge_url
392
+
393
+ def _merge_cookies(self, cookies: CookieTypes | None = None) -> CookieTypes | None:
394
+ """
395
+ Merge a cookies argument together with any cookies on the client,
396
+ to create the cookies used for the outgoing request.
397
+ """
398
+ if cookies or self.cookies:
399
+ merged_cookies = Cookies(self.cookies)
400
+ merged_cookies.update(cookies)
401
+ return merged_cookies
402
+ return cookies
403
+
404
+ def _merge_headers(self, headers: HeaderTypes | None = None) -> HeaderTypes | None:
405
+ """
406
+ Merge a headers argument together with any headers on the client,
407
+ to create the headers used for the outgoing request.
408
+ """
409
+ merged_headers = Headers(self.headers)
410
+ merged_headers.update(headers)
411
+ return merged_headers
412
+
413
+ def _merge_queryparams(
414
+ self, params: QueryParamTypes | None = None
415
+ ) -> QueryParamTypes | None:
416
+ """
417
+ Merge a queryparams argument together with any queryparams on the client,
418
+ to create the queryparams used for the outgoing request.
419
+ """
420
+ if params or self.params:
421
+ merged_queryparams = QueryParams(self.params)
422
+ return merged_queryparams.merge(params)
423
+ return params
424
+
425
+ def _build_auth(self, auth: AuthTypes | None) -> Auth | None:
426
+ if auth is None:
427
+ return None
428
+ elif isinstance(auth, tuple):
429
+ return BasicAuth(username=auth[0], password=auth[1])
430
+ elif isinstance(auth, Auth):
431
+ return auth
432
+ elif callable(auth):
433
+ return FunctionAuth(func=auth)
434
+ else:
435
+ raise TypeError(f'Invalid "auth" argument: {auth!r}')
436
+
437
+ def _build_request_auth(
438
+ self,
439
+ request: Request,
440
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
441
+ ) -> Auth:
442
+ auth = (
443
+ self._auth if isinstance(auth, UseClientDefault) else self._build_auth(auth)
444
+ )
445
+
446
+ if auth is not None:
447
+ return auth
448
+
449
+ username, password = request.url.username, request.url.password
450
+ if username or password:
451
+ return BasicAuth(username=username, password=password)
452
+
453
+ return Auth()
454
+
455
+ def _build_redirect_request(self, request: Request, response: Response) -> Request:
456
+ """
457
+ Given a request and a redirect response, return a new request that
458
+ should be used to effect the redirect.
459
+ """
460
+ method = self._redirect_method(request, response)
461
+ url = self._redirect_url(request, response)
462
+ headers = self._redirect_headers(request, url, method)
463
+ stream = self._redirect_stream(request, method)
464
+ cookies = Cookies(self.cookies)
465
+ return Request(
466
+ method=method,
467
+ url=url,
468
+ headers=headers,
469
+ cookies=cookies,
470
+ stream=stream,
471
+ extensions=request.extensions,
472
+ )
473
+
474
+ def _redirect_method(self, request: Request, response: Response) -> str:
475
+ """
476
+ When being redirected we may want to change the method of the request
477
+ based on certain specs or browser behavior.
478
+ """
479
+ method = request.method
480
+
481
+ # https://tools.ietf.org/html/rfc7231#section-6.4.4
482
+ if response.status_code == codes.SEE_OTHER and method != "HEAD":
483
+ method = "GET"
484
+
485
+ # Do what the browsers do, despite standards...
486
+ # Turn 302s into GETs.
487
+ if response.status_code == codes.FOUND and method != "HEAD":
488
+ method = "GET"
489
+
490
+ # If a POST is responded to with a 301, turn it into a GET.
491
+ # This bizarre behaviour is explained in 'requests' issue 1704.
492
+ if response.status_code == codes.MOVED_PERMANENTLY and method == "POST":
493
+ method = "GET"
494
+
495
+ return method
496
+
497
+ def _redirect_url(self, request: Request, response: Response) -> URL:
498
+ """
499
+ Return the URL for the redirect to follow.
500
+ """
501
+ location = response.headers["Location"]
502
+
503
+ try:
504
+ url = URL(location)
505
+ except InvalidURL as exc:
506
+ raise RemoteProtocolError(
507
+ f"Invalid URL in location header: {exc}.", request=request
508
+ ) from None
509
+
510
+ # Handle malformed 'Location' headers that are "absolute" form, have no host.
511
+ # See: https://github.com/encode/httpx/issues/771
512
+ if url.scheme and not url.host:
513
+ url = url.copy_with(host=request.url.host)
514
+
515
+ # Facilitate relative 'Location' headers, as allowed by RFC 7231.
516
+ # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
517
+ if url.is_relative_url:
518
+ url = request.url.join(url)
519
+
520
+ # Attach previous fragment if needed (RFC 7231 7.1.2)
521
+ if request.url.fragment and not url.fragment:
522
+ url = url.copy_with(fragment=request.url.fragment)
523
+
524
+ return url
525
+
526
+ def _redirect_headers(self, request: Request, url: URL, method: str) -> Headers:
527
+ """
528
+ Return the headers that should be used for the redirect request.
529
+ """
530
+ headers = Headers(request.headers)
531
+
532
+ if not same_origin(url, request.url):
533
+ if not is_https_redirect(request.url, url):
534
+ # Strip Authorization headers when responses are redirected
535
+ # away from the origin. (Except for direct HTTP to HTTPS redirects.)
536
+ headers.pop("Authorization", None)
537
+
538
+ # Update the Host header.
539
+ headers["Host"] = url.netloc.decode("ascii")
540
+
541
+ if method != request.method and method == "GET":
542
+ # If we've switch to a 'GET' request, then strip any headers which
543
+ # are only relevant to the request body.
544
+ headers.pop("Content-Length", None)
545
+ headers.pop("Transfer-Encoding", None)
546
+
547
+ # We should use the client cookie store to determine any cookie header,
548
+ # rather than whatever was on the original outgoing request.
549
+ headers.pop("Cookie", None)
550
+
551
+ return headers
552
+
553
+ def _redirect_stream(
554
+ self, request: Request, method: str
555
+ ) -> SyncByteStream | AsyncByteStream | None:
556
+ """
557
+ Return the body that should be used for the redirect request.
558
+ """
559
+ if method != request.method and method == "GET":
560
+ return None
561
+
562
+ return request.stream
563
+
564
+ def _set_timeout(self, request: Request) -> None:
565
+ if "timeout" not in request.extensions:
566
+ timeout = (
567
+ self.timeout
568
+ if isinstance(self.timeout, UseClientDefault)
569
+ else Timeout(self.timeout)
570
+ )
571
+ request.extensions = dict(**request.extensions, timeout=timeout.as_dict())
572
+
573
+
574
+ class Client(BaseClient):
575
+ """
576
+ An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.
577
+
578
+ It can be shared between threads.
579
+
580
+ Usage:
581
+
582
+ ```python
583
+ >>> client = httpx.Client()
584
+ >>> response = client.get('https://example.org')
585
+ ```
586
+
587
+ **Parameters:**
588
+
589
+ * **auth** - *(optional)* An authentication class to use when sending
590
+ requests.
591
+ * **params** - *(optional)* Query parameters to include in request URLs, as
592
+ a string, dictionary, or sequence of two-tuples.
593
+ * **headers** - *(optional)* Dictionary of HTTP headers to include when
594
+ sending requests.
595
+ * **cookies** - *(optional)* Dictionary of Cookie items to include when
596
+ sending requests.
597
+ * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
598
+ verify the identity of requested hosts. Either `True` (default CA bundle),
599
+ a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
600
+ (which will disable verification).
601
+ * **cert** - *(optional)* An SSL certificate used by the requested host
602
+ to authenticate the client. Either a path to an SSL certificate file, or
603
+ two-tuple of (certificate file, key file), or a three-tuple of (certificate
604
+ file, key file, password).
605
+ * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be
606
+ enabled. Defaults to `False`.
607
+ * **proxy** - *(optional)* A proxy URL where all the traffic should be routed.
608
+ * **proxies** - *(optional)* A dictionary mapping proxy keys to proxy
609
+ URLs.
610
+ * **timeout** - *(optional)* The timeout configuration to use when sending
611
+ requests.
612
+ * **limits** - *(optional)* The limits configuration to use.
613
+ * **max_redirects** - *(optional)* The maximum number of redirect responses
614
+ that should be followed.
615
+ * **base_url** - *(optional)* A URL to use as the base when building
616
+ request URLs.
617
+ * **transport** - *(optional)* A transport class to use for sending requests
618
+ over the network.
619
+ * **app** - *(optional)* An WSGI application to send requests to,
620
+ rather than sending actual network requests.
621
+ * **trust_env** - *(optional)* Enables or disables usage of environment
622
+ variables for configuration.
623
+ * **default_encoding** - *(optional)* The default encoding to use for decoding
624
+ response text, if no charset information is included in a response Content-Type
625
+ header. Set to a callable for automatic character set detection. Default: "utf-8".
626
+ """
627
+
628
+ def __init__(
629
+ self,
630
+ *,
631
+ auth: AuthTypes | None = None,
632
+ params: QueryParamTypes | None = None,
633
+ headers: HeaderTypes | None = None,
634
+ cookies: CookieTypes | None = None,
635
+ verify: VerifyTypes = True,
636
+ cert: CertTypes | None = None,
637
+ http1: bool = True,
638
+ http2: bool = False,
639
+ proxy: ProxyTypes | None = None,
640
+ proxies: ProxiesTypes | None = None,
641
+ mounts: None | (typing.Mapping[str, BaseTransport | None]) = None,
642
+ timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
643
+ follow_redirects: bool = False,
644
+ limits: Limits = DEFAULT_LIMITS,
645
+ max_redirects: int = DEFAULT_MAX_REDIRECTS,
646
+ event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
647
+ base_url: URL | str = "",
648
+ transport: BaseTransport | None = None,
649
+ app: typing.Callable[..., typing.Any] | None = None,
650
+ trust_env: bool = True,
651
+ default_encoding: str | typing.Callable[[bytes], str] = "utf-8",
652
+ ) -> None:
653
+ super().__init__(
654
+ auth=auth,
655
+ params=params,
656
+ headers=headers,
657
+ cookies=cookies,
658
+ timeout=timeout,
659
+ follow_redirects=follow_redirects,
660
+ max_redirects=max_redirects,
661
+ event_hooks=event_hooks,
662
+ base_url=base_url,
663
+ trust_env=trust_env,
664
+ default_encoding=default_encoding,
665
+ )
666
+
667
+ if http2:
668
+ try:
669
+ import h2 # noqa
670
+ except ImportError: # pragma: no cover
671
+ raise ImportError(
672
+ "Using http2=True, but the 'h2' package is not installed. "
673
+ "Make sure to install httpx using `pip install httpx[http2]`."
674
+ ) from None
675
+
676
+ if proxies:
677
+ message = (
678
+ "The 'proxies' argument is now deprecated."
679
+ " Use 'proxy' or 'mounts' instead."
680
+ )
681
+ warnings.warn(message, DeprecationWarning)
682
+ if proxy:
683
+ raise RuntimeError("Use either `proxy` or 'proxies', not both.")
684
+
685
+ if app:
686
+ message = (
687
+ "The 'app' shortcut is now deprecated."
688
+ " Use the explicit style 'transport=WSGITransport(app=...)' instead."
689
+ )
690
+ warnings.warn(message, DeprecationWarning)
691
+
692
+ allow_env_proxies = trust_env and app is None and transport is None
693
+ proxy_map = self._get_proxy_map(proxies or proxy, allow_env_proxies)
694
+
695
+ self._transport = self._init_transport(
696
+ verify=verify,
697
+ cert=cert,
698
+ http1=http1,
699
+ http2=http2,
700
+ limits=limits,
701
+ transport=transport,
702
+ app=app,
703
+ trust_env=trust_env,
704
+ )
705
+ self._mounts: dict[URLPattern, BaseTransport | None] = {
706
+ URLPattern(key): None
707
+ if proxy is None
708
+ else self._init_proxy_transport(
709
+ proxy,
710
+ verify=verify,
711
+ cert=cert,
712
+ http1=http1,
713
+ http2=http2,
714
+ limits=limits,
715
+ trust_env=trust_env,
716
+ )
717
+ for key, proxy in proxy_map.items()
718
+ }
719
+ if mounts is not None:
720
+ self._mounts.update(
721
+ {URLPattern(key): transport for key, transport in mounts.items()}
722
+ )
723
+
724
+ self._mounts = dict(sorted(self._mounts.items()))
725
+
726
+ def _init_transport(
727
+ self,
728
+ verify: VerifyTypes = True,
729
+ cert: CertTypes | None = None,
730
+ http1: bool = True,
731
+ http2: bool = False,
732
+ limits: Limits = DEFAULT_LIMITS,
733
+ transport: BaseTransport | None = None,
734
+ app: typing.Callable[..., typing.Any] | None = None,
735
+ trust_env: bool = True,
736
+ ) -> BaseTransport:
737
+ if transport is not None:
738
+ return transport
739
+
740
+ if app is not None:
741
+ return WSGITransport(app=app)
742
+
743
+ return HTTPTransport(
744
+ verify=verify,
745
+ cert=cert,
746
+ http1=http1,
747
+ http2=http2,
748
+ limits=limits,
749
+ trust_env=trust_env,
750
+ )
751
+
752
+ def _init_proxy_transport(
753
+ self,
754
+ proxy: Proxy,
755
+ verify: VerifyTypes = True,
756
+ cert: CertTypes | None = None,
757
+ http1: bool = True,
758
+ http2: bool = False,
759
+ limits: Limits = DEFAULT_LIMITS,
760
+ trust_env: bool = True,
761
+ ) -> BaseTransport:
762
+ return HTTPTransport(
763
+ verify=verify,
764
+ cert=cert,
765
+ http1=http1,
766
+ http2=http2,
767
+ limits=limits,
768
+ trust_env=trust_env,
769
+ proxy=proxy,
770
+ )
771
+
772
+ def _transport_for_url(self, url: URL) -> BaseTransport:
773
+ """
774
+ Returns the transport instance that should be used for a given URL.
775
+ This will either be the standard connection pool, or a proxy.
776
+ """
777
+ for pattern, transport in self._mounts.items():
778
+ if pattern.matches(url):
779
+ return self._transport if transport is None else transport
780
+
781
+ return self._transport
782
+
783
+ def request(
784
+ self,
785
+ method: str,
786
+ url: URL | str,
787
+ *,
788
+ content: RequestContent | None = None,
789
+ data: RequestData | None = None,
790
+ files: RequestFiles | None = None,
791
+ json: typing.Any | None = None,
792
+ params: QueryParamTypes | None = None,
793
+ headers: HeaderTypes | None = None,
794
+ cookies: CookieTypes | None = None,
795
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
796
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
797
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
798
+ extensions: RequestExtensions | None = None,
799
+ ) -> Response:
800
+ """
801
+ Build and send a request.
802
+
803
+ Equivalent to:
804
+
805
+ ```python
806
+ request = client.build_request(...)
807
+ response = client.send(request, ...)
808
+ ```
809
+
810
+ See `Client.build_request()`, `Client.send()` and
811
+ [Merging of configuration][0] for how the various parameters
812
+ are merged with client-level configuration.
813
+
814
+ [0]: /advanced/clients/#merging-of-configuration
815
+ """
816
+ if cookies is not None:
817
+ message = (
818
+ "Setting per-request cookies=<...> is being deprecated, because "
819
+ "the expected behaviour on cookie persistence is ambiguous. Set "
820
+ "cookies directly on the client instance instead."
821
+ )
822
+ warnings.warn(message, DeprecationWarning)
823
+
824
+ request = self.build_request(
825
+ method=method,
826
+ url=url,
827
+ content=content,
828
+ data=data,
829
+ files=files,
830
+ json=json,
831
+ params=params,
832
+ headers=headers,
833
+ cookies=cookies,
834
+ timeout=timeout,
835
+ extensions=extensions,
836
+ )
837
+ return self.send(request, auth=auth, follow_redirects=follow_redirects)
838
+
839
+ @contextmanager
840
+ def stream(
841
+ self,
842
+ method: str,
843
+ url: URL | str,
844
+ *,
845
+ content: RequestContent | None = None,
846
+ data: RequestData | None = None,
847
+ files: RequestFiles | None = None,
848
+ json: typing.Any | None = None,
849
+ params: QueryParamTypes | None = None,
850
+ headers: HeaderTypes | None = None,
851
+ cookies: CookieTypes | None = None,
852
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
853
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
854
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
855
+ extensions: RequestExtensions | None = None,
856
+ ) -> typing.Iterator[Response]:
857
+ """
858
+ Alternative to `httpx.request()` that streams the response body
859
+ instead of loading it into memory at once.
860
+
861
+ **Parameters**: See `httpx.request`.
862
+
863
+ See also: [Streaming Responses][0]
864
+
865
+ [0]: /quickstart#streaming-responses
866
+ """
867
+ request = self.build_request(
868
+ method=method,
869
+ url=url,
870
+ content=content,
871
+ data=data,
872
+ files=files,
873
+ json=json,
874
+ params=params,
875
+ headers=headers,
876
+ cookies=cookies,
877
+ timeout=timeout,
878
+ extensions=extensions,
879
+ )
880
+ response = self.send(
881
+ request=request,
882
+ auth=auth,
883
+ follow_redirects=follow_redirects,
884
+ stream=True,
885
+ )
886
+ try:
887
+ yield response
888
+ finally:
889
+ response.close()
890
+
891
+ def send(
892
+ self,
893
+ request: Request,
894
+ *,
895
+ stream: bool = False,
896
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
897
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
898
+ ) -> Response:
899
+ """
900
+ Send a request.
901
+
902
+ The request is sent as-is, unmodified.
903
+
904
+ Typically you'll want to build one with `Client.build_request()`
905
+ so that any client-level configuration is merged into the request,
906
+ but passing an explicit `httpx.Request()` is supported as well.
907
+
908
+ See also: [Request instances][0]
909
+
910
+ [0]: /advanced/clients/#request-instances
911
+ """
912
+ if self._state == ClientState.CLOSED:
913
+ raise RuntimeError("Cannot send a request, as the client has been closed.")
914
+
915
+ self._state = ClientState.OPENED
916
+ follow_redirects = (
917
+ self.follow_redirects
918
+ if isinstance(follow_redirects, UseClientDefault)
919
+ else follow_redirects
920
+ )
921
+
922
+ self._set_timeout(request)
923
+
924
+ auth = self._build_request_auth(request, auth)
925
+
926
+ response = self._send_handling_auth(
927
+ request,
928
+ auth=auth,
929
+ follow_redirects=follow_redirects,
930
+ history=[],
931
+ )
932
+ try:
933
+ if not stream:
934
+ response.read()
935
+
936
+ return response
937
+
938
+ except BaseException as exc:
939
+ response.close()
940
+ raise exc
941
+
942
+ def _send_handling_auth(
943
+ self,
944
+ request: Request,
945
+ auth: Auth,
946
+ follow_redirects: bool,
947
+ history: list[Response],
948
+ ) -> Response:
949
+ auth_flow = auth.sync_auth_flow(request)
950
+ try:
951
+ request = next(auth_flow)
952
+
953
+ while True:
954
+ response = self._send_handling_redirects(
955
+ request,
956
+ follow_redirects=follow_redirects,
957
+ history=history,
958
+ )
959
+ try:
960
+ try:
961
+ next_request = auth_flow.send(response)
962
+ except StopIteration:
963
+ return response
964
+
965
+ response.history = list(history)
966
+ response.read()
967
+ request = next_request
968
+ history.append(response)
969
+
970
+ except BaseException as exc:
971
+ response.close()
972
+ raise exc
973
+ finally:
974
+ auth_flow.close()
975
+
976
+ def _send_handling_redirects(
977
+ self,
978
+ request: Request,
979
+ follow_redirects: bool,
980
+ history: list[Response],
981
+ ) -> Response:
982
+ while True:
983
+ if len(history) > self.max_redirects:
984
+ raise TooManyRedirects(
985
+ "Exceeded maximum allowed redirects.", request=request
986
+ )
987
+
988
+ for hook in self._event_hooks["request"]:
989
+ hook(request)
990
+
991
+ response = self._send_single_request(request)
992
+ try:
993
+ for hook in self._event_hooks["response"]:
994
+ hook(response)
995
+ response.history = list(history)
996
+
997
+ if not response.has_redirect_location:
998
+ return response
999
+
1000
+ request = self._build_redirect_request(request, response)
1001
+ history = history + [response]
1002
+
1003
+ if follow_redirects:
1004
+ response.read()
1005
+ else:
1006
+ response.next_request = request
1007
+ return response
1008
+
1009
+ except BaseException as exc:
1010
+ response.close()
1011
+ raise exc
1012
+
1013
+ def _send_single_request(self, request: Request) -> Response:
1014
+ """
1015
+ Sends a single request, without handling any redirections.
1016
+ """
1017
+ transport = self._transport_for_url(request.url)
1018
+ timer = Timer()
1019
+ timer.sync_start()
1020
+
1021
+ if not isinstance(request.stream, SyncByteStream):
1022
+ raise RuntimeError(
1023
+ "Attempted to send an async request with a sync Client instance."
1024
+ )
1025
+
1026
+ with request_context(request=request):
1027
+ response = transport.handle_request(request)
1028
+
1029
+ assert isinstance(response.stream, SyncByteStream)
1030
+
1031
+ response.request = request
1032
+ response.stream = BoundSyncStream(
1033
+ response.stream, response=response, timer=timer
1034
+ )
1035
+ self.cookies.extract_cookies(response)
1036
+ response.default_encoding = self._default_encoding
1037
+
1038
+ logger.info(
1039
+ 'HTTP Request: %s %s "%s %d %s"',
1040
+ request.method,
1041
+ request.url,
1042
+ response.http_version,
1043
+ response.status_code,
1044
+ response.reason_phrase,
1045
+ )
1046
+
1047
+ return response
1048
+
1049
+ def get(
1050
+ self,
1051
+ url: URL | str,
1052
+ *,
1053
+ params: QueryParamTypes | None = None,
1054
+ headers: HeaderTypes | None = None,
1055
+ cookies: CookieTypes | None = None,
1056
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
1057
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1058
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1059
+ extensions: RequestExtensions | None = None,
1060
+ ) -> Response:
1061
+ """
1062
+ Send a `GET` request.
1063
+
1064
+ **Parameters**: See `httpx.request`.
1065
+ """
1066
+ return self.request(
1067
+ "GET",
1068
+ url,
1069
+ params=params,
1070
+ headers=headers,
1071
+ cookies=cookies,
1072
+ auth=auth,
1073
+ follow_redirects=follow_redirects,
1074
+ timeout=timeout,
1075
+ extensions=extensions,
1076
+ )
1077
+
1078
+ def options(
1079
+ self,
1080
+ url: URL | str,
1081
+ *,
1082
+ params: QueryParamTypes | None = None,
1083
+ headers: HeaderTypes | None = None,
1084
+ cookies: CookieTypes | None = None,
1085
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1086
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1087
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1088
+ extensions: RequestExtensions | None = None,
1089
+ ) -> Response:
1090
+ """
1091
+ Send an `OPTIONS` request.
1092
+
1093
+ **Parameters**: See `httpx.request`.
1094
+ """
1095
+ return self.request(
1096
+ "OPTIONS",
1097
+ url,
1098
+ params=params,
1099
+ headers=headers,
1100
+ cookies=cookies,
1101
+ auth=auth,
1102
+ follow_redirects=follow_redirects,
1103
+ timeout=timeout,
1104
+ extensions=extensions,
1105
+ )
1106
+
1107
+ def head(
1108
+ self,
1109
+ url: URL | str,
1110
+ *,
1111
+ params: QueryParamTypes | None = None,
1112
+ headers: HeaderTypes | None = None,
1113
+ cookies: CookieTypes | None = None,
1114
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1115
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1116
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1117
+ extensions: RequestExtensions | None = None,
1118
+ ) -> Response:
1119
+ """
1120
+ Send a `HEAD` request.
1121
+
1122
+ **Parameters**: See `httpx.request`.
1123
+ """
1124
+ return self.request(
1125
+ "HEAD",
1126
+ url,
1127
+ params=params,
1128
+ headers=headers,
1129
+ cookies=cookies,
1130
+ auth=auth,
1131
+ follow_redirects=follow_redirects,
1132
+ timeout=timeout,
1133
+ extensions=extensions,
1134
+ )
1135
+
1136
+ def post(
1137
+ self,
1138
+ url: URL | str,
1139
+ *,
1140
+ content: RequestContent | None = None,
1141
+ data: RequestData | None = None,
1142
+ files: RequestFiles | None = None,
1143
+ json: typing.Any | None = None,
1144
+ params: QueryParamTypes | None = None,
1145
+ headers: HeaderTypes | None = None,
1146
+ cookies: CookieTypes | None = None,
1147
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1148
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1149
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1150
+ extensions: RequestExtensions | None = None,
1151
+ ) -> Response:
1152
+ """
1153
+ Send a `POST` request.
1154
+
1155
+ **Parameters**: See `httpx.request`.
1156
+ """
1157
+ return self.request(
1158
+ "POST",
1159
+ url,
1160
+ content=content,
1161
+ data=data,
1162
+ files=files,
1163
+ json=json,
1164
+ params=params,
1165
+ headers=headers,
1166
+ cookies=cookies,
1167
+ auth=auth,
1168
+ follow_redirects=follow_redirects,
1169
+ timeout=timeout,
1170
+ extensions=extensions,
1171
+ )
1172
+
1173
+ def put(
1174
+ self,
1175
+ url: URL | str,
1176
+ *,
1177
+ content: RequestContent | None = None,
1178
+ data: RequestData | None = None,
1179
+ files: RequestFiles | None = None,
1180
+ json: typing.Any | None = None,
1181
+ params: QueryParamTypes | None = None,
1182
+ headers: HeaderTypes | None = None,
1183
+ cookies: CookieTypes | None = None,
1184
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1185
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1186
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1187
+ extensions: RequestExtensions | None = None,
1188
+ ) -> Response:
1189
+ """
1190
+ Send a `PUT` request.
1191
+
1192
+ **Parameters**: See `httpx.request`.
1193
+ """
1194
+ return self.request(
1195
+ "PUT",
1196
+ url,
1197
+ content=content,
1198
+ data=data,
1199
+ files=files,
1200
+ json=json,
1201
+ params=params,
1202
+ headers=headers,
1203
+ cookies=cookies,
1204
+ auth=auth,
1205
+ follow_redirects=follow_redirects,
1206
+ timeout=timeout,
1207
+ extensions=extensions,
1208
+ )
1209
+
1210
+ def patch(
1211
+ self,
1212
+ url: URL | str,
1213
+ *,
1214
+ content: RequestContent | None = None,
1215
+ data: RequestData | None = None,
1216
+ files: RequestFiles | None = None,
1217
+ json: typing.Any | None = None,
1218
+ params: QueryParamTypes | None = None,
1219
+ headers: HeaderTypes | None = None,
1220
+ cookies: CookieTypes | None = None,
1221
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1222
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1223
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1224
+ extensions: RequestExtensions | None = None,
1225
+ ) -> Response:
1226
+ """
1227
+ Send a `PATCH` request.
1228
+
1229
+ **Parameters**: See `httpx.request`.
1230
+ """
1231
+ return self.request(
1232
+ "PATCH",
1233
+ url,
1234
+ content=content,
1235
+ data=data,
1236
+ files=files,
1237
+ json=json,
1238
+ params=params,
1239
+ headers=headers,
1240
+ cookies=cookies,
1241
+ auth=auth,
1242
+ follow_redirects=follow_redirects,
1243
+ timeout=timeout,
1244
+ extensions=extensions,
1245
+ )
1246
+
1247
+ def delete(
1248
+ self,
1249
+ url: URL | str,
1250
+ *,
1251
+ params: QueryParamTypes | None = None,
1252
+ headers: HeaderTypes | None = None,
1253
+ cookies: CookieTypes | None = None,
1254
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1255
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1256
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1257
+ extensions: RequestExtensions | None = None,
1258
+ ) -> Response:
1259
+ """
1260
+ Send a `DELETE` request.
1261
+
1262
+ **Parameters**: See `httpx.request`.
1263
+ """
1264
+ return self.request(
1265
+ "DELETE",
1266
+ url,
1267
+ params=params,
1268
+ headers=headers,
1269
+ cookies=cookies,
1270
+ auth=auth,
1271
+ follow_redirects=follow_redirects,
1272
+ timeout=timeout,
1273
+ extensions=extensions,
1274
+ )
1275
+
1276
+ def close(self) -> None:
1277
+ """
1278
+ Close transport and proxies.
1279
+ """
1280
+ if self._state != ClientState.CLOSED:
1281
+ self._state = ClientState.CLOSED
1282
+
1283
+ self._transport.close()
1284
+ for transport in self._mounts.values():
1285
+ if transport is not None:
1286
+ transport.close()
1287
+
1288
+ def __enter__(self: T) -> T:
1289
+ if self._state != ClientState.UNOPENED:
1290
+ msg = {
1291
+ ClientState.OPENED: "Cannot open a client instance more than once.",
1292
+ ClientState.CLOSED: (
1293
+ "Cannot reopen a client instance, once it has been closed."
1294
+ ),
1295
+ }[self._state]
1296
+ raise RuntimeError(msg)
1297
+
1298
+ self._state = ClientState.OPENED
1299
+
1300
+ self._transport.__enter__()
1301
+ for transport in self._mounts.values():
1302
+ if transport is not None:
1303
+ transport.__enter__()
1304
+ return self
1305
+
1306
+ def __exit__(
1307
+ self,
1308
+ exc_type: type[BaseException] | None = None,
1309
+ exc_value: BaseException | None = None,
1310
+ traceback: TracebackType | None = None,
1311
+ ) -> None:
1312
+ self._state = ClientState.CLOSED
1313
+
1314
+ self._transport.__exit__(exc_type, exc_value, traceback)
1315
+ for transport in self._mounts.values():
1316
+ if transport is not None:
1317
+ transport.__exit__(exc_type, exc_value, traceback)
1318
+
1319
+
1320
+ class AsyncClient(BaseClient):
1321
+ """
1322
+ An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,
1323
+ cookie persistence, etc.
1324
+
1325
+ It can be shared between tasks.
1326
+
1327
+ Usage:
1328
+
1329
+ ```python
1330
+ >>> async with httpx.AsyncClient() as client:
1331
+ >>> response = await client.get('https://example.org')
1332
+ ```
1333
+
1334
+ **Parameters:**
1335
+
1336
+ * **auth** - *(optional)* An authentication class to use when sending
1337
+ requests.
1338
+ * **params** - *(optional)* Query parameters to include in request URLs, as
1339
+ a string, dictionary, or sequence of two-tuples.
1340
+ * **headers** - *(optional)* Dictionary of HTTP headers to include when
1341
+ sending requests.
1342
+ * **cookies** - *(optional)* Dictionary of Cookie items to include when
1343
+ sending requests.
1344
+ * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
1345
+ verify the identity of requested hosts. Either `True` (default CA bundle),
1346
+ a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
1347
+ (which will disable verification).
1348
+ * **cert** - *(optional)* An SSL certificate used by the requested host
1349
+ to authenticate the client. Either a path to an SSL certificate file, or
1350
+ two-tuple of (certificate file, key file), or a three-tuple of (certificate
1351
+ file, key file, password).
1352
+ * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be
1353
+ enabled. Defaults to `False`.
1354
+ * **proxy** - *(optional)* A proxy URL where all the traffic should be routed.
1355
+ * **proxies** - *(optional)* A dictionary mapping HTTP protocols to proxy
1356
+ URLs.
1357
+ * **timeout** - *(optional)* The timeout configuration to use when sending
1358
+ requests.
1359
+ * **limits** - *(optional)* The limits configuration to use.
1360
+ * **max_redirects** - *(optional)* The maximum number of redirect responses
1361
+ that should be followed.
1362
+ * **base_url** - *(optional)* A URL to use as the base when building
1363
+ request URLs.
1364
+ * **transport** - *(optional)* A transport class to use for sending requests
1365
+ over the network.
1366
+ * **app** - *(optional)* An ASGI application to send requests to,
1367
+ rather than sending actual network requests.
1368
+ * **trust_env** - *(optional)* Enables or disables usage of environment
1369
+ variables for configuration.
1370
+ * **default_encoding** - *(optional)* The default encoding to use for decoding
1371
+ response text, if no charset information is included in a response Content-Type
1372
+ header. Set to a callable for automatic character set detection. Default: "utf-8".
1373
+ """
1374
+
1375
+ def __init__(
1376
+ self,
1377
+ *,
1378
+ auth: AuthTypes | None = None,
1379
+ params: QueryParamTypes | None = None,
1380
+ headers: HeaderTypes | None = None,
1381
+ cookies: CookieTypes | None = None,
1382
+ verify: VerifyTypes = True,
1383
+ cert: CertTypes | None = None,
1384
+ http1: bool = True,
1385
+ http2: bool = False,
1386
+ proxy: ProxyTypes | None = None,
1387
+ proxies: ProxiesTypes | None = None,
1388
+ mounts: None | (typing.Mapping[str, AsyncBaseTransport | None]) = None,
1389
+ timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
1390
+ follow_redirects: bool = False,
1391
+ limits: Limits = DEFAULT_LIMITS,
1392
+ max_redirects: int = DEFAULT_MAX_REDIRECTS,
1393
+ event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
1394
+ base_url: URL | str = "",
1395
+ transport: AsyncBaseTransport | None = None,
1396
+ app: typing.Callable[..., typing.Any] | None = None,
1397
+ trust_env: bool = True,
1398
+ default_encoding: str | typing.Callable[[bytes], str] = "utf-8",
1399
+ ) -> None:
1400
+ super().__init__(
1401
+ auth=auth,
1402
+ params=params,
1403
+ headers=headers,
1404
+ cookies=cookies,
1405
+ timeout=timeout,
1406
+ follow_redirects=follow_redirects,
1407
+ max_redirects=max_redirects,
1408
+ event_hooks=event_hooks,
1409
+ base_url=base_url,
1410
+ trust_env=trust_env,
1411
+ default_encoding=default_encoding,
1412
+ )
1413
+
1414
+ if http2:
1415
+ try:
1416
+ import h2 # noqa
1417
+ except ImportError: # pragma: no cover
1418
+ raise ImportError(
1419
+ "Using http2=True, but the 'h2' package is not installed. "
1420
+ "Make sure to install httpx using `pip install httpx[http2]`."
1421
+ ) from None
1422
+
1423
+ if proxies:
1424
+ message = (
1425
+ "The 'proxies' argument is now deprecated."
1426
+ " Use 'proxy' or 'mounts' instead."
1427
+ )
1428
+ warnings.warn(message, DeprecationWarning)
1429
+ if proxy:
1430
+ raise RuntimeError("Use either `proxy` or 'proxies', not both.")
1431
+
1432
+ if app:
1433
+ message = (
1434
+ "The 'app' shortcut is now deprecated."
1435
+ " Use the explicit style 'transport=ASGITransport(app=...)' instead."
1436
+ )
1437
+ warnings.warn(message, DeprecationWarning)
1438
+
1439
+ allow_env_proxies = trust_env and app is None and transport is None
1440
+ proxy_map = self._get_proxy_map(proxies or proxy, allow_env_proxies)
1441
+
1442
+ self._transport = self._init_transport(
1443
+ verify=verify,
1444
+ cert=cert,
1445
+ http1=http1,
1446
+ http2=http2,
1447
+ limits=limits,
1448
+ transport=transport,
1449
+ app=app,
1450
+ trust_env=trust_env,
1451
+ )
1452
+
1453
+ self._mounts: dict[URLPattern, AsyncBaseTransport | None] = {
1454
+ URLPattern(key): None
1455
+ if proxy is None
1456
+ else self._init_proxy_transport(
1457
+ proxy,
1458
+ verify=verify,
1459
+ cert=cert,
1460
+ http1=http1,
1461
+ http2=http2,
1462
+ limits=limits,
1463
+ trust_env=trust_env,
1464
+ )
1465
+ for key, proxy in proxy_map.items()
1466
+ }
1467
+ if mounts is not None:
1468
+ self._mounts.update(
1469
+ {URLPattern(key): transport for key, transport in mounts.items()}
1470
+ )
1471
+ self._mounts = dict(sorted(self._mounts.items()))
1472
+
1473
+ def _init_transport(
1474
+ self,
1475
+ verify: VerifyTypes = True,
1476
+ cert: CertTypes | None = None,
1477
+ http1: bool = True,
1478
+ http2: bool = False,
1479
+ limits: Limits = DEFAULT_LIMITS,
1480
+ transport: AsyncBaseTransport | None = None,
1481
+ app: typing.Callable[..., typing.Any] | None = None,
1482
+ trust_env: bool = True,
1483
+ ) -> AsyncBaseTransport:
1484
+ if transport is not None:
1485
+ return transport
1486
+
1487
+ if app is not None:
1488
+ return ASGITransport(app=app)
1489
+
1490
+ return AsyncHTTPTransport(
1491
+ verify=verify,
1492
+ cert=cert,
1493
+ http1=http1,
1494
+ http2=http2,
1495
+ limits=limits,
1496
+ trust_env=trust_env,
1497
+ )
1498
+
1499
+ def _init_proxy_transport(
1500
+ self,
1501
+ proxy: Proxy,
1502
+ verify: VerifyTypes = True,
1503
+ cert: CertTypes | None = None,
1504
+ http1: bool = True,
1505
+ http2: bool = False,
1506
+ limits: Limits = DEFAULT_LIMITS,
1507
+ trust_env: bool = True,
1508
+ ) -> AsyncBaseTransport:
1509
+ return AsyncHTTPTransport(
1510
+ verify=verify,
1511
+ cert=cert,
1512
+ http1=http1,
1513
+ http2=http2,
1514
+ limits=limits,
1515
+ trust_env=trust_env,
1516
+ proxy=proxy,
1517
+ )
1518
+
1519
+ def _transport_for_url(self, url: URL) -> AsyncBaseTransport:
1520
+ """
1521
+ Returns the transport instance that should be used for a given URL.
1522
+ This will either be the standard connection pool, or a proxy.
1523
+ """
1524
+ for pattern, transport in self._mounts.items():
1525
+ if pattern.matches(url):
1526
+ return self._transport if transport is None else transport
1527
+
1528
+ return self._transport
1529
+
1530
+ async def request(
1531
+ self,
1532
+ method: str,
1533
+ url: URL | str,
1534
+ *,
1535
+ content: RequestContent | None = None,
1536
+ data: RequestData | None = None,
1537
+ files: RequestFiles | None = None,
1538
+ json: typing.Any | None = None,
1539
+ params: QueryParamTypes | None = None,
1540
+ headers: HeaderTypes | None = None,
1541
+ cookies: CookieTypes | None = None,
1542
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
1543
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1544
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1545
+ extensions: RequestExtensions | None = None,
1546
+ ) -> Response:
1547
+ """
1548
+ Build and send a request.
1549
+
1550
+ Equivalent to:
1551
+
1552
+ ```python
1553
+ request = client.build_request(...)
1554
+ response = await client.send(request, ...)
1555
+ ```
1556
+
1557
+ See `AsyncClient.build_request()`, `AsyncClient.send()`
1558
+ and [Merging of configuration][0] for how the various parameters
1559
+ are merged with client-level configuration.
1560
+
1561
+ [0]: /advanced/clients/#merging-of-configuration
1562
+ """
1563
+
1564
+ if cookies is not None: # pragma: no cover
1565
+ message = (
1566
+ "Setting per-request cookies=<...> is being deprecated, because "
1567
+ "the expected behaviour on cookie persistence is ambiguous. Set "
1568
+ "cookies directly on the client instance instead."
1569
+ )
1570
+ warnings.warn(message, DeprecationWarning)
1571
+
1572
+ request = self.build_request(
1573
+ method=method,
1574
+ url=url,
1575
+ content=content,
1576
+ data=data,
1577
+ files=files,
1578
+ json=json,
1579
+ params=params,
1580
+ headers=headers,
1581
+ cookies=cookies,
1582
+ timeout=timeout,
1583
+ extensions=extensions,
1584
+ )
1585
+ return await self.send(request, auth=auth, follow_redirects=follow_redirects)
1586
+
1587
+ @asynccontextmanager
1588
+ async def stream(
1589
+ self,
1590
+ method: str,
1591
+ url: URL | str,
1592
+ *,
1593
+ content: RequestContent | None = None,
1594
+ data: RequestData | None = None,
1595
+ files: RequestFiles | None = None,
1596
+ json: typing.Any | None = None,
1597
+ params: QueryParamTypes | None = None,
1598
+ headers: HeaderTypes | None = None,
1599
+ cookies: CookieTypes | None = None,
1600
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
1601
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1602
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1603
+ extensions: RequestExtensions | None = None,
1604
+ ) -> typing.AsyncIterator[Response]:
1605
+ """
1606
+ Alternative to `httpx.request()` that streams the response body
1607
+ instead of loading it into memory at once.
1608
+
1609
+ **Parameters**: See `httpx.request`.
1610
+
1611
+ See also: [Streaming Responses][0]
1612
+
1613
+ [0]: /quickstart#streaming-responses
1614
+ """
1615
+ request = self.build_request(
1616
+ method=method,
1617
+ url=url,
1618
+ content=content,
1619
+ data=data,
1620
+ files=files,
1621
+ json=json,
1622
+ params=params,
1623
+ headers=headers,
1624
+ cookies=cookies,
1625
+ timeout=timeout,
1626
+ extensions=extensions,
1627
+ )
1628
+ response = await self.send(
1629
+ request=request,
1630
+ auth=auth,
1631
+ follow_redirects=follow_redirects,
1632
+ stream=True,
1633
+ )
1634
+ try:
1635
+ yield response
1636
+ finally:
1637
+ await response.aclose()
1638
+
1639
+ async def send(
1640
+ self,
1641
+ request: Request,
1642
+ *,
1643
+ stream: bool = False,
1644
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
1645
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1646
+ ) -> Response:
1647
+ """
1648
+ Send a request.
1649
+
1650
+ The request is sent as-is, unmodified.
1651
+
1652
+ Typically you'll want to build one with `AsyncClient.build_request()`
1653
+ so that any client-level configuration is merged into the request,
1654
+ but passing an explicit `httpx.Request()` is supported as well.
1655
+
1656
+ See also: [Request instances][0]
1657
+
1658
+ [0]: /advanced/clients/#request-instances
1659
+ """
1660
+ if self._state == ClientState.CLOSED:
1661
+ raise RuntimeError("Cannot send a request, as the client has been closed.")
1662
+
1663
+ self._state = ClientState.OPENED
1664
+ follow_redirects = (
1665
+ self.follow_redirects
1666
+ if isinstance(follow_redirects, UseClientDefault)
1667
+ else follow_redirects
1668
+ )
1669
+
1670
+ self._set_timeout(request)
1671
+
1672
+ auth = self._build_request_auth(request, auth)
1673
+
1674
+ response = await self._send_handling_auth(
1675
+ request,
1676
+ auth=auth,
1677
+ follow_redirects=follow_redirects,
1678
+ history=[],
1679
+ )
1680
+ try:
1681
+ if not stream:
1682
+ await response.aread()
1683
+
1684
+ return response
1685
+
1686
+ except BaseException as exc:
1687
+ await response.aclose()
1688
+ raise exc
1689
+
1690
+ async def _send_handling_auth(
1691
+ self,
1692
+ request: Request,
1693
+ auth: Auth,
1694
+ follow_redirects: bool,
1695
+ history: list[Response],
1696
+ ) -> Response:
1697
+ auth_flow = auth.async_auth_flow(request)
1698
+ try:
1699
+ request = await auth_flow.__anext__()
1700
+
1701
+ while True:
1702
+ response = await self._send_handling_redirects(
1703
+ request,
1704
+ follow_redirects=follow_redirects,
1705
+ history=history,
1706
+ )
1707
+ try:
1708
+ try:
1709
+ next_request = await auth_flow.asend(response)
1710
+ except StopAsyncIteration:
1711
+ return response
1712
+
1713
+ response.history = list(history)
1714
+ await response.aread()
1715
+ request = next_request
1716
+ history.append(response)
1717
+
1718
+ except BaseException as exc:
1719
+ await response.aclose()
1720
+ raise exc
1721
+ finally:
1722
+ await auth_flow.aclose()
1723
+
1724
+ async def _send_handling_redirects(
1725
+ self,
1726
+ request: Request,
1727
+ follow_redirects: bool,
1728
+ history: list[Response],
1729
+ ) -> Response:
1730
+ while True:
1731
+ if len(history) > self.max_redirects:
1732
+ raise TooManyRedirects(
1733
+ "Exceeded maximum allowed redirects.", request=request
1734
+ )
1735
+
1736
+ for hook in self._event_hooks["request"]:
1737
+ await hook(request)
1738
+
1739
+ response = await self._send_single_request(request)
1740
+ try:
1741
+ for hook in self._event_hooks["response"]:
1742
+ await hook(response)
1743
+
1744
+ response.history = list(history)
1745
+
1746
+ if not response.has_redirect_location:
1747
+ return response
1748
+
1749
+ request = self._build_redirect_request(request, response)
1750
+ history = history + [response]
1751
+
1752
+ if follow_redirects:
1753
+ await response.aread()
1754
+ else:
1755
+ response.next_request = request
1756
+ return response
1757
+
1758
+ except BaseException as exc:
1759
+ await response.aclose()
1760
+ raise exc
1761
+
1762
+ async def _send_single_request(self, request: Request) -> Response:
1763
+ """
1764
+ Sends a single request, without handling any redirections.
1765
+ """
1766
+ transport = self._transport_for_url(request.url)
1767
+ timer = Timer()
1768
+ await timer.async_start()
1769
+
1770
+ if not isinstance(request.stream, AsyncByteStream):
1771
+ raise RuntimeError(
1772
+ "Attempted to send an sync request with an AsyncClient instance."
1773
+ )
1774
+
1775
+ with request_context(request=request):
1776
+ response = await transport.handle_async_request(request)
1777
+
1778
+ assert isinstance(response.stream, AsyncByteStream)
1779
+ response.request = request
1780
+ response.stream = BoundAsyncStream(
1781
+ response.stream, response=response, timer=timer
1782
+ )
1783
+ self.cookies.extract_cookies(response)
1784
+ response.default_encoding = self._default_encoding
1785
+
1786
+ logger.info(
1787
+ 'HTTP Request: %s %s "%s %d %s"',
1788
+ request.method,
1789
+ request.url,
1790
+ response.http_version,
1791
+ response.status_code,
1792
+ response.reason_phrase,
1793
+ )
1794
+
1795
+ return response
1796
+
1797
+ async def get(
1798
+ self,
1799
+ url: URL | str,
1800
+ *,
1801
+ params: QueryParamTypes | None = None,
1802
+ headers: HeaderTypes | None = None,
1803
+ cookies: CookieTypes | None = None,
1804
+ auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
1805
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1806
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1807
+ extensions: RequestExtensions | None = None,
1808
+ ) -> Response:
1809
+ """
1810
+ Send a `GET` request.
1811
+
1812
+ **Parameters**: See `httpx.request`.
1813
+ """
1814
+ return await self.request(
1815
+ "GET",
1816
+ url,
1817
+ params=params,
1818
+ headers=headers,
1819
+ cookies=cookies,
1820
+ auth=auth,
1821
+ follow_redirects=follow_redirects,
1822
+ timeout=timeout,
1823
+ extensions=extensions,
1824
+ )
1825
+
1826
+ async def options(
1827
+ self,
1828
+ url: URL | str,
1829
+ *,
1830
+ params: QueryParamTypes | None = None,
1831
+ headers: HeaderTypes | None = None,
1832
+ cookies: CookieTypes | None = None,
1833
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1834
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1835
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1836
+ extensions: RequestExtensions | None = None,
1837
+ ) -> Response:
1838
+ """
1839
+ Send an `OPTIONS` request.
1840
+
1841
+ **Parameters**: See `httpx.request`.
1842
+ """
1843
+ return await self.request(
1844
+ "OPTIONS",
1845
+ url,
1846
+ params=params,
1847
+ headers=headers,
1848
+ cookies=cookies,
1849
+ auth=auth,
1850
+ follow_redirects=follow_redirects,
1851
+ timeout=timeout,
1852
+ extensions=extensions,
1853
+ )
1854
+
1855
+ async def head(
1856
+ self,
1857
+ url: URL | str,
1858
+ *,
1859
+ params: QueryParamTypes | None = None,
1860
+ headers: HeaderTypes | None = None,
1861
+ cookies: CookieTypes | None = None,
1862
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1863
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1864
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1865
+ extensions: RequestExtensions | None = None,
1866
+ ) -> Response:
1867
+ """
1868
+ Send a `HEAD` request.
1869
+
1870
+ **Parameters**: See `httpx.request`.
1871
+ """
1872
+ return await self.request(
1873
+ "HEAD",
1874
+ url,
1875
+ params=params,
1876
+ headers=headers,
1877
+ cookies=cookies,
1878
+ auth=auth,
1879
+ follow_redirects=follow_redirects,
1880
+ timeout=timeout,
1881
+ extensions=extensions,
1882
+ )
1883
+
1884
+ async def post(
1885
+ self,
1886
+ url: URL | str,
1887
+ *,
1888
+ content: RequestContent | None = None,
1889
+ data: RequestData | None = None,
1890
+ files: RequestFiles | None = None,
1891
+ json: typing.Any | None = None,
1892
+ params: QueryParamTypes | None = None,
1893
+ headers: HeaderTypes | None = None,
1894
+ cookies: CookieTypes | None = None,
1895
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1896
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1897
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1898
+ extensions: RequestExtensions | None = None,
1899
+ ) -> Response:
1900
+ """
1901
+ Send a `POST` request.
1902
+
1903
+ **Parameters**: See `httpx.request`.
1904
+ """
1905
+ return await self.request(
1906
+ "POST",
1907
+ url,
1908
+ content=content,
1909
+ data=data,
1910
+ files=files,
1911
+ json=json,
1912
+ params=params,
1913
+ headers=headers,
1914
+ cookies=cookies,
1915
+ auth=auth,
1916
+ follow_redirects=follow_redirects,
1917
+ timeout=timeout,
1918
+ extensions=extensions,
1919
+ )
1920
+
1921
+ async def put(
1922
+ self,
1923
+ url: URL | str,
1924
+ *,
1925
+ content: RequestContent | None = None,
1926
+ data: RequestData | None = None,
1927
+ files: RequestFiles | None = None,
1928
+ json: typing.Any | None = None,
1929
+ params: QueryParamTypes | None = None,
1930
+ headers: HeaderTypes | None = None,
1931
+ cookies: CookieTypes | None = None,
1932
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1933
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1934
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1935
+ extensions: RequestExtensions | None = None,
1936
+ ) -> Response:
1937
+ """
1938
+ Send a `PUT` request.
1939
+
1940
+ **Parameters**: See `httpx.request`.
1941
+ """
1942
+ return await self.request(
1943
+ "PUT",
1944
+ url,
1945
+ content=content,
1946
+ data=data,
1947
+ files=files,
1948
+ json=json,
1949
+ params=params,
1950
+ headers=headers,
1951
+ cookies=cookies,
1952
+ auth=auth,
1953
+ follow_redirects=follow_redirects,
1954
+ timeout=timeout,
1955
+ extensions=extensions,
1956
+ )
1957
+
1958
+ async def patch(
1959
+ self,
1960
+ url: URL | str,
1961
+ *,
1962
+ content: RequestContent | None = None,
1963
+ data: RequestData | None = None,
1964
+ files: RequestFiles | None = None,
1965
+ json: typing.Any | None = None,
1966
+ params: QueryParamTypes | None = None,
1967
+ headers: HeaderTypes | None = None,
1968
+ cookies: CookieTypes | None = None,
1969
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1970
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
1971
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
1972
+ extensions: RequestExtensions | None = None,
1973
+ ) -> Response:
1974
+ """
1975
+ Send a `PATCH` request.
1976
+
1977
+ **Parameters**: See `httpx.request`.
1978
+ """
1979
+ return await self.request(
1980
+ "PATCH",
1981
+ url,
1982
+ content=content,
1983
+ data=data,
1984
+ files=files,
1985
+ json=json,
1986
+ params=params,
1987
+ headers=headers,
1988
+ cookies=cookies,
1989
+ auth=auth,
1990
+ follow_redirects=follow_redirects,
1991
+ timeout=timeout,
1992
+ extensions=extensions,
1993
+ )
1994
+
1995
+ async def delete(
1996
+ self,
1997
+ url: URL | str,
1998
+ *,
1999
+ params: QueryParamTypes | None = None,
2000
+ headers: HeaderTypes | None = None,
2001
+ cookies: CookieTypes | None = None,
2002
+ auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
2003
+ follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
2004
+ timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
2005
+ extensions: RequestExtensions | None = None,
2006
+ ) -> Response:
2007
+ """
2008
+ Send a `DELETE` request.
2009
+
2010
+ **Parameters**: See `httpx.request`.
2011
+ """
2012
+ return await self.request(
2013
+ "DELETE",
2014
+ url,
2015
+ params=params,
2016
+ headers=headers,
2017
+ cookies=cookies,
2018
+ auth=auth,
2019
+ follow_redirects=follow_redirects,
2020
+ timeout=timeout,
2021
+ extensions=extensions,
2022
+ )
2023
+
2024
+ async def aclose(self) -> None:
2025
+ """
2026
+ Close transport and proxies.
2027
+ """
2028
+ if self._state != ClientState.CLOSED:
2029
+ self._state = ClientState.CLOSED
2030
+
2031
+ await self._transport.aclose()
2032
+ for proxy in self._mounts.values():
2033
+ if proxy is not None:
2034
+ await proxy.aclose()
2035
+
2036
+ async def __aenter__(self: U) -> U:
2037
+ if self._state != ClientState.UNOPENED:
2038
+ msg = {
2039
+ ClientState.OPENED: "Cannot open a client instance more than once.",
2040
+ ClientState.CLOSED: (
2041
+ "Cannot reopen a client instance, once it has been closed."
2042
+ ),
2043
+ }[self._state]
2044
+ raise RuntimeError(msg)
2045
+
2046
+ self._state = ClientState.OPENED
2047
+
2048
+ await self._transport.__aenter__()
2049
+ for proxy in self._mounts.values():
2050
+ if proxy is not None:
2051
+ await proxy.__aenter__()
2052
+ return self
2053
+
2054
+ async def __aexit__(
2055
+ self,
2056
+ exc_type: type[BaseException] | None = None,
2057
+ exc_value: BaseException | None = None,
2058
+ traceback: TracebackType | None = None,
2059
+ ) -> None:
2060
+ self._state = ClientState.CLOSED
2061
+
2062
+ await self._transport.__aexit__(exc_type, exc_value, traceback)
2063
+ for proxy in self._mounts.values():
2064
+ if proxy is not None:
2065
+ await proxy.__aexit__(exc_type, exc_value, traceback)
evalkit_tf437/lib/python3.10/site-packages/httpx/_multipart.py ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import io
4
+ import os
5
+ import typing
6
+ from pathlib import Path
7
+
8
+ from ._types import (
9
+ AsyncByteStream,
10
+ FileContent,
11
+ FileTypes,
12
+ RequestData,
13
+ RequestFiles,
14
+ SyncByteStream,
15
+ )
16
+ from ._utils import (
17
+ format_form_param,
18
+ guess_content_type,
19
+ peek_filelike_length,
20
+ primitive_value_to_str,
21
+ to_bytes,
22
+ )
23
+
24
+
25
+ def get_multipart_boundary_from_content_type(
26
+ content_type: bytes | None,
27
+ ) -> bytes | None:
28
+ if not content_type or not content_type.startswith(b"multipart/form-data"):
29
+ return None
30
+ # parse boundary according to
31
+ # https://www.rfc-editor.org/rfc/rfc2046#section-5.1.1
32
+ if b";" in content_type:
33
+ for section in content_type.split(b";"):
34
+ if section.strip().lower().startswith(b"boundary="):
35
+ return section.strip()[len(b"boundary=") :].strip(b'"')
36
+ return None
37
+
38
+
39
+ class DataField:
40
+ """
41
+ A single form field item, within a multipart form field.
42
+ """
43
+
44
+ def __init__(self, name: str, value: str | bytes | int | float | None) -> None:
45
+ if not isinstance(name, str):
46
+ raise TypeError(
47
+ f"Invalid type for name. Expected str, got {type(name)}: {name!r}"
48
+ )
49
+ if value is not None and not isinstance(value, (str, bytes, int, float)):
50
+ raise TypeError(
51
+ "Invalid type for value. Expected primitive type,"
52
+ f" got {type(value)}: {value!r}"
53
+ )
54
+ self.name = name
55
+ self.value: str | bytes = (
56
+ value if isinstance(value, bytes) else primitive_value_to_str(value)
57
+ )
58
+
59
+ def render_headers(self) -> bytes:
60
+ if not hasattr(self, "_headers"):
61
+ name = format_form_param("name", self.name)
62
+ self._headers = b"".join(
63
+ [b"Content-Disposition: form-data; ", name, b"\r\n\r\n"]
64
+ )
65
+
66
+ return self._headers
67
+
68
+ def render_data(self) -> bytes:
69
+ if not hasattr(self, "_data"):
70
+ self._data = to_bytes(self.value)
71
+
72
+ return self._data
73
+
74
+ def get_length(self) -> int:
75
+ headers = self.render_headers()
76
+ data = self.render_data()
77
+ return len(headers) + len(data)
78
+
79
+ def render(self) -> typing.Iterator[bytes]:
80
+ yield self.render_headers()
81
+ yield self.render_data()
82
+
83
+
84
+ class FileField:
85
+ """
86
+ A single file field item, within a multipart form field.
87
+ """
88
+
89
+ CHUNK_SIZE = 64 * 1024
90
+
91
+ def __init__(self, name: str, value: FileTypes) -> None:
92
+ self.name = name
93
+
94
+ fileobj: FileContent
95
+
96
+ headers: dict[str, str] = {}
97
+ content_type: str | None = None
98
+
99
+ # This large tuple based API largely mirror's requests' API
100
+ # It would be good to think of better APIs for this that we could
101
+ # include in httpx 2.0 since variable length tuples(especially of 4 elements)
102
+ # are quite unwieldly
103
+ if isinstance(value, tuple):
104
+ if len(value) == 2:
105
+ # neither the 3rd parameter (content_type) nor the 4th (headers)
106
+ # was included
107
+ filename, fileobj = value
108
+ elif len(value) == 3:
109
+ filename, fileobj, content_type = value
110
+ else:
111
+ # all 4 parameters included
112
+ filename, fileobj, content_type, headers = value # type: ignore
113
+ else:
114
+ filename = Path(str(getattr(value, "name", "upload"))).name
115
+ fileobj = value
116
+
117
+ if content_type is None:
118
+ content_type = guess_content_type(filename)
119
+
120
+ has_content_type_header = any("content-type" in key.lower() for key in headers)
121
+ if content_type is not None and not has_content_type_header:
122
+ # note that unlike requests, we ignore the content_type provided in the 3rd
123
+ # tuple element if it is also included in the headers requests does
124
+ # the opposite (it overwrites the headerwith the 3rd tuple element)
125
+ headers["Content-Type"] = content_type
126
+
127
+ if isinstance(fileobj, io.StringIO):
128
+ raise TypeError(
129
+ "Multipart file uploads require 'io.BytesIO', not 'io.StringIO'."
130
+ )
131
+ if isinstance(fileobj, io.TextIOBase):
132
+ raise TypeError(
133
+ "Multipart file uploads must be opened in binary mode, not text mode."
134
+ )
135
+
136
+ self.filename = filename
137
+ self.file = fileobj
138
+ self.headers = headers
139
+
140
+ def get_length(self) -> int | None:
141
+ headers = self.render_headers()
142
+
143
+ if isinstance(self.file, (str, bytes)):
144
+ return len(headers) + len(to_bytes(self.file))
145
+
146
+ file_length = peek_filelike_length(self.file)
147
+
148
+ # If we can't determine the filesize without reading it into memory,
149
+ # then return `None` here, to indicate an unknown file length.
150
+ if file_length is None:
151
+ return None
152
+
153
+ return len(headers) + file_length
154
+
155
+ def render_headers(self) -> bytes:
156
+ if not hasattr(self, "_headers"):
157
+ parts = [
158
+ b"Content-Disposition: form-data; ",
159
+ format_form_param("name", self.name),
160
+ ]
161
+ if self.filename:
162
+ filename = format_form_param("filename", self.filename)
163
+ parts.extend([b"; ", filename])
164
+ for header_name, header_value in self.headers.items():
165
+ key, val = f"\r\n{header_name}: ".encode(), header_value.encode()
166
+ parts.extend([key, val])
167
+ parts.append(b"\r\n\r\n")
168
+ self._headers = b"".join(parts)
169
+
170
+ return self._headers
171
+
172
+ def render_data(self) -> typing.Iterator[bytes]:
173
+ if isinstance(self.file, (str, bytes)):
174
+ yield to_bytes(self.file)
175
+ return
176
+
177
+ if hasattr(self.file, "seek"):
178
+ try:
179
+ self.file.seek(0)
180
+ except io.UnsupportedOperation:
181
+ pass
182
+
183
+ chunk = self.file.read(self.CHUNK_SIZE)
184
+ while chunk:
185
+ yield to_bytes(chunk)
186
+ chunk = self.file.read(self.CHUNK_SIZE)
187
+
188
+ def render(self) -> typing.Iterator[bytes]:
189
+ yield self.render_headers()
190
+ yield from self.render_data()
191
+
192
+
193
+ class MultipartStream(SyncByteStream, AsyncByteStream):
194
+ """
195
+ Request content as streaming multipart encoded form data.
196
+ """
197
+
198
+ def __init__(
199
+ self,
200
+ data: RequestData,
201
+ files: RequestFiles,
202
+ boundary: bytes | None = None,
203
+ ) -> None:
204
+ if boundary is None:
205
+ boundary = os.urandom(16).hex().encode("ascii")
206
+
207
+ self.boundary = boundary
208
+ self.content_type = "multipart/form-data; boundary=%s" % boundary.decode(
209
+ "ascii"
210
+ )
211
+ self.fields = list(self._iter_fields(data, files))
212
+
213
+ def _iter_fields(
214
+ self, data: RequestData, files: RequestFiles
215
+ ) -> typing.Iterator[FileField | DataField]:
216
+ for name, value in data.items():
217
+ if isinstance(value, (tuple, list)):
218
+ for item in value:
219
+ yield DataField(name=name, value=item)
220
+ else:
221
+ yield DataField(name=name, value=value)
222
+
223
+ file_items = files.items() if isinstance(files, typing.Mapping) else files
224
+ for name, value in file_items:
225
+ yield FileField(name=name, value=value)
226
+
227
+ def iter_chunks(self) -> typing.Iterator[bytes]:
228
+ for field in self.fields:
229
+ yield b"--%s\r\n" % self.boundary
230
+ yield from field.render()
231
+ yield b"\r\n"
232
+ yield b"--%s--\r\n" % self.boundary
233
+
234
+ def get_content_length(self) -> int | None:
235
+ """
236
+ Return the length of the multipart encoded content, or `None` if
237
+ any of the files have a length that cannot be determined upfront.
238
+ """
239
+ boundary_length = len(self.boundary)
240
+ length = 0
241
+
242
+ for field in self.fields:
243
+ field_length = field.get_length()
244
+ if field_length is None:
245
+ return None
246
+
247
+ length += 2 + boundary_length + 2 # b"--{boundary}\r\n"
248
+ length += field_length
249
+ length += 2 # b"\r\n"
250
+
251
+ length += 2 + boundary_length + 4 # b"--{boundary}--\r\n"
252
+ return length
253
+
254
+ # Content stream interface.
255
+
256
+ def get_headers(self) -> dict[str, str]:
257
+ content_length = self.get_content_length()
258
+ content_type = self.content_type
259
+ if content_length is None:
260
+ return {"Transfer-Encoding": "chunked", "Content-Type": content_type}
261
+ return {"Content-Length": str(content_length), "Content-Type": content_type}
262
+
263
+ def __iter__(self) -> typing.Iterator[bytes]:
264
+ for chunk in self.iter_chunks():
265
+ yield chunk
266
+
267
+ async def __aiter__(self) -> typing.AsyncIterator[bytes]:
268
+ for chunk in self.iter_chunks():
269
+ yield chunk
evalkit_tf437/lib/python3.10/site-packages/httpx/_transports/__pycache__/default.cpython-310.pyc ADDED
Binary file (9.56 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/httpx/_transports/default.py ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Custom transports, with nicely configured defaults.
3
+
4
+ The following additional keyword arguments are currently supported by httpcore...
5
+
6
+ * uds: str
7
+ * local_address: str
8
+ * retries: int
9
+
10
+ Example usages...
11
+
12
+ # Disable HTTP/2 on a single specific domain.
13
+ mounts = {
14
+ "all://": httpx.HTTPTransport(http2=True),
15
+ "all://*example.org": httpx.HTTPTransport()
16
+ }
17
+
18
+ # Using advanced httpcore configuration, with connection retries.
19
+ transport = httpx.HTTPTransport(retries=1)
20
+ client = httpx.Client(transport=transport)
21
+
22
+ # Using advanced httpcore configuration, with unix domain sockets.
23
+ transport = httpx.HTTPTransport(uds="socket.uds")
24
+ client = httpx.Client(transport=transport)
25
+ """
26
+
27
+ from __future__ import annotations
28
+
29
+ import contextlib
30
+ import typing
31
+ from types import TracebackType
32
+
33
+ import httpcore
34
+
35
+ from .._config import DEFAULT_LIMITS, Limits, Proxy, create_ssl_context
36
+ from .._exceptions import (
37
+ ConnectError,
38
+ ConnectTimeout,
39
+ LocalProtocolError,
40
+ NetworkError,
41
+ PoolTimeout,
42
+ ProtocolError,
43
+ ProxyError,
44
+ ReadError,
45
+ ReadTimeout,
46
+ RemoteProtocolError,
47
+ TimeoutException,
48
+ UnsupportedProtocol,
49
+ WriteError,
50
+ WriteTimeout,
51
+ )
52
+ from .._models import Request, Response
53
+ from .._types import AsyncByteStream, CertTypes, ProxyTypes, SyncByteStream, VerifyTypes
54
+ from .._urls import URL
55
+ from .base import AsyncBaseTransport, BaseTransport
56
+
57
+ T = typing.TypeVar("T", bound="HTTPTransport")
58
+ A = typing.TypeVar("A", bound="AsyncHTTPTransport")
59
+
60
+ SOCKET_OPTION = typing.Union[
61
+ typing.Tuple[int, int, int],
62
+ typing.Tuple[int, int, typing.Union[bytes, bytearray]],
63
+ typing.Tuple[int, int, None, int],
64
+ ]
65
+
66
+ __all__ = ["AsyncHTTPTransport", "HTTPTransport"]
67
+
68
+
69
+ @contextlib.contextmanager
70
+ def map_httpcore_exceptions() -> typing.Iterator[None]:
71
+ try:
72
+ yield
73
+ except Exception as exc:
74
+ mapped_exc = None
75
+
76
+ for from_exc, to_exc in HTTPCORE_EXC_MAP.items():
77
+ if not isinstance(exc, from_exc):
78
+ continue
79
+ # We want to map to the most specific exception we can find.
80
+ # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to
81
+ # `httpx.ReadTimeout`, not just `httpx.TimeoutException`.
82
+ if mapped_exc is None or issubclass(to_exc, mapped_exc):
83
+ mapped_exc = to_exc
84
+
85
+ if mapped_exc is None: # pragma: no cover
86
+ raise
87
+
88
+ message = str(exc)
89
+ raise mapped_exc(message) from exc
90
+
91
+
92
+ HTTPCORE_EXC_MAP = {
93
+ httpcore.TimeoutException: TimeoutException,
94
+ httpcore.ConnectTimeout: ConnectTimeout,
95
+ httpcore.ReadTimeout: ReadTimeout,
96
+ httpcore.WriteTimeout: WriteTimeout,
97
+ httpcore.PoolTimeout: PoolTimeout,
98
+ httpcore.NetworkError: NetworkError,
99
+ httpcore.ConnectError: ConnectError,
100
+ httpcore.ReadError: ReadError,
101
+ httpcore.WriteError: WriteError,
102
+ httpcore.ProxyError: ProxyError,
103
+ httpcore.UnsupportedProtocol: UnsupportedProtocol,
104
+ httpcore.ProtocolError: ProtocolError,
105
+ httpcore.LocalProtocolError: LocalProtocolError,
106
+ httpcore.RemoteProtocolError: RemoteProtocolError,
107
+ }
108
+
109
+
110
+ class ResponseStream(SyncByteStream):
111
+ def __init__(self, httpcore_stream: typing.Iterable[bytes]) -> None:
112
+ self._httpcore_stream = httpcore_stream
113
+
114
+ def __iter__(self) -> typing.Iterator[bytes]:
115
+ with map_httpcore_exceptions():
116
+ for part in self._httpcore_stream:
117
+ yield part
118
+
119
+ def close(self) -> None:
120
+ if hasattr(self._httpcore_stream, "close"):
121
+ self._httpcore_stream.close()
122
+
123
+
124
+ class HTTPTransport(BaseTransport):
125
+ def __init__(
126
+ self,
127
+ verify: VerifyTypes = True,
128
+ cert: CertTypes | None = None,
129
+ http1: bool = True,
130
+ http2: bool = False,
131
+ limits: Limits = DEFAULT_LIMITS,
132
+ trust_env: bool = True,
133
+ proxy: ProxyTypes | None = None,
134
+ uds: str | None = None,
135
+ local_address: str | None = None,
136
+ retries: int = 0,
137
+ socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
138
+ ) -> None:
139
+ ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
140
+ proxy = Proxy(url=proxy) if isinstance(proxy, (str, URL)) else proxy
141
+
142
+ if proxy is None:
143
+ self._pool = httpcore.ConnectionPool(
144
+ ssl_context=ssl_context,
145
+ max_connections=limits.max_connections,
146
+ max_keepalive_connections=limits.max_keepalive_connections,
147
+ keepalive_expiry=limits.keepalive_expiry,
148
+ http1=http1,
149
+ http2=http2,
150
+ uds=uds,
151
+ local_address=local_address,
152
+ retries=retries,
153
+ socket_options=socket_options,
154
+ )
155
+ elif proxy.url.scheme in ("http", "https"):
156
+ self._pool = httpcore.HTTPProxy(
157
+ proxy_url=httpcore.URL(
158
+ scheme=proxy.url.raw_scheme,
159
+ host=proxy.url.raw_host,
160
+ port=proxy.url.port,
161
+ target=proxy.url.raw_path,
162
+ ),
163
+ proxy_auth=proxy.raw_auth,
164
+ proxy_headers=proxy.headers.raw,
165
+ ssl_context=ssl_context,
166
+ proxy_ssl_context=proxy.ssl_context,
167
+ max_connections=limits.max_connections,
168
+ max_keepalive_connections=limits.max_keepalive_connections,
169
+ keepalive_expiry=limits.keepalive_expiry,
170
+ http1=http1,
171
+ http2=http2,
172
+ socket_options=socket_options,
173
+ )
174
+ elif proxy.url.scheme == "socks5":
175
+ try:
176
+ import socksio # noqa
177
+ except ImportError: # pragma: no cover
178
+ raise ImportError(
179
+ "Using SOCKS proxy, but the 'socksio' package is not installed. "
180
+ "Make sure to install httpx using `pip install httpx[socks]`."
181
+ ) from None
182
+
183
+ self._pool = httpcore.SOCKSProxy(
184
+ proxy_url=httpcore.URL(
185
+ scheme=proxy.url.raw_scheme,
186
+ host=proxy.url.raw_host,
187
+ port=proxy.url.port,
188
+ target=proxy.url.raw_path,
189
+ ),
190
+ proxy_auth=proxy.raw_auth,
191
+ ssl_context=ssl_context,
192
+ max_connections=limits.max_connections,
193
+ max_keepalive_connections=limits.max_keepalive_connections,
194
+ keepalive_expiry=limits.keepalive_expiry,
195
+ http1=http1,
196
+ http2=http2,
197
+ )
198
+ else: # pragma: no cover
199
+ raise ValueError(
200
+ "Proxy protocol must be either 'http', 'https', or 'socks5',"
201
+ f" but got {proxy.url.scheme!r}."
202
+ )
203
+
204
+ def __enter__(self: T) -> T: # Use generics for subclass support.
205
+ self._pool.__enter__()
206
+ return self
207
+
208
+ def __exit__(
209
+ self,
210
+ exc_type: type[BaseException] | None = None,
211
+ exc_value: BaseException | None = None,
212
+ traceback: TracebackType | None = None,
213
+ ) -> None:
214
+ with map_httpcore_exceptions():
215
+ self._pool.__exit__(exc_type, exc_value, traceback)
216
+
217
+ def handle_request(
218
+ self,
219
+ request: Request,
220
+ ) -> Response:
221
+ assert isinstance(request.stream, SyncByteStream)
222
+
223
+ req = httpcore.Request(
224
+ method=request.method,
225
+ url=httpcore.URL(
226
+ scheme=request.url.raw_scheme,
227
+ host=request.url.raw_host,
228
+ port=request.url.port,
229
+ target=request.url.raw_path,
230
+ ),
231
+ headers=request.headers.raw,
232
+ content=request.stream,
233
+ extensions=request.extensions,
234
+ )
235
+ with map_httpcore_exceptions():
236
+ resp = self._pool.handle_request(req)
237
+
238
+ assert isinstance(resp.stream, typing.Iterable)
239
+
240
+ return Response(
241
+ status_code=resp.status,
242
+ headers=resp.headers,
243
+ stream=ResponseStream(resp.stream),
244
+ extensions=resp.extensions,
245
+ )
246
+
247
+ def close(self) -> None:
248
+ self._pool.close()
249
+
250
+
251
+ class AsyncResponseStream(AsyncByteStream):
252
+ def __init__(self, httpcore_stream: typing.AsyncIterable[bytes]) -> None:
253
+ self._httpcore_stream = httpcore_stream
254
+
255
+ async def __aiter__(self) -> typing.AsyncIterator[bytes]:
256
+ with map_httpcore_exceptions():
257
+ async for part in self._httpcore_stream:
258
+ yield part
259
+
260
+ async def aclose(self) -> None:
261
+ if hasattr(self._httpcore_stream, "aclose"):
262
+ await self._httpcore_stream.aclose()
263
+
264
+
265
+ class AsyncHTTPTransport(AsyncBaseTransport):
266
+ def __init__(
267
+ self,
268
+ verify: VerifyTypes = True,
269
+ cert: CertTypes | None = None,
270
+ http1: bool = True,
271
+ http2: bool = False,
272
+ limits: Limits = DEFAULT_LIMITS,
273
+ trust_env: bool = True,
274
+ proxy: ProxyTypes | None = None,
275
+ uds: str | None = None,
276
+ local_address: str | None = None,
277
+ retries: int = 0,
278
+ socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
279
+ ) -> None:
280
+ ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
281
+ proxy = Proxy(url=proxy) if isinstance(proxy, (str, URL)) else proxy
282
+
283
+ if proxy is None:
284
+ self._pool = httpcore.AsyncConnectionPool(
285
+ ssl_context=ssl_context,
286
+ max_connections=limits.max_connections,
287
+ max_keepalive_connections=limits.max_keepalive_connections,
288
+ keepalive_expiry=limits.keepalive_expiry,
289
+ http1=http1,
290
+ http2=http2,
291
+ uds=uds,
292
+ local_address=local_address,
293
+ retries=retries,
294
+ socket_options=socket_options,
295
+ )
296
+ elif proxy.url.scheme in ("http", "https"):
297
+ self._pool = httpcore.AsyncHTTPProxy(
298
+ proxy_url=httpcore.URL(
299
+ scheme=proxy.url.raw_scheme,
300
+ host=proxy.url.raw_host,
301
+ port=proxy.url.port,
302
+ target=proxy.url.raw_path,
303
+ ),
304
+ proxy_auth=proxy.raw_auth,
305
+ proxy_headers=proxy.headers.raw,
306
+ proxy_ssl_context=proxy.ssl_context,
307
+ ssl_context=ssl_context,
308
+ max_connections=limits.max_connections,
309
+ max_keepalive_connections=limits.max_keepalive_connections,
310
+ keepalive_expiry=limits.keepalive_expiry,
311
+ http1=http1,
312
+ http2=http2,
313
+ socket_options=socket_options,
314
+ )
315
+ elif proxy.url.scheme == "socks5":
316
+ try:
317
+ import socksio # noqa
318
+ except ImportError: # pragma: no cover
319
+ raise ImportError(
320
+ "Using SOCKS proxy, but the 'socksio' package is not installed. "
321
+ "Make sure to install httpx using `pip install httpx[socks]`."
322
+ ) from None
323
+
324
+ self._pool = httpcore.AsyncSOCKSProxy(
325
+ proxy_url=httpcore.URL(
326
+ scheme=proxy.url.raw_scheme,
327
+ host=proxy.url.raw_host,
328
+ port=proxy.url.port,
329
+ target=proxy.url.raw_path,
330
+ ),
331
+ proxy_auth=proxy.raw_auth,
332
+ ssl_context=ssl_context,
333
+ max_connections=limits.max_connections,
334
+ max_keepalive_connections=limits.max_keepalive_connections,
335
+ keepalive_expiry=limits.keepalive_expiry,
336
+ http1=http1,
337
+ http2=http2,
338
+ )
339
+ else: # pragma: no cover
340
+ raise ValueError(
341
+ "Proxy protocol must be either 'http', 'https', or 'socks5',"
342
+ " but got {proxy.url.scheme!r}."
343
+ )
344
+
345
+ async def __aenter__(self: A) -> A: # Use generics for subclass support.
346
+ await self._pool.__aenter__()
347
+ return self
348
+
349
+ async def __aexit__(
350
+ self,
351
+ exc_type: type[BaseException] | None = None,
352
+ exc_value: BaseException | None = None,
353
+ traceback: TracebackType | None = None,
354
+ ) -> None:
355
+ with map_httpcore_exceptions():
356
+ await self._pool.__aexit__(exc_type, exc_value, traceback)
357
+
358
+ async def handle_async_request(
359
+ self,
360
+ request: Request,
361
+ ) -> Response:
362
+ assert isinstance(request.stream, AsyncByteStream)
363
+
364
+ req = httpcore.Request(
365
+ method=request.method,
366
+ url=httpcore.URL(
367
+ scheme=request.url.raw_scheme,
368
+ host=request.url.raw_host,
369
+ port=request.url.port,
370
+ target=request.url.raw_path,
371
+ ),
372
+ headers=request.headers.raw,
373
+ content=request.stream,
374
+ extensions=request.extensions,
375
+ )
376
+ with map_httpcore_exceptions():
377
+ resp = await self._pool.handle_async_request(req)
378
+
379
+ assert isinstance(resp.stream, typing.AsyncIterable)
380
+
381
+ return Response(
382
+ status_code=resp.status,
383
+ headers=resp.headers,
384
+ stream=AsyncResponseStream(resp.stream),
385
+ extensions=resp.extensions,
386
+ )
387
+
388
+ async def aclose(self) -> None:
389
+ await self._pool.aclose()
evalkit_tf437/lib/python3.10/site-packages/httpx/_transports/mock.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from .._models import Request, Response
6
+ from .base import AsyncBaseTransport, BaseTransport
7
+
8
+ SyncHandler = typing.Callable[[Request], Response]
9
+ AsyncHandler = typing.Callable[[Request], typing.Coroutine[None, None, Response]]
10
+
11
+
12
+ __all__ = ["MockTransport"]
13
+
14
+
15
+ class MockTransport(AsyncBaseTransport, BaseTransport):
16
+ def __init__(self, handler: SyncHandler | AsyncHandler) -> None:
17
+ self.handler = handler
18
+
19
+ def handle_request(
20
+ self,
21
+ request: Request,
22
+ ) -> Response:
23
+ request.read()
24
+ response = self.handler(request)
25
+ if not isinstance(response, Response): # pragma: no cover
26
+ raise TypeError("Cannot use an async handler in a sync Client")
27
+ return response
28
+
29
+ async def handle_async_request(
30
+ self,
31
+ request: Request,
32
+ ) -> Response:
33
+ await request.aread()
34
+ response = self.handler(request)
35
+
36
+ # Allow handler to *optionally* be an `async` function.
37
+ # If it is, then the `response` variable need to be awaited to actually
38
+ # return the result.
39
+
40
+ if not isinstance(response, Response):
41
+ response = await response
42
+
43
+ return response
evalkit_tf437/lib/python3.10/site-packages/importlib_metadata-8.5.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/LICENSE.txt ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This implementation of Markdown is licensed under the MIT License:
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2012 Trent Mick
6
+ Copyright (c) 2010 ActiveState Software Inc.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a
9
+ copy of this software and associated documentation files (the
10
+ "Software"), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to permit
13
+ persons to whom the Software is furnished to do so, subject to the
14
+ following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included
17
+ in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+
28
+ All files in a *source package* of markdown2 (i.e. those available on
29
+ pypi.python.org and the Google Code project "downloads" page) are under the
30
+ MIT license. However, in the *subversion repository* there are some files
31
+ (used for performance and testing purposes) that are under different licenses
32
+ as follows:
33
+
34
+ - perf/recipes.pprint
35
+
36
+ Python License. This file includes a number of real-world examples of
37
+ Markdown from the ActiveState Python Cookbook, used for doing some
38
+ performance testing of markdown2.py.
39
+
40
+ - test/php-markdown-cases/...
41
+ test/php-markdown-extra-cases/...
42
+
43
+ GPL. These are from the MDTest package announced here:
44
+ http://six.pairlist.net/pipermail/markdown-discuss/2007-July/000674.html
45
+
46
+ - test/markdown.py
47
+
48
+ GPL 2 or BSD. A copy (currently old) of Python-Markdown -- the other
49
+ Python Markdown implementation.
50
+
51
+ - test/markdown.php
52
+
53
+ BSD-style. This is PHP Markdown
54
+ (http://michelf.com/projects/php-markdown/).
55
+
56
+ - test/Markdown.pl: BSD-style
57
+
58
+ A copy of Perl Markdown (http://daringfireball.net/projects/markdown/).
59
+
evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/METADATA ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: markdown2
3
+ Version: 2.5.1
4
+ Summary: A fast and complete Python implementation of Markdown
5
+ Home-page: https://github.com/trentm/python-markdown2
6
+ Author: Trent Mick
7
+ Author-email: trentm@gmail.com
8
+ Maintainer: Trent Mick
9
+ Maintainer-email: trentm@gmail.com
10
+ License: MIT
11
+ Platform: any
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Topic :: Software Development :: Documentation
25
+ Classifier: Topic :: Text Processing :: Filters
26
+ Classifier: Topic :: Text Processing :: Markup :: HTML
27
+ Requires-Python: >=3.8, <4
28
+ Provides-Extra: all
29
+ Requires-Dist: pygments (>=2.7.3) ; extra == 'all'
30
+ Requires-Dist: wavedrom ; (python_version >= "3.7") and extra == 'all'
31
+ Requires-Dist: latex2mathml ; (python_version >= "3.8.1") and extra == 'all'
32
+ Provides-Extra: code_syntax_highlighting
33
+ Requires-Dist: pygments (>=2.7.3) ; extra == 'code_syntax_highlighting'
34
+ Provides-Extra: latex
35
+ Requires-Dist: latex2mathml ; (python_version >= "3.8.1") and extra == 'latex'
36
+ Provides-Extra: wavedrom
37
+ Requires-Dist: wavedrom ; (python_version >= "3.7") and extra == 'wavedrom'
38
+
39
+ markdown2: A fast and complete Python implementation of Markdown.
40
+
41
+ Markdown is a text-to-HTML filter; it translates an easy-to-read /
42
+ easy-to-write structured text format into HTML. Markdown's text
43
+ format is most similar to that of plain text email, and supports
44
+ features such as headers, *emphasis*, code blocks, blockquotes, and
45
+ links. -- http://daringfireball.net/projects/markdown/
46
+
47
+ This is a fast and complete Python implementation of the Markdown
48
+ spec. See http://github.com/trentm/python-markdown2 for more info.
49
+
50
+
evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/RECORD ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ../../../bin/markdown2,sha256=S5hJ8xWq_xBepC36ry9oYuYgLUwrlSGy1LdtYmhaWSw,227
2
+ __pycache__/markdown2.cpython-310.pyc,,
3
+ markdown2-2.5.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
4
+ markdown2-2.5.1.dist-info/LICENSE.txt,sha256=-MfE1VRAnPYhuNZT2__7cZdF_Tb1xJuDBSWGSbQD75w,2313
5
+ markdown2-2.5.1.dist-info/METADATA,sha256=iHoNmgM5F9LLbWr_9NP5VllDoYDTAHYMXmIkDZulBM0,2168
6
+ markdown2-2.5.1.dist-info/RECORD,,
7
+ markdown2-2.5.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ markdown2-2.5.1.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
9
+ markdown2-2.5.1.dist-info/entry_points.txt,sha256=ZAfeiSjZzwRSLJYMNAPOV-cMgZhEAVdrjG_E3wF0kz4,46
10
+ markdown2-2.5.1.dist-info/top_level.txt,sha256=fDjZIsBNbTniMxzHsMuRyzfmvWbBOoUklf6ycVKreNc,10
11
+ markdown2.py,sha256=cJ4alw5f79UduTFwGynQe3n79NnP4dq5bUKytWNBcTg,161240
evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/REQUESTED ADDED
File without changes
evalkit_tf437/lib/python3.10/site-packages/markdown2-2.5.1.dist-info/entry_points.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [console_scripts]
2
+ markdown2 = markdown2:main
3
+
evalkit_tf437/lib/python3.10/site-packages/nvidia_nvjitlink_cu12-12.6.77.dist-info/REQUESTED ADDED
File without changes
evalkit_tf437/lib/python3.10/site-packages/oauthlib-3.2.2.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
evalkit_tf437/lib/python3.10/site-packages/oauthlib-3.2.2.dist-info/REQUESTED ADDED
File without changes
evalkit_tf437/lib/python3.10/site-packages/oauthlib-3.2.2.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ oauthlib
evalkit_tf437/lib/python3.10/site-packages/opencv_python-4.10.0.84.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ cv2
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/LICENSE ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ This software is made available under the terms of *either* of the licenses
2
+ found in LICENSE.APACHE or LICENSE.BSD. Contributions to this software is made
3
+ under the terms of *both* these licenses.
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/LICENSE.APACHE ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/METADATA ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.3
2
+ Name: packaging
3
+ Version: 24.2
4
+ Summary: Core utilities for Python packages
5
+ Author-email: Donald Stufft <donald@stufft.io>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/x-rst
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: License :: OSI Approved :: BSD License
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Classifier: Typing :: Typed
24
+ Project-URL: Documentation, https://packaging.pypa.io/
25
+ Project-URL: Source, https://github.com/pypa/packaging
26
+
27
+ packaging
28
+ =========
29
+
30
+ .. start-intro
31
+
32
+ Reusable core utilities for various Python Packaging
33
+ `interoperability specifications <https://packaging.python.org/specifications/>`_.
34
+
35
+ This library provides utilities that implement the interoperability
36
+ specifications which have clearly one correct behaviour (eg: :pep:`440`)
37
+ or benefit greatly from having a single shared implementation (eg: :pep:`425`).
38
+
39
+ .. end-intro
40
+
41
+ The ``packaging`` project includes the following: version handling, specifiers,
42
+ markers, requirements, tags, utilities.
43
+
44
+ Documentation
45
+ -------------
46
+
47
+ The `documentation`_ provides information and the API for the following:
48
+
49
+ - Version Handling
50
+ - Specifiers
51
+ - Markers
52
+ - Requirements
53
+ - Tags
54
+ - Utilities
55
+
56
+ Installation
57
+ ------------
58
+
59
+ Use ``pip`` to install these utilities::
60
+
61
+ pip install packaging
62
+
63
+ The ``packaging`` library uses calendar-based versioning (``YY.N``).
64
+
65
+ Discussion
66
+ ----------
67
+
68
+ If you run into bugs, you can file them in our `issue tracker`_.
69
+
70
+ You can also join ``#pypa`` on Freenode to ask questions or get involved.
71
+
72
+
73
+ .. _`documentation`: https://packaging.pypa.io/
74
+ .. _`issue tracker`: https://github.com/pypa/packaging/issues
75
+
76
+
77
+ Code of Conduct
78
+ ---------------
79
+
80
+ Everyone interacting in the packaging project's codebases, issue trackers, chat
81
+ rooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.
82
+
83
+ .. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
84
+
85
+ Contributing
86
+ ------------
87
+
88
+ The ``CONTRIBUTING.rst`` file outlines how to contribute to this project as
89
+ well as how to report a potential security issue. The documentation for this
90
+ project also covers information about `project development`_ and `security`_.
91
+
92
+ .. _`project development`: https://packaging.pypa.io/en/latest/development/
93
+ .. _`security`: https://packaging.pypa.io/en/latest/security/
94
+
95
+ Project History
96
+ ---------------
97
+
98
+ Please review the ``CHANGELOG.rst`` file or the `Changelog documentation`_ for
99
+ recent changes and project history.
100
+
101
+ .. _`Changelog documentation`: https://packaging.pypa.io/en/latest/changelog/
102
+
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/RECORD ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ packaging-24.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ packaging-24.2.dist-info/LICENSE,sha256=ytHvW9NA1z4HS6YU0m996spceUDD2MNIUuZcSQlobEg,197
3
+ packaging-24.2.dist-info/LICENSE.APACHE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
4
+ packaging-24.2.dist-info/LICENSE.BSD,sha256=tw5-m3QvHMb5SLNMFqo5_-zpQZY2S8iP8NIYDwAo-sU,1344
5
+ packaging-24.2.dist-info/METADATA,sha256=ohH86s6k5mIfQxY2TS0LcSfADeOFa4BiCC-bxZV-pNs,3204
6
+ packaging-24.2.dist-info/RECORD,,
7
+ packaging-24.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ packaging-24.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
9
+ packaging/__init__.py,sha256=dk4Ta_vmdVJxYHDcfyhvQNw8V3PgSBomKNXqg-D2JDY,494
10
+ packaging/__pycache__/__init__.cpython-310.pyc,,
11
+ packaging/__pycache__/_elffile.cpython-310.pyc,,
12
+ packaging/__pycache__/_manylinux.cpython-310.pyc,,
13
+ packaging/__pycache__/_musllinux.cpython-310.pyc,,
14
+ packaging/__pycache__/_parser.cpython-310.pyc,,
15
+ packaging/__pycache__/_structures.cpython-310.pyc,,
16
+ packaging/__pycache__/_tokenizer.cpython-310.pyc,,
17
+ packaging/__pycache__/markers.cpython-310.pyc,,
18
+ packaging/__pycache__/metadata.cpython-310.pyc,,
19
+ packaging/__pycache__/requirements.cpython-310.pyc,,
20
+ packaging/__pycache__/specifiers.cpython-310.pyc,,
21
+ packaging/__pycache__/tags.cpython-310.pyc,,
22
+ packaging/__pycache__/utils.cpython-310.pyc,,
23
+ packaging/__pycache__/version.cpython-310.pyc,,
24
+ packaging/_elffile.py,sha256=cflAQAkE25tzhYmq_aCi72QfbT_tn891tPzfpbeHOwE,3306
25
+ packaging/_manylinux.py,sha256=vl5OCoz4kx80H5rwXKeXWjl9WNISGmr4ZgTpTP9lU9c,9612
26
+ packaging/_musllinux.py,sha256=p9ZqNYiOItGee8KcZFeHF_YcdhVwGHdK6r-8lgixvGQ,2694
27
+ packaging/_parser.py,sha256=s_TvTvDNK0NrM2QB3VKThdWFM4Nc0P6JnkObkl3MjpM,10236
28
+ packaging/_structures.py,sha256=q3eVNmbWJGG_S0Dit_S3Ao8qQqz_5PYTXFAKBZe5yr4,1431
29
+ packaging/_tokenizer.py,sha256=J6v5H7Jzvb-g81xp_2QACKwO7LxHQA6ikryMU7zXwN8,5273
30
+ packaging/licenses/__init__.py,sha256=1x5M1nEYjcgwEbLt0dXwz2ukjr18DiCzC0sraQqJ-Ww,5715
31
+ packaging/licenses/__pycache__/__init__.cpython-310.pyc,,
32
+ packaging/licenses/__pycache__/_spdx.cpython-310.pyc,,
33
+ packaging/licenses/_spdx.py,sha256=oAm1ztPFwlsmCKe7lAAsv_OIOfS1cWDu9bNBkeu-2ns,48398
34
+ packaging/markers.py,sha256=c89TNzB7ZdGYhkovm6PYmqGyHxXlYVaLW591PHUNKD8,10561
35
+ packaging/metadata.py,sha256=YJibM7GYe4re8-0a3OlXmGS-XDgTEoO4tlBt2q25Bng,34762
36
+ packaging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ packaging/requirements.py,sha256=gYyRSAdbrIyKDY66ugIDUQjRMvxkH2ALioTmX3tnL6o,2947
38
+ packaging/specifiers.py,sha256=GG1wPNMcL0fMJO68vF53wKMdwnfehDcaI-r9NpTfilA,40074
39
+ packaging/tags.py,sha256=CFqrJzAzc2XNGexerH__T-Y5Iwq7WbsYXsiLERLWxY0,21014
40
+ packaging/utils.py,sha256=0F3Hh9OFuRgrhTgGZUl5K22Fv1YP2tZl1z_2gO6kJiA,5050
41
+ packaging/version.py,sha256=olfyuk_DPbflNkJ4wBWetXQ17c74x3DB501degUv7DY,16676
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/REQUESTED ADDED
File without changes
evalkit_tf437/lib/python3.10/site-packages/packaging-24.2.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.10.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
evalkit_tf437/lib/python3.10/site-packages/pygments/__main__.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ pygments.__main__
3
+ ~~~~~~~~~~~~~~~~~
4
+
5
+ Main entry point for ``python -m pygments``.
6
+
7
+ :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ import sys
12
+ import pygments.cmdline
13
+
14
+ try:
15
+ sys.exit(pygments.cmdline.main(sys.argv))
16
+ except KeyboardInterrupt:
17
+ sys.exit(1)
evalkit_tf437/lib/python3.10/site-packages/pygments/formatter.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ pygments.formatter
3
+ ~~~~~~~~~~~~~~~~~~
4
+
5
+ Base formatter class.
6
+
7
+ :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ import codecs
12
+
13
+ from pygments.util import get_bool_opt
14
+ from pygments.styles import get_style_by_name
15
+
16
+ __all__ = ['Formatter']
17
+
18
+
19
+ def _lookup_style(style):
20
+ if isinstance(style, str):
21
+ return get_style_by_name(style)
22
+ return style
23
+
24
+
25
+ class Formatter:
26
+ """
27
+ Converts a token stream to text.
28
+
29
+ Formatters should have attributes to help selecting them. These
30
+ are similar to the corresponding :class:`~pygments.lexer.Lexer`
31
+ attributes.
32
+
33
+ .. autoattribute:: name
34
+ :no-value:
35
+
36
+ .. autoattribute:: aliases
37
+ :no-value:
38
+
39
+ .. autoattribute:: filenames
40
+ :no-value:
41
+
42
+ You can pass options as keyword arguments to the constructor.
43
+ All formatters accept these basic options:
44
+
45
+ ``style``
46
+ The style to use, can be a string or a Style subclass
47
+ (default: "default"). Not used by e.g. the
48
+ TerminalFormatter.
49
+ ``full``
50
+ Tells the formatter to output a "full" document, i.e.
51
+ a complete self-contained document. This doesn't have
52
+ any effect for some formatters (default: false).
53
+ ``title``
54
+ If ``full`` is true, the title that should be used to
55
+ caption the document (default: '').
56
+ ``encoding``
57
+ If given, must be an encoding name. This will be used to
58
+ convert the Unicode token strings to byte strings in the
59
+ output. If it is "" or None, Unicode strings will be written
60
+ to the output file, which most file-like objects do not
61
+ support (default: None).
62
+ ``outencoding``
63
+ Overrides ``encoding`` if given.
64
+
65
+ """
66
+
67
+ #: Full name for the formatter, in human-readable form.
68
+ name = None
69
+
70
+ #: A list of short, unique identifiers that can be used to lookup
71
+ #: the formatter from a list, e.g. using :func:`.get_formatter_by_name()`.
72
+ aliases = []
73
+
74
+ #: A list of fnmatch patterns that match filenames for which this
75
+ #: formatter can produce output. The patterns in this list should be unique
76
+ #: among all formatters.
77
+ filenames = []
78
+
79
+ #: If True, this formatter outputs Unicode strings when no encoding
80
+ #: option is given.
81
+ unicodeoutput = True
82
+
83
+ def __init__(self, **options):
84
+ """
85
+ As with lexers, this constructor takes arbitrary optional arguments,
86
+ and if you override it, you should first process your own options, then
87
+ call the base class implementation.
88
+ """
89
+ self.style = _lookup_style(options.get('style', 'default'))
90
+ self.full = get_bool_opt(options, 'full', False)
91
+ self.title = options.get('title', '')
92
+ self.encoding = options.get('encoding', None) or None
93
+ if self.encoding in ('guess', 'chardet'):
94
+ # can happen for e.g. pygmentize -O encoding=guess
95
+ self.encoding = 'utf-8'
96
+ self.encoding = options.get('outencoding') or self.encoding
97
+ self.options = options
98
+
99
+ def get_style_defs(self, arg=''):
100
+ """
101
+ This method must return statements or declarations suitable to define
102
+ the current style for subsequent highlighted text (e.g. CSS classes
103
+ in the `HTMLFormatter`).
104
+
105
+ The optional argument `arg` can be used to modify the generation and
106
+ is formatter dependent (it is standardized because it can be given on
107
+ the command line).
108
+
109
+ This method is called by the ``-S`` :doc:`command-line option <cmdline>`,
110
+ the `arg` is then given by the ``-a`` option.
111
+ """
112
+ return ''
113
+
114
+ def format(self, tokensource, outfile):
115
+ """
116
+ This method must format the tokens from the `tokensource` iterable and
117
+ write the formatted version to the file object `outfile`.
118
+
119
+ Formatter options can control how exactly the tokens are converted.
120
+ """
121
+ if self.encoding:
122
+ # wrap the outfile in a StreamWriter
123
+ outfile = codecs.lookup(self.encoding)[3](outfile)
124
+ return self.format_unencoded(tokensource, outfile)
125
+
126
+ # Allow writing Formatter[str] or Formatter[bytes]. That's equivalent to
127
+ # Formatter. This helps when using third-party type stubs from typeshed.
128
+ def __class_getitem__(cls, name):
129
+ return cls
evalkit_tf437/lib/python3.10/site-packages/pygments/formatters/__pycache__/_mapping.cpython-310.pyc ADDED
Binary file (3.98 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/pygments/formatters/__pycache__/bbcode.cpython-310.pyc ADDED
Binary file (3.05 kB). View file