codekingpro commited on
Commit
7bbc3b7
·
verified ·
1 Parent(s): 7a06b56

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. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/__init__.cpython-311.pyc +0 -0
  2. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/_compat.cpython-311.pyc +0 -0
  3. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/exceptions.cpython-311.pyc +0 -0
  4. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/sessions.cpython-311.pyc +0 -0
  5. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/streaming_iterator.cpython-311.pyc +0 -0
  6. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/__init__.py +15 -0
  7. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/appengine.py +206 -0
  8. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/fingerprint.py +48 -0
  9. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/host_header_ssl.py +43 -0
  10. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/socket_options.py +129 -0
  11. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/source.py +67 -0
  12. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/ssl.py +66 -0
  13. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/x509.py +196 -0
  14. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/__init__.py +0 -0
  15. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/_digest_auth_compat.py +29 -0
  16. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/guess.py +146 -0
  17. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/handler.py +142 -0
  18. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/http_proxy_digest.py +103 -0
  19. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/cookies/__init__.py +0 -0
  20. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/cookies/forgetful.py +7 -0
  21. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/downloadutils/__init__.py +0 -0
  22. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/downloadutils/stream.py +176 -0
  23. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/downloadutils/tee.py +123 -0
  24. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/multipart/__init__.py +31 -0
  25. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/multipart/decoder.py +156 -0
  26. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/multipart/encoder.py +655 -0
  27. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__init__.py +97 -0
  28. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__pycache__/__init__.cpython-311.pyc +0 -0
  29. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__pycache__/pool.cpython-311.pyc +0 -0
  30. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__pycache__/thread.cpython-311.pyc +0 -0
  31. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/pool.py +211 -0
  32. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/thread.py +53 -0
  33. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__init__.py +0 -0
  34. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/__init__.cpython-311.pyc +0 -0
  35. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/deprecated.cpython-311.pyc +0 -0
  36. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/dump.cpython-311.pyc +0 -0
  37. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/formdata.cpython-311.pyc +0 -0
  38. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/user_agent.cpython-311.pyc +0 -0
  39. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/deprecated.py +91 -0
  40. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/dump.py +198 -0
  41. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/formdata.py +108 -0
  42. micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/user_agent.py +143 -0
  43. micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/licenses/LICENSE +19 -0
  44. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/__init__.cpython-311.pyc +0 -0
  45. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/__main__.cpython-311.pyc +0 -0
  46. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_emoji_replace.cpython-311.pyc +0 -0
  47. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_export_format.cpython-311.pyc +0 -0
  48. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_extension.cpython-311.pyc +0 -0
  49. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_fileno.cpython-311.pyc +0 -0
  50. micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_inspect.cpython-311.pyc +0 -0
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.68 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/_compat.cpython-311.pyc ADDED
Binary file (14.3 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/exceptions.cpython-311.pyc ADDED
Binary file (1.41 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/sessions.cpython-311.pyc ADDED
Binary file (4.34 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__pycache__/streaming_iterator.cpython-311.pyc ADDED
Binary file (5.57 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/__init__.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ requests-toolbelt.adapters
4
+ ==========================
5
+
6
+ See https://toolbelt.readthedocs.io/ for documentation
7
+
8
+ :copyright: (c) 2014 by Ian Cordasco and Cory Benfield
9
+ :license: Apache v2.0, see LICENSE for more details
10
+ """
11
+
12
+ from .ssl import SSLAdapter
13
+ from .source import SourceAddressAdapter
14
+
15
+ __all__ = ['SSLAdapter', 'SourceAddressAdapter']
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/appengine.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """The App Engine Transport Adapter for requests.
3
+
4
+ .. versionadded:: 0.6.0
5
+
6
+ This requires a version of requests >= 2.10.0 and Python 2.
7
+
8
+ There are two ways to use this library:
9
+
10
+ #. If you're using requests directly, you can use code like:
11
+
12
+ .. code-block:: python
13
+
14
+ >>> import requests
15
+ >>> import ssl
16
+ >>> import requests.packages.urllib3.contrib.appengine as ul_appengine
17
+ >>> from requests_toolbelt.adapters import appengine
18
+ >>> s = requests.Session()
19
+ >>> if ul_appengine.is_appengine_sandbox():
20
+ ... s.mount('http://', appengine.AppEngineAdapter())
21
+ ... s.mount('https://', appengine.AppEngineAdapter())
22
+
23
+ #. If you depend on external libraries which use requests, you can use code
24
+ like:
25
+
26
+ .. code-block:: python
27
+
28
+ >>> from requests_toolbelt.adapters import appengine
29
+ >>> appengine.monkeypatch()
30
+
31
+ which will ensure all requests.Session objects use AppEngineAdapter properly.
32
+
33
+ You are also able to :ref:`disable certificate validation <insecure_appengine>`
34
+ when monkey-patching.
35
+ """
36
+ import requests
37
+ import warnings
38
+ from requests import adapters
39
+ from requests import sessions
40
+
41
+ from .. import exceptions as exc
42
+ from .._compat import gaecontrib
43
+ from .._compat import timeout
44
+
45
+
46
+ class AppEngineMROHack(adapters.HTTPAdapter):
47
+ """Resolves infinite recursion when monkeypatching.
48
+
49
+ This works by injecting itself as the base class of both the
50
+ :class:`AppEngineAdapter` and Requests' default HTTPAdapter, which needs to
51
+ be done because default HTTPAdapter's MRO is recompiled when we
52
+ monkeypatch, at which point this class becomes HTTPAdapter's base class.
53
+ In addition, we use an instantiation flag to avoid infinite recursion.
54
+ """
55
+ _initialized = False
56
+
57
+ def __init__(self, *args, **kwargs):
58
+ if not self._initialized:
59
+ self._initialized = True
60
+ super(AppEngineMROHack, self).__init__(*args, **kwargs)
61
+
62
+
63
+ class AppEngineAdapter(AppEngineMROHack, adapters.HTTPAdapter):
64
+ """The transport adapter for Requests to use urllib3's GAE support.
65
+
66
+ Implements Requests's HTTPAdapter API.
67
+
68
+ When deploying to Google's App Engine service, some of Requests'
69
+ functionality is broken. There is underlying support for GAE in urllib3.
70
+ This functionality, however, is opt-in and needs to be enabled explicitly
71
+ for Requests to be able to use it.
72
+ """
73
+
74
+ __attrs__ = adapters.HTTPAdapter.__attrs__ + ['_validate_certificate']
75
+
76
+ def __init__(self, validate_certificate=True, *args, **kwargs):
77
+ _check_version()
78
+ self._validate_certificate = validate_certificate
79
+ super(AppEngineAdapter, self).__init__(*args, **kwargs)
80
+
81
+ def init_poolmanager(self, connections, maxsize, block=False):
82
+ self.poolmanager = _AppEnginePoolManager(self._validate_certificate)
83
+
84
+
85
+ class InsecureAppEngineAdapter(AppEngineAdapter):
86
+ """An always-insecure GAE adapter for Requests.
87
+
88
+ This is a variant of the the transport adapter for Requests to use
89
+ urllib3's GAE support that does not validate certificates. Use with
90
+ caution!
91
+
92
+ .. note::
93
+ The ``validate_certificate`` keyword argument will not be honored here
94
+ and is not part of the signature because we always force it to
95
+ ``False``.
96
+
97
+ See :class:`AppEngineAdapter` for further details.
98
+ """
99
+
100
+ def __init__(self, *args, **kwargs):
101
+ if kwargs.pop("validate_certificate", False):
102
+ warnings.warn("Certificate validation cannot be specified on the "
103
+ "InsecureAppEngineAdapter, but was present. This "
104
+ "will be ignored and certificate validation will "
105
+ "remain off.", exc.IgnoringGAECertificateValidation)
106
+
107
+ super(InsecureAppEngineAdapter, self).__init__(
108
+ validate_certificate=False, *args, **kwargs)
109
+
110
+
111
+ class _AppEnginePoolManager(object):
112
+ """Implements urllib3's PoolManager API expected by requests.
113
+
114
+ While a real PoolManager map hostnames to reusable Connections,
115
+ AppEngine has no concept of a reusable connection to a host.
116
+ So instead, this class constructs a small Connection per request,
117
+ that is returned to the Adapter and used to access the URL.
118
+ """
119
+
120
+ def __init__(self, validate_certificate=True):
121
+ self.appengine_manager = gaecontrib.AppEngineManager(
122
+ validate_certificate=validate_certificate)
123
+
124
+ def connection_from_url(self, url):
125
+ return _AppEngineConnection(self.appengine_manager, url)
126
+
127
+ def clear(self):
128
+ pass
129
+
130
+
131
+ class _AppEngineConnection(object):
132
+ """Implements urllib3's HTTPConnectionPool API's urlopen().
133
+
134
+ This Connection's urlopen() is called with a host-relative path,
135
+ so in order to properly support opening the URL, we need to store
136
+ the full URL when this Connection is constructed from the PoolManager.
137
+
138
+ This code wraps AppEngineManager.urlopen(), which exposes a different
139
+ API than in the original urllib3 urlopen(), and thus needs this adapter.
140
+ """
141
+
142
+ def __init__(self, appengine_manager, url):
143
+ self.appengine_manager = appengine_manager
144
+ self.url = url
145
+
146
+ def urlopen(self, method, url, body=None, headers=None, retries=None,
147
+ redirect=True, assert_same_host=True,
148
+ timeout=timeout.Timeout.DEFAULT_TIMEOUT,
149
+ pool_timeout=None, release_conn=None, **response_kw):
150
+ # This function's url argument is a host-relative URL,
151
+ # but the AppEngineManager expects an absolute URL.
152
+ # So we saved out the self.url when the AppEngineConnection
153
+ # was constructed, which we then can use down below instead.
154
+
155
+ # We once tried to verify our assumptions here, but sometimes the
156
+ # passed-in URL differs on url fragments, or "http://a.com" vs "/".
157
+
158
+ # urllib3's App Engine adapter only uses Timeout.total, not read or
159
+ # connect.
160
+ if not timeout.total:
161
+ timeout.total = timeout._read or timeout._connect
162
+
163
+ # Jump through the hoops necessary to call AppEngineManager's API.
164
+ return self.appengine_manager.urlopen(
165
+ method,
166
+ self.url,
167
+ body=body,
168
+ headers=headers,
169
+ retries=retries,
170
+ redirect=redirect,
171
+ timeout=timeout,
172
+ **response_kw)
173
+
174
+
175
+ def monkeypatch(validate_certificate=True):
176
+ """Sets up all Sessions to use AppEngineAdapter by default.
177
+
178
+ If you don't want to deal with configuring your own Sessions,
179
+ or if you use libraries that use requests directly (ie requests.post),
180
+ then you may prefer to monkeypatch and auto-configure all Sessions.
181
+
182
+ .. warning: :
183
+
184
+ If ``validate_certificate`` is ``False``, certification validation will
185
+ effectively be disabled for all requests.
186
+ """
187
+ _check_version()
188
+ # HACK: We should consider modifying urllib3 to support this cleanly,
189
+ # so that we can set a module-level variable in the sessions module,
190
+ # instead of overriding an imported HTTPAdapter as is done here.
191
+ adapter = AppEngineAdapter
192
+ if not validate_certificate:
193
+ adapter = InsecureAppEngineAdapter
194
+
195
+ sessions.HTTPAdapter = adapter
196
+ adapters.HTTPAdapter = adapter
197
+
198
+
199
+ def _check_version():
200
+ if gaecontrib is None:
201
+ raise exc.VersionMismatchError(
202
+ "The toolbelt requires at least Requests 2.10.0 to be "
203
+ "installed. Version {} was found instead.".format(
204
+ requests.__version__
205
+ )
206
+ )
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/fingerprint.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Submodule containing the implementation for the FingerprintAdapter.
3
+
4
+ This file contains an implementation of a Transport Adapter that validates
5
+ the fingerprints of SSL certificates presented upon connection.
6
+ """
7
+ from requests.adapters import HTTPAdapter
8
+
9
+ from .._compat import poolmanager
10
+
11
+
12
+ class FingerprintAdapter(HTTPAdapter):
13
+ """
14
+ A HTTPS Adapter for Python Requests that verifies certificate fingerprints,
15
+ instead of certificate hostnames.
16
+
17
+ Example usage:
18
+
19
+ .. code-block:: python
20
+
21
+ import requests
22
+ import ssl
23
+ from requests_toolbelt.adapters.fingerprint import FingerprintAdapter
24
+
25
+ twitter_fingerprint = '...'
26
+ s = requests.Session()
27
+ s.mount(
28
+ 'https://twitter.com',
29
+ FingerprintAdapter(twitter_fingerprint)
30
+ )
31
+
32
+ The fingerprint should be provided as a hexadecimal string, optionally
33
+ containing colons.
34
+ """
35
+
36
+ __attrs__ = HTTPAdapter.__attrs__ + ['fingerprint']
37
+
38
+ def __init__(self, fingerprint, **kwargs):
39
+ self.fingerprint = fingerprint
40
+
41
+ super(FingerprintAdapter, self).__init__(**kwargs)
42
+
43
+ def init_poolmanager(self, connections, maxsize, block=False):
44
+ self.poolmanager = poolmanager.PoolManager(
45
+ num_pools=connections,
46
+ maxsize=maxsize,
47
+ block=block,
48
+ assert_fingerprint=self.fingerprint)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/host_header_ssl.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ requests_toolbelt.adapters.host_header_ssl
4
+ ==========================================
5
+
6
+ This file contains an implementation of the HostHeaderSSLAdapter.
7
+ """
8
+
9
+ from requests.adapters import HTTPAdapter
10
+
11
+
12
+ class HostHeaderSSLAdapter(HTTPAdapter):
13
+ """
14
+ A HTTPS Adapter for Python Requests that sets the hostname for certificate
15
+ verification based on the Host header.
16
+
17
+ This allows requesting the IP address directly via HTTPS without getting
18
+ a "hostname doesn't match" exception.
19
+
20
+ Example usage:
21
+
22
+ >>> s.mount('https://', HostHeaderSSLAdapter())
23
+ >>> s.get("https://93.184.216.34", headers={"Host": "example.org"})
24
+
25
+ """
26
+
27
+ def send(self, request, **kwargs):
28
+ # HTTP headers are case-insensitive (RFC 7230)
29
+ host_header = None
30
+ for header in request.headers:
31
+ if header.lower() == "host":
32
+ host_header = request.headers[header]
33
+ break
34
+
35
+ connection_pool_kwargs = self.poolmanager.connection_pool_kw
36
+
37
+ if host_header:
38
+ connection_pool_kwargs["assert_hostname"] = host_header
39
+ elif "assert_hostname" in connection_pool_kwargs:
40
+ # an assert_hostname from a previous request may have been left
41
+ connection_pool_kwargs.pop("assert_hostname", None)
42
+
43
+ return super(HostHeaderSSLAdapter, self).send(request, **kwargs)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/socket_options.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """The implementation of the SocketOptionsAdapter."""
3
+ import socket
4
+ import warnings
5
+ import sys
6
+
7
+ import requests
8
+ from requests import adapters
9
+
10
+ from .._compat import connection
11
+ from .._compat import poolmanager
12
+ from .. import exceptions as exc
13
+
14
+
15
+ class SocketOptionsAdapter(adapters.HTTPAdapter):
16
+ """An adapter for requests that allows users to specify socket options.
17
+
18
+ Since version 2.4.0 of requests, it is possible to specify a custom list
19
+ of socket options that need to be set before establishing the connection.
20
+
21
+ Example usage::
22
+
23
+ >>> import socket
24
+ >>> import requests
25
+ >>> from requests_toolbelt.adapters import socket_options
26
+ >>> s = requests.Session()
27
+ >>> opts = [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0)]
28
+ >>> adapter = socket_options.SocketOptionsAdapter(socket_options=opts)
29
+ >>> s.mount('http://', adapter)
30
+
31
+ You can also take advantage of the list of default options on this class
32
+ to keep using the original options in addition to your custom options. In
33
+ that case, ``opts`` might look like::
34
+
35
+ >>> opts = socket_options.SocketOptionsAdapter.default_options + opts
36
+
37
+ """
38
+
39
+ if connection is not None:
40
+ default_options = getattr(
41
+ connection.HTTPConnection,
42
+ 'default_socket_options',
43
+ [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]
44
+ )
45
+ else:
46
+ default_options = []
47
+ warnings.warn(exc.RequestsVersionTooOld,
48
+ "This version of Requests is only compatible with a "
49
+ "version of urllib3 which is too old to support "
50
+ "setting options on a socket. This adapter is "
51
+ "functionally useless.")
52
+
53
+ def __init__(self, **kwargs):
54
+ self.socket_options = kwargs.pop('socket_options',
55
+ self.default_options)
56
+
57
+ super(SocketOptionsAdapter, self).__init__(**kwargs)
58
+
59
+ def init_poolmanager(self, connections, maxsize, block=False):
60
+ if requests.__build__ >= 0x020400:
61
+ # NOTE(Ian): Perhaps we should raise a warning
62
+ self.poolmanager = poolmanager.PoolManager(
63
+ num_pools=connections,
64
+ maxsize=maxsize,
65
+ block=block,
66
+ socket_options=self.socket_options
67
+ )
68
+ else:
69
+ super(SocketOptionsAdapter, self).init_poolmanager(
70
+ connections, maxsize, block
71
+ )
72
+
73
+
74
+ class TCPKeepAliveAdapter(SocketOptionsAdapter):
75
+ """An adapter for requests that turns on TCP Keep-Alive by default.
76
+
77
+ The adapter sets 4 socket options:
78
+
79
+ - ``SOL_SOCKET`` ``SO_KEEPALIVE`` - This turns on TCP Keep-Alive
80
+ - ``IPPROTO_TCP`` ``TCP_KEEPINTVL`` 20 - Sets the keep alive interval
81
+ - ``IPPROTO_TCP`` ``TCP_KEEPCNT`` 5 - Sets the number of keep alive probes
82
+ - ``IPPROTO_TCP`` ``TCP_KEEPIDLE`` 60 - Sets the keep alive time if the
83
+ socket library has the ``TCP_KEEPIDLE`` constant
84
+
85
+ The latter three can be overridden by keyword arguments (respectively):
86
+
87
+ - ``interval``
88
+ - ``count``
89
+ - ``idle``
90
+
91
+ You can use this adapter like so::
92
+
93
+ >>> from requests_toolbelt.adapters import socket_options
94
+ >>> tcp = socket_options.TCPKeepAliveAdapter(idle=120, interval=10)
95
+ >>> s = requests.Session()
96
+ >>> s.mount('http://', tcp)
97
+
98
+ """
99
+
100
+ def __init__(self, **kwargs):
101
+ socket_options = kwargs.pop('socket_options',
102
+ SocketOptionsAdapter.default_options)
103
+ idle = kwargs.pop('idle', 60)
104
+ interval = kwargs.pop('interval', 20)
105
+ count = kwargs.pop('count', 5)
106
+ socket_options = socket_options + [
107
+ (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
108
+ ]
109
+
110
+ # NOTE(Ian): OSX does not have these constants defined, so we
111
+ # set them conditionally.
112
+ if getattr(socket, 'TCP_KEEPINTVL', None) is not None:
113
+ socket_options += [(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL,
114
+ interval)]
115
+ elif sys.platform == 'darwin':
116
+ # On OSX, TCP_KEEPALIVE from netinet/tcp.h is not exported
117
+ # by python's socket module
118
+ TCP_KEEPALIVE = getattr(socket, 'TCP_KEEPALIVE', 0x10)
119
+ socket_options += [(socket.IPPROTO_TCP, TCP_KEEPALIVE, interval)]
120
+
121
+ if getattr(socket, 'TCP_KEEPCNT', None) is not None:
122
+ socket_options += [(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, count)]
123
+
124
+ if getattr(socket, 'TCP_KEEPIDLE', None) is not None:
125
+ socket_options += [(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, idle)]
126
+
127
+ super(TCPKeepAliveAdapter, self).__init__(
128
+ socket_options=socket_options, **kwargs
129
+ )
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/source.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ requests_toolbelt.source_adapter
4
+ ================================
5
+
6
+ This file contains an implementation of the SourceAddressAdapter originally
7
+ demonstrated on the Requests GitHub page.
8
+ """
9
+ from requests.adapters import HTTPAdapter
10
+
11
+ from .._compat import poolmanager, basestring
12
+
13
+
14
+ class SourceAddressAdapter(HTTPAdapter):
15
+ """
16
+ A Source Address Adapter for Python Requests that enables you to choose the
17
+ local address to bind to. This allows you to send your HTTP requests from a
18
+ specific interface and IP address.
19
+
20
+ Two address formats are accepted. The first is a string: this will set the
21
+ local IP address to the address given in the string, and will also choose a
22
+ semi-random high port for the local port number.
23
+
24
+ The second is a two-tuple of the form (ip address, port): for example,
25
+ ``('10.10.10.10', 8999)``. This will set the local IP address to the first
26
+ element, and the local port to the second element. If ``0`` is used as the
27
+ port number, a semi-random high port will be selected.
28
+
29
+ .. warning:: Setting an explicit local port can have negative interactions
30
+ with connection-pooling in Requests: in particular, it risks
31
+ the possibility of getting "Address in use" errors. The
32
+ string-only argument is generally preferred to the tuple-form.
33
+
34
+ Example usage:
35
+
36
+ .. code-block:: python
37
+
38
+ import requests
39
+ from requests_toolbelt.adapters.source import SourceAddressAdapter
40
+
41
+ s = requests.Session()
42
+ s.mount('http://', SourceAddressAdapter('10.10.10.10'))
43
+ s.mount('https://', SourceAddressAdapter(('10.10.10.10', 8999)))
44
+ """
45
+ def __init__(self, source_address, **kwargs):
46
+ if isinstance(source_address, basestring):
47
+ self.source_address = (source_address, 0)
48
+ elif isinstance(source_address, tuple):
49
+ self.source_address = source_address
50
+ else:
51
+ raise TypeError(
52
+ "source_address must be IP address string or (ip, port) tuple"
53
+ )
54
+
55
+ super(SourceAddressAdapter, self).__init__(**kwargs)
56
+
57
+ def init_poolmanager(self, connections, maxsize, block=False):
58
+ self.poolmanager = poolmanager.PoolManager(
59
+ num_pools=connections,
60
+ maxsize=maxsize,
61
+ block=block,
62
+ source_address=self.source_address)
63
+
64
+ def proxy_manager_for(self, *args, **kwargs):
65
+ kwargs['source_address'] = self.source_address
66
+ return super(SourceAddressAdapter, self).proxy_manager_for(
67
+ *args, **kwargs)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/ssl.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+
4
+ requests_toolbelt.ssl_adapter
5
+ =============================
6
+
7
+ This file contains an implementation of the SSLAdapter originally demonstrated
8
+ in this blog post:
9
+ https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/
10
+
11
+ """
12
+ import requests
13
+
14
+ from requests.adapters import HTTPAdapter
15
+
16
+ from .._compat import poolmanager
17
+
18
+
19
+ class SSLAdapter(HTTPAdapter):
20
+ """
21
+ A HTTPS Adapter for Python Requests that allows the choice of the SSL/TLS
22
+ version negotiated by Requests. This can be used either to enforce the
23
+ choice of high-security TLS versions (where supported), or to work around
24
+ misbehaving servers that fail to correctly negotiate the default TLS
25
+ version being offered.
26
+
27
+ Example usage:
28
+
29
+ >>> import requests
30
+ >>> import ssl
31
+ >>> from requests_toolbelt import SSLAdapter
32
+ >>> s = requests.Session()
33
+ >>> s.mount('https://', SSLAdapter(ssl.PROTOCOL_TLSv1))
34
+
35
+ You can replace the chosen protocol with any that are available in the
36
+ default Python SSL module. All subsequent requests that match the adapter
37
+ prefix will use the chosen SSL version instead of the default.
38
+
39
+ This adapter will also attempt to change the SSL/TLS version negotiated by
40
+ Requests when using a proxy. However, this may not always be possible:
41
+ prior to Requests v2.4.0 the adapter did not have access to the proxy setup
42
+ code. In earlier versions of Requests, this adapter will not function
43
+ properly when used with proxies.
44
+ """
45
+
46
+ __attrs__ = HTTPAdapter.__attrs__ + ['ssl_version']
47
+
48
+ def __init__(self, ssl_version=None, **kwargs):
49
+ self.ssl_version = ssl_version
50
+
51
+ super(SSLAdapter, self).__init__(**kwargs)
52
+
53
+ def init_poolmanager(self, connections, maxsize, block=False):
54
+ self.poolmanager = poolmanager.PoolManager(
55
+ num_pools=connections,
56
+ maxsize=maxsize,
57
+ block=block,
58
+ ssl_version=self.ssl_version)
59
+
60
+ if requests.__build__ >= 0x020400:
61
+ # Earlier versions of requests either don't have this method or, worse,
62
+ # don't allow passing arbitrary keyword arguments. As a result, only
63
+ # conditionally define this method.
64
+ def proxy_manager_for(self, *args, **kwargs):
65
+ kwargs['ssl_version'] = self.ssl_version
66
+ return super(SSLAdapter, self).proxy_manager_for(*args, **kwargs)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/adapters/x509.py ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """A X509Adapter for use with the requests library.
3
+
4
+ This file contains an implementation of the X509Adapter that will
5
+ allow users to authenticate a request using an arbitrary
6
+ X.509 certificate without needing to convert it to a .pem file
7
+
8
+ """
9
+
10
+ from OpenSSL.crypto import PKey, X509
11
+ from cryptography import x509
12
+ from cryptography.hazmat.primitives.serialization import (load_pem_private_key,
13
+ load_der_private_key)
14
+ from cryptography.hazmat.primitives.serialization import Encoding
15
+ from cryptography.hazmat.backends import default_backend
16
+
17
+ from datetime import datetime
18
+ from requests.adapters import HTTPAdapter
19
+ import requests
20
+
21
+ from .. import exceptions as exc
22
+
23
+ """
24
+ importing the protocol constants from _ssl instead of ssl because only the
25
+ constants are needed and to handle issues caused by importing from ssl on
26
+ the 2.7.x line.
27
+ """
28
+ try:
29
+ from _ssl import PROTOCOL_TLS as PROTOCOL
30
+ except ImportError:
31
+ from _ssl import PROTOCOL_SSLv23 as PROTOCOL
32
+
33
+
34
+ PyOpenSSLContext = None
35
+
36
+
37
+ class X509Adapter(HTTPAdapter):
38
+ r"""Adapter for use with X.509 certificates.
39
+
40
+ Provides an interface for Requests sessions to contact HTTPS urls and
41
+ authenticate with an X.509 cert by implementing the Transport Adapter
42
+ interface. This class will need to be manually instantiated and mounted
43
+ to the session
44
+
45
+ :param pool_connections: The number of urllib3 connection pools to
46
+ cache.
47
+ :param pool_maxsize: The maximum number of connections to save in the
48
+ pool.
49
+ :param max_retries: The maximum number of retries each connection
50
+ should attempt. Note, this applies only to failed DNS lookups,
51
+ socket connections and connection timeouts, never to requests where
52
+ data has made it to the server. By default, Requests does not retry
53
+ failed connections. If you need granular control over the
54
+ conditions under which we retry a request, import urllib3's
55
+ ``Retry`` class and pass that instead.
56
+ :param pool_block: Whether the connection pool should block for
57
+ connections.
58
+
59
+ :param bytes cert_bytes:
60
+ bytes object containing contents of a cryptography.x509Certificate
61
+ object using the encoding specified by the ``encoding`` parameter.
62
+ :param bytes pk_bytes:
63
+ bytes object containing contents of a object that implements
64
+ ``cryptography.hazmat.primitives.serialization.PrivateFormat``
65
+ using the encoding specified by the ``encoding`` parameter.
66
+ :param password:
67
+ string or utf8 encoded bytes containing the passphrase used for the
68
+ private key. None if unencrypted. Defaults to None.
69
+ :param encoding:
70
+ Enumeration detailing the encoding method used on the ``cert_bytes``
71
+ parameter. Can be either PEM or DER. Defaults to PEM.
72
+ :type encoding:
73
+ :class: `cryptography.hazmat.primitives.serialization.Encoding`
74
+
75
+ Usage::
76
+
77
+ >>> import requests
78
+ >>> from requests_toolbelt.adapters.x509 import X509Adapter
79
+ >>> s = requests.Session()
80
+ >>> a = X509Adapter(max_retries=3,
81
+ cert_bytes=b'...', pk_bytes=b'...', encoding='...'
82
+ >>> s.mount('https://', a)
83
+ """
84
+
85
+ def __init__(self, *args, **kwargs):
86
+ self._import_pyopensslcontext()
87
+ self._check_version()
88
+ cert_bytes = kwargs.pop('cert_bytes', None)
89
+ pk_bytes = kwargs.pop('pk_bytes', None)
90
+ password = kwargs.pop('password', None)
91
+ encoding = kwargs.pop('encoding', Encoding.PEM)
92
+
93
+ password_bytes = None
94
+
95
+ if cert_bytes is None or not isinstance(cert_bytes, bytes):
96
+ raise ValueError('Invalid cert content provided. '
97
+ 'You must provide an X.509 cert '
98
+ 'formatted as a byte array.')
99
+ if pk_bytes is None or not isinstance(pk_bytes, bytes):
100
+ raise ValueError('Invalid private key content provided. '
101
+ 'You must provide a private key '
102
+ 'formatted as a byte array.')
103
+
104
+ if isinstance(password, bytes):
105
+ password_bytes = password
106
+ elif password:
107
+ password_bytes = password.encode('utf8')
108
+
109
+ self.ssl_context = create_ssl_context(cert_bytes, pk_bytes,
110
+ password_bytes, encoding)
111
+
112
+ super(X509Adapter, self).__init__(*args, **kwargs)
113
+
114
+ def init_poolmanager(self, *args, **kwargs):
115
+ if self.ssl_context:
116
+ kwargs['ssl_context'] = self.ssl_context
117
+ return super(X509Adapter, self).init_poolmanager(*args, **kwargs)
118
+
119
+ def proxy_manager_for(self, *args, **kwargs):
120
+ if self.ssl_context:
121
+ kwargs['ssl_context'] = self.ssl_context
122
+ return super(X509Adapter, self).proxy_manager_for(*args, **kwargs)
123
+
124
+ def _import_pyopensslcontext(self):
125
+ global PyOpenSSLContext
126
+
127
+ if requests.__build__ < 0x021200:
128
+ PyOpenSSLContext = None
129
+ else:
130
+ try:
131
+ from requests.packages.urllib3.contrib.pyopenssl \
132
+ import PyOpenSSLContext
133
+ except ImportError:
134
+ try:
135
+ from urllib3.contrib.pyopenssl import PyOpenSSLContext
136
+ except ImportError:
137
+ PyOpenSSLContext = None
138
+
139
+ def _check_version(self):
140
+ if PyOpenSSLContext is None:
141
+ raise exc.VersionMismatchError(
142
+ "The X509Adapter requires at least Requests 2.12.0 to be "
143
+ "installed. Version {} was found instead.".format(
144
+ requests.__version__
145
+ )
146
+ )
147
+
148
+
149
+ def check_cert_dates(cert):
150
+ """Verify that the supplied client cert is not invalid."""
151
+
152
+ now = datetime.utcnow()
153
+ if cert.not_valid_after < now or cert.not_valid_before > now:
154
+ raise ValueError('Client certificate expired: Not After: '
155
+ '{:%Y-%m-%d %H:%M:%SZ} '
156
+ 'Not Before: {:%Y-%m-%d %H:%M:%SZ}'
157
+ .format(cert.not_valid_after, cert.not_valid_before))
158
+
159
+
160
+ def create_ssl_context(cert_byes, pk_bytes, password=None,
161
+ encoding=Encoding.PEM):
162
+ """Create an SSL Context with the supplied cert/password.
163
+
164
+ :param cert_bytes array of bytes containing the cert encoded
165
+ using the method supplied in the ``encoding`` parameter
166
+ :param pk_bytes array of bytes containing the private key encoded
167
+ using the method supplied in the ``encoding`` parameter
168
+ :param password array of bytes containing the passphrase to be used
169
+ with the supplied private key. None if unencrypted.
170
+ Defaults to None.
171
+ :param encoding ``cryptography.hazmat.primitives.serialization.Encoding``
172
+ details the encoding method used on the ``cert_bytes`` and
173
+ ``pk_bytes`` parameters. Can be either PEM or DER.
174
+ Defaults to PEM.
175
+ """
176
+ backend = default_backend()
177
+
178
+ cert = None
179
+ key = None
180
+ if encoding == Encoding.PEM:
181
+ cert = x509.load_pem_x509_certificate(cert_byes, backend)
182
+ key = load_pem_private_key(pk_bytes, password, backend)
183
+ elif encoding == Encoding.DER:
184
+ cert = x509.load_der_x509_certificate(cert_byes, backend)
185
+ key = load_der_private_key(pk_bytes, password, backend)
186
+ else:
187
+ raise ValueError('Invalid encoding provided: Must be PEM or DER')
188
+
189
+ if not (cert and key):
190
+ raise ValueError('Cert and key could not be parsed from '
191
+ 'provided data')
192
+ check_cert_dates(cert)
193
+ ssl_context = PyOpenSSLContext(PROTOCOL)
194
+ ssl_context._ctx.use_certificate(X509.from_cryptography(cert))
195
+ ssl_context._ctx.use_privatekey(PKey.from_cryptography_key(key))
196
+ return ssl_context
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/__init__.py ADDED
File without changes
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/_digest_auth_compat.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Provide a compatibility layer for requests.auth.HTTPDigestAuth."""
2
+ import requests
3
+
4
+
5
+ class _ThreadingDescriptor(object):
6
+ def __init__(self, prop, default):
7
+ self.prop = prop
8
+ self.default = default
9
+
10
+ def __get__(self, obj, objtype=None):
11
+ return getattr(obj._thread_local, self.prop, self.default)
12
+
13
+ def __set__(self, obj, value):
14
+ setattr(obj._thread_local, self.prop, value)
15
+
16
+
17
+ class _HTTPDigestAuth(requests.auth.HTTPDigestAuth):
18
+ init = _ThreadingDescriptor('init', True)
19
+ last_nonce = _ThreadingDescriptor('last_nonce', '')
20
+ nonce_count = _ThreadingDescriptor('nonce_count', 0)
21
+ chal = _ThreadingDescriptor('chal', {})
22
+ pos = _ThreadingDescriptor('pos', None)
23
+ num_401_calls = _ThreadingDescriptor('num_401_calls', 1)
24
+
25
+
26
+ if requests.__build__ < 0x020800:
27
+ HTTPDigestAuth = requests.auth.HTTPDigestAuth
28
+ else:
29
+ HTTPDigestAuth = _HTTPDigestAuth
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/guess.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """The module containing the code for GuessAuth."""
3
+ from requests import auth
4
+ from requests import cookies
5
+
6
+ from . import _digest_auth_compat as auth_compat, http_proxy_digest
7
+
8
+
9
+ class GuessAuth(auth.AuthBase):
10
+ """Guesses the auth type by the WWW-Authentication header."""
11
+ def __init__(self, username, password):
12
+ self.username = username
13
+ self.password = password
14
+ self.auth = None
15
+ self.pos = None
16
+
17
+ def _handle_basic_auth_401(self, r, kwargs):
18
+ if self.pos is not None:
19
+ r.request.body.seek(self.pos)
20
+
21
+ # Consume content and release the original connection
22
+ # to allow our new request to reuse the same one.
23
+ r.content
24
+ r.raw.release_conn()
25
+ prep = r.request.copy()
26
+ if not hasattr(prep, '_cookies'):
27
+ prep._cookies = cookies.RequestsCookieJar()
28
+ cookies.extract_cookies_to_jar(prep._cookies, r.request, r.raw)
29
+ prep.prepare_cookies(prep._cookies)
30
+
31
+ self.auth = auth.HTTPBasicAuth(self.username, self.password)
32
+ prep = self.auth(prep)
33
+ _r = r.connection.send(prep, **kwargs)
34
+ _r.history.append(r)
35
+ _r.request = prep
36
+
37
+ return _r
38
+
39
+ def _handle_digest_auth_401(self, r, kwargs):
40
+ self.auth = auth_compat.HTTPDigestAuth(self.username, self.password)
41
+ try:
42
+ self.auth.init_per_thread_state()
43
+ except AttributeError:
44
+ # If we're not on requests 2.8.0+ this method does not exist and
45
+ # is not relevant.
46
+ pass
47
+
48
+ # Check that the attr exists because much older versions of requests
49
+ # set this attribute lazily. For example:
50
+ # https://github.com/kennethreitz/requests/blob/33735480f77891754304e7f13e3cdf83aaaa76aa/requests/auth.py#L59
51
+ if (hasattr(self.auth, 'num_401_calls') and
52
+ self.auth.num_401_calls is None):
53
+ self.auth.num_401_calls = 1
54
+ # Digest auth would resend the request by itself. We can take a
55
+ # shortcut here.
56
+ return self.auth.handle_401(r, **kwargs)
57
+
58
+ def handle_401(self, r, **kwargs):
59
+ """Resends a request with auth headers, if needed."""
60
+
61
+ www_authenticate = r.headers.get('www-authenticate', '').lower()
62
+
63
+ if 'basic' in www_authenticate:
64
+ return self._handle_basic_auth_401(r, kwargs)
65
+
66
+ if 'digest' in www_authenticate:
67
+ return self._handle_digest_auth_401(r, kwargs)
68
+
69
+ def __call__(self, request):
70
+ if self.auth is not None:
71
+ return self.auth(request)
72
+
73
+ try:
74
+ self.pos = request.body.tell()
75
+ except AttributeError:
76
+ pass
77
+
78
+ request.register_hook('response', self.handle_401)
79
+ return request
80
+
81
+
82
+ class GuessProxyAuth(GuessAuth):
83
+ """
84
+ Guesses the auth type by WWW-Authentication and Proxy-Authentication
85
+ headers
86
+ """
87
+ def __init__(self, username=None, password=None,
88
+ proxy_username=None, proxy_password=None):
89
+ super(GuessProxyAuth, self).__init__(username, password)
90
+ self.proxy_username = proxy_username
91
+ self.proxy_password = proxy_password
92
+ self.proxy_auth = None
93
+
94
+ def _handle_basic_auth_407(self, r, kwargs):
95
+ if self.pos is not None:
96
+ r.request.body.seek(self.pos)
97
+
98
+ r.content
99
+ r.raw.release_conn()
100
+ prep = r.request.copy()
101
+ if not hasattr(prep, '_cookies'):
102
+ prep._cookies = cookies.RequestsCookieJar()
103
+ cookies.extract_cookies_to_jar(prep._cookies, r.request, r.raw)
104
+ prep.prepare_cookies(prep._cookies)
105
+
106
+ self.proxy_auth = auth.HTTPProxyAuth(self.proxy_username,
107
+ self.proxy_password)
108
+ prep = self.proxy_auth(prep)
109
+ _r = r.connection.send(prep, **kwargs)
110
+ _r.history.append(r)
111
+ _r.request = prep
112
+
113
+ return _r
114
+
115
+ def _handle_digest_auth_407(self, r, kwargs):
116
+ self.proxy_auth = http_proxy_digest.HTTPProxyDigestAuth(
117
+ username=self.proxy_username,
118
+ password=self.proxy_password)
119
+
120
+ try:
121
+ self.auth.init_per_thread_state()
122
+ except AttributeError:
123
+ pass
124
+
125
+ return self.proxy_auth.handle_407(r, **kwargs)
126
+
127
+ def handle_407(self, r, **kwargs):
128
+ proxy_authenticate = r.headers.get('Proxy-Authenticate', '').lower()
129
+
130
+ if 'basic' in proxy_authenticate:
131
+ return self._handle_basic_auth_407(r, kwargs)
132
+
133
+ if 'digest' in proxy_authenticate:
134
+ return self._handle_digest_auth_407(r, kwargs)
135
+
136
+ def __call__(self, request):
137
+ if self.proxy_auth is not None:
138
+ request = self.proxy_auth(request)
139
+
140
+ try:
141
+ self.pos = request.body.tell()
142
+ except AttributeError:
143
+ pass
144
+
145
+ request.register_hook('response', self.handle_407)
146
+ return super(GuessProxyAuth, self).__call__(request)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/handler.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+
4
+ requests_toolbelt.auth.handler
5
+ ==============================
6
+
7
+ This holds all of the implementation details of the Authentication Handler.
8
+
9
+ """
10
+
11
+ from requests.auth import AuthBase, HTTPBasicAuth
12
+ from requests.compat import urlparse, urlunparse
13
+
14
+
15
+ class AuthHandler(AuthBase):
16
+
17
+ """
18
+
19
+ The ``AuthHandler`` object takes a dictionary of domains paired with
20
+ authentication strategies and will use this to determine which credentials
21
+ to use when making a request. For example, you could do the following:
22
+
23
+ .. code-block:: python
24
+
25
+ from requests import HTTPDigestAuth
26
+ from requests_toolbelt.auth.handler import AuthHandler
27
+
28
+ import requests
29
+
30
+ auth = AuthHandler({
31
+ 'https://api.github.com': ('sigmavirus24', 'fakepassword'),
32
+ 'https://example.com': HTTPDigestAuth('username', 'password')
33
+ })
34
+
35
+ r = requests.get('https://api.github.com/user', auth=auth)
36
+ # => <Response [200]>
37
+ r = requests.get('https://example.com/some/path', auth=auth)
38
+ # => <Response [200]>
39
+
40
+ s = requests.Session()
41
+ s.auth = auth
42
+ r = s.get('https://api.github.com/user')
43
+ # => <Response [200]>
44
+
45
+ .. warning::
46
+
47
+ :class:`requests.auth.HTTPDigestAuth` is not yet thread-safe. If you
48
+ use :class:`AuthHandler` across multiple threads you should
49
+ instantiate a new AuthHandler for each thread with a new
50
+ HTTPDigestAuth instance for each thread.
51
+
52
+ """
53
+
54
+ def __init__(self, strategies):
55
+ self.strategies = dict(strategies)
56
+ self._make_uniform()
57
+
58
+ def __call__(self, request):
59
+ auth = self.get_strategy_for(request.url)
60
+ return auth(request)
61
+
62
+ def __repr__(self):
63
+ return '<AuthHandler({!r})>'.format(self.strategies)
64
+
65
+ def _make_uniform(self):
66
+ existing_strategies = list(self.strategies.items())
67
+ self.strategies = {}
68
+
69
+ for (k, v) in existing_strategies:
70
+ self.add_strategy(k, v)
71
+
72
+ @staticmethod
73
+ def _key_from_url(url):
74
+ parsed = urlparse(url)
75
+ return urlunparse((parsed.scheme.lower(),
76
+ parsed.netloc.lower(),
77
+ '', '', '', ''))
78
+
79
+ def add_strategy(self, domain, strategy):
80
+ """Add a new domain and authentication strategy.
81
+
82
+ :param str domain: The domain you wish to match against. For example:
83
+ ``'https://api.github.com'``
84
+ :param str strategy: The authentication strategy you wish to use for
85
+ that domain. For example: ``('username', 'password')`` or
86
+ ``requests.HTTPDigestAuth('username', 'password')``
87
+
88
+ .. code-block:: python
89
+
90
+ a = AuthHandler({})
91
+ a.add_strategy('https://api.github.com', ('username', 'password'))
92
+
93
+ """
94
+ # Turn tuples into Basic Authentication objects
95
+ if isinstance(strategy, tuple):
96
+ strategy = HTTPBasicAuth(*strategy)
97
+
98
+ key = self._key_from_url(domain)
99
+ self.strategies[key] = strategy
100
+
101
+ def get_strategy_for(self, url):
102
+ """Retrieve the authentication strategy for a specified URL.
103
+
104
+ :param str url: The full URL you will be making a request against. For
105
+ example, ``'https://api.github.com/user'``
106
+ :returns: Callable that adds authentication to a request.
107
+
108
+ .. code-block:: python
109
+
110
+ import requests
111
+ a = AuthHandler({'example.com', ('foo', 'bar')})
112
+ strategy = a.get_strategy_for('http://example.com/example')
113
+ assert isinstance(strategy, requests.auth.HTTPBasicAuth)
114
+
115
+ """
116
+ key = self._key_from_url(url)
117
+ return self.strategies.get(key, NullAuthStrategy())
118
+
119
+ def remove_strategy(self, domain):
120
+ """Remove the domain and strategy from the collection of strategies.
121
+
122
+ :param str domain: The domain you wish remove. For example,
123
+ ``'https://api.github.com'``.
124
+
125
+ .. code-block:: python
126
+
127
+ a = AuthHandler({'example.com', ('foo', 'bar')})
128
+ a.remove_strategy('example.com')
129
+ assert a.strategies == {}
130
+
131
+ """
132
+ key = self._key_from_url(domain)
133
+ if key in self.strategies:
134
+ del self.strategies[key]
135
+
136
+
137
+ class NullAuthStrategy(AuthBase):
138
+ def __repr__(self):
139
+ return '<NullAuthStrategy>'
140
+
141
+ def __call__(self, r):
142
+ return r
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/auth/http_proxy_digest.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """The module containing HTTPProxyDigestAuth."""
3
+ import re
4
+
5
+ from requests import cookies, utils
6
+
7
+ from . import _digest_auth_compat as auth
8
+
9
+
10
+ class HTTPProxyDigestAuth(auth.HTTPDigestAuth):
11
+ """HTTP digest authentication between proxy
12
+
13
+ :param stale_rejects: The number of rejects indicate that:
14
+ the client may wish to simply retry the request
15
+ with a new encrypted response, without reprompting the user for a
16
+ new username and password. i.e., retry build_digest_header
17
+ :type stale_rejects: int
18
+ """
19
+ _pat = re.compile(r'digest ', flags=re.IGNORECASE)
20
+
21
+ def __init__(self, *args, **kwargs):
22
+ super(HTTPProxyDigestAuth, self).__init__(*args, **kwargs)
23
+ self.stale_rejects = 0
24
+
25
+ self.init_per_thread_state()
26
+
27
+ @property
28
+ def stale_rejects(self):
29
+ thread_local = getattr(self, '_thread_local', None)
30
+ if thread_local is None:
31
+ return self._stale_rejects
32
+ return thread_local.stale_rejects
33
+
34
+ @stale_rejects.setter
35
+ def stale_rejects(self, value):
36
+ thread_local = getattr(self, '_thread_local', None)
37
+ if thread_local is None:
38
+ self._stale_rejects = value
39
+ else:
40
+ thread_local.stale_rejects = value
41
+
42
+ def init_per_thread_state(self):
43
+ try:
44
+ super(HTTPProxyDigestAuth, self).init_per_thread_state()
45
+ except AttributeError:
46
+ # If we're not on requests 2.8.0+ this method does not exist
47
+ pass
48
+
49
+ def handle_407(self, r, **kwargs):
50
+ """Handle HTTP 407 only once, otherwise give up
51
+
52
+ :param r: current response
53
+ :returns: responses, along with the new response
54
+ """
55
+ if r.status_code == 407 and self.stale_rejects < 2:
56
+ s_auth = r.headers.get("proxy-authenticate")
57
+ if s_auth is None:
58
+ raise IOError(
59
+ "proxy server violated RFC 7235:"
60
+ "407 response MUST contain header proxy-authenticate")
61
+ elif not self._pat.match(s_auth):
62
+ return r
63
+
64
+ self.chal = utils.parse_dict_header(
65
+ self._pat.sub('', s_auth, count=1))
66
+
67
+ # if we present the user/passwd and still get rejected
68
+ # https://tools.ietf.org/html/rfc2617#section-3.2.1
69
+ if ('Proxy-Authorization' in r.request.headers and
70
+ 'stale' in self.chal):
71
+ if self.chal['stale'].lower() == 'true': # try again
72
+ self.stale_rejects += 1
73
+ # wrong user/passwd
74
+ elif self.chal['stale'].lower() == 'false':
75
+ raise IOError("User or password is invalid")
76
+
77
+ # Consume content and release the original connection
78
+ # to allow our new request to reuse the same one.
79
+ r.content
80
+ r.close()
81
+ prep = r.request.copy()
82
+ cookies.extract_cookies_to_jar(prep._cookies, r.request, r.raw)
83
+ prep.prepare_cookies(prep._cookies)
84
+
85
+ prep.headers['Proxy-Authorization'] = self.build_digest_header(
86
+ prep.method, prep.url)
87
+ _r = r.connection.send(prep, **kwargs)
88
+ _r.history.append(r)
89
+ _r.request = prep
90
+
91
+ return _r
92
+ else: # give up authenticate
93
+ return r
94
+
95
+ def __call__(self, r):
96
+ self.init_per_thread_state()
97
+ # if we have nonce, then just use it, otherwise server will tell us
98
+ if self.last_nonce:
99
+ r.headers['Proxy-Authorization'] = self.build_digest_header(
100
+ r.method, r.url
101
+ )
102
+ r.register_hook('response', self.handle_407)
103
+ return r
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/cookies/__init__.py ADDED
File without changes
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/cookies/forgetful.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """The module containing the code for ForgetfulCookieJar."""
2
+ from requests.cookies import RequestsCookieJar
3
+
4
+
5
+ class ForgetfulCookieJar(RequestsCookieJar):
6
+ def set_cookie(self, *args, **kwargs):
7
+ return
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/downloadutils/__init__.py ADDED
File without changes
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/downloadutils/stream.py ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Utilities for dealing with streamed requests."""
3
+ import os.path
4
+ import re
5
+
6
+ from .. import exceptions as exc
7
+
8
+ # Regular expressions stolen from werkzeug/http.py
9
+ # cd2c97bb0a076da2322f11adce0b2731f9193396 L62-L64
10
+ _QUOTED_STRING_RE = r'"[^"\\]*(?:\\.[^"\\]*)*"'
11
+ _OPTION_HEADER_PIECE_RE = re.compile(
12
+ r';\s*(%s|[^\s;=]+)\s*(?:=\s*(%s|[^;]+))?\s*' % (_QUOTED_STRING_RE,
13
+ _QUOTED_STRING_RE)
14
+ )
15
+ _DEFAULT_CHUNKSIZE = 512
16
+
17
+
18
+ def _get_filename(content_disposition):
19
+ for match in _OPTION_HEADER_PIECE_RE.finditer(content_disposition):
20
+ k, v = match.groups()
21
+ if k == 'filename':
22
+ # ignore any directory paths in the filename
23
+ return os.path.split(v)[1]
24
+ return None
25
+
26
+
27
+ def get_download_file_path(response, path):
28
+ """
29
+ Given a response and a path, return a file path for a download.
30
+
31
+ If a ``path`` parameter is a directory, this function will parse the
32
+ ``Content-Disposition`` header on the response to determine the name of the
33
+ file as reported by the server, and return a file path in the specified
34
+ directory.
35
+
36
+ If ``path`` is empty or None, this function will return a path relative
37
+ to the process' current working directory.
38
+
39
+ If path is a full file path, return it.
40
+
41
+ :param response: A Response object from requests
42
+ :type response: requests.models.Response
43
+ :param str path: Directory or file path.
44
+ :returns: full file path to download as
45
+ :rtype: str
46
+ :raises: :class:`requests_toolbelt.exceptions.StreamingError`
47
+ """
48
+ path_is_dir = path and os.path.isdir(path)
49
+
50
+ if path and not path_is_dir:
51
+ # fully qualified file path
52
+ filepath = path
53
+ else:
54
+ response_filename = _get_filename(
55
+ response.headers.get('content-disposition', '')
56
+ )
57
+ if not response_filename:
58
+ raise exc.StreamingError('No filename given to stream response to')
59
+
60
+ if path_is_dir:
61
+ # directory to download to
62
+ filepath = os.path.join(path, response_filename)
63
+ else:
64
+ # fallback to downloading to current working directory
65
+ filepath = response_filename
66
+
67
+ return filepath
68
+
69
+
70
+ def stream_response_to_file(response, path=None, chunksize=_DEFAULT_CHUNKSIZE):
71
+ """Stream a response body to the specified file.
72
+
73
+ Either use the ``path`` provided or use the name provided in the
74
+ ``Content-Disposition`` header.
75
+
76
+ .. warning::
77
+
78
+ If you pass this function an open file-like object as the ``path``
79
+ parameter, the function will not close that file for you.
80
+
81
+ .. warning::
82
+
83
+ This function will not automatically close the response object
84
+ passed in as the ``response`` parameter.
85
+
86
+ If a ``path`` parameter is a directory, this function will parse the
87
+ ``Content-Disposition`` header on the response to determine the name of the
88
+ file as reported by the server, and return a file path in the specified
89
+ directory. If no ``path`` parameter is supplied, this function will default
90
+ to the process' current working directory.
91
+
92
+ .. code-block:: python
93
+
94
+ import requests
95
+ from requests_toolbelt import exceptions
96
+ from requests_toolbelt.downloadutils import stream
97
+
98
+ r = requests.get(url, stream=True)
99
+ try:
100
+ filename = stream.stream_response_to_file(r)
101
+ except exceptions.StreamingError as e:
102
+ # The toolbelt could not find the filename in the
103
+ # Content-Disposition
104
+ print(e.message)
105
+
106
+ You can also specify the filename as a string. This will be passed to
107
+ the built-in :func:`open` and we will read the content into the file.
108
+
109
+ .. code-block:: python
110
+
111
+ import requests
112
+ from requests_toolbelt.downloadutils import stream
113
+
114
+ r = requests.get(url, stream=True)
115
+ filename = stream.stream_response_to_file(r, path='myfile')
116
+
117
+ If the calculated download file path already exists, this function will
118
+ raise a StreamingError.
119
+
120
+ Instead, if you want to manage the file object yourself, you need to
121
+ provide either a :class:`io.BytesIO` object or a file opened with the
122
+ `'b'` flag. See the two examples below for more details.
123
+
124
+ .. code-block:: python
125
+
126
+ import requests
127
+ from requests_toolbelt.downloadutils import stream
128
+
129
+ with open('myfile', 'wb') as fd:
130
+ r = requests.get(url, stream=True)
131
+ filename = stream.stream_response_to_file(r, path=fd)
132
+
133
+ print('{} saved to {}'.format(url, filename))
134
+
135
+ .. code-block:: python
136
+
137
+ import io
138
+ import requests
139
+ from requests_toolbelt.downloadutils import stream
140
+
141
+ b = io.BytesIO()
142
+ r = requests.get(url, stream=True)
143
+ filename = stream.stream_response_to_file(r, path=b)
144
+ assert filename is None
145
+
146
+ :param response: A Response object from requests
147
+ :type response: requests.models.Response
148
+ :param path: *(optional)*, Either a string with the path to the location
149
+ to save the response content, or a file-like object expecting bytes.
150
+ :type path: :class:`str`, or object with a :meth:`write`
151
+ :param int chunksize: (optional), Size of chunk to attempt to stream
152
+ (default 512B).
153
+ :returns: The name of the file, if one can be determined, else None
154
+ :rtype: str
155
+ :raises: :class:`requests_toolbelt.exceptions.StreamingError`
156
+ """
157
+ pre_opened = False
158
+ fd = None
159
+ filename = None
160
+ if path and callable(getattr(path, 'write', None)):
161
+ pre_opened = True
162
+ fd = path
163
+ filename = getattr(fd, 'name', None)
164
+ else:
165
+ filename = get_download_file_path(response, path)
166
+ if os.path.exists(filename):
167
+ raise exc.StreamingError("File already exists: %s" % filename)
168
+ fd = open(filename, 'wb')
169
+
170
+ for chunk in response.iter_content(chunk_size=chunksize):
171
+ fd.write(chunk)
172
+
173
+ if not pre_opened:
174
+ fd.close()
175
+
176
+ return filename
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/downloadutils/tee.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tee function implementations."""
2
+ import io
3
+
4
+ _DEFAULT_CHUNKSIZE = 65536
5
+
6
+ __all__ = ['tee', 'tee_to_file', 'tee_to_bytearray']
7
+
8
+
9
+ def _tee(response, callback, chunksize, decode_content):
10
+ for chunk in response.raw.stream(amt=chunksize,
11
+ decode_content=decode_content):
12
+ callback(chunk)
13
+ yield chunk
14
+
15
+
16
+ def tee(response, fileobject, chunksize=_DEFAULT_CHUNKSIZE,
17
+ decode_content=None):
18
+ """Stream the response both to the generator and a file.
19
+
20
+ This will stream the response body while writing the bytes to
21
+ ``fileobject``.
22
+
23
+ Example usage:
24
+
25
+ .. code-block:: python
26
+
27
+ resp = requests.get(url, stream=True)
28
+ with open('save_file', 'wb') as save_file:
29
+ for chunk in tee(resp, save_file):
30
+ # do stuff with chunk
31
+
32
+ .. code-block:: python
33
+
34
+ import io
35
+
36
+ resp = requests.get(url, stream=True)
37
+ fileobject = io.BytesIO()
38
+
39
+ for chunk in tee(resp, fileobject):
40
+ # do stuff with chunk
41
+
42
+ :param response: Response from requests.
43
+ :type response: requests.Response
44
+ :param fileobject: Writable file-like object.
45
+ :type fileobject: file, io.BytesIO
46
+ :param int chunksize: (optional), Size of chunk to attempt to stream.
47
+ :param bool decode_content: (optional), If True, this will decode the
48
+ compressed content of the response.
49
+ :raises: TypeError if the fileobject wasn't opened with the right mode
50
+ or isn't a BytesIO object.
51
+ """
52
+ # We will be streaming the raw bytes from over the wire, so we need to
53
+ # ensure that writing to the fileobject will preserve those bytes. On
54
+ # Python3, if the user passes an io.StringIO, this will fail, so we need
55
+ # to check for BytesIO instead.
56
+ if not ('b' in getattr(fileobject, 'mode', '') or
57
+ isinstance(fileobject, io.BytesIO)):
58
+ raise TypeError('tee() will write bytes directly to this fileobject'
59
+ ', it must be opened with the "b" flag if it is a file'
60
+ ' or inherit from io.BytesIO.')
61
+
62
+ return _tee(response, fileobject.write, chunksize, decode_content)
63
+
64
+
65
+ def tee_to_file(response, filename, chunksize=_DEFAULT_CHUNKSIZE,
66
+ decode_content=None):
67
+ """Stream the response both to the generator and a file.
68
+
69
+ This will open a file named ``filename`` and stream the response body
70
+ while writing the bytes to the opened file object.
71
+
72
+ Example usage:
73
+
74
+ .. code-block:: python
75
+
76
+ resp = requests.get(url, stream=True)
77
+ for chunk in tee_to_file(resp, 'save_file'):
78
+ # do stuff with chunk
79
+
80
+ :param response: Response from requests.
81
+ :type response: requests.Response
82
+ :param str filename: Name of file in which we write the response content.
83
+ :param int chunksize: (optional), Size of chunk to attempt to stream.
84
+ :param bool decode_content: (optional), If True, this will decode the
85
+ compressed content of the response.
86
+ """
87
+ with open(filename, 'wb') as fd:
88
+ for chunk in tee(response, fd, chunksize, decode_content):
89
+ yield chunk
90
+
91
+
92
+ def tee_to_bytearray(response, bytearr, chunksize=_DEFAULT_CHUNKSIZE,
93
+ decode_content=None):
94
+ """Stream the response both to the generator and a bytearray.
95
+
96
+ This will stream the response provided to the function, add them to the
97
+ provided :class:`bytearray` and yield them to the user.
98
+
99
+ .. note::
100
+
101
+ This uses the :meth:`bytearray.extend` by default instead of passing
102
+ the bytearray into the ``readinto`` method.
103
+
104
+ Example usage:
105
+
106
+ .. code-block:: python
107
+
108
+ b = bytearray()
109
+ resp = requests.get(url, stream=True)
110
+ for chunk in tee_to_bytearray(resp, b):
111
+ # do stuff with chunk
112
+
113
+ :param response: Response from requests.
114
+ :type response: requests.Response
115
+ :param bytearray bytearr: Array to add the streamed bytes to.
116
+ :param int chunksize: (optional), Size of chunk to attempt to stream.
117
+ :param bool decode_content: (optional), If True, this will decode the
118
+ compressed content of the response.
119
+ """
120
+ if not isinstance(bytearr, bytearray):
121
+ raise TypeError('tee_to_bytearray() expects bytearr to be a '
122
+ 'bytearray')
123
+ return _tee(response, bytearr.extend, chunksize, decode_content)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/multipart/__init__.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ requests_toolbelt.multipart
3
+ ===========================
4
+
5
+ See https://toolbelt.readthedocs.io/ for documentation
6
+
7
+ :copyright: (c) 2014 by Ian Cordasco and Cory Benfield
8
+ :license: Apache v2.0, see LICENSE for more details
9
+ """
10
+
11
+ from .encoder import MultipartEncoder, MultipartEncoderMonitor
12
+ from .decoder import MultipartDecoder
13
+ from .decoder import ImproperBodyPartContentException
14
+ from .decoder import NonMultipartContentTypeException
15
+
16
+ __title__ = 'requests-toolbelt'
17
+ __authors__ = 'Ian Cordasco, Cory Benfield'
18
+ __license__ = 'Apache v2.0'
19
+ __copyright__ = 'Copyright 2014 Ian Cordasco, Cory Benfield'
20
+
21
+ __all__ = [
22
+ 'MultipartEncoder',
23
+ 'MultipartEncoderMonitor',
24
+ 'MultipartDecoder',
25
+ 'ImproperBodyPartContentException',
26
+ 'NonMultipartContentTypeException',
27
+ '__title__',
28
+ '__authors__',
29
+ '__license__',
30
+ '__copyright__',
31
+ ]
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/multipart/decoder.py ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+
4
+ requests_toolbelt.multipart.decoder
5
+ ===================================
6
+
7
+ This holds all the implementation details of the MultipartDecoder
8
+
9
+ """
10
+
11
+ import sys
12
+ import email.parser
13
+ from .encoder import encode_with
14
+ from requests.structures import CaseInsensitiveDict
15
+
16
+
17
+ def _split_on_find(content, bound):
18
+ point = content.find(bound)
19
+ return content[:point], content[point + len(bound):]
20
+
21
+
22
+ class ImproperBodyPartContentException(Exception):
23
+ pass
24
+
25
+
26
+ class NonMultipartContentTypeException(Exception):
27
+ pass
28
+
29
+
30
+ def _header_parser(string, encoding):
31
+ major = sys.version_info[0]
32
+ if major == 3:
33
+ string = string.decode(encoding)
34
+ headers = email.parser.HeaderParser().parsestr(string).items()
35
+ return (
36
+ (encode_with(k, encoding), encode_with(v, encoding))
37
+ for k, v in headers
38
+ )
39
+
40
+
41
+ class BodyPart(object):
42
+ """
43
+
44
+ The ``BodyPart`` object is a ``Response``-like interface to an individual
45
+ subpart of a multipart response. It is expected that these will
46
+ generally be created by objects of the ``MultipartDecoder`` class.
47
+
48
+ Like ``Response``, there is a ``CaseInsensitiveDict`` object named headers,
49
+ ``content`` to access bytes, ``text`` to access unicode, and ``encoding``
50
+ to access the unicode codec.
51
+
52
+ """
53
+
54
+ def __init__(self, content, encoding):
55
+ self.encoding = encoding
56
+ headers = {}
57
+ # Split into header section (if any) and the content
58
+ if b'\r\n\r\n' in content:
59
+ first, self.content = _split_on_find(content, b'\r\n\r\n')
60
+ if first != b'':
61
+ headers = _header_parser(first.lstrip(), encoding)
62
+ else:
63
+ raise ImproperBodyPartContentException(
64
+ 'content does not contain CR-LF-CR-LF'
65
+ )
66
+ self.headers = CaseInsensitiveDict(headers)
67
+
68
+ @property
69
+ def text(self):
70
+ """Content of the ``BodyPart`` in unicode."""
71
+ return self.content.decode(self.encoding)
72
+
73
+
74
+ class MultipartDecoder(object):
75
+ """
76
+
77
+ The ``MultipartDecoder`` object parses the multipart payload of
78
+ a bytestring into a tuple of ``Response``-like ``BodyPart`` objects.
79
+
80
+ The basic usage is::
81
+
82
+ import requests
83
+ from requests_toolbelt import MultipartDecoder
84
+
85
+ response = requests.get(url)
86
+ decoder = MultipartDecoder.from_response(response)
87
+ for part in decoder.parts:
88
+ print(part.headers['content-type'])
89
+
90
+ If the multipart content is not from a response, basic usage is::
91
+
92
+ from requests_toolbelt import MultipartDecoder
93
+
94
+ decoder = MultipartDecoder(content, content_type)
95
+ for part in decoder.parts:
96
+ print(part.headers['content-type'])
97
+
98
+ For both these usages, there is an optional ``encoding`` parameter. This is
99
+ a string, which is the name of the unicode codec to use (default is
100
+ ``'utf-8'``).
101
+
102
+ """
103
+ def __init__(self, content, content_type, encoding='utf-8'):
104
+ #: Original Content-Type header
105
+ self.content_type = content_type
106
+ #: Response body encoding
107
+ self.encoding = encoding
108
+ #: Parsed parts of the multipart response body
109
+ self.parts = tuple()
110
+ self._find_boundary()
111
+ self._parse_body(content)
112
+
113
+ def _find_boundary(self):
114
+ ct_info = tuple(x.strip() for x in self.content_type.split(';'))
115
+ mimetype = ct_info[0]
116
+ if mimetype.split('/')[0].lower() != 'multipart':
117
+ raise NonMultipartContentTypeException(
118
+ "Unexpected mimetype in content-type: '{}'".format(mimetype)
119
+ )
120
+ for item in ct_info[1:]:
121
+ attr, value = _split_on_find(
122
+ item,
123
+ '='
124
+ )
125
+ if attr.lower() == 'boundary':
126
+ self.boundary = encode_with(value.strip('"'), self.encoding)
127
+
128
+ @staticmethod
129
+ def _fix_first_part(part, boundary_marker):
130
+ bm_len = len(boundary_marker)
131
+ if boundary_marker == part[:bm_len]:
132
+ return part[bm_len:]
133
+ else:
134
+ return part
135
+
136
+ def _parse_body(self, content):
137
+ boundary = b''.join((b'--', self.boundary))
138
+
139
+ def body_part(part):
140
+ fixed = MultipartDecoder._fix_first_part(part, boundary)
141
+ return BodyPart(fixed, self.encoding)
142
+
143
+ def test_part(part):
144
+ return (part != b'' and
145
+ part != b'\r\n' and
146
+ part[:4] != b'--\r\n' and
147
+ part != b'--')
148
+
149
+ parts = content.split(b''.join((b'\r\n', boundary)))
150
+ self.parts = tuple(body_part(x) for x in parts if test_part(x))
151
+
152
+ @classmethod
153
+ def from_response(cls, response, encoding='utf-8'):
154
+ content = response.content
155
+ content_type = response.headers.get('content-type', None)
156
+ return cls(content, content_type, encoding)
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/multipart/encoder.py ADDED
@@ -0,0 +1,655 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+
4
+ requests_toolbelt.multipart.encoder
5
+ ===================================
6
+
7
+ This holds all of the implementation details of the MultipartEncoder
8
+
9
+ """
10
+ import contextlib
11
+ import io
12
+ import os
13
+ from uuid import uuid4
14
+
15
+ import requests
16
+
17
+ from .._compat import fields
18
+
19
+
20
+ class FileNotSupportedError(Exception):
21
+ """File not supported error."""
22
+
23
+
24
+ class MultipartEncoder(object):
25
+
26
+ """
27
+
28
+ The ``MultipartEncoder`` object is a generic interface to the engine that
29
+ will create a ``multipart/form-data`` body for you.
30
+
31
+ The basic usage is:
32
+
33
+ .. code-block:: python
34
+
35
+ import requests
36
+ from requests_toolbelt import MultipartEncoder
37
+
38
+ encoder = MultipartEncoder({'field': 'value',
39
+ 'other_field': 'other_value'})
40
+ r = requests.post('https://httpbin.org/post', data=encoder,
41
+ headers={'Content-Type': encoder.content_type})
42
+
43
+ If you do not need to take advantage of streaming the post body, you can
44
+ also do:
45
+
46
+ .. code-block:: python
47
+
48
+ r = requests.post('https://httpbin.org/post',
49
+ data=encoder.to_string(),
50
+ headers={'Content-Type': encoder.content_type})
51
+
52
+ If you want the encoder to use a specific order, you can use an
53
+ OrderedDict or more simply, a list of tuples:
54
+
55
+ .. code-block:: python
56
+
57
+ encoder = MultipartEncoder([('field', 'value'),
58
+ ('other_field', 'other_value')])
59
+
60
+ .. versionchanged:: 0.4.0
61
+
62
+ You can also provide tuples as part values as you would provide them to
63
+ requests' ``files`` parameter.
64
+
65
+ .. code-block:: python
66
+
67
+ encoder = MultipartEncoder({
68
+ 'field': ('file_name', b'{"a": "b"}', 'application/json',
69
+ {'X-My-Header': 'my-value'})
70
+ ])
71
+
72
+ .. warning::
73
+
74
+ This object will end up directly in :mod:`httplib`. Currently,
75
+ :mod:`httplib` has a hard-coded read size of **8192 bytes**. This
76
+ means that it will loop until the file has been read and your upload
77
+ could take a while. This is **not** a bug in requests. A feature is
78
+ being considered for this object to allow you, the user, to specify
79
+ what size should be returned on a read. If you have opinions on this,
80
+ please weigh in on `this issue`_.
81
+
82
+ .. _this issue:
83
+ https://github.com/requests/toolbelt/issues/75
84
+
85
+ """
86
+
87
+ def __init__(self, fields, boundary=None, encoding='utf-8'):
88
+ #: Boundary value either passed in by the user or created
89
+ self.boundary_value = boundary or uuid4().hex
90
+
91
+ # Computed boundary
92
+ self.boundary = '--{}'.format(self.boundary_value)
93
+
94
+ #: Encoding of the data being passed in
95
+ self.encoding = encoding
96
+
97
+ # Pre-encoded boundary
98
+ self._encoded_boundary = b''.join([
99
+ encode_with(self.boundary, self.encoding),
100
+ encode_with('\r\n', self.encoding)
101
+ ])
102
+
103
+ #: Fields provided by the user
104
+ self.fields = fields
105
+
106
+ #: Whether or not the encoder is finished
107
+ self.finished = False
108
+
109
+ #: Pre-computed parts of the upload
110
+ self.parts = []
111
+
112
+ # Pre-computed parts iterator
113
+ self._iter_parts = iter([])
114
+
115
+ # The part we're currently working with
116
+ self._current_part = None
117
+
118
+ # Cached computation of the body's length
119
+ self._len = None
120
+
121
+ # Our buffer
122
+ self._buffer = CustomBytesIO(encoding=encoding)
123
+
124
+ # Pre-compute each part's headers
125
+ self._prepare_parts()
126
+
127
+ # Load boundary into buffer
128
+ self._write_boundary()
129
+
130
+ @property
131
+ def len(self):
132
+ """Length of the multipart/form-data body.
133
+
134
+ requests will first attempt to get the length of the body by calling
135
+ ``len(body)`` and then by checking for the ``len`` attribute.
136
+
137
+ On 32-bit systems, the ``__len__`` method cannot return anything
138
+ larger than an integer (in C) can hold. If the total size of the body
139
+ is even slightly larger than 4GB users will see an OverflowError. This
140
+ manifested itself in `bug #80`_.
141
+
142
+ As such, we now calculate the length lazily as a property.
143
+
144
+ .. _bug #80:
145
+ https://github.com/requests/toolbelt/issues/80
146
+ """
147
+ # If _len isn't already calculated, calculate, return, and set it
148
+ return self._len or self._calculate_length()
149
+
150
+ def __repr__(self):
151
+ return '<MultipartEncoder: {!r}>'.format(self.fields)
152
+
153
+ def _calculate_length(self):
154
+ """
155
+ This uses the parts to calculate the length of the body.
156
+
157
+ This returns the calculated length so __len__ can be lazy.
158
+ """
159
+ boundary_len = len(self.boundary) # Length of --{boundary}
160
+ # boundary length + header length + body length + len('\r\n') * 2
161
+ self._len = sum(
162
+ (boundary_len + total_len(p) + 4) for p in self.parts
163
+ ) + boundary_len + 4
164
+ return self._len
165
+
166
+ def _calculate_load_amount(self, read_size):
167
+ """This calculates how many bytes need to be added to the buffer.
168
+
169
+ When a consumer read's ``x`` from the buffer, there are two cases to
170
+ satisfy:
171
+
172
+ 1. Enough data in the buffer to return the requested amount
173
+ 2. Not enough data
174
+
175
+ This function uses the amount of unread bytes in the buffer and
176
+ determines how much the Encoder has to load before it can return the
177
+ requested amount of bytes.
178
+
179
+ :param int read_size: the number of bytes the consumer requests
180
+ :returns: int -- the number of bytes that must be loaded into the
181
+ buffer before the read can be satisfied. This will be strictly
182
+ non-negative
183
+ """
184
+ amount = read_size - total_len(self._buffer)
185
+ return amount if amount > 0 else 0
186
+
187
+ def _load(self, amount):
188
+ """Load ``amount`` number of bytes into the buffer."""
189
+ self._buffer.smart_truncate()
190
+ part = self._current_part or self._next_part()
191
+ while amount == -1 or amount > 0:
192
+ written = 0
193
+ if part and not part.bytes_left_to_write():
194
+ written += self._write(b'\r\n')
195
+ written += self._write_boundary()
196
+ part = self._next_part()
197
+
198
+ if not part:
199
+ written += self._write_closing_boundary()
200
+ self.finished = True
201
+ break
202
+
203
+ written += part.write_to(self._buffer, amount)
204
+
205
+ if amount != -1:
206
+ amount -= written
207
+
208
+ def _next_part(self):
209
+ try:
210
+ p = self._current_part = next(self._iter_parts)
211
+ except StopIteration:
212
+ p = None
213
+ return p
214
+
215
+ def _iter_fields(self):
216
+ _fields = self.fields
217
+ if hasattr(self.fields, 'items'):
218
+ _fields = list(self.fields.items())
219
+ for k, v in _fields:
220
+ file_name = None
221
+ file_type = None
222
+ file_headers = None
223
+ if isinstance(v, (list, tuple)):
224
+ if len(v) == 2:
225
+ file_name, file_pointer = v
226
+ elif len(v) == 3:
227
+ file_name, file_pointer, file_type = v
228
+ else:
229
+ file_name, file_pointer, file_type, file_headers = v
230
+ else:
231
+ file_pointer = v
232
+
233
+ field = fields.RequestField(name=k, data=file_pointer,
234
+ filename=file_name,
235
+ headers=file_headers)
236
+ field.make_multipart(content_type=file_type)
237
+ yield field
238
+
239
+ def _prepare_parts(self):
240
+ """This uses the fields provided by the user and creates Part objects.
241
+
242
+ It populates the `parts` attribute and uses that to create a
243
+ generator for iteration.
244
+ """
245
+ enc = self.encoding
246
+ self.parts = [Part.from_field(f, enc) for f in self._iter_fields()]
247
+ self._iter_parts = iter(self.parts)
248
+
249
+ def _write(self, bytes_to_write):
250
+ """Write the bytes to the end of the buffer.
251
+
252
+ :param bytes bytes_to_write: byte-string (or bytearray) to append to
253
+ the buffer
254
+ :returns: int -- the number of bytes written
255
+ """
256
+ return self._buffer.append(bytes_to_write)
257
+
258
+ def _write_boundary(self):
259
+ """Write the boundary to the end of the buffer."""
260
+ return self._write(self._encoded_boundary)
261
+
262
+ def _write_closing_boundary(self):
263
+ """Write the bytes necessary to finish a multipart/form-data body."""
264
+ with reset(self._buffer):
265
+ self._buffer.seek(-2, 2)
266
+ self._buffer.write(b'--\r\n')
267
+ return 2
268
+
269
+ def _write_headers(self, headers):
270
+ """Write the current part's headers to the buffer."""
271
+ return self._write(encode_with(headers, self.encoding))
272
+
273
+ @property
274
+ def content_type(self):
275
+ return str(
276
+ 'multipart/form-data; boundary={}'.format(self.boundary_value)
277
+ )
278
+
279
+ def to_string(self):
280
+ """Return the entirety of the data in the encoder.
281
+
282
+ .. note::
283
+
284
+ This simply reads all of the data it can. If you have started
285
+ streaming or reading data from the encoder, this method will only
286
+ return whatever data is left in the encoder.
287
+
288
+ .. note::
289
+
290
+ This method affects the internal state of the encoder. Calling
291
+ this method will exhaust the encoder.
292
+
293
+ :returns: the multipart message
294
+ :rtype: bytes
295
+ """
296
+
297
+ return self.read()
298
+
299
+ def read(self, size=-1):
300
+ """Read data from the streaming encoder.
301
+
302
+ :param int size: (optional), If provided, ``read`` will return exactly
303
+ that many bytes. If it is not provided, it will return the
304
+ remaining bytes.
305
+ :returns: bytes
306
+ """
307
+ if self.finished:
308
+ return self._buffer.read(size)
309
+
310
+ bytes_to_load = size
311
+ if bytes_to_load != -1 and bytes_to_load is not None:
312
+ bytes_to_load = self._calculate_load_amount(int(size))
313
+
314
+ self._load(bytes_to_load)
315
+ return self._buffer.read(size)
316
+
317
+
318
+ def IDENTITY(monitor):
319
+ return monitor
320
+
321
+
322
+ class MultipartEncoderMonitor(object):
323
+
324
+ """
325
+ An object used to monitor the progress of a :class:`MultipartEncoder`.
326
+
327
+ The :class:`MultipartEncoder` should only be responsible for preparing and
328
+ streaming the data. For anyone who wishes to monitor it, they shouldn't be
329
+ using that instance to manage that as well. Using this class, they can
330
+ monitor an encoder and register a callback. The callback receives the
331
+ instance of the monitor.
332
+
333
+ To use this monitor, you construct your :class:`MultipartEncoder` as you
334
+ normally would.
335
+
336
+ .. code-block:: python
337
+
338
+ from requests_toolbelt import (MultipartEncoder,
339
+ MultipartEncoderMonitor)
340
+ import requests
341
+
342
+ def callback(monitor):
343
+ # Do something with this information
344
+ pass
345
+
346
+ m = MultipartEncoder(fields={'field0': 'value0'})
347
+ monitor = MultipartEncoderMonitor(m, callback)
348
+ headers = {'Content-Type': monitor.content_type}
349
+ r = requests.post('https://httpbin.org/post', data=monitor,
350
+ headers=headers)
351
+
352
+ Alternatively, if your use case is very simple, you can use the following
353
+ pattern.
354
+
355
+ .. code-block:: python
356
+
357
+ from requests_toolbelt import MultipartEncoderMonitor
358
+ import requests
359
+
360
+ def callback(monitor):
361
+ # Do something with this information
362
+ pass
363
+
364
+ monitor = MultipartEncoderMonitor.from_fields(
365
+ fields={'field0': 'value0'}, callback
366
+ )
367
+ headers = {'Content-Type': montior.content_type}
368
+ r = requests.post('https://httpbin.org/post', data=monitor,
369
+ headers=headers)
370
+
371
+ """
372
+
373
+ def __init__(self, encoder, callback=None):
374
+ #: Instance of the :class:`MultipartEncoder` being monitored
375
+ self.encoder = encoder
376
+
377
+ #: Optionally function to call after a read
378
+ self.callback = callback or IDENTITY
379
+
380
+ #: Number of bytes already read from the :class:`MultipartEncoder`
381
+ #: instance
382
+ self.bytes_read = 0
383
+
384
+ #: Avoid the same problem in bug #80
385
+ self.len = self.encoder.len
386
+
387
+ @classmethod
388
+ def from_fields(cls, fields, boundary=None, encoding='utf-8',
389
+ callback=None):
390
+ encoder = MultipartEncoder(fields, boundary, encoding)
391
+ return cls(encoder, callback)
392
+
393
+ @property
394
+ def content_type(self):
395
+ return self.encoder.content_type
396
+
397
+ def to_string(self):
398
+ return self.read()
399
+
400
+ def read(self, size=-1):
401
+ string = self.encoder.read(size)
402
+ self.bytes_read += len(string)
403
+ self.callback(self)
404
+ return string
405
+
406
+
407
+ def encode_with(string, encoding):
408
+ """Encoding ``string`` with ``encoding`` if necessary.
409
+
410
+ :param str string: If string is a bytes object, it will not encode it.
411
+ Otherwise, this function will encode it with the provided encoding.
412
+ :param str encoding: The encoding with which to encode string.
413
+ :returns: encoded bytes object
414
+ """
415
+ if not (string is None or isinstance(string, bytes)):
416
+ return string.encode(encoding)
417
+ return string
418
+
419
+
420
+ def readable_data(data, encoding):
421
+ """Coerce the data to an object with a ``read`` method."""
422
+ if hasattr(data, 'read'):
423
+ return data
424
+
425
+ return CustomBytesIO(data, encoding)
426
+
427
+
428
+ def total_len(o):
429
+ if hasattr(o, '__len__'):
430
+ return len(o)
431
+
432
+ if hasattr(o, 'len'):
433
+ return o.len
434
+
435
+ if hasattr(o, 'fileno'):
436
+ try:
437
+ fileno = o.fileno()
438
+ except io.UnsupportedOperation:
439
+ pass
440
+ else:
441
+ return os.fstat(fileno).st_size
442
+
443
+ if hasattr(o, 'getvalue'):
444
+ # e.g. BytesIO, cStringIO.StringIO
445
+ return len(o.getvalue())
446
+
447
+
448
+ @contextlib.contextmanager
449
+ def reset(buffer):
450
+ """Keep track of the buffer's current position and write to the end.
451
+
452
+ This is a context manager meant to be used when adding data to the buffer.
453
+ It eliminates the need for every function to be concerned with the
454
+ position of the cursor in the buffer.
455
+ """
456
+ original_position = buffer.tell()
457
+ buffer.seek(0, 2)
458
+ yield
459
+ buffer.seek(original_position, 0)
460
+
461
+
462
+ def coerce_data(data, encoding):
463
+ """Ensure that every object's __len__ behaves uniformly."""
464
+ if not isinstance(data, CustomBytesIO):
465
+ if hasattr(data, 'getvalue'):
466
+ return CustomBytesIO(data.getvalue(), encoding)
467
+
468
+ if hasattr(data, 'fileno'):
469
+ return FileWrapper(data)
470
+
471
+ if not hasattr(data, 'read'):
472
+ return CustomBytesIO(data, encoding)
473
+
474
+ return data
475
+
476
+
477
+ def to_list(fields):
478
+ if hasattr(fields, 'items'):
479
+ return list(fields.items())
480
+ return list(fields)
481
+
482
+
483
+ class Part(object):
484
+ def __init__(self, headers, body):
485
+ self.headers = headers
486
+ self.body = body
487
+ self.headers_unread = True
488
+ self.len = len(self.headers) + total_len(self.body)
489
+
490
+ @classmethod
491
+ def from_field(cls, field, encoding):
492
+ """Create a part from a Request Field generated by urllib3."""
493
+ headers = encode_with(field.render_headers(), encoding)
494
+ body = coerce_data(field.data, encoding)
495
+ return cls(headers, body)
496
+
497
+ def bytes_left_to_write(self):
498
+ """Determine if there are bytes left to write.
499
+
500
+ :returns: bool -- ``True`` if there are bytes left to write, otherwise
501
+ ``False``
502
+ """
503
+ to_read = 0
504
+ if self.headers_unread:
505
+ to_read += len(self.headers)
506
+
507
+ return (to_read + total_len(self.body)) > 0
508
+
509
+ def write_to(self, buffer, size):
510
+ """Write the requested amount of bytes to the buffer provided.
511
+
512
+ The number of bytes written may exceed size on the first read since we
513
+ load the headers ambitiously.
514
+
515
+ :param CustomBytesIO buffer: buffer we want to write bytes to
516
+ :param int size: number of bytes requested to be written to the buffer
517
+ :returns: int -- number of bytes actually written
518
+ """
519
+ written = 0
520
+ if self.headers_unread:
521
+ written += buffer.append(self.headers)
522
+ self.headers_unread = False
523
+
524
+ while total_len(self.body) > 0 and (size == -1 or written < size):
525
+ amount_to_read = size
526
+ if size != -1:
527
+ amount_to_read = size - written
528
+ written += buffer.append(self.body.read(amount_to_read))
529
+
530
+ return written
531
+
532
+
533
+ class CustomBytesIO(io.BytesIO):
534
+ def __init__(self, buffer=None, encoding='utf-8'):
535
+ buffer = encode_with(buffer, encoding)
536
+ super(CustomBytesIO, self).__init__(buffer)
537
+
538
+ def _get_end(self):
539
+ current_pos = self.tell()
540
+ self.seek(0, 2)
541
+ length = self.tell()
542
+ self.seek(current_pos, 0)
543
+ return length
544
+
545
+ @property
546
+ def len(self):
547
+ length = self._get_end()
548
+ return length - self.tell()
549
+
550
+ def append(self, bytes):
551
+ with reset(self):
552
+ written = self.write(bytes)
553
+ return written
554
+
555
+ def smart_truncate(self):
556
+ to_be_read = total_len(self)
557
+ already_read = self._get_end() - to_be_read
558
+
559
+ if already_read >= to_be_read:
560
+ old_bytes = self.read()
561
+ self.seek(0, 0)
562
+ self.truncate()
563
+ self.write(old_bytes)
564
+ self.seek(0, 0) # We want to be at the beginning
565
+
566
+
567
+ class FileWrapper(object):
568
+ def __init__(self, file_object):
569
+ self.fd = file_object
570
+
571
+ @property
572
+ def len(self):
573
+ return total_len(self.fd) - self.fd.tell()
574
+
575
+ def read(self, length=-1):
576
+ return self.fd.read(length)
577
+
578
+
579
+ class FileFromURLWrapper(object):
580
+ """File from URL wrapper.
581
+
582
+ The :class:`FileFromURLWrapper` object gives you the ability to stream file
583
+ from provided URL in chunks by :class:`MultipartEncoder`.
584
+ Provide a stateless solution for streaming file from one server to another.
585
+ You can use the :class:`FileFromURLWrapper` without a session or with
586
+ a session as demonstated by the examples below:
587
+
588
+ .. code-block:: python
589
+ # no session
590
+
591
+ import requests
592
+ from requests_toolbelt import MultipartEncoder, FileFromURLWrapper
593
+
594
+ url = 'https://httpbin.org/image/png'
595
+ streaming_encoder = MultipartEncoder(
596
+ fields={
597
+ 'file': FileFromURLWrapper(url)
598
+ }
599
+ )
600
+ r = requests.post(
601
+ 'https://httpbin.org/post', data=streaming_encoder,
602
+ headers={'Content-Type': streaming_encoder.content_type}
603
+ )
604
+
605
+ .. code-block:: python
606
+ # using a session
607
+
608
+ import requests
609
+ from requests_toolbelt import MultipartEncoder, FileFromURLWrapper
610
+
611
+ session = requests.Session()
612
+ url = 'https://httpbin.org/image/png'
613
+ streaming_encoder = MultipartEncoder(
614
+ fields={
615
+ 'file': FileFromURLWrapper(url, session=session)
616
+ }
617
+ )
618
+ r = session.post(
619
+ 'https://httpbin.org/post', data=streaming_encoder,
620
+ headers={'Content-Type': streaming_encoder.content_type}
621
+ )
622
+
623
+ """
624
+
625
+ def __init__(self, file_url, session=None):
626
+ self.session = session or requests.Session()
627
+ requested_file = self._request_for_file(file_url)
628
+ self.len = int(requested_file.headers['content-length'])
629
+ self.raw_data = requested_file.raw
630
+
631
+ def _request_for_file(self, file_url):
632
+ """Make call for file under provided URL."""
633
+ response = self.session.get(file_url, stream=True)
634
+ content_length = response.headers.get('content-length', None)
635
+ if content_length is None:
636
+ error_msg = (
637
+ "Data from provided URL {url} is not supported. Lack of "
638
+ "content-length Header in requested file response.".format(
639
+ url=file_url)
640
+ )
641
+ raise FileNotSupportedError(error_msg)
642
+ elif not content_length.isdigit():
643
+ error_msg = (
644
+ "Data from provided URL {url} is not supported. content-length"
645
+ " header value is not a digit.".format(url=file_url)
646
+ )
647
+ raise FileNotSupportedError(error_msg)
648
+ return response
649
+
650
+ def read(self, chunk_size):
651
+ """Read file in chunks."""
652
+ chunk_size = chunk_size if chunk_size >= 0 else self.len
653
+ chunk = self.raw_data.read(chunk_size) or b''
654
+ self.len -= len(chunk) if chunk else 0 # left to read
655
+ return chunk
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__init__.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This module provides the API for ``requests_toolbelt.threaded``.
3
+
4
+ The module provides a clean and simple API for making requests via a thread
5
+ pool. The thread pool will use sessions for increased performance.
6
+
7
+ A simple use-case is:
8
+
9
+ .. code-block:: python
10
+
11
+ from requests_toolbelt import threaded
12
+
13
+ urls_to_get = [{
14
+ 'url': 'https://api.github.com/users/sigmavirus24',
15
+ 'method': 'GET',
16
+ }, {
17
+ 'url': 'https://api.github.com/repos/requests/toolbelt',
18
+ 'method': 'GET',
19
+ }, {
20
+ 'url': 'https://google.com',
21
+ 'method': 'GET',
22
+ }]
23
+ responses, errors = threaded.map(urls_to_get)
24
+
25
+ By default, the threaded submodule will detect the number of CPUs your
26
+ computer has and use that if no other number of processes is selected. To
27
+ change this, always use the keyword argument ``num_processes``. Using the
28
+ above example, we would expand it like so:
29
+
30
+ .. code-block:: python
31
+
32
+ responses, errors = threaded.map(urls_to_get, num_processes=10)
33
+
34
+ You can also customize how a :class:`requests.Session` is initialized by
35
+ creating a callback function:
36
+
37
+ .. code-block:: python
38
+
39
+ from requests_toolbelt import user_agent
40
+
41
+ def initialize_session(session):
42
+ session.headers['User-Agent'] = user_agent('my-scraper', '0.1')
43
+ session.headers['Accept'] = 'application/json'
44
+
45
+ responses, errors = threaded.map(urls_to_get,
46
+ initializer=initialize_session)
47
+
48
+ .. autofunction:: requests_toolbelt.threaded.map
49
+
50
+ Inspiration is blatantly drawn from the standard library's multiprocessing
51
+ library. See the following references:
52
+
53
+ - multiprocessing's `pool source`_
54
+
55
+ - map and map_async `inspiration`_
56
+
57
+ .. _pool source:
58
+ https://hg.python.org/cpython/file/8ef4f75a8018/Lib/multiprocessing/pool.py
59
+ .. _inspiration:
60
+ https://hg.python.org/cpython/file/8ef4f75a8018/Lib/multiprocessing/pool.py#l340
61
+ """
62
+ from . import pool
63
+ from .._compat import queue
64
+
65
+
66
+ def map(requests, **kwargs):
67
+ r"""Simple interface to the threaded Pool object.
68
+
69
+ This function takes a list of dictionaries representing requests to make
70
+ using Sessions in threads and returns a tuple where the first item is
71
+ a generator of successful responses and the second is a generator of
72
+ exceptions.
73
+
74
+ :param list requests:
75
+ Collection of dictionaries representing requests to make with the Pool
76
+ object.
77
+ :param \*\*kwargs:
78
+ Keyword arguments that are passed to the
79
+ :class:`~requests_toolbelt.threaded.pool.Pool` object.
80
+ :returns: Tuple of responses and exceptions from the pool
81
+ :rtype: (:class:`~requests_toolbelt.threaded.pool.ThreadResponse`,
82
+ :class:`~requests_toolbelt.threaded.pool.ThreadException`)
83
+ """
84
+ if not (requests and all(isinstance(r, dict) for r in requests)):
85
+ raise ValueError('map expects a list of dictionaries.')
86
+
87
+ # Build our queue of requests
88
+ job_queue = queue.Queue()
89
+ for request in requests:
90
+ job_queue.put(request)
91
+
92
+ # Ensure the user doesn't try to pass their own job_queue
93
+ kwargs['job_queue'] = job_queue
94
+
95
+ threadpool = pool.Pool(**kwargs)
96
+ threadpool.join_all()
97
+ return threadpool.responses(), threadpool.exceptions()
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (4.03 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__pycache__/pool.cpython-311.pyc ADDED
Binary file (9.64 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/__pycache__/thread.cpython-311.pyc ADDED
Binary file (3.34 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/pool.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Module implementing the Pool for :mod:``requests_toolbelt.threaded``."""
2
+ import multiprocessing
3
+ import requests
4
+
5
+ from . import thread
6
+ from .._compat import queue
7
+
8
+
9
+ class Pool(object):
10
+ """Pool that manages the threads containing sessions.
11
+
12
+ :param queue:
13
+ The queue you're expected to use to which you should add items.
14
+ :type queue: queue.Queue
15
+ :param initializer:
16
+ Function used to initialize an instance of ``session``.
17
+ :type initializer: collections.Callable
18
+ :param auth_generator:
19
+ Function used to generate new auth credentials for the session.
20
+ :type auth_generator: collections.Callable
21
+ :param int num_process:
22
+ Number of threads to create.
23
+ :param session:
24
+ :type session: requests.Session
25
+ """
26
+
27
+ def __init__(self, job_queue, initializer=None, auth_generator=None,
28
+ num_processes=None, session=requests.Session):
29
+ if num_processes is None:
30
+ num_processes = multiprocessing.cpu_count() or 1
31
+
32
+ if num_processes < 1:
33
+ raise ValueError("Number of processes should at least be 1.")
34
+
35
+ self._job_queue = job_queue
36
+ self._response_queue = queue.Queue()
37
+ self._exc_queue = queue.Queue()
38
+ self._processes = num_processes
39
+ self._initializer = initializer or _identity
40
+ self._auth = auth_generator or _identity
41
+ self._session = session
42
+ self._pool = [
43
+ thread.SessionThread(self._new_session(), self._job_queue,
44
+ self._response_queue, self._exc_queue)
45
+ for _ in range(self._processes)
46
+ ]
47
+
48
+ def _new_session(self):
49
+ return self._auth(self._initializer(self._session()))
50
+
51
+ @classmethod
52
+ def from_exceptions(cls, exceptions, **kwargs):
53
+ r"""Create a :class:`~Pool` from an :class:`~ThreadException`\ s.
54
+
55
+ Provided an iterable that provides :class:`~ThreadException` objects,
56
+ this classmethod will generate a new pool to retry the requests that
57
+ caused the exceptions.
58
+
59
+ :param exceptions:
60
+ Iterable that returns :class:`~ThreadException`
61
+ :type exceptions: iterable
62
+ :param kwargs:
63
+ Keyword arguments passed to the :class:`~Pool` initializer.
64
+ :returns: An initialized :class:`~Pool` object.
65
+ :rtype: :class:`~Pool`
66
+ """
67
+ job_queue = queue.Queue()
68
+ for exc in exceptions:
69
+ job_queue.put(exc.request_kwargs)
70
+
71
+ return cls(job_queue=job_queue, **kwargs)
72
+
73
+ @classmethod
74
+ def from_urls(cls, urls, request_kwargs=None, **kwargs):
75
+ """Create a :class:`~Pool` from an iterable of URLs.
76
+
77
+ :param urls:
78
+ Iterable that returns URLs with which we create a pool.
79
+ :type urls: iterable
80
+ :param dict request_kwargs:
81
+ Dictionary of other keyword arguments to provide to the request
82
+ method.
83
+ :param kwargs:
84
+ Keyword arguments passed to the :class:`~Pool` initializer.
85
+ :returns: An initialized :class:`~Pool` object.
86
+ :rtype: :class:`~Pool`
87
+ """
88
+ request_dict = {'method': 'GET'}
89
+ request_dict.update(request_kwargs or {})
90
+ job_queue = queue.Queue()
91
+ for url in urls:
92
+ job = request_dict.copy()
93
+ job.update({'url': url})
94
+ job_queue.put(job)
95
+
96
+ return cls(job_queue=job_queue, **kwargs)
97
+
98
+ def exceptions(self):
99
+ """Iterate over all the exceptions in the pool.
100
+
101
+ :returns: Generator of :class:`~ThreadException`
102
+ """
103
+ while True:
104
+ exc = self.get_exception()
105
+ if exc is None:
106
+ break
107
+ yield exc
108
+
109
+ def get_exception(self):
110
+ """Get an exception from the pool.
111
+
112
+ :rtype: :class:`~ThreadException`
113
+ """
114
+ try:
115
+ (request, exc) = self._exc_queue.get_nowait()
116
+ except queue.Empty:
117
+ return None
118
+ else:
119
+ return ThreadException(request, exc)
120
+
121
+ def get_response(self):
122
+ """Get a response from the pool.
123
+
124
+ :rtype: :class:`~ThreadResponse`
125
+ """
126
+ try:
127
+ (request, response) = self._response_queue.get_nowait()
128
+ except queue.Empty:
129
+ return None
130
+ else:
131
+ return ThreadResponse(request, response)
132
+
133
+ def responses(self):
134
+ """Iterate over all the responses in the pool.
135
+
136
+ :returns: Generator of :class:`~ThreadResponse`
137
+ """
138
+ while True:
139
+ resp = self.get_response()
140
+ if resp is None:
141
+ break
142
+ yield resp
143
+
144
+ def join_all(self):
145
+ """Join all the threads to the master thread."""
146
+ for session_thread in self._pool:
147
+ session_thread.join()
148
+
149
+
150
+ class ThreadProxy(object):
151
+ proxied_attr = None
152
+
153
+ def __getattr__(self, attr):
154
+ """Proxy attribute accesses to the proxied object."""
155
+ get = object.__getattribute__
156
+ if attr not in self.attrs:
157
+ response = get(self, self.proxied_attr)
158
+ return getattr(response, attr)
159
+ else:
160
+ return get(self, attr)
161
+
162
+
163
+ class ThreadResponse(ThreadProxy):
164
+ """A wrapper around a requests Response object.
165
+
166
+ This will proxy most attribute access actions to the Response object. For
167
+ example, if you wanted the parsed JSON from the response, you might do:
168
+
169
+ .. code-block:: python
170
+
171
+ thread_response = pool.get_response()
172
+ json = thread_response.json()
173
+
174
+ """
175
+ proxied_attr = 'response'
176
+ attrs = frozenset(['request_kwargs', 'response'])
177
+
178
+ def __init__(self, request_kwargs, response):
179
+ #: The original keyword arguments provided to the queue
180
+ self.request_kwargs = request_kwargs
181
+ #: The wrapped response
182
+ self.response = response
183
+
184
+
185
+ class ThreadException(ThreadProxy):
186
+ """A wrapper around an exception raised during a request.
187
+
188
+ This will proxy most attribute access actions to the exception object. For
189
+ example, if you wanted the message from the exception, you might do:
190
+
191
+ .. code-block:: python
192
+
193
+ thread_exc = pool.get_exception()
194
+ msg = thread_exc.message
195
+
196
+ """
197
+ proxied_attr = 'exception'
198
+ attrs = frozenset(['request_kwargs', 'exception'])
199
+
200
+ def __init__(self, request_kwargs, exception):
201
+ #: The original keyword arguments provided to the queue
202
+ self.request_kwargs = request_kwargs
203
+ #: The captured and wrapped exception
204
+ self.exception = exception
205
+
206
+
207
+ def _identity(session_obj):
208
+ return session_obj
209
+
210
+
211
+ __all__ = ['ThreadException', 'ThreadResponse', 'Pool']
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/threaded/thread.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Module containing the SessionThread class."""
2
+ import threading
3
+ import uuid
4
+
5
+ import requests.exceptions as exc
6
+
7
+ from .._compat import queue
8
+
9
+
10
+ class SessionThread(object):
11
+ def __init__(self, initialized_session, job_queue, response_queue,
12
+ exception_queue):
13
+ self._session = initialized_session
14
+ self._jobs = job_queue
15
+ self._create_worker()
16
+ self._responses = response_queue
17
+ self._exceptions = exception_queue
18
+
19
+ def _create_worker(self):
20
+ self._worker = threading.Thread(
21
+ target=self._make_request,
22
+ name=uuid.uuid4(),
23
+ )
24
+ self._worker.daemon = True
25
+ self._worker._state = 0
26
+ self._worker.start()
27
+
28
+ def _handle_request(self, kwargs):
29
+ try:
30
+ response = self._session.request(**kwargs)
31
+ except exc.RequestException as e:
32
+ self._exceptions.put((kwargs, e))
33
+ else:
34
+ self._responses.put((kwargs, response))
35
+ finally:
36
+ self._jobs.task_done()
37
+
38
+ def _make_request(self):
39
+ while True:
40
+ try:
41
+ kwargs = self._jobs.get_nowait()
42
+ except queue.Empty:
43
+ break
44
+
45
+ self._handle_request(kwargs)
46
+
47
+ def is_alive(self):
48
+ """Proxy to the thread's ``is_alive`` method."""
49
+ return self._worker.is_alive()
50
+
51
+ def join(self):
52
+ """Join this thread to the master thread."""
53
+ self._worker.join()
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__init__.py ADDED
File without changes
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (217 Bytes). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/deprecated.cpython-311.pyc ADDED
Binary file (3.83 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/dump.cpython-311.pyc ADDED
Binary file (9.02 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/formdata.cpython-311.pyc ADDED
Binary file (4.96 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/__pycache__/user_agent.cpython-311.pyc ADDED
Binary file (6.73 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/deprecated.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """A collection of functions deprecated in requests.utils."""
3
+ import re
4
+ import sys
5
+
6
+ from requests import utils
7
+
8
+ find_charset = re.compile(
9
+ br'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I
10
+ ).findall
11
+
12
+ find_pragma = re.compile(
13
+ br'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I
14
+ ).findall
15
+
16
+ find_xml = re.compile(
17
+ br'^<\?xml.*?encoding=["\']*(.+?)["\'>]'
18
+ ).findall
19
+
20
+
21
+ def get_encodings_from_content(content):
22
+ """Return encodings from given content string.
23
+
24
+ .. code-block:: python
25
+
26
+ import requests
27
+ from requests_toolbelt.utils import deprecated
28
+
29
+ r = requests.get(url)
30
+ encodings = deprecated.get_encodings_from_content(r)
31
+
32
+ :param content: bytestring to extract encodings from
33
+ :type content: bytes
34
+ :return: encodings detected in the provided content
35
+ :rtype: list(str)
36
+ """
37
+ encodings = (find_charset(content) + find_pragma(content)
38
+ + find_xml(content))
39
+ if (3, 0) <= sys.version_info < (4, 0):
40
+ encodings = [encoding.decode('utf8') for encoding in encodings]
41
+ return encodings
42
+
43
+
44
+ def get_unicode_from_response(response):
45
+ """Return the requested content back in unicode.
46
+
47
+ This will first attempt to retrieve the encoding from the response
48
+ headers. If that fails, it will use
49
+ :func:`requests_toolbelt.utils.deprecated.get_encodings_from_content`
50
+ to determine encodings from HTML elements.
51
+
52
+ .. code-block:: python
53
+
54
+ import requests
55
+ from requests_toolbelt.utils import deprecated
56
+
57
+ r = requests.get(url)
58
+ text = deprecated.get_unicode_from_response(r)
59
+
60
+ :param response: Response object to get unicode content from.
61
+ :type response: requests.models.Response
62
+ """
63
+ tried_encodings = set()
64
+
65
+ # Try charset from content-type
66
+ encoding = utils.get_encoding_from_headers(response.headers)
67
+
68
+ if encoding:
69
+ try:
70
+ return str(response.content, encoding)
71
+ except UnicodeError:
72
+ tried_encodings.add(encoding.lower())
73
+
74
+ encodings = get_encodings_from_content(response.content)
75
+
76
+ for _encoding in encodings:
77
+ _encoding = _encoding.lower()
78
+ if _encoding in tried_encodings:
79
+ continue
80
+ try:
81
+ return str(response.content, _encoding)
82
+ except UnicodeError:
83
+ tried_encodings.add(_encoding)
84
+
85
+ # Fall back:
86
+ if encoding:
87
+ try:
88
+ return str(response.content, encoding, errors='replace')
89
+ except TypeError:
90
+ pass
91
+ return response.text
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/dump.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """This module provides functions for dumping information about responses."""
2
+ import collections
3
+
4
+ from requests import compat
5
+
6
+
7
+ __all__ = ('dump_response', 'dump_all')
8
+
9
+ HTTP_VERSIONS = {
10
+ 9: b'0.9',
11
+ 10: b'1.0',
12
+ 11: b'1.1',
13
+ }
14
+
15
+ _PrefixSettings = collections.namedtuple('PrefixSettings',
16
+ ['request', 'response'])
17
+
18
+
19
+ class PrefixSettings(_PrefixSettings):
20
+ def __new__(cls, request, response):
21
+ request = _coerce_to_bytes(request)
22
+ response = _coerce_to_bytes(response)
23
+ return super(PrefixSettings, cls).__new__(cls, request, response)
24
+
25
+
26
+ def _get_proxy_information(response):
27
+ if getattr(response.connection, 'proxy_manager', False):
28
+ proxy_info = {}
29
+ request_url = response.request.url
30
+ if request_url.startswith('https://'):
31
+ proxy_info['method'] = 'CONNECT'
32
+
33
+ proxy_info['request_path'] = request_url
34
+ return proxy_info
35
+ return None
36
+
37
+
38
+ def _format_header(name, value):
39
+ return (_coerce_to_bytes(name) + b': ' + _coerce_to_bytes(value) +
40
+ b'\r\n')
41
+
42
+
43
+ def _build_request_path(url, proxy_info):
44
+ uri = compat.urlparse(url)
45
+ proxy_url = proxy_info.get('request_path')
46
+ if proxy_url is not None:
47
+ request_path = _coerce_to_bytes(proxy_url)
48
+ return request_path, uri
49
+
50
+ request_path = _coerce_to_bytes(uri.path)
51
+ if uri.query:
52
+ request_path += b'?' + _coerce_to_bytes(uri.query)
53
+
54
+ return request_path, uri
55
+
56
+
57
+ def _dump_request_data(request, prefixes, bytearr, proxy_info=None):
58
+ if proxy_info is None:
59
+ proxy_info = {}
60
+
61
+ prefix = prefixes.request
62
+ method = _coerce_to_bytes(proxy_info.pop('method', request.method))
63
+ request_path, uri = _build_request_path(request.url, proxy_info)
64
+
65
+ # <prefix><METHOD> <request-path> HTTP/1.1
66
+ bytearr.extend(prefix + method + b' ' + request_path + b' HTTP/1.1\r\n')
67
+
68
+ # <prefix>Host: <request-host> OR host header specified by user
69
+ headers = request.headers.copy()
70
+ host_header = _coerce_to_bytes(headers.pop('Host', uri.netloc))
71
+ bytearr.extend(prefix + b'Host: ' + host_header + b'\r\n')
72
+
73
+ for name, value in headers.items():
74
+ bytearr.extend(prefix + _format_header(name, value))
75
+
76
+ bytearr.extend(prefix + b'\r\n')
77
+ if request.body:
78
+ if isinstance(request.body, compat.basestring):
79
+ bytearr.extend(prefix + _coerce_to_bytes(request.body))
80
+ else:
81
+ # In the event that the body is a file-like object, let's not try
82
+ # to read everything into memory.
83
+ bytearr.extend(b'<< Request body is not a string-like type >>')
84
+ bytearr.extend(b'\r\n')
85
+ bytearr.extend(b'\r\n')
86
+
87
+
88
+ def _dump_response_data(response, prefixes, bytearr):
89
+ prefix = prefixes.response
90
+ # Let's interact almost entirely with urllib3's response
91
+ raw = response.raw
92
+
93
+ # Let's convert the version int from httplib to bytes
94
+ version_str = HTTP_VERSIONS.get(raw.version, b'?')
95
+
96
+ # <prefix>HTTP/<version_str> <status_code> <reason>
97
+ bytearr.extend(prefix + b'HTTP/' + version_str + b' ' +
98
+ str(raw.status).encode('ascii') + b' ' +
99
+ _coerce_to_bytes(response.reason) + b'\r\n')
100
+
101
+ headers = raw.headers
102
+ for name in headers.keys():
103
+ for value in headers.getlist(name):
104
+ bytearr.extend(prefix + _format_header(name, value))
105
+
106
+ bytearr.extend(prefix + b'\r\n')
107
+
108
+ bytearr.extend(response.content)
109
+
110
+
111
+ def _coerce_to_bytes(data):
112
+ if not isinstance(data, bytes) and hasattr(data, 'encode'):
113
+ data = data.encode('utf-8')
114
+ # Don't bail out with an exception if data is None
115
+ return data if data is not None else b''
116
+
117
+
118
+ def dump_response(response, request_prefix=b'< ', response_prefix=b'> ',
119
+ data_array=None):
120
+ """Dump a single request-response cycle's information.
121
+
122
+ This will take a response object and dump only the data that requests can
123
+ see for that single request-response cycle.
124
+
125
+ Example::
126
+
127
+ import requests
128
+ from requests_toolbelt.utils import dump
129
+
130
+ resp = requests.get('https://api.github.com/users/sigmavirus24')
131
+ data = dump.dump_response(resp)
132
+ print(data.decode('utf-8'))
133
+
134
+ :param response:
135
+ The response to format
136
+ :type response: :class:`requests.Response`
137
+ :param request_prefix: (*optional*)
138
+ Bytes to prefix each line of the request data
139
+ :type request_prefix: :class:`bytes`
140
+ :param response_prefix: (*optional*)
141
+ Bytes to prefix each line of the response data
142
+ :type response_prefix: :class:`bytes`
143
+ :param data_array: (*optional*)
144
+ Bytearray to which we append the request-response cycle data
145
+ :type data_array: :class:`bytearray`
146
+ :returns: Formatted bytes of request and response information.
147
+ :rtype: :class:`bytearray`
148
+ """
149
+ data = data_array if data_array is not None else bytearray()
150
+ prefixes = PrefixSettings(request_prefix, response_prefix)
151
+
152
+ if not hasattr(response, 'request'):
153
+ raise ValueError('Response has no associated request')
154
+
155
+ proxy_info = _get_proxy_information(response)
156
+ _dump_request_data(response.request, prefixes, data,
157
+ proxy_info=proxy_info)
158
+ _dump_response_data(response, prefixes, data)
159
+ return data
160
+
161
+
162
+ def dump_all(response, request_prefix=b'< ', response_prefix=b'> '):
163
+ """Dump all requests and responses including redirects.
164
+
165
+ This takes the response returned by requests and will dump all
166
+ request-response pairs in the redirect history in order followed by the
167
+ final request-response.
168
+
169
+ Example::
170
+
171
+ import requests
172
+ from requests_toolbelt.utils import dump
173
+
174
+ resp = requests.get('https://httpbin.org/redirect/5')
175
+ data = dump.dump_all(resp)
176
+ print(data.decode('utf-8'))
177
+
178
+ :param response:
179
+ The response to format
180
+ :type response: :class:`requests.Response`
181
+ :param request_prefix: (*optional*)
182
+ Bytes to prefix each line of the request data
183
+ :type request_prefix: :class:`bytes`
184
+ :param response_prefix: (*optional*)
185
+ Bytes to prefix each line of the response data
186
+ :type response_prefix: :class:`bytes`
187
+ :returns: Formatted bytes of request and response information.
188
+ :rtype: :class:`bytearray`
189
+ """
190
+ data = bytearray()
191
+
192
+ history = list(response.history[:])
193
+ history.append(response)
194
+
195
+ for response in history:
196
+ dump_response(response, request_prefix, response_prefix, data)
197
+
198
+ return data
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/formdata.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Implementation of nested form-data encoding function(s)."""
3
+ from .._compat import basestring
4
+ from .._compat import urlencode as _urlencode
5
+
6
+
7
+ __all__ = ('urlencode',)
8
+
9
+
10
+ def urlencode(query, *args, **kwargs):
11
+ """Handle nested form-data queries and serialize them appropriately.
12
+
13
+ There are times when a website expects a nested form data query to be sent
14
+ but, the standard library's urlencode function does not appropriately
15
+ handle the nested structures. In that case, you need this function which
16
+ will flatten the structure first and then properly encode it for you.
17
+
18
+ When using this to send data in the body of a request, make sure you
19
+ specify the appropriate Content-Type header for the request.
20
+
21
+ .. code-block:: python
22
+
23
+ import requests
24
+ from requests_toolbelt.utils import formdata
25
+
26
+ query = {
27
+ 'my_dict': {
28
+ 'foo': 'bar',
29
+ 'biz': 'baz",
30
+ },
31
+ 'a': 'b',
32
+ }
33
+
34
+ resp = requests.get(url, params=formdata.urlencode(query))
35
+ # or
36
+ resp = requests.post(
37
+ url,
38
+ data=formdata.urlencode(query),
39
+ headers={
40
+ 'Content-Type': 'application/x-www-form-urlencoded'
41
+ },
42
+ )
43
+
44
+ Similarly, you can specify a list of nested tuples, e.g.,
45
+
46
+ .. code-block:: python
47
+
48
+ import requests
49
+ from requests_toolbelt.utils import formdata
50
+
51
+ query = [
52
+ ('my_list', [
53
+ ('foo', 'bar'),
54
+ ('biz', 'baz'),
55
+ ]),
56
+ ('a', 'b'),
57
+ ]
58
+
59
+ resp = requests.get(url, params=formdata.urlencode(query))
60
+ # or
61
+ resp = requests.post(
62
+ url,
63
+ data=formdata.urlencode(query),
64
+ headers={
65
+ 'Content-Type': 'application/x-www-form-urlencoded'
66
+ },
67
+ )
68
+
69
+ For additional parameter and return information, see the official
70
+ `urlencode`_ documentation.
71
+
72
+ .. _urlencode:
73
+ https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlencode
74
+ """
75
+ expand_classes = (dict, list, tuple)
76
+ original_query_list = _to_kv_list(query)
77
+
78
+ if not all(_is_two_tuple(i) for i in original_query_list):
79
+ raise ValueError("Expected query to be able to be converted to a "
80
+ "list comprised of length 2 tuples.")
81
+
82
+ query_list = original_query_list
83
+ while any(isinstance(v, expand_classes) for _, v in query_list):
84
+ query_list = _expand_query_values(query_list)
85
+
86
+ return _urlencode(query_list, *args, **kwargs)
87
+
88
+
89
+ def _to_kv_list(dict_or_list):
90
+ if hasattr(dict_or_list, 'items'):
91
+ return list(dict_or_list.items())
92
+ return dict_or_list
93
+
94
+
95
+ def _is_two_tuple(item):
96
+ return isinstance(item, (list, tuple)) and len(item) == 2
97
+
98
+
99
+ def _expand_query_values(original_query_list):
100
+ query_list = []
101
+ for key, value in original_query_list:
102
+ if isinstance(value, basestring):
103
+ query_list.append((key, value))
104
+ else:
105
+ key_fmt = key + '[%s]'
106
+ value_list = _to_kv_list(value)
107
+ query_list.extend((key_fmt % k, v) for k, v in value_list)
108
+ return query_list
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/utils/user_agent.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import collections
3
+ import platform
4
+ import sys
5
+
6
+
7
+ def user_agent(name, version, extras=None):
8
+ """Return an internet-friendly user_agent string.
9
+
10
+ The majority of this code has been wilfully stolen from the equivalent
11
+ function in Requests.
12
+
13
+ :param name: The intended name of the user-agent, e.g. "python-requests".
14
+ :param version: The version of the user-agent, e.g. "0.0.1".
15
+ :param extras: List of two-item tuples that are added to the user-agent
16
+ string.
17
+ :returns: Formatted user-agent string
18
+ :rtype: str
19
+ """
20
+ if extras is None:
21
+ extras = []
22
+
23
+ return UserAgentBuilder(
24
+ name, version
25
+ ).include_extras(
26
+ extras
27
+ ).include_implementation(
28
+ ).include_system().build()
29
+
30
+
31
+ class UserAgentBuilder(object):
32
+ """Class to provide a greater level of control than :func:`user_agent`.
33
+
34
+ This is used by :func:`user_agent` to build its User-Agent string.
35
+
36
+ .. code-block:: python
37
+
38
+ user_agent_str = UserAgentBuilder(
39
+ name='requests-toolbelt',
40
+ version='17.4.0',
41
+ ).include_implementation(
42
+ ).include_system(
43
+ ).include_extras([
44
+ ('requests', '2.14.2'),
45
+ ('urllib3', '1.21.2'),
46
+ ]).build()
47
+
48
+ """
49
+
50
+ format_string = '%s/%s'
51
+
52
+ def __init__(self, name, version):
53
+ """Initialize our builder with the name and version of our user agent.
54
+
55
+ :param str name:
56
+ Name of our user-agent.
57
+ :param str version:
58
+ The version string for user-agent.
59
+ """
60
+ self._pieces = collections.deque([(name, version)])
61
+
62
+ def build(self):
63
+ """Finalize the User-Agent string.
64
+
65
+ :returns:
66
+ Formatted User-Agent string.
67
+ :rtype:
68
+ str
69
+ """
70
+ return " ".join([self.format_string % piece for piece in self._pieces])
71
+
72
+ def include_extras(self, extras):
73
+ """Include extra portions of the User-Agent.
74
+
75
+ :param list extras:
76
+ list of tuples of extra-name and extra-version
77
+ """
78
+ if any(len(extra) != 2 for extra in extras):
79
+ raise ValueError('Extras should be a sequence of two item tuples.')
80
+
81
+ self._pieces.extend(extras)
82
+ return self
83
+
84
+ def include_implementation(self):
85
+ """Append the implementation string to the user-agent string.
86
+
87
+ This adds the the information that you're using CPython 2.7.13 to the
88
+ User-Agent.
89
+ """
90
+ self._pieces.append(_implementation_tuple())
91
+ return self
92
+
93
+ def include_system(self):
94
+ """Append the information about the Operating System."""
95
+ self._pieces.append(_platform_tuple())
96
+ return self
97
+
98
+
99
+ def _implementation_tuple():
100
+ """Return the tuple of interpreter name and version.
101
+
102
+ Returns a string that provides both the name and the version of the Python
103
+ implementation currently running. For example, on CPython 2.7.5 it will
104
+ return "CPython/2.7.5".
105
+
106
+ This function works best on CPython and PyPy: in particular, it probably
107
+ doesn't work for Jython or IronPython. Future investigation should be done
108
+ to work out the correct shape of the code for those platforms.
109
+ """
110
+ implementation = platform.python_implementation()
111
+
112
+ if implementation == 'CPython':
113
+ implementation_version = platform.python_version()
114
+ elif implementation == 'PyPy':
115
+ implementation_version = '%s.%s.%s' % (sys.pypy_version_info.major,
116
+ sys.pypy_version_info.minor,
117
+ sys.pypy_version_info.micro)
118
+ if sys.pypy_version_info.releaselevel != 'final':
119
+ implementation_version = ''.join([
120
+ implementation_version, sys.pypy_version_info.releaselevel
121
+ ])
122
+ elif implementation == 'Jython':
123
+ implementation_version = platform.python_version() # Complete Guess
124
+ elif implementation == 'IronPython':
125
+ implementation_version = platform.python_version() # Complete Guess
126
+ else:
127
+ implementation_version = 'Unknown'
128
+
129
+ return (implementation, implementation_version)
130
+
131
+
132
+ def _implementation_string():
133
+ return "%s/%s" % _implementation_tuple()
134
+
135
+
136
+ def _platform_tuple():
137
+ try:
138
+ p_system = platform.system()
139
+ p_release = platform.release()
140
+ except IOError:
141
+ p_system = 'Unknown'
142
+ p_release = 'Unknown'
143
+ return (p_system, p_release)
micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2020 Will McGugan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (7.54 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/__main__.cpython-311.pyc ADDED
Binary file (10.6 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_emoji_replace.cpython-311.pyc ADDED
Binary file (1.93 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_export_format.cpython-311.pyc ADDED
Binary file (2.36 kB). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_extension.cpython-311.pyc ADDED
Binary file (614 Bytes). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_fileno.cpython-311.pyc ADDED
Binary file (980 Bytes). View file
 
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__pycache__/_inspect.cpython-311.pyc ADDED
Binary file (14.4 kB). View file