Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests-2.34.0.dist-info/WHEEL +5 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests-2.34.0.dist-info/top_level.txt +1 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/INSTALLER +1 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/LICENSE +15 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/METADATA +270 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/RECORD +36 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/WHEEL +6 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/top_level.txt +1 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/__init__.py +20 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth1_auth.py +112 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth1_session.py +395 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth2_auth.py +36 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth2_session.py +587 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/AUTHORS.rst +57 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/INSTALLER +1 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/LICENSE +13 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/METADATA +521 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/RECORD +75 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/WHEEL +6 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/top_level.txt +1 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__init__.py +34 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/_compat.py +302 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/exceptions.py +25 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/sessions.py +89 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/streaming_iterator.py +116 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/INSTALLER +1 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/METADATA +479 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/RECORD +206 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/WHEEL +4 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__init__.py +177 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__main__.py +245 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_emoji_codes.py +0 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_emoji_replace.py +31 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_export_format.py +76 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_extension.py +10 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_fileno.py +24 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_inspect.py +272 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_log_render.py +94 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_loop.py +43 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_null_file.py +69 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_palettes.py +309 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_pick.py +17 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_ratio.py +153 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_spinners.py +482 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_stack.py +16 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_timer.py +19 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_win32_console.py +661 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_windows.py +71 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_windows_renderer.py +56 -0
- micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_wrap.py +93 -0
micromamba_root/envs/pytorch_env/Lib/site-packages/requests-2.34.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (82.0.1)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests-2.34.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
requests
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ISC License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2014 Kenneth Reitz.
|
| 4 |
+
|
| 5 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 6 |
+
purpose with or without fee is hereby granted, provided that the above
|
| 7 |
+
copyright notice and this permission notice appear in all copies.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 10 |
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 11 |
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 12 |
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 13 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 14 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 15 |
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: requests-oauthlib
|
| 3 |
+
Version: 2.0.0
|
| 4 |
+
Summary: OAuthlib authentication support for Requests.
|
| 5 |
+
Home-page: https://github.com/requests/requests-oauthlib
|
| 6 |
+
Author: Kenneth Reitz
|
| 7 |
+
Author-email: me@kennethreitz.com
|
| 8 |
+
License: ISC
|
| 9 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 10 |
+
Classifier: Intended Audience :: Developers
|
| 11 |
+
Classifier: Natural Language :: English
|
| 12 |
+
Classifier: License :: OSI Approved :: BSD License
|
| 13 |
+
Classifier: Programming Language :: Python
|
| 14 |
+
Classifier: Programming Language :: Python :: 3
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.4
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.5
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.6
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 24 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 25 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 26 |
+
Requires-Python: >=3.4
|
| 27 |
+
Description-Content-Type: text/x-rst
|
| 28 |
+
License-File: LICENSE
|
| 29 |
+
Requires-Dist: oauthlib >=3.0.0
|
| 30 |
+
Requires-Dist: requests >=2.0.0
|
| 31 |
+
Provides-Extra: rsa
|
| 32 |
+
Requires-Dist: oauthlib[signedtoken] >=3.0.0 ; extra == 'rsa'
|
| 33 |
+
|
| 34 |
+
Requests-OAuthlib |build-status| |coverage-status| |docs|
|
| 35 |
+
=========================================================
|
| 36 |
+
|
| 37 |
+
This project provides first-class OAuth library support for `Requests <https://requests.readthedocs.io>`_.
|
| 38 |
+
|
| 39 |
+
The OAuth 1 workflow
|
| 40 |
+
--------------------
|
| 41 |
+
|
| 42 |
+
OAuth 1 can seem overly complicated and it sure has its quirks. Luckily,
|
| 43 |
+
requests_oauthlib hides most of these and let you focus at the task at hand.
|
| 44 |
+
|
| 45 |
+
Accessing protected resources using requests_oauthlib is as simple as:
|
| 46 |
+
|
| 47 |
+
.. code-block:: pycon
|
| 48 |
+
|
| 49 |
+
>>> from requests_oauthlib import OAuth1Session
|
| 50 |
+
>>> twitter = OAuth1Session('client_key',
|
| 51 |
+
client_secret='client_secret',
|
| 52 |
+
resource_owner_key='resource_owner_key',
|
| 53 |
+
resource_owner_secret='resource_owner_secret')
|
| 54 |
+
>>> url = 'https://api.twitter.com/1/account/settings.json'
|
| 55 |
+
>>> r = twitter.get(url)
|
| 56 |
+
|
| 57 |
+
Before accessing resources you will need to obtain a few credentials from your
|
| 58 |
+
provider (e.g. Twitter) and authorization from the user for whom you wish to
|
| 59 |
+
retrieve resources for. You can read all about this in the full
|
| 60 |
+
`OAuth 1 workflow guide on RTD <https://requests-oauthlib.readthedocs.io/en/latest/oauth1_workflow.html>`_.
|
| 61 |
+
|
| 62 |
+
The OAuth 2 workflow
|
| 63 |
+
--------------------
|
| 64 |
+
|
| 65 |
+
OAuth 2 is generally simpler than OAuth 1 but comes in more flavours. The most
|
| 66 |
+
common being the Authorization Code Grant, also known as the WebApplication
|
| 67 |
+
flow.
|
| 68 |
+
|
| 69 |
+
Fetching a protected resource after obtaining an access token can be extremely
|
| 70 |
+
simple. However, before accessing resources you will need to obtain a few
|
| 71 |
+
credentials from your provider (e.g. Google) and authorization from the user
|
| 72 |
+
for whom you wish to retrieve resources for. You can read all about this in the
|
| 73 |
+
full `OAuth 2 workflow guide on RTD <https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html>`_.
|
| 74 |
+
|
| 75 |
+
Installation
|
| 76 |
+
-------------
|
| 77 |
+
|
| 78 |
+
To install requests and requests_oauthlib you can use pip:
|
| 79 |
+
|
| 80 |
+
.. code-block:: bash
|
| 81 |
+
|
| 82 |
+
pip install requests requests-oauthlib
|
| 83 |
+
|
| 84 |
+
.. |build-status| image:: https://github.com/requests/requests-oauthlib/actions/workflows/run-tests.yml/badge.svg
|
| 85 |
+
:target: https://github.com/requests/requests-oauthlib/actions
|
| 86 |
+
.. |coverage-status| image:: https://img.shields.io/coveralls/requests/requests-oauthlib.svg
|
| 87 |
+
:target: https://coveralls.io/r/requests/requests-oauthlib
|
| 88 |
+
.. |docs| image:: https://readthedocs.org/projects/requests-oauthlib/badge/
|
| 89 |
+
:alt: Documentation Status
|
| 90 |
+
:scale: 100%
|
| 91 |
+
:target: https://requests-oauthlib.readthedocs.io/
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
History
|
| 95 |
+
-------
|
| 96 |
+
|
| 97 |
+
v2.0.0 (22 March 2024)
|
| 98 |
+
++++++++++++++++++++++++
|
| 99 |
+
|
| 100 |
+
Full set of changes are in [github](https://github.com/requests/requests-oauthlib/milestone/4?closed=1).
|
| 101 |
+
|
| 102 |
+
Additions & changes:
|
| 103 |
+
|
| 104 |
+
- ``OAuth2Session`` now correctly uses the ``self.verify`` value if ``verify``
|
| 105 |
+
is not overridden in ``fetch_token`` and ``refresh_token``. Fixes `#404
|
| 106 |
+
<https://github.com/requests/requests-oauthlib/issues/404>`_.
|
| 107 |
+
- ``OAuth2Session`` constructor now uses its ``client.scope`` when a ``client``
|
| 108 |
+
is provided and ``scope`` is not overridden. Fixes `#408
|
| 109 |
+
<https://github.com/requests/requests-oauthlib/issues/408>`_
|
| 110 |
+
- Add ``refresh_token_request`` and ``access_token_request`` compliance hooks
|
| 111 |
+
- Add PKCE support and Auth0 example
|
| 112 |
+
- Add support for Python 3.8-3.12
|
| 113 |
+
- Remove support of Python 2.x, <3.7
|
| 114 |
+
- Migrated to Github Action
|
| 115 |
+
- Updated dependencies
|
| 116 |
+
- Cleanup some docs and examples
|
| 117 |
+
|
| 118 |
+
v1.4.0 (27 Feb 2024)
|
| 119 |
+
++++++++++++++++++++++++
|
| 120 |
+
|
| 121 |
+
- Version 2.0.0 published initially as 1.4.0, it was yanked eventually.
|
| 122 |
+
|
| 123 |
+
v1.3.1 (21 January 2022)
|
| 124 |
+
++++++++++++++++++++++++
|
| 125 |
+
|
| 126 |
+
- Add initial support for OAuth Mutual TLS (draft-ietf-oauth-mtls)
|
| 127 |
+
- Removed outdated LinkedIn Compliance Fixes
|
| 128 |
+
- Add eBay compliance fix
|
| 129 |
+
- Add Spotify OAuth 2 Tutorial
|
| 130 |
+
- Add support for python 3.8, 3.9
|
| 131 |
+
- Fixed LinkedIn Compliance Fixes
|
| 132 |
+
- Fixed ReadTheDocs Documentation and sphinx errors
|
| 133 |
+
- Moved pipeline to GitHub Actions
|
| 134 |
+
|
| 135 |
+
v1.3.0 (6 November 2019)
|
| 136 |
+
++++++++++++++++++++++++
|
| 137 |
+
|
| 138 |
+
- Instagram compliance fix
|
| 139 |
+
- Added ``force_querystring`` argument to fetch_token() method on OAuth2Session
|
| 140 |
+
|
| 141 |
+
v1.2.0 (14 January 2019)
|
| 142 |
+
++++++++++++++++++++++++
|
| 143 |
+
|
| 144 |
+
- This project now depends on OAuthlib 3.0.0 and above. It does **not** support
|
| 145 |
+
versions of OAuthlib before 3.0.0.
|
| 146 |
+
- Updated oauth2 tests to use 'sess' for an OAuth2Session instance instead of `auth`
|
| 147 |
+
because OAuth2Session objects and methods acceept an `auth` paramether which is
|
| 148 |
+
typically an instance of `requests.auth.HTTPBasicAuth`
|
| 149 |
+
- `OAuth2Session.fetch_token` previously tried to guess how and where to provide
|
| 150 |
+
"client" and "user" credentials incorrectly. This was incompatible with some
|
| 151 |
+
OAuth servers and incompatible with breaking changes in oauthlib that seek to
|
| 152 |
+
correctly provide the `client_id`. The older implementation also did not raise
|
| 153 |
+
the correct exceptions when username and password are not present on Legacy
|
| 154 |
+
clients.
|
| 155 |
+
- Avoid automatic netrc authentication for OAuth2Session.
|
| 156 |
+
|
| 157 |
+
v1.1.0 (9 January 2019)
|
| 158 |
+
+++++++++++++++++++++++
|
| 159 |
+
|
| 160 |
+
- Adjusted version specifier for ``oauthlib`` dependency: this project is
|
| 161 |
+
not yet compatible with ``oauthlib`` 3.0.0.
|
| 162 |
+
- Dropped dependency on ``nose``.
|
| 163 |
+
- Minor changes to clean up the code and make it more readable/maintainable.
|
| 164 |
+
|
| 165 |
+
v1.0.0 (4 June 2018)
|
| 166 |
+
++++++++++++++++++++
|
| 167 |
+
|
| 168 |
+
- **Removed support for Python 2.6 and Python 3.3.**
|
| 169 |
+
This project now supports Python 2.7, and Python 3.4 and above.
|
| 170 |
+
- Added several examples to the documentation.
|
| 171 |
+
- Added plentymarkets compliance fix.
|
| 172 |
+
- Added a ``token`` property to OAuth1Session, to match the corresponding
|
| 173 |
+
``token`` property on OAuth2Session.
|
| 174 |
+
|
| 175 |
+
v0.8.0 (14 February 2017)
|
| 176 |
+
+++++++++++++++++++++++++
|
| 177 |
+
|
| 178 |
+
- Added Fitbit compliance fix.
|
| 179 |
+
- Fixed an issue where newlines in the response body for the access token
|
| 180 |
+
request would cause errors when trying to extract the token.
|
| 181 |
+
- Fixed an issue introduced in v0.7.0 where users passing ``auth`` to several
|
| 182 |
+
methods would encounter conflicts with the ``client_id`` and
|
| 183 |
+
``client_secret``-derived auth. The user-supplied ``auth`` argument is now
|
| 184 |
+
used in preference to those options.
|
| 185 |
+
|
| 186 |
+
v0.7.0 (22 September 2016)
|
| 187 |
+
++++++++++++++++++++++++++
|
| 188 |
+
|
| 189 |
+
- Allowed ``OAuth2Session.request`` to take the ``client_id`` and
|
| 190 |
+
``client_secret`` parameters for the purposes of automatic token refresh,
|
| 191 |
+
which may need them.
|
| 192 |
+
|
| 193 |
+
v0.6.2 (12 July 2016)
|
| 194 |
+
+++++++++++++++++++++
|
| 195 |
+
|
| 196 |
+
- Use ``client_id`` and ``client_secret`` for the Authorization header if
|
| 197 |
+
provided.
|
| 198 |
+
- Allow explicit bypass of the Authorization header by setting ``auth=False``.
|
| 199 |
+
- Pass through the ``proxies`` kwarg when refreshing tokens.
|
| 200 |
+
- Miscellaneous cleanups.
|
| 201 |
+
|
| 202 |
+
v0.6.1 (19 February 2016)
|
| 203 |
+
+++++++++++++++++++++++++
|
| 204 |
+
|
| 205 |
+
- Fixed a bug when sending authorization in headers with no username and
|
| 206 |
+
password present.
|
| 207 |
+
- Make sure we clear the session token before obtaining a new one.
|
| 208 |
+
- Some improvements to the Slack compliance fix.
|
| 209 |
+
- Avoid timing problems around token refresh.
|
| 210 |
+
- Allow passing arbitrary arguments to requests when calling
|
| 211 |
+
``fetch_request_token`` and ``fetch_access_token``.
|
| 212 |
+
|
| 213 |
+
v0.6.0 (14 December 2015)
|
| 214 |
+
+++++++++++++++++++++++++
|
| 215 |
+
|
| 216 |
+
- Add compliance fix for Slack.
|
| 217 |
+
- Add compliance fix for Mailchimp.
|
| 218 |
+
- ``TokenRequestDenied`` exceptions now carry the entire response, not just the
|
| 219 |
+
status code.
|
| 220 |
+
- Pass through keyword arguments when refreshing tokens automatically.
|
| 221 |
+
- Send authorization in headers, not just body, to maximize compatibility.
|
| 222 |
+
- More getters/setters available for OAuth2 session client values.
|
| 223 |
+
- Allow sending custom headers when refreshing tokens, and set some defaults.
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
v0.5.0 (4 May 2015)
|
| 227 |
+
+++++++++++++++++++
|
| 228 |
+
- Fix ``TypeError`` being raised instead of ``TokenMissing`` error.
|
| 229 |
+
- Raise requests exceptions on 4XX and 5XX responses in the OAuth2 flow.
|
| 230 |
+
- Avoid ``AttributeError`` when initializing the ``OAuth2Session`` class
|
| 231 |
+
without complete client information.
|
| 232 |
+
|
| 233 |
+
v0.4.2 (16 October 2014)
|
| 234 |
+
++++++++++++++++++++++++
|
| 235 |
+
- New ``authorized`` property on OAuth1Session and OAuth2Session, which allows
|
| 236 |
+
you to easily determine if the session is already authorized with OAuth tokens
|
| 237 |
+
or not.
|
| 238 |
+
- New ``TokenMissing`` and ``VerifierMissing`` exception classes for OAuth1Session:
|
| 239 |
+
this will make it easier to catch and identify these exceptions.
|
| 240 |
+
|
| 241 |
+
v0.4.1 (6 June 2014)
|
| 242 |
+
++++++++++++++++++++
|
| 243 |
+
- New install target ``[rsa]`` for people using OAuth1 RSA-SHA1 signature
|
| 244 |
+
method.
|
| 245 |
+
- Fixed bug in OAuth2 where supplied state param was not used in auth url.
|
| 246 |
+
- OAuth2 HTTPS checking can be disabled by setting environment variable
|
| 247 |
+
``OAUTHLIB_INSECURE_TRANSPORT``.
|
| 248 |
+
- OAuth1 now re-authorize upon redirects.
|
| 249 |
+
- OAuth1 token fetching now raise a detailed error message when the
|
| 250 |
+
response body is incorrectly encoded or the request was denied.
|
| 251 |
+
- Added support for custom OAuth1 clients.
|
| 252 |
+
- OAuth2 compliance fix for Sina Weibo.
|
| 253 |
+
- Multiple fixes to facebook compliance fix.
|
| 254 |
+
- Compliance fixes now re-encode body properly as bytes in Python 3.
|
| 255 |
+
- Logging now properly done under ``requests_oauthlib`` namespace instead
|
| 256 |
+
of piggybacking on oauthlib namespace.
|
| 257 |
+
- Logging introduced for OAuth1 auth and session.
|
| 258 |
+
|
| 259 |
+
v0.4.0 (29 September 2013)
|
| 260 |
+
++++++++++++++++++++++++++
|
| 261 |
+
- OAuth1Session methods only return unicode strings. #55.
|
| 262 |
+
- Renamed requests_oauthlib.core to requests_oauthlib.oauth1_auth for consistency. #79.
|
| 263 |
+
- Added Facebook compliance fix and access_token_response hook to OAuth2Session. #63.
|
| 264 |
+
- Added LinkedIn compliance fix.
|
| 265 |
+
- Added refresh_token_response compliance hook, invoked before parsing the refresh token.
|
| 266 |
+
- Correctly limit compliance hooks to running only once!
|
| 267 |
+
- Content type guessing should only be done when no content type is given
|
| 268 |
+
- OAuth1 now updates r.headers instead of replacing it with non case insensitive dict
|
| 269 |
+
- Remove last use of Response.content (in OAuth1Session). #44.
|
| 270 |
+
- State param can now be supplied in OAuth2Session.authorize_url
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests_oauthlib-2.0.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
requests_oauthlib-2.0.0.dist-info/LICENSE,sha256=rgGEavrYqCkf5qCJZvMBWvmo_2ddhLmB-Xk8Ei94dug,745
|
| 3 |
+
requests_oauthlib-2.0.0.dist-info/METADATA,sha256=fYXqOcFm2fIyb4nO6QYzHSyA7S3epNMe_AIABrR_yso,11133
|
| 4 |
+
requests_oauthlib-2.0.0.dist-info/RECORD,,
|
| 5 |
+
requests_oauthlib-2.0.0.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
|
| 6 |
+
requests_oauthlib-2.0.0.dist-info/top_level.txt,sha256=vx1R42DWBO64h6iu8Gco0F01TVTPWXSRWBaV1GwVRTQ,18
|
| 7 |
+
requests_oauthlib/__init__.py,sha256=chvYiICdcieGrRc_e5WtFxaXq6T_esmicL_BLWDend4,548
|
| 8 |
+
requests_oauthlib/__pycache__/__init__.cpython-311.pyc,,
|
| 9 |
+
requests_oauthlib/__pycache__/oauth1_auth.cpython-311.pyc,,
|
| 10 |
+
requests_oauthlib/__pycache__/oauth1_session.cpython-311.pyc,,
|
| 11 |
+
requests_oauthlib/__pycache__/oauth2_auth.cpython-311.pyc,,
|
| 12 |
+
requests_oauthlib/__pycache__/oauth2_session.cpython-311.pyc,,
|
| 13 |
+
requests_oauthlib/compliance_fixes/__init__.py,sha256=e0qXlL1FTbe7kxTLFmTYN9ipFNZks-sgGiYqhryBobw,377
|
| 14 |
+
requests_oauthlib/compliance_fixes/__pycache__/__init__.cpython-311.pyc,,
|
| 15 |
+
requests_oauthlib/compliance_fixes/__pycache__/douban.cpython-311.pyc,,
|
| 16 |
+
requests_oauthlib/compliance_fixes/__pycache__/ebay.cpython-311.pyc,,
|
| 17 |
+
requests_oauthlib/compliance_fixes/__pycache__/facebook.cpython-311.pyc,,
|
| 18 |
+
requests_oauthlib/compliance_fixes/__pycache__/fitbit.cpython-311.pyc,,
|
| 19 |
+
requests_oauthlib/compliance_fixes/__pycache__/instagram.cpython-311.pyc,,
|
| 20 |
+
requests_oauthlib/compliance_fixes/__pycache__/mailchimp.cpython-311.pyc,,
|
| 21 |
+
requests_oauthlib/compliance_fixes/__pycache__/plentymarkets.cpython-311.pyc,,
|
| 22 |
+
requests_oauthlib/compliance_fixes/__pycache__/slack.cpython-311.pyc,,
|
| 23 |
+
requests_oauthlib/compliance_fixes/__pycache__/weibo.cpython-311.pyc,,
|
| 24 |
+
requests_oauthlib/compliance_fixes/douban.py,sha256=9RTafRu0nWyiAn9r8502CEY6yvozcanXV2pwnKPUJNw,413
|
| 25 |
+
requests_oauthlib/compliance_fixes/ebay.py,sha256=NRUxIMKVMP0QULur9REutsyZIqIP_AwOANjlji9ZgAE,832
|
| 26 |
+
requests_oauthlib/compliance_fixes/facebook.py,sha256=rybiH839YwzyY13SiGA676iHCBTh3mqFdam5tqx041I,995
|
| 27 |
+
requests_oauthlib/compliance_fixes/fitbit.py,sha256=cI4PPpTnXJpZw1SY-N8ocshV2pVvep679d_pRIJPImg,846
|
| 28 |
+
requests_oauthlib/compliance_fixes/instagram.py,sha256=YEvXWKmhM6yY4k378V2mNll4VKyOJkZBH0fRvU6fDM0,875
|
| 29 |
+
requests_oauthlib/compliance_fixes/mailchimp.py,sha256=SVFQlnbuXZCLeKv6Ymhg9eSBScHCXV93PXLHWhUPAN0,679
|
| 30 |
+
requests_oauthlib/compliance_fixes/plentymarkets.py,sha256=s7lrTZhINakiKjlbOISTeHTSXsNkcG8wfKcEVlQUMos,737
|
| 31 |
+
requests_oauthlib/compliance_fixes/slack.py,sha256=4ZQg1ny0vU-hf8NJjKwgZEggH2OB7N3aJ9Gt2v7cVc4,1380
|
| 32 |
+
requests_oauthlib/compliance_fixes/weibo.py,sha256=TL8uu4XMD_Mh9tXIKMNA8TT1gOIraBipTKoXkSpR2sM,385
|
| 33 |
+
requests_oauthlib/oauth1_auth.py,sha256=F3XfhVODV80nnCEPDHueU1gmqxhhjGTmnDEYGtRYwJc,3604
|
| 34 |
+
requests_oauthlib/oauth1_session.py,sha256=A6j7CgQ8n2Ir4An-8U0J9lyUNeY8H5Wff5I5PWHzlHc,16942
|
| 35 |
+
requests_oauthlib/oauth2_auth.py,sha256=MXs8vIbBOhXj9NLiw_-J24k56L_XRJ0tFH_EMpshYUk,1508
|
| 36 |
+
requests_oauthlib/oauth2_session.py,sha256=K4XtdpNTiU6Dq8JvEsj8aUpMdavWSCZAuTOc_xhZcBw,23932
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.43.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py2-none-any
|
| 5 |
+
Tag: py3-none-any
|
| 6 |
+
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib-2.0.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
requests_oauthlib
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ruff: noqa: F401
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
from .oauth1_auth import OAuth1
|
| 5 |
+
from .oauth1_session import OAuth1Session
|
| 6 |
+
from .oauth2_auth import OAuth2
|
| 7 |
+
from .oauth2_session import OAuth2Session, TokenUpdated
|
| 8 |
+
|
| 9 |
+
__version__ = "2.0.0"
|
| 10 |
+
|
| 11 |
+
import requests
|
| 12 |
+
|
| 13 |
+
if requests.__version__ < "2.0.0":
|
| 14 |
+
msg = (
|
| 15 |
+
"You are using requests version %s, which is older than "
|
| 16 |
+
"requests-oauthlib expects, please upgrade to 2.0.0 or later."
|
| 17 |
+
)
|
| 18 |
+
raise Warning(msg % requests.__version__)
|
| 19 |
+
|
| 20 |
+
logging.getLogger("requests_oauthlib").addHandler(logging.NullHandler())
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth1_auth.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
from oauthlib.common import extract_params
|
| 5 |
+
from oauthlib.oauth1 import Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER
|
| 6 |
+
from oauthlib.oauth1 import SIGNATURE_TYPE_BODY
|
| 7 |
+
from requests.utils import to_native_string
|
| 8 |
+
from requests.auth import AuthBase
|
| 9 |
+
|
| 10 |
+
CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded"
|
| 11 |
+
CONTENT_TYPE_MULTI_PART = "multipart/form-data"
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
log = logging.getLogger(__name__)
|
| 15 |
+
|
| 16 |
+
# OBS!: Correct signing of requests are conditional on invoking OAuth1
|
| 17 |
+
# as the last step of preparing a request, or at least having the
|
| 18 |
+
# content-type set properly.
|
| 19 |
+
class OAuth1(AuthBase):
|
| 20 |
+
"""Signs the request using OAuth 1 (RFC5849)"""
|
| 21 |
+
|
| 22 |
+
client_class = Client
|
| 23 |
+
|
| 24 |
+
def __init__(
|
| 25 |
+
self,
|
| 26 |
+
client_key,
|
| 27 |
+
client_secret=None,
|
| 28 |
+
resource_owner_key=None,
|
| 29 |
+
resource_owner_secret=None,
|
| 30 |
+
callback_uri=None,
|
| 31 |
+
signature_method=SIGNATURE_HMAC,
|
| 32 |
+
signature_type=SIGNATURE_TYPE_AUTH_HEADER,
|
| 33 |
+
rsa_key=None,
|
| 34 |
+
verifier=None,
|
| 35 |
+
decoding="utf-8",
|
| 36 |
+
client_class=None,
|
| 37 |
+
force_include_body=False,
|
| 38 |
+
**kwargs
|
| 39 |
+
):
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
signature_type = signature_type.upper()
|
| 43 |
+
except AttributeError:
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
client_class = client_class or self.client_class
|
| 47 |
+
|
| 48 |
+
self.force_include_body = force_include_body
|
| 49 |
+
|
| 50 |
+
self.client = client_class(
|
| 51 |
+
client_key,
|
| 52 |
+
client_secret,
|
| 53 |
+
resource_owner_key,
|
| 54 |
+
resource_owner_secret,
|
| 55 |
+
callback_uri,
|
| 56 |
+
signature_method,
|
| 57 |
+
signature_type,
|
| 58 |
+
rsa_key,
|
| 59 |
+
verifier,
|
| 60 |
+
decoding=decoding,
|
| 61 |
+
**kwargs
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
def __call__(self, r):
|
| 65 |
+
"""Add OAuth parameters to the request.
|
| 66 |
+
|
| 67 |
+
Parameters may be included from the body if the content-type is
|
| 68 |
+
urlencoded, if no content type is set a guess is made.
|
| 69 |
+
"""
|
| 70 |
+
# Overwriting url is safe here as request will not modify it past
|
| 71 |
+
# this point.
|
| 72 |
+
log.debug("Signing request %s using client %s", r, self.client)
|
| 73 |
+
|
| 74 |
+
content_type = r.headers.get("Content-Type", "")
|
| 75 |
+
if (
|
| 76 |
+
not content_type
|
| 77 |
+
and extract_params(r.body)
|
| 78 |
+
or self.client.signature_type == SIGNATURE_TYPE_BODY
|
| 79 |
+
):
|
| 80 |
+
content_type = CONTENT_TYPE_FORM_URLENCODED
|
| 81 |
+
if not isinstance(content_type, str):
|
| 82 |
+
content_type = content_type.decode("utf-8")
|
| 83 |
+
|
| 84 |
+
is_form_encoded = CONTENT_TYPE_FORM_URLENCODED in content_type
|
| 85 |
+
|
| 86 |
+
log.debug(
|
| 87 |
+
"Including body in call to sign: %s",
|
| 88 |
+
is_form_encoded or self.force_include_body,
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
if is_form_encoded:
|
| 92 |
+
r.headers["Content-Type"] = CONTENT_TYPE_FORM_URLENCODED
|
| 93 |
+
r.url, headers, r.body = self.client.sign(
|
| 94 |
+
str(r.url), str(r.method), r.body or "", r.headers
|
| 95 |
+
)
|
| 96 |
+
elif self.force_include_body:
|
| 97 |
+
# To allow custom clients to work on non form encoded bodies.
|
| 98 |
+
r.url, headers, r.body = self.client.sign(
|
| 99 |
+
str(r.url), str(r.method), r.body or "", r.headers
|
| 100 |
+
)
|
| 101 |
+
else:
|
| 102 |
+
# Omit body data in the signing of non form-encoded requests
|
| 103 |
+
r.url, headers, _ = self.client.sign(
|
| 104 |
+
str(r.url), str(r.method), None, r.headers
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
r.prepare_headers(headers)
|
| 108 |
+
r.url = to_native_string(r.url)
|
| 109 |
+
log.debug("Updated url: %s", r.url)
|
| 110 |
+
log.debug("Updated headers: %s", headers)
|
| 111 |
+
log.debug("Updated body: %r", r.body)
|
| 112 |
+
return r
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth1_session.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from urllib.parse import urlparse
|
| 2 |
+
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
from oauthlib.common import add_params_to_uri
|
| 6 |
+
from oauthlib.common import urldecode as _urldecode
|
| 7 |
+
from oauthlib.oauth1 import SIGNATURE_HMAC, SIGNATURE_RSA, SIGNATURE_TYPE_AUTH_HEADER
|
| 8 |
+
import requests
|
| 9 |
+
|
| 10 |
+
from . import OAuth1
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
log = logging.getLogger(__name__)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def urldecode(body):
|
| 17 |
+
"""Parse query or json to python dictionary"""
|
| 18 |
+
try:
|
| 19 |
+
return _urldecode(body)
|
| 20 |
+
except Exception:
|
| 21 |
+
import json
|
| 22 |
+
|
| 23 |
+
return json.loads(body)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class TokenRequestDenied(ValueError):
|
| 27 |
+
def __init__(self, message, response):
|
| 28 |
+
super(TokenRequestDenied, self).__init__(message)
|
| 29 |
+
self.response = response
|
| 30 |
+
|
| 31 |
+
@property
|
| 32 |
+
def status_code(self):
|
| 33 |
+
"""For backwards-compatibility purposes"""
|
| 34 |
+
return self.response.status_code
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class TokenMissing(ValueError):
|
| 38 |
+
def __init__(self, message, response):
|
| 39 |
+
super(TokenMissing, self).__init__(message)
|
| 40 |
+
self.response = response
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class VerifierMissing(ValueError):
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class OAuth1Session(requests.Session):
|
| 48 |
+
"""Request signing and convenience methods for the oauth dance.
|
| 49 |
+
|
| 50 |
+
What is the difference between OAuth1Session and OAuth1?
|
| 51 |
+
|
| 52 |
+
OAuth1Session actually uses OAuth1 internally and its purpose is to assist
|
| 53 |
+
in the OAuth workflow through convenience methods to prepare authorization
|
| 54 |
+
URLs and parse the various token and redirection responses. It also provide
|
| 55 |
+
rudimentary validation of responses.
|
| 56 |
+
|
| 57 |
+
An example of the OAuth workflow using a basic CLI app and Twitter.
|
| 58 |
+
|
| 59 |
+
>>> # Credentials obtained during the registration.
|
| 60 |
+
>>> client_key = 'client key'
|
| 61 |
+
>>> client_secret = 'secret'
|
| 62 |
+
>>> callback_uri = 'https://127.0.0.1/callback'
|
| 63 |
+
>>>
|
| 64 |
+
>>> # Endpoints found in the OAuth provider API documentation
|
| 65 |
+
>>> request_token_url = 'https://api.twitter.com/oauth/request_token'
|
| 66 |
+
>>> authorization_url = 'https://api.twitter.com/oauth/authorize'
|
| 67 |
+
>>> access_token_url = 'https://api.twitter.com/oauth/access_token'
|
| 68 |
+
>>>
|
| 69 |
+
>>> oauth_session = OAuth1Session(client_key,client_secret=client_secret, callback_uri=callback_uri)
|
| 70 |
+
>>>
|
| 71 |
+
>>> # First step, fetch the request token.
|
| 72 |
+
>>> oauth_session.fetch_request_token(request_token_url)
|
| 73 |
+
{
|
| 74 |
+
'oauth_token': 'kjerht2309u',
|
| 75 |
+
'oauth_token_secret': 'lsdajfh923874',
|
| 76 |
+
}
|
| 77 |
+
>>>
|
| 78 |
+
>>> # Second step. Follow this link and authorize
|
| 79 |
+
>>> oauth_session.authorization_url(authorization_url)
|
| 80 |
+
'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&oauth_callback=https%3A%2F%2F127.0.0.1%2Fcallback'
|
| 81 |
+
>>>
|
| 82 |
+
>>> # Third step. Fetch the access token
|
| 83 |
+
>>> redirect_response = input('Paste the full redirect URL here.')
|
| 84 |
+
>>> oauth_session.parse_authorization_response(redirect_response)
|
| 85 |
+
{
|
| 86 |
+
'oauth_token: 'kjerht2309u',
|
| 87 |
+
'oauth_token_secret: 'lsdajfh923874',
|
| 88 |
+
'oauth_verifier: 'w34o8967345',
|
| 89 |
+
}
|
| 90 |
+
>>> oauth_session.fetch_access_token(access_token_url)
|
| 91 |
+
{
|
| 92 |
+
'oauth_token': 'sdf0o9823sjdfsdf',
|
| 93 |
+
'oauth_token_secret': '2kjshdfp92i34asdasd',
|
| 94 |
+
}
|
| 95 |
+
>>> # Done. You can now make OAuth requests.
|
| 96 |
+
>>> status_url = 'http://api.twitter.com/1/statuses/update.json'
|
| 97 |
+
>>> new_status = {'status': 'hello world!'}
|
| 98 |
+
>>> oauth_session.post(status_url, data=new_status)
|
| 99 |
+
<Response [200]>
|
| 100 |
+
"""
|
| 101 |
+
|
| 102 |
+
def __init__(
|
| 103 |
+
self,
|
| 104 |
+
client_key,
|
| 105 |
+
client_secret=None,
|
| 106 |
+
resource_owner_key=None,
|
| 107 |
+
resource_owner_secret=None,
|
| 108 |
+
callback_uri=None,
|
| 109 |
+
signature_method=SIGNATURE_HMAC,
|
| 110 |
+
signature_type=SIGNATURE_TYPE_AUTH_HEADER,
|
| 111 |
+
rsa_key=None,
|
| 112 |
+
verifier=None,
|
| 113 |
+
client_class=None,
|
| 114 |
+
force_include_body=False,
|
| 115 |
+
**kwargs
|
| 116 |
+
):
|
| 117 |
+
"""Construct the OAuth 1 session.
|
| 118 |
+
|
| 119 |
+
:param client_key: A client specific identifier.
|
| 120 |
+
:param client_secret: A client specific secret used to create HMAC and
|
| 121 |
+
plaintext signatures.
|
| 122 |
+
:param resource_owner_key: A resource owner key, also referred to as
|
| 123 |
+
request token or access token depending on
|
| 124 |
+
when in the workflow it is used.
|
| 125 |
+
:param resource_owner_secret: A resource owner secret obtained with
|
| 126 |
+
either a request or access token. Often
|
| 127 |
+
referred to as token secret.
|
| 128 |
+
:param callback_uri: The URL the user is redirect back to after
|
| 129 |
+
authorization.
|
| 130 |
+
:param signature_method: Signature methods determine how the OAuth
|
| 131 |
+
signature is created. The three options are
|
| 132 |
+
oauthlib.oauth1.SIGNATURE_HMAC (default),
|
| 133 |
+
oauthlib.oauth1.SIGNATURE_RSA and
|
| 134 |
+
oauthlib.oauth1.SIGNATURE_PLAIN.
|
| 135 |
+
:param signature_type: Signature type decides where the OAuth
|
| 136 |
+
parameters are added. Either in the
|
| 137 |
+
Authorization header (default) or to the URL
|
| 138 |
+
query parameters or the request body. Defined as
|
| 139 |
+
oauthlib.oauth1.SIGNATURE_TYPE_AUTH_HEADER,
|
| 140 |
+
oauthlib.oauth1.SIGNATURE_TYPE_QUERY and
|
| 141 |
+
oauthlib.oauth1.SIGNATURE_TYPE_BODY
|
| 142 |
+
respectively.
|
| 143 |
+
:param rsa_key: The private RSA key as a string. Can only be used with
|
| 144 |
+
signature_method=oauthlib.oauth1.SIGNATURE_RSA.
|
| 145 |
+
:param verifier: A verifier string to prove authorization was granted.
|
| 146 |
+
:param client_class: A subclass of `oauthlib.oauth1.Client` to use with
|
| 147 |
+
`requests_oauthlib.OAuth1` instead of the default
|
| 148 |
+
:param force_include_body: Always include the request body in the
|
| 149 |
+
signature creation.
|
| 150 |
+
:param **kwargs: Additional keyword arguments passed to `OAuth1`
|
| 151 |
+
"""
|
| 152 |
+
super(OAuth1Session, self).__init__()
|
| 153 |
+
self._client = OAuth1(
|
| 154 |
+
client_key,
|
| 155 |
+
client_secret=client_secret,
|
| 156 |
+
resource_owner_key=resource_owner_key,
|
| 157 |
+
resource_owner_secret=resource_owner_secret,
|
| 158 |
+
callback_uri=callback_uri,
|
| 159 |
+
signature_method=signature_method,
|
| 160 |
+
signature_type=signature_type,
|
| 161 |
+
rsa_key=rsa_key,
|
| 162 |
+
verifier=verifier,
|
| 163 |
+
client_class=client_class,
|
| 164 |
+
force_include_body=force_include_body,
|
| 165 |
+
**kwargs
|
| 166 |
+
)
|
| 167 |
+
self.auth = self._client
|
| 168 |
+
|
| 169 |
+
@property
|
| 170 |
+
def token(self):
|
| 171 |
+
oauth_token = self._client.client.resource_owner_key
|
| 172 |
+
oauth_token_secret = self._client.client.resource_owner_secret
|
| 173 |
+
oauth_verifier = self._client.client.verifier
|
| 174 |
+
|
| 175 |
+
token_dict = {}
|
| 176 |
+
if oauth_token:
|
| 177 |
+
token_dict["oauth_token"] = oauth_token
|
| 178 |
+
if oauth_token_secret:
|
| 179 |
+
token_dict["oauth_token_secret"] = oauth_token_secret
|
| 180 |
+
if oauth_verifier:
|
| 181 |
+
token_dict["oauth_verifier"] = oauth_verifier
|
| 182 |
+
|
| 183 |
+
return token_dict
|
| 184 |
+
|
| 185 |
+
@token.setter
|
| 186 |
+
def token(self, value):
|
| 187 |
+
self._populate_attributes(value)
|
| 188 |
+
|
| 189 |
+
@property
|
| 190 |
+
def authorized(self):
|
| 191 |
+
"""Boolean that indicates whether this session has an OAuth token
|
| 192 |
+
or not. If `self.authorized` is True, you can reasonably expect
|
| 193 |
+
OAuth-protected requests to the resource to succeed. If
|
| 194 |
+
`self.authorized` is False, you need the user to go through the OAuth
|
| 195 |
+
authentication dance before OAuth-protected requests to the resource
|
| 196 |
+
will succeed.
|
| 197 |
+
"""
|
| 198 |
+
if self._client.client.signature_method == SIGNATURE_RSA:
|
| 199 |
+
# RSA only uses resource_owner_key
|
| 200 |
+
return bool(self._client.client.resource_owner_key)
|
| 201 |
+
else:
|
| 202 |
+
# other methods of authentication use all three pieces
|
| 203 |
+
return (
|
| 204 |
+
bool(self._client.client.client_secret)
|
| 205 |
+
and bool(self._client.client.resource_owner_key)
|
| 206 |
+
and bool(self._client.client.resource_owner_secret)
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
def authorization_url(self, url, request_token=None, **kwargs):
|
| 210 |
+
"""Create an authorization URL by appending request_token and optional
|
| 211 |
+
kwargs to url.
|
| 212 |
+
|
| 213 |
+
This is the second step in the OAuth 1 workflow. The user should be
|
| 214 |
+
redirected to this authorization URL, grant access to you, and then
|
| 215 |
+
be redirected back to you. The redirection back can either be specified
|
| 216 |
+
during client registration or by supplying a callback URI per request.
|
| 217 |
+
|
| 218 |
+
:param url: The authorization endpoint URL.
|
| 219 |
+
:param request_token: The previously obtained request token.
|
| 220 |
+
:param kwargs: Optional parameters to append to the URL.
|
| 221 |
+
:returns: The authorization URL with new parameters embedded.
|
| 222 |
+
|
| 223 |
+
An example using a registered default callback URI.
|
| 224 |
+
|
| 225 |
+
>>> request_token_url = 'https://api.twitter.com/oauth/request_token'
|
| 226 |
+
>>> authorization_url = 'https://api.twitter.com/oauth/authorize'
|
| 227 |
+
>>> oauth_session = OAuth1Session('client-key', client_secret='secret')
|
| 228 |
+
>>> oauth_session.fetch_request_token(request_token_url)
|
| 229 |
+
{
|
| 230 |
+
'oauth_token': 'sdf0o9823sjdfsdf',
|
| 231 |
+
'oauth_token_secret': '2kjshdfp92i34asdasd',
|
| 232 |
+
}
|
| 233 |
+
>>> oauth_session.authorization_url(authorization_url)
|
| 234 |
+
'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf'
|
| 235 |
+
>>> oauth_session.authorization_url(authorization_url, foo='bar')
|
| 236 |
+
'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&foo=bar'
|
| 237 |
+
|
| 238 |
+
An example using an explicit callback URI.
|
| 239 |
+
|
| 240 |
+
>>> request_token_url = 'https://api.twitter.com/oauth/request_token'
|
| 241 |
+
>>> authorization_url = 'https://api.twitter.com/oauth/authorize'
|
| 242 |
+
>>> oauth_session = OAuth1Session('client-key', client_secret='secret', callback_uri='https://127.0.0.1/callback')
|
| 243 |
+
>>> oauth_session.fetch_request_token(request_token_url)
|
| 244 |
+
{
|
| 245 |
+
'oauth_token': 'sdf0o9823sjdfsdf',
|
| 246 |
+
'oauth_token_secret': '2kjshdfp92i34asdasd',
|
| 247 |
+
}
|
| 248 |
+
>>> oauth_session.authorization_url(authorization_url)
|
| 249 |
+
'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&oauth_callback=https%3A%2F%2F127.0.0.1%2Fcallback'
|
| 250 |
+
"""
|
| 251 |
+
kwargs["oauth_token"] = request_token or self._client.client.resource_owner_key
|
| 252 |
+
log.debug("Adding parameters %s to url %s", kwargs, url)
|
| 253 |
+
return add_params_to_uri(url, kwargs.items())
|
| 254 |
+
|
| 255 |
+
def fetch_request_token(self, url, realm=None, **request_kwargs):
|
| 256 |
+
"""Fetch a request token.
|
| 257 |
+
|
| 258 |
+
This is the first step in the OAuth 1 workflow. A request token is
|
| 259 |
+
obtained by making a signed post request to url. The token is then
|
| 260 |
+
parsed from the application/x-www-form-urlencoded response and ready
|
| 261 |
+
to be used to construct an authorization url.
|
| 262 |
+
|
| 263 |
+
:param url: The request token endpoint URL.
|
| 264 |
+
:param realm: A list of realms to request access to.
|
| 265 |
+
:param request_kwargs: Optional arguments passed to ''post''
|
| 266 |
+
function in ''requests.Session''
|
| 267 |
+
:returns: The response in dict format.
|
| 268 |
+
|
| 269 |
+
Note that a previously set callback_uri will be reset for your
|
| 270 |
+
convenience, or else signature creation will be incorrect on
|
| 271 |
+
consecutive requests.
|
| 272 |
+
|
| 273 |
+
>>> request_token_url = 'https://api.twitter.com/oauth/request_token'
|
| 274 |
+
>>> oauth_session = OAuth1Session('client-key', client_secret='secret')
|
| 275 |
+
>>> oauth_session.fetch_request_token(request_token_url)
|
| 276 |
+
{
|
| 277 |
+
'oauth_token': 'sdf0o9823sjdfsdf',
|
| 278 |
+
'oauth_token_secret': '2kjshdfp92i34asdasd',
|
| 279 |
+
}
|
| 280 |
+
"""
|
| 281 |
+
self._client.client.realm = " ".join(realm) if realm else None
|
| 282 |
+
token = self._fetch_token(url, **request_kwargs)
|
| 283 |
+
log.debug("Resetting callback_uri and realm (not needed in next phase).")
|
| 284 |
+
self._client.client.callback_uri = None
|
| 285 |
+
self._client.client.realm = None
|
| 286 |
+
return token
|
| 287 |
+
|
| 288 |
+
def fetch_access_token(self, url, verifier=None, **request_kwargs):
|
| 289 |
+
"""Fetch an access token.
|
| 290 |
+
|
| 291 |
+
This is the final step in the OAuth 1 workflow. An access token is
|
| 292 |
+
obtained using all previously obtained credentials, including the
|
| 293 |
+
verifier from the authorization step.
|
| 294 |
+
|
| 295 |
+
Note that a previously set verifier will be reset for your
|
| 296 |
+
convenience, or else signature creation will be incorrect on
|
| 297 |
+
consecutive requests.
|
| 298 |
+
|
| 299 |
+
>>> access_token_url = 'https://api.twitter.com/oauth/access_token'
|
| 300 |
+
>>> redirect_response = 'https://127.0.0.1/callback?oauth_token=kjerht2309uf&oauth_token_secret=lsdajfh923874&oauth_verifier=w34o8967345'
|
| 301 |
+
>>> oauth_session = OAuth1Session('client-key', client_secret='secret')
|
| 302 |
+
>>> oauth_session.parse_authorization_response(redirect_response)
|
| 303 |
+
{
|
| 304 |
+
'oauth_token: 'kjerht2309u',
|
| 305 |
+
'oauth_token_secret: 'lsdajfh923874',
|
| 306 |
+
'oauth_verifier: 'w34o8967345',
|
| 307 |
+
}
|
| 308 |
+
>>> oauth_session.fetch_access_token(access_token_url)
|
| 309 |
+
{
|
| 310 |
+
'oauth_token': 'sdf0o9823sjdfsdf',
|
| 311 |
+
'oauth_token_secret': '2kjshdfp92i34asdasd',
|
| 312 |
+
}
|
| 313 |
+
"""
|
| 314 |
+
if verifier:
|
| 315 |
+
self._client.client.verifier = verifier
|
| 316 |
+
if not getattr(self._client.client, "verifier", None):
|
| 317 |
+
raise VerifierMissing("No client verifier has been set.")
|
| 318 |
+
token = self._fetch_token(url, **request_kwargs)
|
| 319 |
+
log.debug("Resetting verifier attribute, should not be used anymore.")
|
| 320 |
+
self._client.client.verifier = None
|
| 321 |
+
return token
|
| 322 |
+
|
| 323 |
+
def parse_authorization_response(self, url):
|
| 324 |
+
"""Extract parameters from the post authorization redirect response URL.
|
| 325 |
+
|
| 326 |
+
:param url: The full URL that resulted from the user being redirected
|
| 327 |
+
back from the OAuth provider to you, the client.
|
| 328 |
+
:returns: A dict of parameters extracted from the URL.
|
| 329 |
+
|
| 330 |
+
>>> redirect_response = 'https://127.0.0.1/callback?oauth_token=kjerht2309uf&oauth_token_secret=lsdajfh923874&oauth_verifier=w34o8967345'
|
| 331 |
+
>>> oauth_session = OAuth1Session('client-key', client_secret='secret')
|
| 332 |
+
>>> oauth_session.parse_authorization_response(redirect_response)
|
| 333 |
+
{
|
| 334 |
+
'oauth_token: 'kjerht2309u',
|
| 335 |
+
'oauth_token_secret: 'lsdajfh923874',
|
| 336 |
+
'oauth_verifier: 'w34o8967345',
|
| 337 |
+
}
|
| 338 |
+
"""
|
| 339 |
+
log.debug("Parsing token from query part of url %s", url)
|
| 340 |
+
token = dict(urldecode(urlparse(url).query))
|
| 341 |
+
log.debug("Updating internal client token attribute.")
|
| 342 |
+
self._populate_attributes(token)
|
| 343 |
+
self.token = token
|
| 344 |
+
return token
|
| 345 |
+
|
| 346 |
+
def _populate_attributes(self, token):
|
| 347 |
+
if "oauth_token" in token:
|
| 348 |
+
self._client.client.resource_owner_key = token["oauth_token"]
|
| 349 |
+
else:
|
| 350 |
+
raise TokenMissing(
|
| 351 |
+
"Response does not contain a token: {resp}".format(resp=token), token
|
| 352 |
+
)
|
| 353 |
+
if "oauth_token_secret" in token:
|
| 354 |
+
self._client.client.resource_owner_secret = token["oauth_token_secret"]
|
| 355 |
+
if "oauth_verifier" in token:
|
| 356 |
+
self._client.client.verifier = token["oauth_verifier"]
|
| 357 |
+
|
| 358 |
+
def _fetch_token(self, url, **request_kwargs):
|
| 359 |
+
log.debug("Fetching token from %s using client %s", url, self._client.client)
|
| 360 |
+
r = self.post(url, **request_kwargs)
|
| 361 |
+
|
| 362 |
+
if r.status_code >= 400:
|
| 363 |
+
error = "Token request failed with code %s, response was '%s'."
|
| 364 |
+
raise TokenRequestDenied(error % (r.status_code, r.text), r)
|
| 365 |
+
|
| 366 |
+
log.debug('Decoding token from response "%s"', r.text)
|
| 367 |
+
try:
|
| 368 |
+
token = dict(urldecode(r.text.strip()))
|
| 369 |
+
except ValueError as e:
|
| 370 |
+
error = (
|
| 371 |
+
"Unable to decode token from token response. "
|
| 372 |
+
"This is commonly caused by an unsuccessful request where"
|
| 373 |
+
" a non urlencoded error message is returned. "
|
| 374 |
+
"The decoding error was %s"
|
| 375 |
+
"" % e
|
| 376 |
+
)
|
| 377 |
+
raise ValueError(error)
|
| 378 |
+
|
| 379 |
+
log.debug("Obtained token %s", token)
|
| 380 |
+
log.debug("Updating internal client attributes from token data.")
|
| 381 |
+
self._populate_attributes(token)
|
| 382 |
+
self.token = token
|
| 383 |
+
return token
|
| 384 |
+
|
| 385 |
+
def rebuild_auth(self, prepared_request, response):
|
| 386 |
+
"""
|
| 387 |
+
When being redirected we should always strip Authorization
|
| 388 |
+
header, since nonce may not be reused as per OAuth spec.
|
| 389 |
+
"""
|
| 390 |
+
if "Authorization" in prepared_request.headers:
|
| 391 |
+
# If we get redirected to a new host, we should strip out
|
| 392 |
+
# any authentication headers.
|
| 393 |
+
prepared_request.headers.pop("Authorization", True)
|
| 394 |
+
prepared_request.prepare_auth(self.auth)
|
| 395 |
+
return
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth2_auth.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
|
| 2 |
+
from oauthlib.oauth2 import is_secure_transport
|
| 3 |
+
from requests.auth import AuthBase
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class OAuth2(AuthBase):
|
| 7 |
+
"""Adds proof of authorization (OAuth2 token) to the request."""
|
| 8 |
+
|
| 9 |
+
def __init__(self, client_id=None, client=None, token=None):
|
| 10 |
+
"""Construct a new OAuth 2 authorization object.
|
| 11 |
+
|
| 12 |
+
:param client_id: Client id obtained during registration
|
| 13 |
+
:param client: :class:`oauthlib.oauth2.Client` to be used. Default is
|
| 14 |
+
WebApplicationClient which is useful for any
|
| 15 |
+
hosted application but not mobile or desktop.
|
| 16 |
+
:param token: Token dictionary, must include access_token
|
| 17 |
+
and token_type.
|
| 18 |
+
"""
|
| 19 |
+
self._client = client or WebApplicationClient(client_id, token=token)
|
| 20 |
+
if token:
|
| 21 |
+
for k, v in token.items():
|
| 22 |
+
setattr(self._client, k, v)
|
| 23 |
+
|
| 24 |
+
def __call__(self, r):
|
| 25 |
+
"""Append an OAuth 2 token to the request.
|
| 26 |
+
|
| 27 |
+
Note that currently HTTPS is required for all requests. There may be
|
| 28 |
+
a token type that allows for plain HTTP in the future and then this
|
| 29 |
+
should be updated to allow plain HTTP on a white list basis.
|
| 30 |
+
"""
|
| 31 |
+
if not is_secure_transport(r.url):
|
| 32 |
+
raise InsecureTransportError()
|
| 33 |
+
r.url, r.headers, r.body = self._client.add_token(
|
| 34 |
+
r.url, http_method=r.method, body=r.body, headers=r.headers
|
| 35 |
+
)
|
| 36 |
+
return r
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_oauthlib/oauth2_session.py
ADDED
|
@@ -0,0 +1,587 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
|
| 3 |
+
from oauthlib.common import generate_token, urldecode
|
| 4 |
+
from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
|
| 5 |
+
from oauthlib.oauth2 import LegacyApplicationClient
|
| 6 |
+
from oauthlib.oauth2 import TokenExpiredError, is_secure_transport
|
| 7 |
+
import requests
|
| 8 |
+
|
| 9 |
+
log = logging.getLogger(__name__)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class TokenUpdated(Warning):
|
| 13 |
+
def __init__(self, token):
|
| 14 |
+
super(TokenUpdated, self).__init__()
|
| 15 |
+
self.token = token
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class OAuth2Session(requests.Session):
|
| 19 |
+
"""Versatile OAuth 2 extension to :class:`requests.Session`.
|
| 20 |
+
|
| 21 |
+
Supports any grant type adhering to :class:`oauthlib.oauth2.Client` spec
|
| 22 |
+
including the four core OAuth 2 grants.
|
| 23 |
+
|
| 24 |
+
Can be used to create authorization urls, fetch tokens and access protected
|
| 25 |
+
resources using the :class:`requests.Session` interface you are used to.
|
| 26 |
+
|
| 27 |
+
- :class:`oauthlib.oauth2.WebApplicationClient` (default): Authorization Code Grant
|
| 28 |
+
- :class:`oauthlib.oauth2.MobileApplicationClient`: Implicit Grant
|
| 29 |
+
- :class:`oauthlib.oauth2.LegacyApplicationClient`: Password Credentials Grant
|
| 30 |
+
- :class:`oauthlib.oauth2.BackendApplicationClient`: Client Credentials Grant
|
| 31 |
+
|
| 32 |
+
Note that the only time you will be using Implicit Grant from python is if
|
| 33 |
+
you are driving a user agent able to obtain URL fragments.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
def __init__(
|
| 37 |
+
self,
|
| 38 |
+
client_id=None,
|
| 39 |
+
client=None,
|
| 40 |
+
auto_refresh_url=None,
|
| 41 |
+
auto_refresh_kwargs=None,
|
| 42 |
+
scope=None,
|
| 43 |
+
redirect_uri=None,
|
| 44 |
+
token=None,
|
| 45 |
+
state=None,
|
| 46 |
+
token_updater=None,
|
| 47 |
+
pkce=None,
|
| 48 |
+
**kwargs
|
| 49 |
+
):
|
| 50 |
+
"""Construct a new OAuth 2 client session.
|
| 51 |
+
|
| 52 |
+
:param client_id: Client id obtained during registration
|
| 53 |
+
:param client: :class:`oauthlib.oauth2.Client` to be used. Default is
|
| 54 |
+
WebApplicationClient which is useful for any
|
| 55 |
+
hosted application but not mobile or desktop.
|
| 56 |
+
:param scope: List of scopes you wish to request access to
|
| 57 |
+
:param redirect_uri: Redirect URI you registered as callback
|
| 58 |
+
:param token: Token dictionary, must include access_token
|
| 59 |
+
and token_type.
|
| 60 |
+
:param state: State string used to prevent CSRF. This will be given
|
| 61 |
+
when creating the authorization url and must be supplied
|
| 62 |
+
when parsing the authorization response.
|
| 63 |
+
Can be either a string or a no argument callable.
|
| 64 |
+
:auto_refresh_url: Refresh token endpoint URL, must be HTTPS. Supply
|
| 65 |
+
this if you wish the client to automatically refresh
|
| 66 |
+
your access tokens.
|
| 67 |
+
:auto_refresh_kwargs: Extra arguments to pass to the refresh token
|
| 68 |
+
endpoint.
|
| 69 |
+
:token_updater: Method with one argument, token, to be used to update
|
| 70 |
+
your token database on automatic token refresh. If not
|
| 71 |
+
set a TokenUpdated warning will be raised when a token
|
| 72 |
+
has been refreshed. This warning will carry the token
|
| 73 |
+
in its token argument.
|
| 74 |
+
:param pkce: Set "S256" or "plain" to enable PKCE. Default is disabled.
|
| 75 |
+
:param kwargs: Arguments to pass to the Session constructor.
|
| 76 |
+
"""
|
| 77 |
+
super(OAuth2Session, self).__init__(**kwargs)
|
| 78 |
+
self._client = client or WebApplicationClient(client_id, token=token)
|
| 79 |
+
self.token = token or {}
|
| 80 |
+
self._scope = scope
|
| 81 |
+
self.redirect_uri = redirect_uri
|
| 82 |
+
self.state = state or generate_token
|
| 83 |
+
self._state = state
|
| 84 |
+
self.auto_refresh_url = auto_refresh_url
|
| 85 |
+
self.auto_refresh_kwargs = auto_refresh_kwargs or {}
|
| 86 |
+
self.token_updater = token_updater
|
| 87 |
+
self._pkce = pkce
|
| 88 |
+
|
| 89 |
+
if self._pkce not in ["S256", "plain", None]:
|
| 90 |
+
raise AttributeError("Wrong value for {}(.., pkce={})".format(self.__class__, self._pkce))
|
| 91 |
+
|
| 92 |
+
# Ensure that requests doesn't do any automatic auth. See #278.
|
| 93 |
+
# The default behavior can be re-enabled by setting auth to None.
|
| 94 |
+
self.auth = lambda r: r
|
| 95 |
+
|
| 96 |
+
# Allow customizations for non compliant providers through various
|
| 97 |
+
# hooks to adjust requests and responses.
|
| 98 |
+
self.compliance_hook = {
|
| 99 |
+
"access_token_response": set(),
|
| 100 |
+
"refresh_token_response": set(),
|
| 101 |
+
"protected_request": set(),
|
| 102 |
+
"refresh_token_request": set(),
|
| 103 |
+
"access_token_request": set(),
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
@property
|
| 107 |
+
def scope(self):
|
| 108 |
+
"""By default the scope from the client is used, except if overridden"""
|
| 109 |
+
if self._scope is not None:
|
| 110 |
+
return self._scope
|
| 111 |
+
elif self._client is not None:
|
| 112 |
+
return self._client.scope
|
| 113 |
+
else:
|
| 114 |
+
return None
|
| 115 |
+
|
| 116 |
+
@scope.setter
|
| 117 |
+
def scope(self, scope):
|
| 118 |
+
self._scope = scope
|
| 119 |
+
|
| 120 |
+
def new_state(self):
|
| 121 |
+
"""Generates a state string to be used in authorizations."""
|
| 122 |
+
try:
|
| 123 |
+
self._state = self.state()
|
| 124 |
+
log.debug("Generated new state %s.", self._state)
|
| 125 |
+
except TypeError:
|
| 126 |
+
self._state = self.state
|
| 127 |
+
log.debug("Re-using previously supplied state %s.", self._state)
|
| 128 |
+
return self._state
|
| 129 |
+
|
| 130 |
+
@property
|
| 131 |
+
def client_id(self):
|
| 132 |
+
return getattr(self._client, "client_id", None)
|
| 133 |
+
|
| 134 |
+
@client_id.setter
|
| 135 |
+
def client_id(self, value):
|
| 136 |
+
self._client.client_id = value
|
| 137 |
+
|
| 138 |
+
@client_id.deleter
|
| 139 |
+
def client_id(self):
|
| 140 |
+
del self._client.client_id
|
| 141 |
+
|
| 142 |
+
@property
|
| 143 |
+
def token(self):
|
| 144 |
+
return getattr(self._client, "token", None)
|
| 145 |
+
|
| 146 |
+
@token.setter
|
| 147 |
+
def token(self, value):
|
| 148 |
+
self._client.token = value
|
| 149 |
+
self._client.populate_token_attributes(value)
|
| 150 |
+
|
| 151 |
+
@property
|
| 152 |
+
def access_token(self):
|
| 153 |
+
return getattr(self._client, "access_token", None)
|
| 154 |
+
|
| 155 |
+
@access_token.setter
|
| 156 |
+
def access_token(self, value):
|
| 157 |
+
self._client.access_token = value
|
| 158 |
+
|
| 159 |
+
@access_token.deleter
|
| 160 |
+
def access_token(self):
|
| 161 |
+
del self._client.access_token
|
| 162 |
+
|
| 163 |
+
@property
|
| 164 |
+
def authorized(self):
|
| 165 |
+
"""Boolean that indicates whether this session has an OAuth token
|
| 166 |
+
or not. If `self.authorized` is True, you can reasonably expect
|
| 167 |
+
OAuth-protected requests to the resource to succeed. If
|
| 168 |
+
`self.authorized` is False, you need the user to go through the OAuth
|
| 169 |
+
authentication dance before OAuth-protected requests to the resource
|
| 170 |
+
will succeed.
|
| 171 |
+
"""
|
| 172 |
+
return bool(self.access_token)
|
| 173 |
+
|
| 174 |
+
def authorization_url(self, url, state=None, **kwargs):
|
| 175 |
+
"""Form an authorization URL.
|
| 176 |
+
|
| 177 |
+
:param url: Authorization endpoint url, must be HTTPS.
|
| 178 |
+
:param state: An optional state string for CSRF protection. If not
|
| 179 |
+
given it will be generated for you.
|
| 180 |
+
:param kwargs: Extra parameters to include.
|
| 181 |
+
:return: authorization_url, state
|
| 182 |
+
"""
|
| 183 |
+
state = state or self.new_state()
|
| 184 |
+
if self._pkce:
|
| 185 |
+
self._code_verifier = self._client.create_code_verifier(43)
|
| 186 |
+
kwargs["code_challenge_method"] = self._pkce
|
| 187 |
+
kwargs["code_challenge"] = self._client.create_code_challenge(
|
| 188 |
+
code_verifier=self._code_verifier,
|
| 189 |
+
code_challenge_method=self._pkce
|
| 190 |
+
)
|
| 191 |
+
return (
|
| 192 |
+
self._client.prepare_request_uri(
|
| 193 |
+
url,
|
| 194 |
+
redirect_uri=self.redirect_uri,
|
| 195 |
+
scope=self.scope,
|
| 196 |
+
state=state,
|
| 197 |
+
**kwargs
|
| 198 |
+
),
|
| 199 |
+
state,
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
def fetch_token(
|
| 203 |
+
self,
|
| 204 |
+
token_url,
|
| 205 |
+
code=None,
|
| 206 |
+
authorization_response=None,
|
| 207 |
+
body="",
|
| 208 |
+
auth=None,
|
| 209 |
+
username=None,
|
| 210 |
+
password=None,
|
| 211 |
+
method="POST",
|
| 212 |
+
force_querystring=False,
|
| 213 |
+
timeout=None,
|
| 214 |
+
headers=None,
|
| 215 |
+
verify=None,
|
| 216 |
+
proxies=None,
|
| 217 |
+
include_client_id=None,
|
| 218 |
+
client_secret=None,
|
| 219 |
+
cert=None,
|
| 220 |
+
**kwargs
|
| 221 |
+
):
|
| 222 |
+
"""Generic method for fetching an access token from the token endpoint.
|
| 223 |
+
|
| 224 |
+
If you are using the MobileApplicationClient you will want to use
|
| 225 |
+
`token_from_fragment` instead of `fetch_token`.
|
| 226 |
+
|
| 227 |
+
The current implementation enforces the RFC guidelines.
|
| 228 |
+
|
| 229 |
+
:param token_url: Token endpoint URL, must use HTTPS.
|
| 230 |
+
:param code: Authorization code (used by WebApplicationClients).
|
| 231 |
+
:param authorization_response: Authorization response URL, the callback
|
| 232 |
+
URL of the request back to you. Used by
|
| 233 |
+
WebApplicationClients instead of code.
|
| 234 |
+
:param body: Optional application/x-www-form-urlencoded body to add the
|
| 235 |
+
include in the token request. Prefer kwargs over body.
|
| 236 |
+
:param auth: An auth tuple or method as accepted by `requests`.
|
| 237 |
+
:param username: Username required by LegacyApplicationClients to appear
|
| 238 |
+
in the request body.
|
| 239 |
+
:param password: Password required by LegacyApplicationClients to appear
|
| 240 |
+
in the request body.
|
| 241 |
+
:param method: The HTTP method used to make the request. Defaults
|
| 242 |
+
to POST, but may also be GET. Other methods should
|
| 243 |
+
be added as needed.
|
| 244 |
+
:param force_querystring: If True, force the request body to be sent
|
| 245 |
+
in the querystring instead.
|
| 246 |
+
:param timeout: Timeout of the request in seconds.
|
| 247 |
+
:param headers: Dict to default request headers with.
|
| 248 |
+
:param verify: Verify SSL certificate.
|
| 249 |
+
:param proxies: The `proxies` argument is passed onto `requests`.
|
| 250 |
+
:param include_client_id: Should the request body include the
|
| 251 |
+
`client_id` parameter. Default is `None`,
|
| 252 |
+
which will attempt to autodetect. This can be
|
| 253 |
+
forced to always include (True) or never
|
| 254 |
+
include (False).
|
| 255 |
+
:param client_secret: The `client_secret` paired to the `client_id`.
|
| 256 |
+
This is generally required unless provided in the
|
| 257 |
+
`auth` tuple. If the value is `None`, it will be
|
| 258 |
+
omitted from the request, however if the value is
|
| 259 |
+
an empty string, an empty string will be sent.
|
| 260 |
+
:param cert: Client certificate to send for OAuth 2.0 Mutual-TLS Client
|
| 261 |
+
Authentication (draft-ietf-oauth-mtls). Can either be the
|
| 262 |
+
path of a file containing the private key and certificate or
|
| 263 |
+
a tuple of two filenames for certificate and key.
|
| 264 |
+
:param kwargs: Extra parameters to include in the token request.
|
| 265 |
+
:return: A token dict
|
| 266 |
+
"""
|
| 267 |
+
if not is_secure_transport(token_url):
|
| 268 |
+
raise InsecureTransportError()
|
| 269 |
+
|
| 270 |
+
if not code and authorization_response:
|
| 271 |
+
self._client.parse_request_uri_response(
|
| 272 |
+
authorization_response, state=self._state
|
| 273 |
+
)
|
| 274 |
+
code = self._client.code
|
| 275 |
+
elif not code and isinstance(self._client, WebApplicationClient):
|
| 276 |
+
code = self._client.code
|
| 277 |
+
if not code:
|
| 278 |
+
raise ValueError(
|
| 279 |
+
"Please supply either code or " "authorization_response parameters."
|
| 280 |
+
)
|
| 281 |
+
|
| 282 |
+
if self._pkce:
|
| 283 |
+
if self._code_verifier is None:
|
| 284 |
+
raise ValueError(
|
| 285 |
+
"Code verifier is not found, authorization URL must be generated before"
|
| 286 |
+
)
|
| 287 |
+
kwargs["code_verifier"] = self._code_verifier
|
| 288 |
+
|
| 289 |
+
# Earlier versions of this library build an HTTPBasicAuth header out of
|
| 290 |
+
# `username` and `password`. The RFC states, however these attributes
|
| 291 |
+
# must be in the request body and not the header.
|
| 292 |
+
# If an upstream server is not spec compliant and requires them to
|
| 293 |
+
# appear as an Authorization header, supply an explicit `auth` header
|
| 294 |
+
# to this function.
|
| 295 |
+
# This check will allow for empty strings, but not `None`.
|
| 296 |
+
#
|
| 297 |
+
# References
|
| 298 |
+
# 4.3.2 - Resource Owner Password Credentials Grant
|
| 299 |
+
# https://tools.ietf.org/html/rfc6749#section-4.3.2
|
| 300 |
+
|
| 301 |
+
if isinstance(self._client, LegacyApplicationClient):
|
| 302 |
+
if username is None:
|
| 303 |
+
raise ValueError(
|
| 304 |
+
"`LegacyApplicationClient` requires both the "
|
| 305 |
+
"`username` and `password` parameters."
|
| 306 |
+
)
|
| 307 |
+
if password is None:
|
| 308 |
+
raise ValueError(
|
| 309 |
+
"The required parameter `username` was supplied, "
|
| 310 |
+
"but `password` was not."
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
# merge username and password into kwargs for `prepare_request_body`
|
| 314 |
+
if username is not None:
|
| 315 |
+
kwargs["username"] = username
|
| 316 |
+
if password is not None:
|
| 317 |
+
kwargs["password"] = password
|
| 318 |
+
|
| 319 |
+
# is an auth explicitly supplied?
|
| 320 |
+
if auth is not None:
|
| 321 |
+
# if we're dealing with the default of `include_client_id` (None):
|
| 322 |
+
# we will assume the `auth` argument is for an RFC compliant server
|
| 323 |
+
# and we should not send the `client_id` in the body.
|
| 324 |
+
# This approach allows us to still force the client_id by submitting
|
| 325 |
+
# `include_client_id=True` along with an `auth` object.
|
| 326 |
+
if include_client_id is None:
|
| 327 |
+
include_client_id = False
|
| 328 |
+
|
| 329 |
+
# otherwise we may need to create an auth header
|
| 330 |
+
else:
|
| 331 |
+
# since we don't have an auth header, we MAY need to create one
|
| 332 |
+
# it is possible that we want to send the `client_id` in the body
|
| 333 |
+
# if so, `include_client_id` should be set to True
|
| 334 |
+
# otherwise, we will generate an auth header
|
| 335 |
+
if include_client_id is not True:
|
| 336 |
+
client_id = self.client_id
|
| 337 |
+
if client_id:
|
| 338 |
+
log.debug(
|
| 339 |
+
'Encoding `client_id` "%s" with `client_secret` '
|
| 340 |
+
"as Basic auth credentials.",
|
| 341 |
+
client_id,
|
| 342 |
+
)
|
| 343 |
+
client_secret = client_secret if client_secret is not None else ""
|
| 344 |
+
auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
|
| 345 |
+
|
| 346 |
+
if include_client_id:
|
| 347 |
+
# this was pulled out of the params
|
| 348 |
+
# it needs to be passed into prepare_request_body
|
| 349 |
+
if client_secret is not None:
|
| 350 |
+
kwargs["client_secret"] = client_secret
|
| 351 |
+
|
| 352 |
+
body = self._client.prepare_request_body(
|
| 353 |
+
code=code,
|
| 354 |
+
body=body,
|
| 355 |
+
redirect_uri=self.redirect_uri,
|
| 356 |
+
include_client_id=include_client_id,
|
| 357 |
+
**kwargs
|
| 358 |
+
)
|
| 359 |
+
|
| 360 |
+
headers = headers or {
|
| 361 |
+
"Accept": "application/json",
|
| 362 |
+
"Content-Type": "application/x-www-form-urlencoded",
|
| 363 |
+
}
|
| 364 |
+
self.token = {}
|
| 365 |
+
request_kwargs = {}
|
| 366 |
+
if method.upper() == "POST":
|
| 367 |
+
request_kwargs["params" if force_querystring else "data"] = dict(
|
| 368 |
+
urldecode(body)
|
| 369 |
+
)
|
| 370 |
+
elif method.upper() == "GET":
|
| 371 |
+
request_kwargs["params"] = dict(urldecode(body))
|
| 372 |
+
else:
|
| 373 |
+
raise ValueError("The method kwarg must be POST or GET.")
|
| 374 |
+
|
| 375 |
+
for hook in self.compliance_hook["access_token_request"]:
|
| 376 |
+
log.debug("Invoking access_token_request hook %s.", hook)
|
| 377 |
+
token_url, headers, request_kwargs = hook(
|
| 378 |
+
token_url, headers, request_kwargs
|
| 379 |
+
)
|
| 380 |
+
|
| 381 |
+
r = self.request(
|
| 382 |
+
method=method,
|
| 383 |
+
url=token_url,
|
| 384 |
+
timeout=timeout,
|
| 385 |
+
headers=headers,
|
| 386 |
+
auth=auth,
|
| 387 |
+
verify=verify,
|
| 388 |
+
proxies=proxies,
|
| 389 |
+
cert=cert,
|
| 390 |
+
**request_kwargs
|
| 391 |
+
)
|
| 392 |
+
|
| 393 |
+
log.debug("Request to fetch token completed with status %s.", r.status_code)
|
| 394 |
+
log.debug("Request url was %s", r.request.url)
|
| 395 |
+
log.debug("Request headers were %s", r.request.headers)
|
| 396 |
+
log.debug("Request body was %s", r.request.body)
|
| 397 |
+
log.debug("Response headers were %s and content %s.", r.headers, r.text)
|
| 398 |
+
log.debug(
|
| 399 |
+
"Invoking %d token response hooks.",
|
| 400 |
+
len(self.compliance_hook["access_token_response"]),
|
| 401 |
+
)
|
| 402 |
+
for hook in self.compliance_hook["access_token_response"]:
|
| 403 |
+
log.debug("Invoking hook %s.", hook)
|
| 404 |
+
r = hook(r)
|
| 405 |
+
|
| 406 |
+
self._client.parse_request_body_response(r.text, scope=self.scope)
|
| 407 |
+
self.token = self._client.token
|
| 408 |
+
log.debug("Obtained token %s.", self.token)
|
| 409 |
+
return self.token
|
| 410 |
+
|
| 411 |
+
def token_from_fragment(self, authorization_response):
|
| 412 |
+
"""Parse token from the URI fragment, used by MobileApplicationClients.
|
| 413 |
+
|
| 414 |
+
:param authorization_response: The full URL of the redirect back to you
|
| 415 |
+
:return: A token dict
|
| 416 |
+
"""
|
| 417 |
+
self._client.parse_request_uri_response(
|
| 418 |
+
authorization_response, state=self._state
|
| 419 |
+
)
|
| 420 |
+
self.token = self._client.token
|
| 421 |
+
return self.token
|
| 422 |
+
|
| 423 |
+
def refresh_token(
|
| 424 |
+
self,
|
| 425 |
+
token_url,
|
| 426 |
+
refresh_token=None,
|
| 427 |
+
body="",
|
| 428 |
+
auth=None,
|
| 429 |
+
timeout=None,
|
| 430 |
+
headers=None,
|
| 431 |
+
verify=None,
|
| 432 |
+
proxies=None,
|
| 433 |
+
**kwargs
|
| 434 |
+
):
|
| 435 |
+
"""Fetch a new access token using a refresh token.
|
| 436 |
+
|
| 437 |
+
:param token_url: The token endpoint, must be HTTPS.
|
| 438 |
+
:param refresh_token: The refresh_token to use.
|
| 439 |
+
:param body: Optional application/x-www-form-urlencoded body to add the
|
| 440 |
+
include in the token request. Prefer kwargs over body.
|
| 441 |
+
:param auth: An auth tuple or method as accepted by `requests`.
|
| 442 |
+
:param timeout: Timeout of the request in seconds.
|
| 443 |
+
:param headers: A dict of headers to be used by `requests`.
|
| 444 |
+
:param verify: Verify SSL certificate.
|
| 445 |
+
:param proxies: The `proxies` argument will be passed to `requests`.
|
| 446 |
+
:param kwargs: Extra parameters to include in the token request.
|
| 447 |
+
:return: A token dict
|
| 448 |
+
"""
|
| 449 |
+
if not token_url:
|
| 450 |
+
raise ValueError("No token endpoint set for auto_refresh.")
|
| 451 |
+
|
| 452 |
+
if not is_secure_transport(token_url):
|
| 453 |
+
raise InsecureTransportError()
|
| 454 |
+
|
| 455 |
+
refresh_token = refresh_token or self.token.get("refresh_token")
|
| 456 |
+
|
| 457 |
+
log.debug(
|
| 458 |
+
"Adding auto refresh key word arguments %s.", self.auto_refresh_kwargs
|
| 459 |
+
)
|
| 460 |
+
kwargs.update(self.auto_refresh_kwargs)
|
| 461 |
+
body = self._client.prepare_refresh_body(
|
| 462 |
+
body=body, refresh_token=refresh_token, scope=self.scope, **kwargs
|
| 463 |
+
)
|
| 464 |
+
log.debug("Prepared refresh token request body %s", body)
|
| 465 |
+
|
| 466 |
+
if headers is None:
|
| 467 |
+
headers = {
|
| 468 |
+
"Accept": "application/json",
|
| 469 |
+
"Content-Type": ("application/x-www-form-urlencoded"),
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
for hook in self.compliance_hook["refresh_token_request"]:
|
| 473 |
+
log.debug("Invoking refresh_token_request hook %s.", hook)
|
| 474 |
+
token_url, headers, body = hook(token_url, headers, body)
|
| 475 |
+
|
| 476 |
+
r = self.post(
|
| 477 |
+
token_url,
|
| 478 |
+
data=dict(urldecode(body)),
|
| 479 |
+
auth=auth,
|
| 480 |
+
timeout=timeout,
|
| 481 |
+
headers=headers,
|
| 482 |
+
verify=verify,
|
| 483 |
+
withhold_token=True,
|
| 484 |
+
proxies=proxies,
|
| 485 |
+
)
|
| 486 |
+
log.debug("Request to refresh token completed with status %s.", r.status_code)
|
| 487 |
+
log.debug("Response headers were %s and content %s.", r.headers, r.text)
|
| 488 |
+
log.debug(
|
| 489 |
+
"Invoking %d token response hooks.",
|
| 490 |
+
len(self.compliance_hook["refresh_token_response"]),
|
| 491 |
+
)
|
| 492 |
+
for hook in self.compliance_hook["refresh_token_response"]:
|
| 493 |
+
log.debug("Invoking hook %s.", hook)
|
| 494 |
+
r = hook(r)
|
| 495 |
+
|
| 496 |
+
self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
|
| 497 |
+
if "refresh_token" not in self.token:
|
| 498 |
+
log.debug("No new refresh token given. Re-using old.")
|
| 499 |
+
self.token["refresh_token"] = refresh_token
|
| 500 |
+
return self.token
|
| 501 |
+
|
| 502 |
+
def request(
|
| 503 |
+
self,
|
| 504 |
+
method,
|
| 505 |
+
url,
|
| 506 |
+
data=None,
|
| 507 |
+
headers=None,
|
| 508 |
+
withhold_token=False,
|
| 509 |
+
client_id=None,
|
| 510 |
+
client_secret=None,
|
| 511 |
+
files=None,
|
| 512 |
+
**kwargs
|
| 513 |
+
):
|
| 514 |
+
"""Intercept all requests and add the OAuth 2 token if present."""
|
| 515 |
+
if not is_secure_transport(url):
|
| 516 |
+
raise InsecureTransportError()
|
| 517 |
+
if self.token and not withhold_token:
|
| 518 |
+
log.debug(
|
| 519 |
+
"Invoking %d protected resource request hooks.",
|
| 520 |
+
len(self.compliance_hook["protected_request"]),
|
| 521 |
+
)
|
| 522 |
+
for hook in self.compliance_hook["protected_request"]:
|
| 523 |
+
log.debug("Invoking hook %s.", hook)
|
| 524 |
+
url, headers, data = hook(url, headers, data)
|
| 525 |
+
|
| 526 |
+
log.debug("Adding token %s to request.", self.token)
|
| 527 |
+
try:
|
| 528 |
+
url, headers, data = self._client.add_token(
|
| 529 |
+
url, http_method=method, body=data, headers=headers
|
| 530 |
+
)
|
| 531 |
+
# Attempt to retrieve and save new access token if expired
|
| 532 |
+
except TokenExpiredError:
|
| 533 |
+
if self.auto_refresh_url:
|
| 534 |
+
log.debug(
|
| 535 |
+
"Auto refresh is set, attempting to refresh at %s.",
|
| 536 |
+
self.auto_refresh_url,
|
| 537 |
+
)
|
| 538 |
+
|
| 539 |
+
# We mustn't pass auth twice.
|
| 540 |
+
auth = kwargs.pop("auth", None)
|
| 541 |
+
if client_id and client_secret and (auth is None):
|
| 542 |
+
log.debug(
|
| 543 |
+
'Encoding client_id "%s" with client_secret as Basic auth credentials.',
|
| 544 |
+
client_id,
|
| 545 |
+
)
|
| 546 |
+
auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
|
| 547 |
+
token = self.refresh_token(
|
| 548 |
+
self.auto_refresh_url, auth=auth, **kwargs
|
| 549 |
+
)
|
| 550 |
+
if self.token_updater:
|
| 551 |
+
log.debug(
|
| 552 |
+
"Updating token to %s using %s.", token, self.token_updater
|
| 553 |
+
)
|
| 554 |
+
self.token_updater(token)
|
| 555 |
+
url, headers, data = self._client.add_token(
|
| 556 |
+
url, http_method=method, body=data, headers=headers
|
| 557 |
+
)
|
| 558 |
+
else:
|
| 559 |
+
raise TokenUpdated(token)
|
| 560 |
+
else:
|
| 561 |
+
raise
|
| 562 |
+
|
| 563 |
+
log.debug("Requesting url %s using method %s.", url, method)
|
| 564 |
+
log.debug("Supplying headers %s and data %s", headers, data)
|
| 565 |
+
log.debug("Passing through key word arguments %s.", kwargs)
|
| 566 |
+
return super(OAuth2Session, self).request(
|
| 567 |
+
method, url, headers=headers, data=data, files=files, **kwargs
|
| 568 |
+
)
|
| 569 |
+
|
| 570 |
+
def register_compliance_hook(self, hook_type, hook):
|
| 571 |
+
"""Register a hook for request/response tweaking.
|
| 572 |
+
|
| 573 |
+
Available hooks are:
|
| 574 |
+
access_token_response invoked before token parsing.
|
| 575 |
+
refresh_token_response invoked before refresh token parsing.
|
| 576 |
+
protected_request invoked before making a request.
|
| 577 |
+
access_token_request invoked before making a token fetch request.
|
| 578 |
+
refresh_token_request invoked before making a refresh request.
|
| 579 |
+
|
| 580 |
+
If you find a new hook is needed please send a GitHub PR request
|
| 581 |
+
or open an issue.
|
| 582 |
+
"""
|
| 583 |
+
if hook_type not in self.compliance_hook:
|
| 584 |
+
raise ValueError(
|
| 585 |
+
"Hook type %s is not in %s.", hook_type, self.compliance_hook
|
| 586 |
+
)
|
| 587 |
+
self.compliance_hook[hook_type].add(hook)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/AUTHORS.rst
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Requests-toolbelt is written and maintained by Ian Cordasco, Cory Benfield and
|
| 2 |
+
various contributors:
|
| 3 |
+
|
| 4 |
+
Development Lead
|
| 5 |
+
````````````````
|
| 6 |
+
|
| 7 |
+
- Ian Cordasco
|
| 8 |
+
|
| 9 |
+
- Cory Benfield
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Requests
|
| 13 |
+
````````
|
| 14 |
+
|
| 15 |
+
- Kenneth Reitz <me@kennethreitz.com> and various contributors
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
Urllib3
|
| 19 |
+
```````
|
| 20 |
+
|
| 21 |
+
- Andrey Petrov <andrey.petrov@shazow.net>
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Patches and Suggestions
|
| 25 |
+
```````````````````````
|
| 26 |
+
|
| 27 |
+
- Jay De Lanoy <jay@delanoy.co>
|
| 28 |
+
|
| 29 |
+
- Zhaoyu Luo <luozhaoyu90@gmail.com>
|
| 30 |
+
|
| 31 |
+
- Markus Unterwaditzer <markus@unterwaditzer.net>
|
| 32 |
+
|
| 33 |
+
- Bryce Boe <bbzbryce@gmail.com> (@bboe)
|
| 34 |
+
|
| 35 |
+
- Dan Lipsitt (https://github.com/DanLipsitt)
|
| 36 |
+
|
| 37 |
+
- Cea Stapleton (http://www.ceastapleton.com)
|
| 38 |
+
|
| 39 |
+
- Patrick Creech <pcreech@redhat.com>
|
| 40 |
+
|
| 41 |
+
- Mike Lambert (@mikelambert)
|
| 42 |
+
|
| 43 |
+
- Ryan Barrett (https://snarfed.org/)
|
| 44 |
+
|
| 45 |
+
- Victor Grau Serrat (@lacabra)
|
| 46 |
+
|
| 47 |
+
- Yorgos Pagles <yorgos@pagles.org>
|
| 48 |
+
|
| 49 |
+
- Thomas Hauk <thauk@copperleaf.com>
|
| 50 |
+
|
| 51 |
+
- Achim Herwig <python@wodca.de>
|
| 52 |
+
|
| 53 |
+
- Ryan Ashley <rashley-iqt>
|
| 54 |
+
|
| 55 |
+
- Sam Bull (@greatestape)
|
| 56 |
+
|
| 57 |
+
- Florence Blanc-Renaud <flo@redhat.com> (@flo-renaud)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright 2014 Ian Cordasco, Cory Benfield
|
| 2 |
+
|
| 3 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
you may not use this file except in compliance with the License.
|
| 5 |
+
You may obtain a copy of the License at
|
| 6 |
+
|
| 7 |
+
https://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
|
| 9 |
+
Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
See the License for the specific language governing permissions and
|
| 13 |
+
limitations under the License.
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: requests-toolbelt
|
| 3 |
+
Version: 1.0.0
|
| 4 |
+
Summary: A utility belt for advanced users of python-requests
|
| 5 |
+
Home-page: https://toolbelt.readthedocs.io/
|
| 6 |
+
Author: Ian Cordasco, Cory Benfield
|
| 7 |
+
Author-email: graffatcolmingov@gmail.com
|
| 8 |
+
License: Apache 2.0
|
| 9 |
+
Project-URL: Changelog, https://github.com/requests/toolbelt/blob/master/HISTORY.rst
|
| 10 |
+
Project-URL: Source, https://github.com/requests/toolbelt
|
| 11 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 12 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 13 |
+
Classifier: Intended Audience :: Developers
|
| 14 |
+
Classifier: Programming Language :: Python
|
| 15 |
+
Classifier: Programming Language :: Python :: 2
|
| 16 |
+
Classifier: Programming Language :: Python :: 2.7
|
| 17 |
+
Classifier: Programming Language :: Python :: 3
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.4
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.5
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.6
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 25 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 26 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 27 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 28 |
+
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
|
| 29 |
+
Description-Content-Type: text/x-rst
|
| 30 |
+
License-File: LICENSE
|
| 31 |
+
License-File: AUTHORS.rst
|
| 32 |
+
Requires-Dist: requests (<3.0.0,>=2.0.1)
|
| 33 |
+
|
| 34 |
+
The Requests Toolbelt
|
| 35 |
+
=====================
|
| 36 |
+
|
| 37 |
+
This is just a collection of utilities for `python-requests`_, but don't
|
| 38 |
+
really belong in ``requests`` proper. The minimum tested requests version is
|
| 39 |
+
``2.1.0``. In reality, the toolbelt should work with ``2.0.1`` as well, but
|
| 40 |
+
some idiosyncracies prevent effective or sane testing on that version.
|
| 41 |
+
|
| 42 |
+
``pip install requests-toolbelt`` to get started!
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
multipart/form-data Encoder
|
| 46 |
+
---------------------------
|
| 47 |
+
|
| 48 |
+
The main attraction is a streaming multipart form-data object, ``MultipartEncoder``.
|
| 49 |
+
Its API looks like this:
|
| 50 |
+
|
| 51 |
+
.. code-block:: python
|
| 52 |
+
|
| 53 |
+
from requests_toolbelt import MultipartEncoder
|
| 54 |
+
import requests
|
| 55 |
+
|
| 56 |
+
m = MultipartEncoder(
|
| 57 |
+
fields={'field0': 'value', 'field1': 'value',
|
| 58 |
+
'field2': ('filename', open('file.py', 'rb'), 'text/plain')}
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
r = requests.post('http://httpbin.org/post', data=m,
|
| 62 |
+
headers={'Content-Type': m.content_type})
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
You can also use ``multipart/form-data`` encoding for requests that don't
|
| 66 |
+
require files:
|
| 67 |
+
|
| 68 |
+
.. code-block:: python
|
| 69 |
+
|
| 70 |
+
from requests_toolbelt import MultipartEncoder
|
| 71 |
+
import requests
|
| 72 |
+
|
| 73 |
+
m = MultipartEncoder(fields={'field0': 'value', 'field1': 'value'})
|
| 74 |
+
|
| 75 |
+
r = requests.post('http://httpbin.org/post', data=m,
|
| 76 |
+
headers={'Content-Type': m.content_type})
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
Or, you can just create the string and examine the data:
|
| 80 |
+
|
| 81 |
+
.. code-block:: python
|
| 82 |
+
|
| 83 |
+
# Assuming `m` is one of the above
|
| 84 |
+
m.to_string() # Always returns unicode
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
User-Agent constructor
|
| 88 |
+
----------------------
|
| 89 |
+
|
| 90 |
+
You can easily construct a requests-style ``User-Agent`` string::
|
| 91 |
+
|
| 92 |
+
from requests_toolbelt import user_agent
|
| 93 |
+
|
| 94 |
+
headers = {
|
| 95 |
+
'User-Agent': user_agent('my_package', '0.0.1')
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
r = requests.get('https://api.github.com/users', headers=headers)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
SSLAdapter
|
| 102 |
+
----------
|
| 103 |
+
|
| 104 |
+
The ``SSLAdapter`` was originally published on `Cory Benfield's blog`_.
|
| 105 |
+
This adapter allows the user to choose one of the SSL protocols made available
|
| 106 |
+
in Python's ``ssl`` module for outgoing HTTPS connections:
|
| 107 |
+
|
| 108 |
+
.. code-block:: python
|
| 109 |
+
|
| 110 |
+
from requests_toolbelt import SSLAdapter
|
| 111 |
+
import requests
|
| 112 |
+
import ssl
|
| 113 |
+
|
| 114 |
+
s = requests.Session()
|
| 115 |
+
s.mount('https://', SSLAdapter(ssl.PROTOCOL_TLSv1))
|
| 116 |
+
|
| 117 |
+
cookies/ForgetfulCookieJar
|
| 118 |
+
--------------------------
|
| 119 |
+
|
| 120 |
+
The ``ForgetfulCookieJar`` prevents a particular requests session from storing
|
| 121 |
+
cookies:
|
| 122 |
+
|
| 123 |
+
.. code-block:: python
|
| 124 |
+
|
| 125 |
+
from requests_toolbelt.cookies.forgetful import ForgetfulCookieJar
|
| 126 |
+
|
| 127 |
+
session = requests.Session()
|
| 128 |
+
session.cookies = ForgetfulCookieJar()
|
| 129 |
+
|
| 130 |
+
Contributing
|
| 131 |
+
------------
|
| 132 |
+
|
| 133 |
+
Please read the `suggested workflow
|
| 134 |
+
<https://toolbelt.readthedocs.io/en/latest/contributing.html>`_ for
|
| 135 |
+
contributing to this project.
|
| 136 |
+
|
| 137 |
+
Please report any bugs on the `issue tracker`_
|
| 138 |
+
|
| 139 |
+
.. _Cory Benfield's blog: https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/
|
| 140 |
+
.. _python-requests: https://github.com/kennethreitz/requests
|
| 141 |
+
.. _issue tracker: https://github.com/requests/toolbelt/issues
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
History
|
| 145 |
+
=======
|
| 146 |
+
|
| 147 |
+
1.0.0 -- 2023-05-01
|
| 148 |
+
-------------------
|
| 149 |
+
|
| 150 |
+
Breaking Changes
|
| 151 |
+
~~~~~~~~~~~~~~~~
|
| 152 |
+
|
| 153 |
+
- Removed Google App Engine support to allow using urllib3 2.0
|
| 154 |
+
|
| 155 |
+
Fixed Bugs
|
| 156 |
+
~~~~~~~~~~
|
| 157 |
+
|
| 158 |
+
- Ensured the test suite no longer reaches the Internet
|
| 159 |
+
|
| 160 |
+
Miscellaneous
|
| 161 |
+
~~~~~~~~~~~~~
|
| 162 |
+
|
| 163 |
+
- Added explicit support for Python 3.11
|
| 164 |
+
|
| 165 |
+
0.10.1 -- 2022-10-25
|
| 166 |
+
--------------------
|
| 167 |
+
|
| 168 |
+
Fixed Bugs
|
| 169 |
+
~~~~~~~~~~
|
| 170 |
+
|
| 171 |
+
- Fix urllib3 warning to only emit on X509Adapter usage
|
| 172 |
+
|
| 173 |
+
0.10.0 -- 2022-10-06
|
| 174 |
+
--------------------
|
| 175 |
+
|
| 176 |
+
New Features
|
| 177 |
+
~~~~~~~~~~~~
|
| 178 |
+
|
| 179 |
+
- Add support for preparing requests in BaseUrlSession
|
| 180 |
+
|
| 181 |
+
Fixed Bugs
|
| 182 |
+
~~~~~~~~~~
|
| 183 |
+
|
| 184 |
+
- Fixing missing newline in dump utility
|
| 185 |
+
|
| 186 |
+
0.9.1 -- 2019-01-29
|
| 187 |
+
-------------------
|
| 188 |
+
|
| 189 |
+
Fixed Bugs
|
| 190 |
+
~~~~~~~~~~
|
| 191 |
+
|
| 192 |
+
- Fix import of pyOpenSSL shim from urllib3 for PKCS12 adapter
|
| 193 |
+
|
| 194 |
+
0.9.0 -- 2019-01-29
|
| 195 |
+
-------------------
|
| 196 |
+
|
| 197 |
+
New Features
|
| 198 |
+
~~~~~~~~~~~~
|
| 199 |
+
|
| 200 |
+
- Add X509 Adapter that can handle PKCS12
|
| 201 |
+
- Add stateless solution for streaming files by MultipartEncoder from one host to another (in chunks)
|
| 202 |
+
|
| 203 |
+
Fixed Bugs
|
| 204 |
+
~~~~~~~~~~
|
| 205 |
+
|
| 206 |
+
- Update link to example
|
| 207 |
+
- Move import of ``ABCs`` from collections into version-specific part of
|
| 208 |
+
_compat module
|
| 209 |
+
- Fix backwards incompatibility in ``get_encodings_from_content``
|
| 210 |
+
- Correct callback documentation for ``MultipartEncoderMonitor``
|
| 211 |
+
- Fix bug when ``MultipartEncoder`` is asked to encode zero parts
|
| 212 |
+
- Correct the type of non string request body dumps
|
| 213 |
+
- Removed content from being stored in MultipartDecoder
|
| 214 |
+
- Fix bug by enabling support for contenttype with capital letters.
|
| 215 |
+
- Coerce proxy URL to bytes before dumping request
|
| 216 |
+
- Avoid bailing out with exception upon empty response reason
|
| 217 |
+
- Corrected Pool documentation
|
| 218 |
+
- Corrected parentheses match in example usage
|
| 219 |
+
- Fix "oject" to "object" in ``MultipartEncoder``
|
| 220 |
+
- Fix URL for the project after the move
|
| 221 |
+
- Add fix for OSX TCPKeepAliveAdapter
|
| 222 |
+
|
| 223 |
+
Miscellaneous
|
| 224 |
+
~~~~~~~~~~~~~
|
| 225 |
+
|
| 226 |
+
- Remove py33 from testing and add Python 3.6 and nightly testing to the travis matrix.
|
| 227 |
+
|
| 228 |
+
0.8.0 -- 2017-05-20
|
| 229 |
+
-------------------
|
| 230 |
+
|
| 231 |
+
More information about this release can be found on the `0.8.0 milestone`_.
|
| 232 |
+
|
| 233 |
+
New Features
|
| 234 |
+
~~~~~~~~~~~~
|
| 235 |
+
|
| 236 |
+
- Add ``UserAgentBuilder`` to provide more control over generated User-Agent
|
| 237 |
+
strings.
|
| 238 |
+
|
| 239 |
+
Fixed Bugs
|
| 240 |
+
~~~~~~~~~~
|
| 241 |
+
|
| 242 |
+
- Include ``_validate_certificate`` in the lits of picked attributes on the
|
| 243 |
+
``AppEngineAdapter``.
|
| 244 |
+
- Fix backwards incompatibility in ``get_encodings_from_content``
|
| 245 |
+
|
| 246 |
+
.. _0.8.0 milestone:
|
| 247 |
+
https://github.com/requests/toolbelt/milestones/0.8.0
|
| 248 |
+
|
| 249 |
+
0.7.1 -- 2017-02-13
|
| 250 |
+
-------------------
|
| 251 |
+
|
| 252 |
+
More information about this release can be found on the `0.7.1 milestone`_.
|
| 253 |
+
|
| 254 |
+
Fixed Bugs
|
| 255 |
+
~~~~~~~~~~
|
| 256 |
+
|
| 257 |
+
- Fixed monkey-patching for the AppEngineAdapter.
|
| 258 |
+
|
| 259 |
+
- Make it easier to disable certificate verification when monkey-patching
|
| 260 |
+
AppEngine.
|
| 261 |
+
|
| 262 |
+
- Handle ``multipart/form-data`` bodies without a trailing ``CRLF``.
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
.. links
|
| 266 |
+
.. _0.7.1 milestone:
|
| 267 |
+
https://github.com/requests/toolbelt/milestone/9
|
| 268 |
+
|
| 269 |
+
0.7.0 -- 2016-07-21
|
| 270 |
+
-------------------
|
| 271 |
+
|
| 272 |
+
More information about this release can be found on the `0.7.0 milestone`_.
|
| 273 |
+
|
| 274 |
+
New Features
|
| 275 |
+
~~~~~~~~~~~~
|
| 276 |
+
|
| 277 |
+
- Add ``BaseUrlSession`` to allow developers to have a session that has a
|
| 278 |
+
"Base" URL. See the documentation for more details and examples.
|
| 279 |
+
|
| 280 |
+
- Split the logic of ``stream_response_to_file`` into two separate functions:
|
| 281 |
+
|
| 282 |
+
* ``get_download_file_path`` to generate the file name from the Response.
|
| 283 |
+
|
| 284 |
+
* ``stream_response_to_file`` which will use ``get_download_file_path`` if
|
| 285 |
+
necessary
|
| 286 |
+
|
| 287 |
+
Fixed Bugs
|
| 288 |
+
~~~~~~~~~~
|
| 289 |
+
|
| 290 |
+
- Fixed the issue for people using *very* old versions of Requests where they
|
| 291 |
+
would see an ImportError from ``requests_toolbelt._compat`` when trying to
|
| 292 |
+
import ``connection``.
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
.. _0.7.0 milestone:
|
| 296 |
+
https://github.com/requests/toolbelt/milestones/0.7.0
|
| 297 |
+
|
| 298 |
+
0.6.2 -- 2016-05-10
|
| 299 |
+
-------------------
|
| 300 |
+
|
| 301 |
+
Fixed Bugs
|
| 302 |
+
~~~~~~~~~~
|
| 303 |
+
|
| 304 |
+
- When passing a timeout via Requests, it was not appropriately translated to
|
| 305 |
+
the timeout that the urllib3 code was expecting.
|
| 306 |
+
|
| 307 |
+
0.6.1 -- 2016-05-05
|
| 308 |
+
-------------------
|
| 309 |
+
|
| 310 |
+
Fixed Bugs
|
| 311 |
+
~~~~~~~~~~
|
| 312 |
+
|
| 313 |
+
- Remove assertion about request URLs in the AppEngineAdapter.
|
| 314 |
+
|
| 315 |
+
- Prevent pip from installing requests 3.0.0 when that is released until we
|
| 316 |
+
are ready to handle it.
|
| 317 |
+
|
| 318 |
+
0.6.0 -- 2016-01-27
|
| 319 |
+
-------------------
|
| 320 |
+
|
| 321 |
+
More information about this release can be found on the `0.6.0 milestone`_.
|
| 322 |
+
|
| 323 |
+
New Features
|
| 324 |
+
~~~~~~~~~~~~
|
| 325 |
+
|
| 326 |
+
- Add ``AppEngineAdapter`` to support developers using Google's AppEngine
|
| 327 |
+
platform with Requests.
|
| 328 |
+
|
| 329 |
+
- Add ``GuessProxyAuth`` class to support guessing between Basic and Digest
|
| 330 |
+
Authentication for proxies.
|
| 331 |
+
|
| 332 |
+
Fixed Bugs
|
| 333 |
+
~~~~~~~~~~
|
| 334 |
+
|
| 335 |
+
- Ensure that proxies use the correct TLS version when using the
|
| 336 |
+
``SSLAdapter``.
|
| 337 |
+
|
| 338 |
+
- Fix an ``AttributeError`` when using the ``HTTPProxyDigestAuth`` class.
|
| 339 |
+
|
| 340 |
+
Miscellaneous
|
| 341 |
+
~~~~~~~~~~~~~
|
| 342 |
+
|
| 343 |
+
- Drop testing support for Python 3.2. virtualenv and pip have stopped
|
| 344 |
+
supporting it meaning that it is harder to test for this with our CI
|
| 345 |
+
infrastructure. Moving forward we will make a best-effort attempt to
|
| 346 |
+
support 3.2 but will not test for it.
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
.. _0.6.0 milestone:
|
| 350 |
+
https://github.com/requests/toolbelt/milestones/0.6.0
|
| 351 |
+
|
| 352 |
+
0.5.1 -- 2015-12-16
|
| 353 |
+
-------------------
|
| 354 |
+
|
| 355 |
+
More information about this release can be found on the `0.5.1 milestone`_.
|
| 356 |
+
|
| 357 |
+
Fixed Bugs
|
| 358 |
+
~~~~~~~~~~
|
| 359 |
+
|
| 360 |
+
- Now papers over the differences in requests' ``super_len`` function from
|
| 361 |
+
versions prior to 2.9.0 and versions 2.9.0 and later.
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
.. _0.5.1 milestone:
|
| 365 |
+
https://github.com/requests/toolbelt/milestones/0.5.1
|
| 366 |
+
|
| 367 |
+
0.5.0 -- 2015-11-24
|
| 368 |
+
-------------------
|
| 369 |
+
|
| 370 |
+
More information about this release can be found on the `milestone
|
| 371 |
+
<https://github.com/requests/toolbelt/issues?utf8=%E2%9C%93&q=is%3Aall+milestone%3A0.5+>`_
|
| 372 |
+
for 0.5.0.
|
| 373 |
+
|
| 374 |
+
New Features
|
| 375 |
+
~~~~~~~~~~~~
|
| 376 |
+
|
| 377 |
+
- The ``tee`` submodule was added to ``requests_toolbelt.downloadutils``. It
|
| 378 |
+
allows you to iterate over the bytes of a response while also writing them
|
| 379 |
+
to a file. The ``tee.tee`` function, expects you to pass an open file
|
| 380 |
+
object, while ``tee.tee_to_file`` will use the provided file name to open
|
| 381 |
+
the file for you.
|
| 382 |
+
|
| 383 |
+
- Added a new parameter to ``requests_toolbelt.utils.user_agent`` that allows
|
| 384 |
+
the user to specify additional items.
|
| 385 |
+
|
| 386 |
+
- Added nested form-data helper,
|
| 387 |
+
``requests_toolbelt.utils.formdata.urlencode``.
|
| 388 |
+
|
| 389 |
+
- Added the ``ForgetfulCookieJar`` to ``requests_toolbelt.cookies``.
|
| 390 |
+
|
| 391 |
+
- Added utilities for dumping the information about a request-response cycle
|
| 392 |
+
in ``requests_toolbelt.utils.dump``.
|
| 393 |
+
|
| 394 |
+
- Implemented the API described in the ``requests_toolbelt.threaded`` module
|
| 395 |
+
docstring, i.e., added ``requests_toolbelt.threaded.map`` as an available
|
| 396 |
+
function.
|
| 397 |
+
|
| 398 |
+
Fixed Bugs
|
| 399 |
+
~~~~~~~~~~
|
| 400 |
+
|
| 401 |
+
- Now papers over the API differences in versions of requests installed from
|
| 402 |
+
system packages versus versions of requests installed from PyPI.
|
| 403 |
+
|
| 404 |
+
- Allow string types for ``SourceAddressAdapter``.
|
| 405 |
+
|
| 406 |
+
0.4.0 -- 2015-04-03
|
| 407 |
+
-------------------
|
| 408 |
+
|
| 409 |
+
For more information about this release, please see `milestone 0.4.0
|
| 410 |
+
<https://github.com/requests/toolbelt/issues?q=milestone%3A0.4>`_
|
| 411 |
+
on the project's page.
|
| 412 |
+
|
| 413 |
+
New Features
|
| 414 |
+
~~~~~~~~~~~~
|
| 415 |
+
|
| 416 |
+
- A naive implemenation of a thread pool is now included in the toolbelt. See
|
| 417 |
+
the docs in ``docs/threading.rst`` or on `Read The Docs
|
| 418 |
+
<https://toolbelt.readthedocs.io/>`_.
|
| 419 |
+
|
| 420 |
+
- The ``StreamingIterator`` now accepts files (such as ``sys.stdin``) without
|
| 421 |
+
a specific length and will properly stream them.
|
| 422 |
+
|
| 423 |
+
- The ``MultipartEncoder`` now accepts exactly the same format of fields as
|
| 424 |
+
requests' ``files`` parameter does. In other words, you can now also pass in
|
| 425 |
+
extra headers to add to a part in the body. You can also now specify a
|
| 426 |
+
custom ``Content-Type`` for a part.
|
| 427 |
+
|
| 428 |
+
- An implementation of HTTP Digest Authentication for Proxies is now included.
|
| 429 |
+
|
| 430 |
+
- A transport adapter that allows a user to specify a specific Certificate
|
| 431 |
+
Fingerprint is now included in the toolbelt.
|
| 432 |
+
|
| 433 |
+
- A transport adapter that simplifies how users specify socket options is now
|
| 434 |
+
included.
|
| 435 |
+
|
| 436 |
+
- A transport adapter that simplifies how users can specify TCP Keep-Alive
|
| 437 |
+
options is now included in the toolbelt.
|
| 438 |
+
|
| 439 |
+
- Deprecated functions from ``requests.utils`` are now included and
|
| 440 |
+
maintained.
|
| 441 |
+
|
| 442 |
+
- An authentication tool that allows users to specify how to authenticate to
|
| 443 |
+
several different domains at once is now included.
|
| 444 |
+
|
| 445 |
+
- A function to save streamed responses to disk by analyzing the
|
| 446 |
+
``Content-Disposition`` header is now included in the toolbelt.
|
| 447 |
+
|
| 448 |
+
Fixed Bugs
|
| 449 |
+
~~~~~~~~~~
|
| 450 |
+
|
| 451 |
+
- The ``MultipartEncoder`` will now allow users to upload files larger than
|
| 452 |
+
4GB on 32-bit systems.
|
| 453 |
+
|
| 454 |
+
- The ``MultipartEncoder`` will now accept empty unicode strings for form
|
| 455 |
+
values.
|
| 456 |
+
|
| 457 |
+
0.3.1 -- 2014-06-23
|
| 458 |
+
-------------------
|
| 459 |
+
|
| 460 |
+
- Fix the fact that 0.3.0 bundle did not include the ``StreamingIterator``
|
| 461 |
+
|
| 462 |
+
0.3.0 -- 2014-05-21
|
| 463 |
+
-------------------
|
| 464 |
+
|
| 465 |
+
Bug Fixes
|
| 466 |
+
~~~~~~~~~
|
| 467 |
+
|
| 468 |
+
- Complete rewrite of ``MultipartEncoder`` fixes bug where bytes were lost in
|
| 469 |
+
uploads
|
| 470 |
+
|
| 471 |
+
New Features
|
| 472 |
+
~~~~~~~~~~~~
|
| 473 |
+
|
| 474 |
+
- ``MultipartDecoder`` to accept ``multipart/form-data`` response bodies and
|
| 475 |
+
parse them into an easy to use object.
|
| 476 |
+
|
| 477 |
+
- ``SourceAddressAdapter`` to allow users to choose a local address to bind
|
| 478 |
+
connections to.
|
| 479 |
+
|
| 480 |
+
- ``GuessAuth`` which accepts a username and password and uses the
|
| 481 |
+
``WWW-Authenticate`` header to determine how to authenticate against a
|
| 482 |
+
server.
|
| 483 |
+
|
| 484 |
+
- ``MultipartEncoderMonitor`` wraps an instance of the ``MultipartEncoder``
|
| 485 |
+
and keeps track of how many bytes were read and will call the provided
|
| 486 |
+
callback.
|
| 487 |
+
|
| 488 |
+
- ``StreamingIterator`` will wrap an iterator and stream the upload instead of
|
| 489 |
+
chunk it, provided you also provide the length of the content you wish to
|
| 490 |
+
upload.
|
| 491 |
+
|
| 492 |
+
0.2.0 -- 2014-02-24
|
| 493 |
+
-------------------
|
| 494 |
+
|
| 495 |
+
- Add ability to tell ``MultipartEncoder`` which encoding to use. By default
|
| 496 |
+
it uses 'utf-8'.
|
| 497 |
+
|
| 498 |
+
- Fix #10 - allow users to install with pip
|
| 499 |
+
|
| 500 |
+
- Fix #9 - Fix ``MultipartEncoder#to_string`` so that it properly handles file
|
| 501 |
+
objects as fields
|
| 502 |
+
|
| 503 |
+
0.1.2 -- 2014-01-19
|
| 504 |
+
-------------------
|
| 505 |
+
|
| 506 |
+
- At some point during development we broke how we handle normal file objects.
|
| 507 |
+
Thanks to @konomae this is now fixed.
|
| 508 |
+
|
| 509 |
+
0.1.1 -- 2014-01-19
|
| 510 |
+
-------------------
|
| 511 |
+
|
| 512 |
+
- Handle ``io.BytesIO``-like objects better
|
| 513 |
+
|
| 514 |
+
0.1.0 -- 2014-01-18
|
| 515 |
+
-------------------
|
| 516 |
+
|
| 517 |
+
- Add initial implementation of the streaming ``MultipartEncoder``
|
| 518 |
+
|
| 519 |
+
- Add initial implementation of the ``user_agent`` function
|
| 520 |
+
|
| 521 |
+
- Add the ``SSLAdapter``
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests_toolbelt-1.0.0.dist-info/AUTHORS.rst,sha256=V98Zj2LJCYqslcm47B8LjvwCQID2HVoO2J70xdo88DE,986
|
| 2 |
+
requests_toolbelt-1.0.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 3 |
+
requests_toolbelt-1.0.0.dist-info/LICENSE,sha256=H4z4vazZjtbTbQ_sDAf3dlrOvW6BIFliq1FGAjs8hY0,596
|
| 4 |
+
requests_toolbelt-1.0.0.dist-info/METADATA,sha256=-lLyYjfMjRSNJcV0b9ykmaVtDnZeaQlcw1ZKB8ziOWc,14638
|
| 5 |
+
requests_toolbelt-1.0.0.dist-info/RECORD,,
|
| 6 |
+
requests_toolbelt-1.0.0.dist-info/WHEEL,sha256=a-zpFRIJzOq5QfuhBzbhiA1eHTzNCJn8OdRvhdNX0Rk,110
|
| 7 |
+
requests_toolbelt-1.0.0.dist-info/top_level.txt,sha256=94d34hHwG8qjeDXYn9Co3jucG_N9CkO-V5kWQ6Cre8w,18
|
| 8 |
+
requests_toolbelt/__init__.py,sha256=ZUDjGuNOjooYe7jy2PoScTWLIr073PfmGUsc_KEp-Vk,1188
|
| 9 |
+
requests_toolbelt/__pycache__/__init__.cpython-311.pyc,,
|
| 10 |
+
requests_toolbelt/__pycache__/_compat.cpython-311.pyc,,
|
| 11 |
+
requests_toolbelt/__pycache__/exceptions.cpython-311.pyc,,
|
| 12 |
+
requests_toolbelt/__pycache__/sessions.cpython-311.pyc,,
|
| 13 |
+
requests_toolbelt/__pycache__/streaming_iterator.cpython-311.pyc,,
|
| 14 |
+
requests_toolbelt/_compat.py,sha256=K7xMtOshOUWDtGG2hBfuw89R1BdkIvAz_x62CCMRvdg,9260
|
| 15 |
+
requests_toolbelt/adapters/__init__.py,sha256=KRELTDZ21X2INIl7MmxjDXaw4gTY8G4UuO5mVBE3bek,370
|
| 16 |
+
requests_toolbelt/adapters/__pycache__/__init__.cpython-311.pyc,,
|
| 17 |
+
requests_toolbelt/adapters/__pycache__/appengine.cpython-311.pyc,,
|
| 18 |
+
requests_toolbelt/adapters/__pycache__/fingerprint.cpython-311.pyc,,
|
| 19 |
+
requests_toolbelt/adapters/__pycache__/host_header_ssl.cpython-311.pyc,,
|
| 20 |
+
requests_toolbelt/adapters/__pycache__/socket_options.cpython-311.pyc,,
|
| 21 |
+
requests_toolbelt/adapters/__pycache__/source.cpython-311.pyc,,
|
| 22 |
+
requests_toolbelt/adapters/__pycache__/ssl.cpython-311.pyc,,
|
| 23 |
+
requests_toolbelt/adapters/__pycache__/x509.cpython-311.pyc,,
|
| 24 |
+
requests_toolbelt/adapters/appengine.py,sha256=pnN0SB-mUNKTSsOCVfg95bE60AIY6TMfD2pAswSWIVE,7539
|
| 25 |
+
requests_toolbelt/adapters/fingerprint.py,sha256=NRL_75ZO-nIvOOG8KIqgzXLoLN6B6leRKfT78P3cQQE,1404
|
| 26 |
+
requests_toolbelt/adapters/host_header_ssl.py,sha256=6UbWnM3DYG6PROLPjzuCo3PEw-BxLXTUMtl68sAOIlk,1396
|
| 27 |
+
requests_toolbelt/adapters/socket_options.py,sha256=ri41pRVuH1my9RNEsi6-VuYlR620D4sTDa9VRcztzbM,4789
|
| 28 |
+
requests_toolbelt/adapters/source.py,sha256=n0WBD4vOUZm2aZqKEFzmiQo8_uslXBkNqG2wti4lKDg,2608
|
| 29 |
+
requests_toolbelt/adapters/ssl.py,sha256=QGjVCHwqSTzvP58EIYOb47CdLB9KPg5AmGDNQ7buwwA,2399
|
| 30 |
+
requests_toolbelt/adapters/x509.py,sha256=qaB-kmjRMUvQbCdlEX-lqLZZIQC_65kexTVAUCWaqqQ,7854
|
| 31 |
+
requests_toolbelt/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 32 |
+
requests_toolbelt/auth/__pycache__/__init__.cpython-311.pyc,,
|
| 33 |
+
requests_toolbelt/auth/__pycache__/_digest_auth_compat.cpython-311.pyc,,
|
| 34 |
+
requests_toolbelt/auth/__pycache__/guess.cpython-311.pyc,,
|
| 35 |
+
requests_toolbelt/auth/__pycache__/handler.cpython-311.pyc,,
|
| 36 |
+
requests_toolbelt/auth/__pycache__/http_proxy_digest.cpython-311.pyc,,
|
| 37 |
+
requests_toolbelt/auth/_digest_auth_compat.py,sha256=Japu0u8KwV3IFbRiEmzrxVR6MxINnpmbPYeEqyh_zbM,910
|
| 38 |
+
requests_toolbelt/auth/guess.py,sha256=QSl22nPByDKiuACvR5uxpVbtGcMby8SwAHjwsPW9sD0,4944
|
| 39 |
+
requests_toolbelt/auth/handler.py,sha256=2Ct2BYgdyVVxyT2mP7ez_4mDo8XXS50rqUmnoB2o_yk,4407
|
| 40 |
+
requests_toolbelt/auth/http_proxy_digest.py,sha256=eN15w0UpEFBrf54G9TISz9M0N7U3gSza4KvW2GJ9kwk,3706
|
| 41 |
+
requests_toolbelt/cookies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 42 |
+
requests_toolbelt/cookies/__pycache__/__init__.cpython-311.pyc,,
|
| 43 |
+
requests_toolbelt/cookies/__pycache__/forgetful.cpython-311.pyc,,
|
| 44 |
+
requests_toolbelt/cookies/forgetful.py,sha256=B3_AB6lyRHJG4WvvKobS5W_MTP31BQ5RrLs3uYVx7cs,213
|
| 45 |
+
requests_toolbelt/downloadutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 46 |
+
requests_toolbelt/downloadutils/__pycache__/__init__.cpython-311.pyc,,
|
| 47 |
+
requests_toolbelt/downloadutils/__pycache__/stream.cpython-311.pyc,,
|
| 48 |
+
requests_toolbelt/downloadutils/__pycache__/tee.cpython-311.pyc,,
|
| 49 |
+
requests_toolbelt/downloadutils/stream.py,sha256=1YyqD3KxmIq5RK7aXntWEl7ZTrg4ks7Bldiy4K4X2I0,6024
|
| 50 |
+
requests_toolbelt/downloadutils/tee.py,sha256=qV9Bwq83OZWDg-lW0YsP4Cdzsu0gc797GCSv6w7dPPw,4365
|
| 51 |
+
requests_toolbelt/exceptions.py,sha256=cByQPGXQ4gEon-gZj9TfZPDotKXz3YneKSFFm2bdTLk,695
|
| 52 |
+
requests_toolbelt/multipart/__init__.py,sha256=vKIDFWJ-mw7e3dg2k1eXx8Pm8bNPul3PdNSFIPP5MbM,854
|
| 53 |
+
requests_toolbelt/multipart/__pycache__/__init__.cpython-311.pyc,,
|
| 54 |
+
requests_toolbelt/multipart/__pycache__/decoder.cpython-311.pyc,,
|
| 55 |
+
requests_toolbelt/multipart/__pycache__/encoder.cpython-311.pyc,,
|
| 56 |
+
requests_toolbelt/multipart/decoder.py,sha256=p5a4ImwdTCLU1-nIA86G6XXMNzpMm3hbg0S8vtMDRoU,4861
|
| 57 |
+
requests_toolbelt/multipart/encoder.py,sha256=dE2FmcONVEBvU-yyNBr8m0wjVIUuQBiGHCL8q6IVS8Y,20769
|
| 58 |
+
requests_toolbelt/sessions.py,sha256=QcxNvFCKQZSP4lVhC0gTty9ya6YCBFbCQmCiJO5T5mk,3102
|
| 59 |
+
requests_toolbelt/streaming_iterator.py,sha256=RoBpiFO996ixJ7XBdeTEDcvdt2gO8UifRZHLydRUlQ0,4044
|
| 60 |
+
requests_toolbelt/threaded/__init__.py,sha256=ZUw0h0PkLXz9H0qsPKgSD0_kX8SpLH8yjb3RvIWkuOg,3213
|
| 61 |
+
requests_toolbelt/threaded/__pycache__/__init__.cpython-311.pyc,,
|
| 62 |
+
requests_toolbelt/threaded/__pycache__/pool.cpython-311.pyc,,
|
| 63 |
+
requests_toolbelt/threaded/__pycache__/thread.cpython-311.pyc,,
|
| 64 |
+
requests_toolbelt/threaded/pool.py,sha256=8xSLI2_xElatT09jDVDua3693WXkm6vWFPQBHhLs48Y,6628
|
| 65 |
+
requests_toolbelt/threaded/thread.py,sha256=16UmWaK_lZgDcKkBkS1j-6_K3zKIok314g7Fpllj2Jg,1465
|
| 66 |
+
requests_toolbelt/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 67 |
+
requests_toolbelt/utils/__pycache__/__init__.cpython-311.pyc,,
|
| 68 |
+
requests_toolbelt/utils/__pycache__/deprecated.cpython-311.pyc,,
|
| 69 |
+
requests_toolbelt/utils/__pycache__/dump.cpython-311.pyc,,
|
| 70 |
+
requests_toolbelt/utils/__pycache__/formdata.cpython-311.pyc,,
|
| 71 |
+
requests_toolbelt/utils/__pycache__/user_agent.cpython-311.pyc,,
|
| 72 |
+
requests_toolbelt/utils/deprecated.py,sha256=KERWioUNTuwTCRFJOyW_zJKib20-iNETE879znAcnJU,2558
|
| 73 |
+
requests_toolbelt/utils/dump.py,sha256=k3HV82gacdRLjv10En60lr3ocO_2xxtJ6_JO6mgZE8s,6522
|
| 74 |
+
requests_toolbelt/utils/formdata.py,sha256=ppqpIdkW6V0CNyeFiKAytDU0H9g1yXLzZU0QTuWrjb0,3233
|
| 75 |
+
requests_toolbelt/utils/user_agent.py,sha256=iyeEadoOTsWMANRh2XzhDnwnUyX8K6BT9yZAfVTiwh0,4524
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.40.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py2-none-any
|
| 5 |
+
Tag: py3-none-any
|
| 6 |
+
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt-1.0.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
requests_toolbelt
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""
|
| 3 |
+
requests-toolbelt
|
| 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 .adapters import SSLAdapter, SourceAddressAdapter
|
| 13 |
+
from .auth.guess import GuessAuth
|
| 14 |
+
from .multipart import (
|
| 15 |
+
MultipartEncoder, MultipartEncoderMonitor, MultipartDecoder,
|
| 16 |
+
ImproperBodyPartContentException, NonMultipartContentTypeException
|
| 17 |
+
)
|
| 18 |
+
from .streaming_iterator import StreamingIterator
|
| 19 |
+
from .utils.user_agent import user_agent
|
| 20 |
+
|
| 21 |
+
__title__ = 'requests-toolbelt'
|
| 22 |
+
__authors__ = 'Ian Cordasco, Cory Benfield'
|
| 23 |
+
__license__ = 'Apache v2.0'
|
| 24 |
+
__copyright__ = 'Copyright 2014 Ian Cordasco, Cory Benfield'
|
| 25 |
+
__version__ = '1.0.0'
|
| 26 |
+
__version_info__ = tuple(int(i) for i in __version__.split('.'))
|
| 27 |
+
|
| 28 |
+
__all__ = [
|
| 29 |
+
'GuessAuth', 'MultipartEncoder', 'MultipartEncoderMonitor',
|
| 30 |
+
'MultipartDecoder', 'SSLAdapter', 'SourceAddressAdapter',
|
| 31 |
+
'StreamingIterator', 'user_agent', 'ImproperBodyPartContentException',
|
| 32 |
+
'NonMultipartContentTypeException', '__title__', '__authors__',
|
| 33 |
+
'__license__', '__copyright__', '__version__', '__version_info__',
|
| 34 |
+
]
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/_compat.py
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Private module full of compatibility hacks.
|
| 2 |
+
|
| 3 |
+
Primarily this is for downstream redistributions of requests that unvendor
|
| 4 |
+
urllib3 without providing a shim.
|
| 5 |
+
|
| 6 |
+
.. warning::
|
| 7 |
+
|
| 8 |
+
This module is private. If you use it, and something breaks, you were
|
| 9 |
+
warned
|
| 10 |
+
"""
|
| 11 |
+
import sys
|
| 12 |
+
|
| 13 |
+
import requests
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
from requests.packages.urllib3 import fields
|
| 17 |
+
from requests.packages.urllib3 import filepost
|
| 18 |
+
from requests.packages.urllib3 import poolmanager
|
| 19 |
+
except ImportError:
|
| 20 |
+
from urllib3 import fields
|
| 21 |
+
from urllib3 import filepost
|
| 22 |
+
from urllib3 import poolmanager
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
from requests.packages.urllib3.connection import HTTPConnection
|
| 26 |
+
from requests.packages.urllib3 import connection
|
| 27 |
+
except ImportError:
|
| 28 |
+
try:
|
| 29 |
+
from urllib3.connection import HTTPConnection
|
| 30 |
+
from urllib3 import connection
|
| 31 |
+
except ImportError:
|
| 32 |
+
HTTPConnection = None
|
| 33 |
+
connection = None
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
if requests.__build__ < 0x020300:
|
| 37 |
+
timeout = None
|
| 38 |
+
else:
|
| 39 |
+
try:
|
| 40 |
+
from requests.packages.urllib3.util import timeout
|
| 41 |
+
except ImportError:
|
| 42 |
+
from urllib3.util import timeout
|
| 43 |
+
|
| 44 |
+
PY3 = sys.version_info > (3, 0)
|
| 45 |
+
|
| 46 |
+
if PY3:
|
| 47 |
+
from collections.abc import Mapping, MutableMapping
|
| 48 |
+
import queue
|
| 49 |
+
from urllib.parse import urlencode, urljoin
|
| 50 |
+
else:
|
| 51 |
+
from collections import Mapping, MutableMapping
|
| 52 |
+
import Queue as queue
|
| 53 |
+
from urllib import urlencode
|
| 54 |
+
from urlparse import urljoin
|
| 55 |
+
|
| 56 |
+
try:
|
| 57 |
+
basestring = basestring
|
| 58 |
+
except NameError:
|
| 59 |
+
basestring = (str, bytes)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class HTTPHeaderDict(MutableMapping):
|
| 63 |
+
"""
|
| 64 |
+
:param headers:
|
| 65 |
+
An iterable of field-value pairs. Must not contain multiple field names
|
| 66 |
+
when compared case-insensitively.
|
| 67 |
+
|
| 68 |
+
:param kwargs:
|
| 69 |
+
Additional field-value pairs to pass in to ``dict.update``.
|
| 70 |
+
|
| 71 |
+
A ``dict`` like container for storing HTTP Headers.
|
| 72 |
+
|
| 73 |
+
Field names are stored and compared case-insensitively in compliance with
|
| 74 |
+
RFC 7230. Iteration provides the first case-sensitive key seen for each
|
| 75 |
+
case-insensitive pair.
|
| 76 |
+
|
| 77 |
+
Using ``__setitem__`` syntax overwrites fields that compare equal
|
| 78 |
+
case-insensitively in order to maintain ``dict``'s api. For fields that
|
| 79 |
+
compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
|
| 80 |
+
in a loop.
|
| 81 |
+
|
| 82 |
+
If multiple fields that are equal case-insensitively are passed to the
|
| 83 |
+
constructor or ``.update``, the behavior is undefined and some will be
|
| 84 |
+
lost.
|
| 85 |
+
|
| 86 |
+
>>> headers = HTTPHeaderDict()
|
| 87 |
+
>>> headers.add('Set-Cookie', 'foo=bar')
|
| 88 |
+
>>> headers.add('set-cookie', 'baz=quxx')
|
| 89 |
+
>>> headers['content-length'] = '7'
|
| 90 |
+
>>> headers['SET-cookie']
|
| 91 |
+
'foo=bar, baz=quxx'
|
| 92 |
+
>>> headers['Content-Length']
|
| 93 |
+
'7'
|
| 94 |
+
"""
|
| 95 |
+
|
| 96 |
+
def __init__(self, headers=None, **kwargs):
|
| 97 |
+
super(HTTPHeaderDict, self).__init__()
|
| 98 |
+
self._container = {}
|
| 99 |
+
if headers is not None:
|
| 100 |
+
if isinstance(headers, HTTPHeaderDict):
|
| 101 |
+
self._copy_from(headers)
|
| 102 |
+
else:
|
| 103 |
+
self.extend(headers)
|
| 104 |
+
if kwargs:
|
| 105 |
+
self.extend(kwargs)
|
| 106 |
+
|
| 107 |
+
def __setitem__(self, key, val):
|
| 108 |
+
self._container[key.lower()] = (key, val)
|
| 109 |
+
return self._container[key.lower()]
|
| 110 |
+
|
| 111 |
+
def __getitem__(self, key):
|
| 112 |
+
val = self._container[key.lower()]
|
| 113 |
+
return ', '.join(val[1:])
|
| 114 |
+
|
| 115 |
+
def __delitem__(self, key):
|
| 116 |
+
del self._container[key.lower()]
|
| 117 |
+
|
| 118 |
+
def __contains__(self, key):
|
| 119 |
+
return key.lower() in self._container
|
| 120 |
+
|
| 121 |
+
def __eq__(self, other):
|
| 122 |
+
if not isinstance(other, Mapping) and not hasattr(other, 'keys'):
|
| 123 |
+
return False
|
| 124 |
+
if not isinstance(other, type(self)):
|
| 125 |
+
other = type(self)(other)
|
| 126 |
+
return ({k.lower(): v for k, v in self.itermerged()} ==
|
| 127 |
+
{k.lower(): v for k, v in other.itermerged()})
|
| 128 |
+
|
| 129 |
+
def __ne__(self, other):
|
| 130 |
+
return not self.__eq__(other)
|
| 131 |
+
|
| 132 |
+
if not PY3: # Python 2
|
| 133 |
+
iterkeys = MutableMapping.iterkeys
|
| 134 |
+
itervalues = MutableMapping.itervalues
|
| 135 |
+
|
| 136 |
+
__marker = object()
|
| 137 |
+
|
| 138 |
+
def __len__(self):
|
| 139 |
+
return len(self._container)
|
| 140 |
+
|
| 141 |
+
def __iter__(self):
|
| 142 |
+
# Only provide the originally cased names
|
| 143 |
+
for vals in self._container.values():
|
| 144 |
+
yield vals[0]
|
| 145 |
+
|
| 146 |
+
def pop(self, key, default=__marker):
|
| 147 |
+
"""D.pop(k[,d]) -> v, remove specified key and return its value.
|
| 148 |
+
|
| 149 |
+
If key is not found, d is returned if given, otherwise KeyError is
|
| 150 |
+
raised.
|
| 151 |
+
"""
|
| 152 |
+
# Using the MutableMapping function directly fails due to the private
|
| 153 |
+
# marker.
|
| 154 |
+
# Using ordinary dict.pop would expose the internal structures.
|
| 155 |
+
# So let's reinvent the wheel.
|
| 156 |
+
try:
|
| 157 |
+
value = self[key]
|
| 158 |
+
except KeyError:
|
| 159 |
+
if default is self.__marker:
|
| 160 |
+
raise
|
| 161 |
+
return default
|
| 162 |
+
else:
|
| 163 |
+
del self[key]
|
| 164 |
+
return value
|
| 165 |
+
|
| 166 |
+
def discard(self, key):
|
| 167 |
+
try:
|
| 168 |
+
del self[key]
|
| 169 |
+
except KeyError:
|
| 170 |
+
pass
|
| 171 |
+
|
| 172 |
+
def add(self, key, val):
|
| 173 |
+
"""Adds a (name, value) pair, doesn't overwrite the value if it already
|
| 174 |
+
exists.
|
| 175 |
+
|
| 176 |
+
>>> headers = HTTPHeaderDict(foo='bar')
|
| 177 |
+
>>> headers.add('Foo', 'baz')
|
| 178 |
+
>>> headers['foo']
|
| 179 |
+
'bar, baz'
|
| 180 |
+
"""
|
| 181 |
+
key_lower = key.lower()
|
| 182 |
+
new_vals = key, val
|
| 183 |
+
# Keep the common case aka no item present as fast as possible
|
| 184 |
+
vals = self._container.setdefault(key_lower, new_vals)
|
| 185 |
+
if new_vals is not vals:
|
| 186 |
+
# new_vals was not inserted, as there was a previous one
|
| 187 |
+
if isinstance(vals, list):
|
| 188 |
+
# If already several items got inserted, we have a list
|
| 189 |
+
vals.append(val)
|
| 190 |
+
else:
|
| 191 |
+
# vals should be a tuple then, i.e. only one item so far
|
| 192 |
+
# Need to convert the tuple to list for further extension
|
| 193 |
+
self._container[key_lower] = [vals[0], vals[1], val]
|
| 194 |
+
|
| 195 |
+
def extend(self, *args, **kwargs):
|
| 196 |
+
"""Generic import function for any type of header-like object.
|
| 197 |
+
Adapted version of MutableMapping.update in order to insert items
|
| 198 |
+
with self.add instead of self.__setitem__
|
| 199 |
+
"""
|
| 200 |
+
if len(args) > 1:
|
| 201 |
+
raise TypeError("extend() takes at most 1 positional "
|
| 202 |
+
"arguments ({} given)".format(len(args)))
|
| 203 |
+
other = args[0] if len(args) >= 1 else ()
|
| 204 |
+
|
| 205 |
+
if isinstance(other, HTTPHeaderDict):
|
| 206 |
+
for key, val in other.iteritems():
|
| 207 |
+
self.add(key, val)
|
| 208 |
+
elif isinstance(other, Mapping):
|
| 209 |
+
for key in other:
|
| 210 |
+
self.add(key, other[key])
|
| 211 |
+
elif hasattr(other, "keys"):
|
| 212 |
+
for key in other.keys():
|
| 213 |
+
self.add(key, other[key])
|
| 214 |
+
else:
|
| 215 |
+
for key, value in other:
|
| 216 |
+
self.add(key, value)
|
| 217 |
+
|
| 218 |
+
for key, value in kwargs.items():
|
| 219 |
+
self.add(key, value)
|
| 220 |
+
|
| 221 |
+
def getlist(self, key):
|
| 222 |
+
"""Returns a list of all the values for the named field. Returns an
|
| 223 |
+
empty list if the key doesn't exist."""
|
| 224 |
+
try:
|
| 225 |
+
vals = self._container[key.lower()]
|
| 226 |
+
except KeyError:
|
| 227 |
+
return []
|
| 228 |
+
else:
|
| 229 |
+
if isinstance(vals, tuple):
|
| 230 |
+
return [vals[1]]
|
| 231 |
+
else:
|
| 232 |
+
return vals[1:]
|
| 233 |
+
|
| 234 |
+
# Backwards compatibility for httplib
|
| 235 |
+
getheaders = getlist
|
| 236 |
+
getallmatchingheaders = getlist
|
| 237 |
+
iget = getlist
|
| 238 |
+
|
| 239 |
+
def __repr__(self):
|
| 240 |
+
return "%s(%s)" % (type(self).__name__, dict(self.itermerged()))
|
| 241 |
+
|
| 242 |
+
def _copy_from(self, other):
|
| 243 |
+
for key in other:
|
| 244 |
+
val = other.getlist(key)
|
| 245 |
+
if isinstance(val, list):
|
| 246 |
+
# Don't need to convert tuples
|
| 247 |
+
val = list(val)
|
| 248 |
+
self._container[key.lower()] = [key] + val
|
| 249 |
+
|
| 250 |
+
def copy(self):
|
| 251 |
+
clone = type(self)()
|
| 252 |
+
clone._copy_from(self)
|
| 253 |
+
return clone
|
| 254 |
+
|
| 255 |
+
def iteritems(self):
|
| 256 |
+
"""Iterate over all header lines, including duplicate ones."""
|
| 257 |
+
for key in self:
|
| 258 |
+
vals = self._container[key.lower()]
|
| 259 |
+
for val in vals[1:]:
|
| 260 |
+
yield vals[0], val
|
| 261 |
+
|
| 262 |
+
def itermerged(self):
|
| 263 |
+
"""Iterate over all headers, merging duplicate ones together."""
|
| 264 |
+
for key in self:
|
| 265 |
+
val = self._container[key.lower()]
|
| 266 |
+
yield val[0], ', '.join(val[1:])
|
| 267 |
+
|
| 268 |
+
def items(self):
|
| 269 |
+
return list(self.iteritems())
|
| 270 |
+
|
| 271 |
+
@classmethod
|
| 272 |
+
def from_httplib(cls, message): # Python 2
|
| 273 |
+
"""Read headers from a Python 2 httplib message object."""
|
| 274 |
+
# python2.7 does not expose a proper API for exporting multiheaders
|
| 275 |
+
# efficiently. This function re-reads raw lines from the message
|
| 276 |
+
# object and extracts the multiheaders properly.
|
| 277 |
+
headers = []
|
| 278 |
+
|
| 279 |
+
for line in message.headers:
|
| 280 |
+
if line.startswith((' ', '\t')):
|
| 281 |
+
key, value = headers[-1]
|
| 282 |
+
headers[-1] = (key, value + '\r\n' + line.rstrip())
|
| 283 |
+
continue
|
| 284 |
+
|
| 285 |
+
key, value = line.split(':', 1)
|
| 286 |
+
headers.append((key, value.strip()))
|
| 287 |
+
|
| 288 |
+
return cls(headers)
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
__all__ = (
|
| 292 |
+
'basestring',
|
| 293 |
+
'connection',
|
| 294 |
+
'fields',
|
| 295 |
+
'filepost',
|
| 296 |
+
'poolmanager',
|
| 297 |
+
'timeout',
|
| 298 |
+
'HTTPHeaderDict',
|
| 299 |
+
'queue',
|
| 300 |
+
'urlencode',
|
| 301 |
+
'urljoin',
|
| 302 |
+
)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/exceptions.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""Collection of exceptions raised by requests-toolbelt."""
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class StreamingError(Exception):
|
| 6 |
+
"""Used in :mod:`requests_toolbelt.downloadutils.stream`."""
|
| 7 |
+
pass
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class VersionMismatchError(Exception):
|
| 11 |
+
"""Used to indicate a version mismatch in the version of requests required.
|
| 12 |
+
|
| 13 |
+
The feature in use requires a newer version of Requests to function
|
| 14 |
+
appropriately but the version installed is not sufficient.
|
| 15 |
+
"""
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class RequestsVersionTooOld(Warning):
|
| 20 |
+
"""Used to indicate that the Requests version is too old.
|
| 21 |
+
|
| 22 |
+
If the version of Requests is too old to support a feature, we will issue
|
| 23 |
+
this warning to the user.
|
| 24 |
+
"""
|
| 25 |
+
pass
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/sessions.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
from ._compat import urljoin
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class BaseUrlSession(requests.Session):
|
| 7 |
+
"""A Session with a URL that all requests will use as a base.
|
| 8 |
+
|
| 9 |
+
Let's start by looking at a few examples:
|
| 10 |
+
|
| 11 |
+
.. code-block:: python
|
| 12 |
+
|
| 13 |
+
>>> from requests_toolbelt import sessions
|
| 14 |
+
>>> s = sessions.BaseUrlSession(
|
| 15 |
+
... base_url='https://example.com/resource/')
|
| 16 |
+
>>> r = s.get('sub-resource/', params={'foo': 'bar'})
|
| 17 |
+
>>> print(r.request.url)
|
| 18 |
+
https://example.com/resource/sub-resource/?foo=bar
|
| 19 |
+
|
| 20 |
+
Our call to the ``get`` method will make a request to the URL passed in
|
| 21 |
+
when we created the Session and the partial resource name we provide.
|
| 22 |
+
We implement this by overriding the ``request`` method of the Session.
|
| 23 |
+
|
| 24 |
+
Likewise, we override the ``prepare_request`` method so you can construct
|
| 25 |
+
a PreparedRequest in the same way:
|
| 26 |
+
|
| 27 |
+
.. code-block:: python
|
| 28 |
+
|
| 29 |
+
>>> from requests import Request
|
| 30 |
+
>>> from requests_toolbelt import sessions
|
| 31 |
+
>>> s = sessions.BaseUrlSession(
|
| 32 |
+
... base_url='https://example.com/resource/')
|
| 33 |
+
>>> request = Request(method='GET', url='sub-resource/')
|
| 34 |
+
>>> prepared_request = s.prepare_request(request)
|
| 35 |
+
>>> r = s.send(prepared_request)
|
| 36 |
+
>>> print(r.request.url)
|
| 37 |
+
https://example.com/resource/sub-resource
|
| 38 |
+
|
| 39 |
+
.. note::
|
| 40 |
+
|
| 41 |
+
The base URL that you provide and the path you provide are **very**
|
| 42 |
+
important.
|
| 43 |
+
|
| 44 |
+
Let's look at another *similar* example
|
| 45 |
+
|
| 46 |
+
.. code-block:: python
|
| 47 |
+
|
| 48 |
+
>>> from requests_toolbelt import sessions
|
| 49 |
+
>>> s = sessions.BaseUrlSession(
|
| 50 |
+
... base_url='https://example.com/resource/')
|
| 51 |
+
>>> r = s.get('/sub-resource/', params={'foo': 'bar'})
|
| 52 |
+
>>> print(r.request.url)
|
| 53 |
+
https://example.com/sub-resource/?foo=bar
|
| 54 |
+
|
| 55 |
+
The key difference here is that we called ``get`` with ``/sub-resource/``,
|
| 56 |
+
i.e., there was a leading ``/``. This changes how we create the URL
|
| 57 |
+
because we rely on :mod:`urllib.parse.urljoin`.
|
| 58 |
+
|
| 59 |
+
To override how we generate the URL, sub-class this method and override the
|
| 60 |
+
``create_url`` method.
|
| 61 |
+
|
| 62 |
+
Based on implementation from
|
| 63 |
+
https://github.com/kennethreitz/requests/issues/2554#issuecomment-109341010
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
base_url = None
|
| 67 |
+
|
| 68 |
+
def __init__(self, base_url=None):
|
| 69 |
+
if base_url:
|
| 70 |
+
self.base_url = base_url
|
| 71 |
+
super(BaseUrlSession, self).__init__()
|
| 72 |
+
|
| 73 |
+
def request(self, method, url, *args, **kwargs):
|
| 74 |
+
"""Send the request after generating the complete URL."""
|
| 75 |
+
url = self.create_url(url)
|
| 76 |
+
return super(BaseUrlSession, self).request(
|
| 77 |
+
method, url, *args, **kwargs
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
def prepare_request(self, request, *args, **kwargs):
|
| 81 |
+
"""Prepare the request after generating the complete URL."""
|
| 82 |
+
request.url = self.create_url(request.url)
|
| 83 |
+
return super(BaseUrlSession, self).prepare_request(
|
| 84 |
+
request, *args, **kwargs
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
def create_url(self, url):
|
| 88 |
+
"""Create the URL based off this partial path."""
|
| 89 |
+
return urljoin(self.base_url, url)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/requests_toolbelt/streaming_iterator.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
requests_toolbelt.streaming_iterator
|
| 5 |
+
====================================
|
| 6 |
+
|
| 7 |
+
This holds the implementation details for the :class:`StreamingIterator`. It
|
| 8 |
+
is designed for the case where you, the user, know the size of the upload but
|
| 9 |
+
need to provide the data as an iterator. This class will allow you to specify
|
| 10 |
+
the size and stream the data without using a chunked transfer-encoding.
|
| 11 |
+
|
| 12 |
+
"""
|
| 13 |
+
from requests.utils import super_len
|
| 14 |
+
|
| 15 |
+
from .multipart.encoder import CustomBytesIO, encode_with
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class StreamingIterator(object):
|
| 19 |
+
|
| 20 |
+
"""
|
| 21 |
+
This class provides a way of allowing iterators with a known size to be
|
| 22 |
+
streamed instead of chunked.
|
| 23 |
+
|
| 24 |
+
In requests, if you pass in an iterator it assumes you want to use
|
| 25 |
+
chunked transfer-encoding to upload the data, which not all servers
|
| 26 |
+
support well. Additionally, you may want to set the content-length
|
| 27 |
+
yourself to avoid this but that will not work. The only way to preempt
|
| 28 |
+
requests using a chunked transfer-encoding and forcing it to stream the
|
| 29 |
+
uploads is to mimic a very specific interace. Instead of having to know
|
| 30 |
+
these details you can instead just use this class. You simply provide the
|
| 31 |
+
size and iterator and pass the instance of StreamingIterator to requests
|
| 32 |
+
via the data parameter like so:
|
| 33 |
+
|
| 34 |
+
.. code-block:: python
|
| 35 |
+
|
| 36 |
+
from requests_toolbelt import StreamingIterator
|
| 37 |
+
|
| 38 |
+
import requests
|
| 39 |
+
|
| 40 |
+
# Let iterator be some generator that you already have and size be
|
| 41 |
+
# the size of the data produced by the iterator
|
| 42 |
+
|
| 43 |
+
r = requests.post(url, data=StreamingIterator(size, iterator))
|
| 44 |
+
|
| 45 |
+
You can also pass file-like objects to :py:class:`StreamingIterator` in
|
| 46 |
+
case requests can't determize the filesize itself. This is the case with
|
| 47 |
+
streaming file objects like ``stdin`` or any sockets. Wrapping e.g. files
|
| 48 |
+
that are on disk with ``StreamingIterator`` is unnecessary, because
|
| 49 |
+
requests can determine the filesize itself.
|
| 50 |
+
|
| 51 |
+
Naturally, you should also set the `Content-Type` of your upload
|
| 52 |
+
appropriately because the toolbelt will not attempt to guess that for you.
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
def __init__(self, size, iterator, encoding='utf-8'):
|
| 56 |
+
#: The expected size of the upload
|
| 57 |
+
self.size = int(size)
|
| 58 |
+
|
| 59 |
+
if self.size < 0:
|
| 60 |
+
raise ValueError(
|
| 61 |
+
'The size of the upload must be a positive integer'
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
#: Attribute that requests will check to determine the length of the
|
| 65 |
+
#: body. See bug #80 for more details
|
| 66 |
+
self.len = self.size
|
| 67 |
+
|
| 68 |
+
#: Encoding the input data is using
|
| 69 |
+
self.encoding = encoding
|
| 70 |
+
|
| 71 |
+
#: The iterator used to generate the upload data
|
| 72 |
+
self.iterator = iterator
|
| 73 |
+
|
| 74 |
+
if hasattr(iterator, 'read'):
|
| 75 |
+
self._file = iterator
|
| 76 |
+
else:
|
| 77 |
+
self._file = _IteratorAsBinaryFile(iterator, encoding)
|
| 78 |
+
|
| 79 |
+
def read(self, size=-1):
|
| 80 |
+
return encode_with(self._file.read(size), self.encoding)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
class _IteratorAsBinaryFile(object):
|
| 84 |
+
def __init__(self, iterator, encoding='utf-8'):
|
| 85 |
+
#: The iterator used to generate the upload data
|
| 86 |
+
self.iterator = iterator
|
| 87 |
+
|
| 88 |
+
#: Encoding the iterator is using
|
| 89 |
+
self.encoding = encoding
|
| 90 |
+
|
| 91 |
+
# The buffer we use to provide the correct number of bytes requested
|
| 92 |
+
# during a read
|
| 93 |
+
self._buffer = CustomBytesIO()
|
| 94 |
+
|
| 95 |
+
def _get_bytes(self):
|
| 96 |
+
try:
|
| 97 |
+
return encode_with(next(self.iterator), self.encoding)
|
| 98 |
+
except StopIteration:
|
| 99 |
+
return b''
|
| 100 |
+
|
| 101 |
+
def _load_bytes(self, size):
|
| 102 |
+
self._buffer.smart_truncate()
|
| 103 |
+
amount_to_load = size - super_len(self._buffer)
|
| 104 |
+
bytes_to_append = True
|
| 105 |
+
|
| 106 |
+
while amount_to_load > 0 and bytes_to_append:
|
| 107 |
+
bytes_to_append = self._get_bytes()
|
| 108 |
+
amount_to_load -= self._buffer.append(bytes_to_append)
|
| 109 |
+
|
| 110 |
+
def read(self, size=-1):
|
| 111 |
+
size = int(size)
|
| 112 |
+
if size == -1:
|
| 113 |
+
return b''.join(self.iterator)
|
| 114 |
+
|
| 115 |
+
self._load_bytes(size)
|
| 116 |
+
return self._buffer.read(size)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: rich
|
| 3 |
+
Version: 15.0.0
|
| 4 |
+
Summary: Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
|
| 5 |
+
License: MIT
|
| 6 |
+
License-File: LICENSE
|
| 7 |
+
Author: Will McGugan
|
| 8 |
+
Author-email: willmcgugan@gmail.com
|
| 9 |
+
Requires-Python: >=3.9.0
|
| 10 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 11 |
+
Classifier: Environment :: Console
|
| 12 |
+
Classifier: Framework :: IPython
|
| 13 |
+
Classifier: Intended Audience :: Developers
|
| 14 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 15 |
+
Classifier: Operating System :: MacOS
|
| 16 |
+
Classifier: Operating System :: Microsoft :: Windows
|
| 17 |
+
Classifier: Operating System :: POSIX :: Linux
|
| 18 |
+
Classifier: Programming Language :: Python :: 3
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 25 |
+
Classifier: Typing :: Typed
|
| 26 |
+
Provides-Extra: jupyter
|
| 27 |
+
Requires-Dist: ipywidgets (>=7.5.1,<9) ; extra == "jupyter"
|
| 28 |
+
Requires-Dist: markdown-it-py (>=2.2.0)
|
| 29 |
+
Requires-Dist: pygments (>=2.13.0,<3.0.0)
|
| 30 |
+
Project-URL: Documentation, https://rich.readthedocs.io/en/latest/
|
| 31 |
+
Project-URL: Homepage, https://github.com/Textualize/rich
|
| 32 |
+
Description-Content-Type: text/markdown
|
| 33 |
+
|
| 34 |
+
[](https://pypi.org/project/rich/) [](https://badge.fury.io/py/rich)
|
| 35 |
+
|
| 36 |
+
[](https://pepy.tech/project/rich)
|
| 37 |
+
[](https://codecov.io/gh/Textualize/rich)
|
| 38 |
+
[](https://www.willmcgugan.com/tag/rich/)
|
| 39 |
+
[](https://twitter.com/willmcgugan)
|
| 40 |
+
|
| 41 |
+

|
| 42 |
+
|
| 43 |
+
[English readme](https://github.com/textualize/rich/blob/master/README.md)
|
| 44 |
+
• [简体中文 readme](https://github.com/textualize/rich/blob/master/README.cn.md)
|
| 45 |
+
• [正體中文 readme](https://github.com/textualize/rich/blob/master/README.zh-tw.md)
|
| 46 |
+
• [Lengua española readme](https://github.com/textualize/rich/blob/master/README.es.md)
|
| 47 |
+
• [Deutsche readme](https://github.com/textualize/rich/blob/master/README.de.md)
|
| 48 |
+
• [Läs på svenska](https://github.com/textualize/rich/blob/master/README.sv.md)
|
| 49 |
+
• [日本語 readme](https://github.com/textualize/rich/blob/master/README.ja.md)
|
| 50 |
+
• [한국어 readme](https://github.com/textualize/rich/blob/master/README.kr.md)
|
| 51 |
+
• [Français readme](https://github.com/textualize/rich/blob/master/README.fr.md)
|
| 52 |
+
• [Schwizerdütsch readme](https://github.com/textualize/rich/blob/master/README.de-ch.md)
|
| 53 |
+
• [हिन्दी readme](https://github.com/textualize/rich/blob/master/README.hi.md)
|
| 54 |
+
• [Português brasileiro readme](https://github.com/textualize/rich/blob/master/README.pt-br.md)
|
| 55 |
+
• [Italian readme](https://github.com/textualize/rich/blob/master/README.it.md)
|
| 56 |
+
• [Русский readme](https://github.com/textualize/rich/blob/master/README.ru.md)
|
| 57 |
+
• [Indonesian readme](https://github.com/textualize/rich/blob/master/README.id.md)
|
| 58 |
+
• [فارسی readme](https://github.com/textualize/rich/blob/master/README.fa.md)
|
| 59 |
+
• [Türkçe readme](https://github.com/textualize/rich/blob/master/README.tr.md)
|
| 60 |
+
• [Polskie readme](https://github.com/textualize/rich/blob/master/README.pl.md)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
Rich is a Python library for _rich_ text and beautiful formatting in the terminal.
|
| 64 |
+
|
| 65 |
+
The [Rich API](https://rich.readthedocs.io/en/latest/) makes it easy to add color and style to terminal output. Rich can also render pretty tables, progress bars, markdown, syntax highlighted source code, tracebacks, and more — out of the box.
|
| 66 |
+
|
| 67 |
+

|
| 68 |
+
|
| 69 |
+
For a video introduction to Rich see [calmcode.io](https://calmcode.io/rich/introduction.html) by [@fishnets88](https://twitter.com/fishnets88).
|
| 70 |
+
|
| 71 |
+
See what [people are saying about Rich](https://www.willmcgugan.com/blog/pages/post/rich-tweets/).
|
| 72 |
+
|
| 73 |
+
## Compatibility
|
| 74 |
+
|
| 75 |
+
Rich works with Linux, macOS and Windows. True color / emoji works with new Windows Terminal, classic terminal is limited to 16 colors. Rich requires Python 3.8 or later.
|
| 76 |
+
|
| 77 |
+
Rich works with [Jupyter notebooks](https://jupyter.org/) with no additional configuration required.
|
| 78 |
+
|
| 79 |
+
## Installing
|
| 80 |
+
|
| 81 |
+
Install with `pip` or your favorite PyPI package manager.
|
| 82 |
+
|
| 83 |
+
```sh
|
| 84 |
+
python -m pip install rich
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
Run the following to test Rich output on your terminal:
|
| 88 |
+
|
| 89 |
+
```sh
|
| 90 |
+
python -m rich
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## Rich Print
|
| 94 |
+
|
| 95 |
+
To effortlessly add rich output to your application, you can import the [rich print](https://rich.readthedocs.io/en/latest/introduction.html#quick-start) method, which has the same signature as the builtin Python function. Try this:
|
| 96 |
+
|
| 97 |
+
```python
|
| 98 |
+
from rich import print
|
| 99 |
+
|
| 100 |
+
print("Hello, [bold magenta]World[/bold magenta]!", ":vampire:", locals())
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+

|
| 104 |
+
|
| 105 |
+
## Rich REPL
|
| 106 |
+
|
| 107 |
+
Rich can be installed in the Python REPL, so that any data structures will be pretty printed and highlighted.
|
| 108 |
+
|
| 109 |
+
```python
|
| 110 |
+
>>> from rich import pretty
|
| 111 |
+
>>> pretty.install()
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+

|
| 115 |
+
|
| 116 |
+
## Using the Console
|
| 117 |
+
|
| 118 |
+
For more control over rich terminal content, import and construct a [Console](https://rich.readthedocs.io/en/latest/reference/console.html#rich.console.Console) object.
|
| 119 |
+
|
| 120 |
+
```python
|
| 121 |
+
from rich.console import Console
|
| 122 |
+
|
| 123 |
+
console = Console()
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
The Console object has a `print` method which has an intentionally similar interface to the builtin `print` function. Here's an example of use:
|
| 127 |
+
|
| 128 |
+
```python
|
| 129 |
+
console.print("Hello", "World!")
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
As you might expect, this will print `"Hello World!"` to the terminal. Note that unlike the builtin `print` function, Rich will word-wrap your text to fit within the terminal width.
|
| 133 |
+
|
| 134 |
+
There are a few ways of adding color and style to your output. You can set a style for the entire output by adding a `style` keyword argument. Here's an example:
|
| 135 |
+
|
| 136 |
+
```python
|
| 137 |
+
console.print("Hello", "World!", style="bold red")
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
The output will be something like the following:
|
| 141 |
+
|
| 142 |
+

|
| 143 |
+
|
| 144 |
+
That's fine for styling a line of text at a time. For more finely grained styling, Rich renders a special markup which is similar in syntax to [bbcode](https://en.wikipedia.org/wiki/BBCode). Here's an example:
|
| 145 |
+
|
| 146 |
+
```python
|
| 147 |
+
console.print("Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i].")
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+

|
| 151 |
+
|
| 152 |
+
You can use a Console object to generate sophisticated output with minimal effort. See the [Console API](https://rich.readthedocs.io/en/latest/console.html) docs for details.
|
| 153 |
+
|
| 154 |
+
## Rich Inspect
|
| 155 |
+
|
| 156 |
+
Rich has an [inspect](https://rich.readthedocs.io/en/latest/reference/init.html?highlight=inspect#rich.inspect) function which can produce a report on any Python object, such as class, instance, or builtin.
|
| 157 |
+
|
| 158 |
+
```python
|
| 159 |
+
>>> my_list = ["foo", "bar"]
|
| 160 |
+
>>> from rich import inspect
|
| 161 |
+
>>> inspect(my_list, methods=True)
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+

|
| 165 |
+
|
| 166 |
+
See the [inspect docs](https://rich.readthedocs.io/en/latest/reference/init.html#rich.inspect) for details.
|
| 167 |
+
|
| 168 |
+
# Rich Library
|
| 169 |
+
|
| 170 |
+
Rich contains a number of builtin _renderables_ you can use to create elegant output in your CLI and help you debug your code.
|
| 171 |
+
|
| 172 |
+
Click the following headings for details:
|
| 173 |
+
|
| 174 |
+
<details>
|
| 175 |
+
<summary>Log</summary>
|
| 176 |
+
|
| 177 |
+
The Console object has a `log()` method which has a similar interface to `print()`, but also renders a column for the current time and the file and line which made the call. By default Rich will do syntax highlighting for Python structures and for repr strings. If you log a collection (i.e. a dict or a list) Rich will pretty print it so that it fits in the available space. Here's an example of some of these features.
|
| 178 |
+
|
| 179 |
+
```python
|
| 180 |
+
from rich.console import Console
|
| 181 |
+
console = Console()
|
| 182 |
+
|
| 183 |
+
test_data = [
|
| 184 |
+
{"jsonrpc": "2.0", "method": "sum", "params": [None, 1, 2, 4, False, True], "id": "1",},
|
| 185 |
+
{"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
|
| 186 |
+
{"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": "2"},
|
| 187 |
+
]
|
| 188 |
+
|
| 189 |
+
def test_log():
|
| 190 |
+
enabled = False
|
| 191 |
+
context = {
|
| 192 |
+
"foo": "bar",
|
| 193 |
+
}
|
| 194 |
+
movies = ["Deadpool", "Rise of the Skywalker"]
|
| 195 |
+
console.log("Hello from", console, "!")
|
| 196 |
+
console.log(test_data, log_locals=True)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
test_log()
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
The above produces the following output:
|
| 203 |
+
|
| 204 |
+

|
| 205 |
+
|
| 206 |
+
Note the `log_locals` argument, which outputs a table containing the local variables where the log method was called.
|
| 207 |
+
|
| 208 |
+
The log method could be used for logging to the terminal for long running applications such as servers, but is also a very nice debugging aid.
|
| 209 |
+
|
| 210 |
+
</details>
|
| 211 |
+
<details>
|
| 212 |
+
<summary>Logging Handler</summary>
|
| 213 |
+
|
| 214 |
+
You can also use the builtin [Handler class](https://rich.readthedocs.io/en/latest/logging.html) to format and colorize output from Python's logging module. Here's an example of the output:
|
| 215 |
+
|
| 216 |
+

|
| 217 |
+
|
| 218 |
+
</details>
|
| 219 |
+
|
| 220 |
+
<details>
|
| 221 |
+
<summary>Emoji</summary>
|
| 222 |
+
|
| 223 |
+
To insert an emoji in to console output place the name between two colons. Here's an example:
|
| 224 |
+
|
| 225 |
+
```python
|
| 226 |
+
>>> console.print(":smiley: :vampire: :pile_of_poo: :thumbs_up: :raccoon:")
|
| 227 |
+
😃 🧛 💩 👍 🦝
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
Please use this feature wisely.
|
| 231 |
+
|
| 232 |
+
</details>
|
| 233 |
+
|
| 234 |
+
<details>
|
| 235 |
+
<summary>Tables</summary>
|
| 236 |
+
|
| 237 |
+
Rich can render flexible [tables](https://rich.readthedocs.io/en/latest/tables.html) with unicode box characters. There is a large variety of formatting options for borders, styles, cell alignment etc.
|
| 238 |
+
|
| 239 |
+

|
| 240 |
+
|
| 241 |
+
The animation above was generated with [table_movie.py](https://github.com/textualize/rich/blob/master/examples/table_movie.py) in the examples directory.
|
| 242 |
+
|
| 243 |
+
Here's a simpler table example:
|
| 244 |
+
|
| 245 |
+
```python
|
| 246 |
+
from rich.console import Console
|
| 247 |
+
from rich.table import Table
|
| 248 |
+
|
| 249 |
+
console = Console()
|
| 250 |
+
|
| 251 |
+
table = Table(show_header=True, header_style="bold magenta")
|
| 252 |
+
table.add_column("Date", style="dim", width=12)
|
| 253 |
+
table.add_column("Title")
|
| 254 |
+
table.add_column("Production Budget", justify="right")
|
| 255 |
+
table.add_column("Box Office", justify="right")
|
| 256 |
+
table.add_row(
|
| 257 |
+
"Dec 20, 2019", "Star Wars: The Rise of Skywalker", "$275,000,000", "$375,126,118"
|
| 258 |
+
)
|
| 259 |
+
table.add_row(
|
| 260 |
+
"May 25, 2018",
|
| 261 |
+
"[red]Solo[/red]: A Star Wars Story",
|
| 262 |
+
"$275,000,000",
|
| 263 |
+
"$393,151,347",
|
| 264 |
+
)
|
| 265 |
+
table.add_row(
|
| 266 |
+
"Dec 15, 2017",
|
| 267 |
+
"Star Wars Ep. VIII: The Last Jedi",
|
| 268 |
+
"$262,000,000",
|
| 269 |
+
"[bold]$1,332,539,889[/bold]",
|
| 270 |
+
)
|
| 271 |
+
|
| 272 |
+
console.print(table)
|
| 273 |
+
```
|
| 274 |
+
|
| 275 |
+
This produces the following output:
|
| 276 |
+
|
| 277 |
+

|
| 278 |
+
|
| 279 |
+
Note that console markup is rendered in the same way as `print()` and `log()`. In fact, anything that is renderable by Rich may be included in the headers / rows (even other tables).
|
| 280 |
+
|
| 281 |
+
The `Table` class is smart enough to resize columns to fit the available width of the terminal, wrapping text as required. Here's the same example, with the terminal made smaller than the table above:
|
| 282 |
+
|
| 283 |
+

|
| 284 |
+
|
| 285 |
+
</details>
|
| 286 |
+
|
| 287 |
+
<details>
|
| 288 |
+
<summary>Progress Bars</summary>
|
| 289 |
+
|
| 290 |
+
Rich can render multiple flicker-free [progress](https://rich.readthedocs.io/en/latest/progress.html) bars to track long-running tasks.
|
| 291 |
+
|
| 292 |
+
For basic usage, wrap any sequence in the `track` function and iterate over the result. Here's an example:
|
| 293 |
+
|
| 294 |
+
```python
|
| 295 |
+
from rich.progress import track
|
| 296 |
+
|
| 297 |
+
for step in track(range(100)):
|
| 298 |
+
do_step(step)
|
| 299 |
+
```
|
| 300 |
+
|
| 301 |
+
It's not much harder to add multiple progress bars. Here's an example taken from the docs:
|
| 302 |
+
|
| 303 |
+

|
| 304 |
+
|
| 305 |
+
The columns may be configured to show any details you want. Built-in columns include percentage complete, file size, file speed, and time remaining. Here's another example showing a download in progress:
|
| 306 |
+
|
| 307 |
+

|
| 308 |
+
|
| 309 |
+
To try this out yourself, see [examples/downloader.py](https://github.com/textualize/rich/blob/master/examples/downloader.py) which can download multiple URLs simultaneously while displaying progress.
|
| 310 |
+
|
| 311 |
+
</details>
|
| 312 |
+
|
| 313 |
+
<details>
|
| 314 |
+
<summary>Status</summary>
|
| 315 |
+
|
| 316 |
+
For situations where it is hard to calculate progress, you can use the [status](https://rich.readthedocs.io/en/latest/reference/console.html#rich.console.Console.status) method which will display a 'spinner' animation and message. The animation won't prevent you from using the console as normal. Here's an example:
|
| 317 |
+
|
| 318 |
+
```python
|
| 319 |
+
from time import sleep
|
| 320 |
+
from rich.console import Console
|
| 321 |
+
|
| 322 |
+
console = Console()
|
| 323 |
+
tasks = [f"task {n}" for n in range(1, 11)]
|
| 324 |
+
|
| 325 |
+
with console.status("[bold green]Working on tasks...") as status:
|
| 326 |
+
while tasks:
|
| 327 |
+
task = tasks.pop(0)
|
| 328 |
+
sleep(1)
|
| 329 |
+
console.log(f"{task} complete")
|
| 330 |
+
```
|
| 331 |
+
|
| 332 |
+
This generates the following output in the terminal.
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
|
| 336 |
+
The spinner animations were borrowed from [cli-spinners](https://www.npmjs.com/package/cli-spinners). You can select a spinner by specifying the `spinner` parameter. Run the following command to see the available values:
|
| 337 |
+
|
| 338 |
+
```
|
| 339 |
+
python -m rich.spinner
|
| 340 |
+
```
|
| 341 |
+
|
| 342 |
+
The above command generates the following output in the terminal:
|
| 343 |
+
|
| 344 |
+

|
| 345 |
+
|
| 346 |
+
</details>
|
| 347 |
+
|
| 348 |
+
<details>
|
| 349 |
+
<summary>Tree</summary>
|
| 350 |
+
|
| 351 |
+
Rich can render a [tree](https://rich.readthedocs.io/en/latest/tree.html) with guide lines. A tree is ideal for displaying a file structure, or any other hierarchical data.
|
| 352 |
+
|
| 353 |
+
The labels of the tree can be simple text or anything else Rich can render. Run the following for a demonstration:
|
| 354 |
+
|
| 355 |
+
```
|
| 356 |
+
python -m rich.tree
|
| 357 |
+
```
|
| 358 |
+
|
| 359 |
+
This generates the following output:
|
| 360 |
+
|
| 361 |
+

|
| 362 |
+
|
| 363 |
+
See the [tree.py](https://github.com/textualize/rich/blob/master/examples/tree.py) example for a script that displays a tree view of any directory, similar to the linux `tree` command.
|
| 364 |
+
|
| 365 |
+
</details>
|
| 366 |
+
|
| 367 |
+
<details>
|
| 368 |
+
<summary>Columns</summary>
|
| 369 |
+
|
| 370 |
+
Rich can render content in neat [columns](https://rich.readthedocs.io/en/latest/columns.html) with equal or optimal width. Here's a very basic clone of the (MacOS / Linux) `ls` command which displays a directory listing in columns:
|
| 371 |
+
|
| 372 |
+
```python
|
| 373 |
+
import os
|
| 374 |
+
import sys
|
| 375 |
+
|
| 376 |
+
from rich import print
|
| 377 |
+
from rich.columns import Columns
|
| 378 |
+
|
| 379 |
+
directory = os.listdir(sys.argv[1])
|
| 380 |
+
print(Columns(directory))
|
| 381 |
+
```
|
| 382 |
+
|
| 383 |
+
The following screenshot is the output from the [columns example](https://github.com/textualize/rich/blob/master/examples/columns.py) which displays data pulled from an API in columns:
|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
|
| 387 |
+
</details>
|
| 388 |
+
|
| 389 |
+
<details>
|
| 390 |
+
<summary>Markdown</summary>
|
| 391 |
+
|
| 392 |
+
Rich can render [markdown](https://rich.readthedocs.io/en/latest/markdown.html) and does a reasonable job of translating the formatting to the terminal.
|
| 393 |
+
|
| 394 |
+
To render markdown import the `Markdown` class and construct it with a string containing markdown code. Then print it to the console. Here's an example:
|
| 395 |
+
|
| 396 |
+
```python
|
| 397 |
+
from rich.console import Console
|
| 398 |
+
from rich.markdown import Markdown
|
| 399 |
+
|
| 400 |
+
console = Console()
|
| 401 |
+
with open("README.md") as readme:
|
| 402 |
+
markdown = Markdown(readme.read())
|
| 403 |
+
console.print(markdown)
|
| 404 |
+
```
|
| 405 |
+
|
| 406 |
+
This will produce output something like the following:
|
| 407 |
+
|
| 408 |
+

|
| 409 |
+
|
| 410 |
+
</details>
|
| 411 |
+
|
| 412 |
+
<details>
|
| 413 |
+
<summary>Syntax Highlighting</summary>
|
| 414 |
+
|
| 415 |
+
Rich uses the [pygments](https://pygments.org/) library to implement [syntax highlighting](https://rich.readthedocs.io/en/latest/syntax.html). Usage is similar to rendering markdown; construct a `Syntax` object and print it to the console. Here's an example:
|
| 416 |
+
|
| 417 |
+
```python
|
| 418 |
+
from rich.console import Console
|
| 419 |
+
from rich.syntax import Syntax
|
| 420 |
+
|
| 421 |
+
my_code = '''
|
| 422 |
+
def iter_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]:
|
| 423 |
+
"""Iterate and generate a tuple with a flag for first and last value."""
|
| 424 |
+
iter_values = iter(values)
|
| 425 |
+
try:
|
| 426 |
+
previous_value = next(iter_values)
|
| 427 |
+
except StopIteration:
|
| 428 |
+
return
|
| 429 |
+
first = True
|
| 430 |
+
for value in iter_values:
|
| 431 |
+
yield first, False, previous_value
|
| 432 |
+
first = False
|
| 433 |
+
previous_value = value
|
| 434 |
+
yield first, True, previous_value
|
| 435 |
+
'''
|
| 436 |
+
syntax = Syntax(my_code, "python", theme="monokai", line_numbers=True)
|
| 437 |
+
console = Console()
|
| 438 |
+
console.print(syntax)
|
| 439 |
+
```
|
| 440 |
+
|
| 441 |
+
This will produce the following output:
|
| 442 |
+
|
| 443 |
+

|
| 444 |
+
|
| 445 |
+
</details>
|
| 446 |
+
|
| 447 |
+
<details>
|
| 448 |
+
<summary>Tracebacks</summary>
|
| 449 |
+
|
| 450 |
+
Rich can render [beautiful tracebacks](https://rich.readthedocs.io/en/latest/traceback.html) which are easier to read and show more code than standard Python tracebacks. You can set Rich as the default traceback handler so all uncaught exceptions will be rendered by Rich.
|
| 451 |
+
|
| 452 |
+
Here's what it looks like on OSX (similar on Linux):
|
| 453 |
+
|
| 454 |
+

|
| 455 |
+
|
| 456 |
+
</details>
|
| 457 |
+
|
| 458 |
+
All Rich renderables make use of the [Console Protocol](https://rich.readthedocs.io/en/latest/protocol.html), which you can also use to implement your own Rich content.
|
| 459 |
+
|
| 460 |
+
# Rich CLI
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
See also [Rich CLI](https://github.com/textualize/rich-cli) for a command line application powered by Rich. Syntax highlight code, render markdown, display CSVs in tables, and more, directly from the command prompt.
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+

|
| 467 |
+
|
| 468 |
+
# Textual
|
| 469 |
+
|
| 470 |
+
See also Rich's sister project, [Textual](https://github.com/Textualize/textual), which you can use to build sophisticated User Interfaces in the terminal.
|
| 471 |
+
|
| 472 |
+

|
| 473 |
+
|
| 474 |
+
# Toad
|
| 475 |
+
|
| 476 |
+
[Toad](https://github.com/batrachianai/toad) is a unified interface for agentic coding. Built with Rich and Textual.
|
| 477 |
+
|
| 478 |
+

|
| 479 |
+
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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2 |
+
rich-15.0.0.dist-info/METADATA,sha256=-tNPxgP6xEgb-B-N1ilJL8MCwOwxkJyGZEdRUSr7Ljs,18445
|
| 3 |
+
rich-15.0.0.dist-info/RECORD,,
|
| 4 |
+
rich-15.0.0.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
| 5 |
+
rich-15.0.0.dist-info/licenses/LICENSE,sha256=3u18F6QxgVgZCj6iOcyHmlpQJxzruYrnAl9I--WNyhU,1056
|
| 6 |
+
rich/__init__.py,sha256=j7AA9_z_PANQbmRTwTkWZc_DVdqtBBHxBqGrMsz21CI,6131
|
| 7 |
+
rich/__main__.py,sha256=kcy8BtBEUkYLCogRkwhCdJs0VNx6KF1n8kFU2g-7plg,7725
|
| 8 |
+
rich/__pycache__/__init__.cpython-311.pyc,,
|
| 9 |
+
rich/__pycache__/__main__.cpython-311.pyc,,
|
| 10 |
+
rich/__pycache__/_emoji_codes.cpython-311.pyc,,
|
| 11 |
+
rich/__pycache__/_emoji_replace.cpython-311.pyc,,
|
| 12 |
+
rich/__pycache__/_export_format.cpython-311.pyc,,
|
| 13 |
+
rich/__pycache__/_extension.cpython-311.pyc,,
|
| 14 |
+
rich/__pycache__/_fileno.cpython-311.pyc,,
|
| 15 |
+
rich/__pycache__/_inspect.cpython-311.pyc,,
|
| 16 |
+
rich/__pycache__/_log_render.cpython-311.pyc,,
|
| 17 |
+
rich/__pycache__/_loop.cpython-311.pyc,,
|
| 18 |
+
rich/__pycache__/_null_file.cpython-311.pyc,,
|
| 19 |
+
rich/__pycache__/_palettes.cpython-311.pyc,,
|
| 20 |
+
rich/__pycache__/_pick.cpython-311.pyc,,
|
| 21 |
+
rich/__pycache__/_ratio.cpython-311.pyc,,
|
| 22 |
+
rich/__pycache__/_spinners.cpython-311.pyc,,
|
| 23 |
+
rich/__pycache__/_stack.cpython-311.pyc,,
|
| 24 |
+
rich/__pycache__/_timer.cpython-311.pyc,,
|
| 25 |
+
rich/__pycache__/_win32_console.cpython-311.pyc,,
|
| 26 |
+
rich/__pycache__/_windows.cpython-311.pyc,,
|
| 27 |
+
rich/__pycache__/_windows_renderer.cpython-311.pyc,,
|
| 28 |
+
rich/__pycache__/_wrap.cpython-311.pyc,,
|
| 29 |
+
rich/__pycache__/abc.cpython-311.pyc,,
|
| 30 |
+
rich/__pycache__/align.cpython-311.pyc,,
|
| 31 |
+
rich/__pycache__/ansi.cpython-311.pyc,,
|
| 32 |
+
rich/__pycache__/bar.cpython-311.pyc,,
|
| 33 |
+
rich/__pycache__/box.cpython-311.pyc,,
|
| 34 |
+
rich/__pycache__/cells.cpython-311.pyc,,
|
| 35 |
+
rich/__pycache__/color.cpython-311.pyc,,
|
| 36 |
+
rich/__pycache__/color_triplet.cpython-311.pyc,,
|
| 37 |
+
rich/__pycache__/columns.cpython-311.pyc,,
|
| 38 |
+
rich/__pycache__/console.cpython-311.pyc,,
|
| 39 |
+
rich/__pycache__/constrain.cpython-311.pyc,,
|
| 40 |
+
rich/__pycache__/containers.cpython-311.pyc,,
|
| 41 |
+
rich/__pycache__/control.cpython-311.pyc,,
|
| 42 |
+
rich/__pycache__/default_styles.cpython-311.pyc,,
|
| 43 |
+
rich/__pycache__/diagnose.cpython-311.pyc,,
|
| 44 |
+
rich/__pycache__/emoji.cpython-311.pyc,,
|
| 45 |
+
rich/__pycache__/errors.cpython-311.pyc,,
|
| 46 |
+
rich/__pycache__/file_proxy.cpython-311.pyc,,
|
| 47 |
+
rich/__pycache__/filesize.cpython-311.pyc,,
|
| 48 |
+
rich/__pycache__/highlighter.cpython-311.pyc,,
|
| 49 |
+
rich/__pycache__/json.cpython-311.pyc,,
|
| 50 |
+
rich/__pycache__/jupyter.cpython-311.pyc,,
|
| 51 |
+
rich/__pycache__/layout.cpython-311.pyc,,
|
| 52 |
+
rich/__pycache__/live.cpython-311.pyc,,
|
| 53 |
+
rich/__pycache__/live_render.cpython-311.pyc,,
|
| 54 |
+
rich/__pycache__/logging.cpython-311.pyc,,
|
| 55 |
+
rich/__pycache__/markdown.cpython-311.pyc,,
|
| 56 |
+
rich/__pycache__/markup.cpython-311.pyc,,
|
| 57 |
+
rich/__pycache__/measure.cpython-311.pyc,,
|
| 58 |
+
rich/__pycache__/padding.cpython-311.pyc,,
|
| 59 |
+
rich/__pycache__/pager.cpython-311.pyc,,
|
| 60 |
+
rich/__pycache__/palette.cpython-311.pyc,,
|
| 61 |
+
rich/__pycache__/panel.cpython-311.pyc,,
|
| 62 |
+
rich/__pycache__/pretty.cpython-311.pyc,,
|
| 63 |
+
rich/__pycache__/progress.cpython-311.pyc,,
|
| 64 |
+
rich/__pycache__/progress_bar.cpython-311.pyc,,
|
| 65 |
+
rich/__pycache__/prompt.cpython-311.pyc,,
|
| 66 |
+
rich/__pycache__/protocol.cpython-311.pyc,,
|
| 67 |
+
rich/__pycache__/region.cpython-311.pyc,,
|
| 68 |
+
rich/__pycache__/repr.cpython-311.pyc,,
|
| 69 |
+
rich/__pycache__/rule.cpython-311.pyc,,
|
| 70 |
+
rich/__pycache__/scope.cpython-311.pyc,,
|
| 71 |
+
rich/__pycache__/screen.cpython-311.pyc,,
|
| 72 |
+
rich/__pycache__/segment.cpython-311.pyc,,
|
| 73 |
+
rich/__pycache__/spinner.cpython-311.pyc,,
|
| 74 |
+
rich/__pycache__/status.cpython-311.pyc,,
|
| 75 |
+
rich/__pycache__/style.cpython-311.pyc,,
|
| 76 |
+
rich/__pycache__/styled.cpython-311.pyc,,
|
| 77 |
+
rich/__pycache__/syntax.cpython-311.pyc,,
|
| 78 |
+
rich/__pycache__/table.cpython-311.pyc,,
|
| 79 |
+
rich/__pycache__/terminal_theme.cpython-311.pyc,,
|
| 80 |
+
rich/__pycache__/text.cpython-311.pyc,,
|
| 81 |
+
rich/__pycache__/theme.cpython-311.pyc,,
|
| 82 |
+
rich/__pycache__/themes.cpython-311.pyc,,
|
| 83 |
+
rich/__pycache__/traceback.cpython-311.pyc,,
|
| 84 |
+
rich/__pycache__/tree.cpython-311.pyc,,
|
| 85 |
+
rich/_emoji_codes.py,sha256=hu1VL9nbVdppJrVoijVshRlcRRe_v3dju3Mmd2sKZdY,140235
|
| 86 |
+
rich/_emoji_replace.py,sha256=ysSn8smSqQW22XEfCH0lJ80vogUYZKr9dPImfUG2e6Y,1067
|
| 87 |
+
rich/_export_format.py,sha256=RI08pSrm5tBSzPMvnbTqbD9WIalaOoN5d4M1RTmLq1Y,2128
|
| 88 |
+
rich/_extension.py,sha256=G66PkbH_QdTJh6jD-J228O76CmAnr2hLQv72CgPPuzE,241
|
| 89 |
+
rich/_fileno.py,sha256=HWZxP5C2ajMbHryvAQZseflVfQoGzsKOHzKGsLD8ynQ,799
|
| 90 |
+
rich/_inspect.py,sha256=5pUYCqveN4ekb_mgHOYCipyZCrMGEJZYZs3y5QqmCf0,9894
|
| 91 |
+
rich/_log_render.py,sha256=xBKCxqiO4FZk8eG56f8crFdrmJxFrJsQE3V3F-fFekc,3213
|
| 92 |
+
rich/_loop.py,sha256=hV_6CLdoPm0va22Wpw4zKqM0RYsz3TZxXj0PoS-9eDQ,1236
|
| 93 |
+
rich/_null_file.py,sha256=ADGKp1yt-k70FMKV6tnqCqecB-rSJzp-WQsD7LPL-kg,1394
|
| 94 |
+
rich/_palettes.py,sha256=cdev1JQKZ0JvlguV9ipHgznTdnvlIzUFDBb0It2PzjI,7063
|
| 95 |
+
rich/_pick.py,sha256=evDt8QN4lF5CiwrUIXlOJCntitBCOsI3ZLPEIAVRLJU,423
|
| 96 |
+
rich/_ratio.py,sha256=IOtl78sQCYZsmHyxhe45krkb68u9xVz7zFsXVJD-b2Y,5325
|
| 97 |
+
rich/_spinners.py,sha256=U2r1_g_1zSjsjiUdAESc2iAMc3i4ri_S8PYP6kQ5z1I,19919
|
| 98 |
+
rich/_stack.py,sha256=-C8OK7rxn3sIUdVwxZBBpeHhIzX0eI-VM3MemYfaXm0,351
|
| 99 |
+
rich/_timer.py,sha256=zelxbT6oPFZnNrwWPpc1ktUeAT-Vc4fuFcRZLQGLtMI,417
|
| 100 |
+
rich/_unicode_data/__init__.py,sha256=40PhAFp3b88yPnRtTG6i9g5xj-5w98CET3C4Ip1LJAI,2631
|
| 101 |
+
rich/_unicode_data/__pycache__/__init__.cpython-311.pyc,,
|
| 102 |
+
rich/_unicode_data/__pycache__/_versions.cpython-311.pyc,,
|
| 103 |
+
rich/_unicode_data/__pycache__/unicode10-0-0.cpython-311.pyc,,
|
| 104 |
+
rich/_unicode_data/__pycache__/unicode11-0-0.cpython-311.pyc,,
|
| 105 |
+
rich/_unicode_data/__pycache__/unicode12-0-0.cpython-311.pyc,,
|
| 106 |
+
rich/_unicode_data/__pycache__/unicode12-1-0.cpython-311.pyc,,
|
| 107 |
+
rich/_unicode_data/__pycache__/unicode13-0-0.cpython-311.pyc,,
|
| 108 |
+
rich/_unicode_data/__pycache__/unicode14-0-0.cpython-311.pyc,,
|
| 109 |
+
rich/_unicode_data/__pycache__/unicode15-0-0.cpython-311.pyc,,
|
| 110 |
+
rich/_unicode_data/__pycache__/unicode15-1-0.cpython-311.pyc,,
|
| 111 |
+
rich/_unicode_data/__pycache__/unicode16-0-0.cpython-311.pyc,,
|
| 112 |
+
rich/_unicode_data/__pycache__/unicode17-0-0.cpython-311.pyc,,
|
| 113 |
+
rich/_unicode_data/__pycache__/unicode4-1-0.cpython-311.pyc,,
|
| 114 |
+
rich/_unicode_data/__pycache__/unicode5-0-0.cpython-311.pyc,,
|
| 115 |
+
rich/_unicode_data/__pycache__/unicode5-1-0.cpython-311.pyc,,
|
| 116 |
+
rich/_unicode_data/__pycache__/unicode5-2-0.cpython-311.pyc,,
|
| 117 |
+
rich/_unicode_data/__pycache__/unicode6-0-0.cpython-311.pyc,,
|
| 118 |
+
rich/_unicode_data/__pycache__/unicode6-1-0.cpython-311.pyc,,
|
| 119 |
+
rich/_unicode_data/__pycache__/unicode6-2-0.cpython-311.pyc,,
|
| 120 |
+
rich/_unicode_data/__pycache__/unicode6-3-0.cpython-311.pyc,,
|
| 121 |
+
rich/_unicode_data/__pycache__/unicode7-0-0.cpython-311.pyc,,
|
| 122 |
+
rich/_unicode_data/__pycache__/unicode8-0-0.cpython-311.pyc,,
|
| 123 |
+
rich/_unicode_data/__pycache__/unicode9-0-0.cpython-311.pyc,,
|
| 124 |
+
rich/_unicode_data/_versions.py,sha256=ftILR3G5dqmlQmCJYNovuyXfFneJY2eH2RvpV19tyYE,298
|
| 125 |
+
rich/_unicode_data/unicode10-0-0.py,sha256=FUstYPZwDF15BEuAERqXHqIPvC1KY1SL20qLj999Fzo,14496
|
| 126 |
+
rich/_unicode_data/unicode11-0-0.py,sha256=jp8SRKFBlIaHMafxAfhLiU7FizwdcgPVvytR3kSFtZo,14874
|
| 127 |
+
rich/_unicode_data/unicode12-0-0.py,sha256=0XHXSjW5EXue6Qfgl_u0bK7NstiSdmqrR_F_Wqhs5bE,15216
|
| 128 |
+
rich/_unicode_data/unicode12-1-0.py,sha256=kWcRGh1UVwsmK9qflfGsO_aM8AuNhLthJcsyXAOQryI,15189
|
| 129 |
+
rich/_unicode_data/unicode13-0-0.py,sha256=DokduALtgaB-WvapW7X7PmM3kZFbgnCo9ifINWZtuDs,15519
|
| 130 |
+
rich/_unicode_data/unicode14-0-0.py,sha256=Ni-3JnGf5sB4kGl8ip-Iyqoum-awJjZV0RoSNuo0yu8,15884
|
| 131 |
+
rich/_unicode_data/unicode15-0-0.py,sha256=DBHkV5Si9vmtv_MiW6NmPQb8yUeP4N-9hNt2juZr4ZE,16156
|
| 132 |
+
rich/_unicode_data/unicode15-1-0.py,sha256=uyCZLYrg0q7wGt3-uBdsF0Ay_x8MTMvFqK6aMOkl9rA,16129
|
| 133 |
+
rich/_unicode_data/unicode16-0-0.py,sha256=5iGpbczVQ7BD2QGYb6k1h_OdILQXXuhcvI6dQFLKbMc,16480
|
| 134 |
+
rich/_unicode_data/unicode17-0-0.py,sha256=NXbjFsAaTYdj6TYgk5Q9disv40LZHbedFGRl_48_9Y0,16704
|
| 135 |
+
rich/_unicode_data/unicode4-1-0.py,sha256=yIApQGEG7VOFYY2FFfvOdPprE6VpDusjLlTlCy4G_Rw,9488
|
| 136 |
+
rich/_unicode_data/unicode5-0-0.py,sha256=PkEI1x4RGwXSmgqHiu88jyz14VQT8bWiOtBDrECaVZg,9613
|
| 137 |
+
rich/_unicode_data/unicode5-1-0.py,sha256=C0-PWziqpkVkf3PkPz2GWNwidCrjef5AHQGBpqTPkuY,9650
|
| 138 |
+
rich/_unicode_data/unicode5-2-0.py,sha256=gM88qri3_9b0I37DGK1-ah-0SUed2VmvxUddB5UZLto,10390
|
| 139 |
+
rich/_unicode_data/unicode6-0-0.py,sha256=hhcAipqKU81dZ4YbDXIlT7KEK9yNG_Lx-5GLgNTF75g,10604
|
| 140 |
+
rich/_unicode_data/unicode6-1-0.py,sha256=PtUJYxwtU5S2A44YY_69Ka_wTkq-c7QCa-yibmkHvJs,10899
|
| 141 |
+
rich/_unicode_data/unicode6-2-0.py,sha256=TdTOctGwO-OYVGif1DoRJvsaQISHw5EXHPt58fjB55g,10899
|
| 142 |
+
rich/_unicode_data/unicode6-3-0.py,sha256=G9l8chu2MJTwZ_d_0tmH7PBg8KYYHaeuJCJNCHGHkDc,10924
|
| 143 |
+
rich/_unicode_data/unicode7-0-0.py,sha256=po9GGYW7ilGU9MwGE6fny-OofqbDwelQrnOIm-IusjI,11630
|
| 144 |
+
rich/_unicode_data/unicode8-0-0.py,sha256=4PjyI-w2Uj9xtanNlZm1d_2khcetMQlIefaoU2joGkY,11864
|
| 145 |
+
rich/_unicode_data/unicode9-0-0.py,sha256=A-pQjvkTICUGXEDOiWNMqa6z6vv1E__HJffzu7zLi9c,14148
|
| 146 |
+
rich/_win32_console.py,sha256=o2QN_IRx10biGP3Ap1neaqX8FBGlUKSmWM6Kw4OSg-U,22719
|
| 147 |
+
rich/_windows.py,sha256=is3WpbHMj8WaTHYB11hc6lP2t4hlvt4TViTlHSmjsi0,1901
|
| 148 |
+
rich/_windows_renderer.py,sha256=d799xOnxLbCCCzGu9-U7YLmIQkxtxQIBFQQ6iu4veSc,2759
|
| 149 |
+
rich/_wrap.py,sha256=FlSsom5EX0LVkA3KWy34yHnCfLtqX-ZIepXKh-70rpc,3404
|
| 150 |
+
rich/abc.py,sha256=dALMOGfKVNeAbvqq66IpTQxQUerxD7AE4FKwqd0eQKk,878
|
| 151 |
+
rich/align.py,sha256=a8MbP-iJjoOFonxqgoP3YketKMWU3WFZaxjqAv2Qc5E,10726
|
| 152 |
+
rich/ansi.py,sha256=TQ7pdksq0b3XPcw_tSGvL_QthPxNLKOYQImPQYWp6pM,6947
|
| 153 |
+
rich/bar.py,sha256=ldbVHOzKJOnflVNuv1xS7g6dLX2E3wMnXkdPbpzJTcs,3263
|
| 154 |
+
rich/box.py,sha256=SSolg8_pzHzY9QvJQo-qp0tbPsnj8O_2W4hmi1l-Zo0,10650
|
| 155 |
+
rich/cells.py,sha256=fPRSnquYlCO4THgmUokOJOhNlcx8C4NZ2Xv9JM_7GbE,12335
|
| 156 |
+
rich/color.py,sha256=3HSULVDj7qQkXUdFWv78JOiSZzfy5y1nkcYhna296V0,18211
|
| 157 |
+
rich/color_triplet.py,sha256=3lhQkdJbvWPoLDO-AnYImAWmJvV5dlgYNCVZ97ORaN4,1054
|
| 158 |
+
rich/columns.py,sha256=HUX0KcMm9dsKNi11fTbiM_h2iDtl8ySCaVcxlalEzq8,7131
|
| 159 |
+
rich/console.py,sha256=RTP8ZpY2I6KiFEe1Adb1H4z-5-FHdReAk6Xm62HcE1o,101361
|
| 160 |
+
rich/constrain.py,sha256=1VIPuC8AgtKWrcncQrjBdYqA3JVWysu6jZo1rrh7c7Q,1288
|
| 161 |
+
rich/containers.py,sha256=c_56TxcedGYqDepHBMTuZdUIijitAQgnox-Qde0Z1qo,5502
|
| 162 |
+
rich/control.py,sha256=HnsraFTzBaUQDzKJWXsfPv-PPmgGypSgSv7oANackqs,6475
|
| 163 |
+
rich/default_styles.py,sha256=DqEUiGrj4N0eAcgDwjGeUSe8BLMxZw57L9RXnTCroTs,8401
|
| 164 |
+
rich/diagnose.py,sha256=1RWnQoppPXjC_49AB4vtV048DK3ksQSq671C83Y6f-g,977
|
| 165 |
+
rich/emoji.py,sha256=z7ABu0_61WJPWOM_dxhUHNaA0B6RQuZX3reljs1iWE8,2388
|
| 166 |
+
rich/errors.py,sha256=5pP3Kc5d4QJ_c0KFsxrfyhjiPVe7J1zOqSFbFAzcV-Y,642
|
| 167 |
+
rich/file_proxy.py,sha256=MvlB3tSsuVmH4qCWXK9SK3S_OohVRIczUw_Fufmsdt8,1750
|
| 168 |
+
rich/filesize.py,sha256=_iz9lIpRgvW7MNSeCZnLg-HwzbP4GETg543WqD8SFs0,2484
|
| 169 |
+
rich/highlighter.py,sha256=MIapWwjR8ahUcsDicgN4xLRbanbh5x_Qzh5kfdDrKKk,9729
|
| 170 |
+
rich/json.py,sha256=omC2WHTgURxEosna1ftoSJCne2EX7MDuQtCdswS3qsk,5019
|
| 171 |
+
rich/jupyter.py,sha256=G9pOJmR4ESIFYSd4MKGqmHqCtstx0oRWpyeTgv54-Xc,3228
|
| 172 |
+
rich/layout.py,sha256=WR8PCSroYnteIT3zawxQ3k3ad1sQO5wGG1SZOoeBuBM,13944
|
| 173 |
+
rich/live.py,sha256=UKvqLSuSzNHIBz5pxRrU7SPsnG48vJJx2TMHiaHlmnI,15317
|
| 174 |
+
rich/live_render.py,sha256=jQO3X_p2wemGI2bdCAY_e5j9xXNTwDxuujbpoSRsH6c,3803
|
| 175 |
+
rich/logging.py,sha256=7vhk7r_LhWTcwteyjLLM5Nfc839fwBuIiISvBZcGwzo,12622
|
| 176 |
+
rich/markdown.py,sha256=MmbNh8IhWgdGNQkeNTHWNR470KQVACt_9aJu6TMourA,26549
|
| 177 |
+
rich/markup.py,sha256=btpr271BLhiCR1jNglRnv2BpIzVcNefYwSMeW9teDbc,8427
|
| 178 |
+
rich/measure.py,sha256=HmrIJX8sWRTHbgh8MxEay_83VkqNW_70s8aKP5ZcYI8,5305
|
| 179 |
+
rich/padding.py,sha256=h8XnIivLrNtlxI3vQPKHXh4hAwjOJqZx0slM0z3g1_M,4896
|
| 180 |
+
rich/pager.py,sha256=SO_ETBFKbg3n_AgOzXm41Sv36YxXAyI3_R-KOY2_uSc,828
|
| 181 |
+
rich/palette.py,sha256=Ar6ZUrYHiFt6-Rr2k-k9F8V7hxgJYHNdqjk2vVXsLgc,3288
|
| 182 |
+
rich/panel.py,sha256=9sQl00hPIqH5G2gALQo4NepFwpP0k9wT-s_gOms5pIc,11157
|
| 183 |
+
rich/pretty.py,sha256=lxW_bhBfDTKe-grtzP1KQhQsqPZxfZN14th4JRVoLzQ,36349
|
| 184 |
+
rich/progress.py,sha256=Z6Yz6pYO26LFXx24cXKvk2bEX6FkjK2Z5e2fy0Bt78s,60393
|
| 185 |
+
rich/progress_bar.py,sha256=mZTPpJUwcfcdgQCTTz3kyY-fc79ddLwtx6Ghhxfo064,8162
|
| 186 |
+
rich/prompt.py,sha256=1SIuBEelovvwCG2wp22PZwskA3IkmAsOxf0ruFkOhOk,12448
|
| 187 |
+
rich/protocol.py,sha256=9OHzfZXAnidZqaZgSFsX5KsJg8JHHNUc8jk9dsxa1ik,1348
|
| 188 |
+
rich/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 189 |
+
rich/region.py,sha256=rNT9xZrVZTYIXZC0NYn41CJQwYNbR-KecPOxTgQvB8Y,166
|
| 190 |
+
rich/repr.py,sha256=mFexGTVledesZiMD3jBBBBoICoWh-XPFAUq3Hu7iX4U,4436
|
| 191 |
+
rich/rule.py,sha256=umO21Wjw0FcYAeTB3UumNLCsDWhejzxnjlf2VwiXiDI,4590
|
| 192 |
+
rich/scope.py,sha256=x-jkKIE-j7ZxA9I07lya5iVAuDAyUKM58HWtNZQUzRc,3239
|
| 193 |
+
rich/screen.py,sha256=rL_j2wX-4SeuIOI2oOlc418QP9EAvD59GInUmEAE6jQ,1579
|
| 194 |
+
rich/segment.py,sha256=17JAw4bmsV_LrJ8PnhI9XH2DaN-fOEPF-8mgx7joLDM,25740
|
| 195 |
+
rich/spinner.py,sha256=onIhpKlljRHppTZasxO8kXgtYyCHUkpSgKglRJ3o51g,4214
|
| 196 |
+
rich/status.py,sha256=kkPph3YeAZBo-X-4wPp8gTqZyU466NLwZBA4PZTTewo,4424
|
| 197 |
+
rich/style.py,sha256=yp4TsNKNPUxBytoFWfy7kzE2Gh_9TYA7fs2ULXfbm00,27068
|
| 198 |
+
rich/styled.py,sha256=wljVsVTXbABMMZvkzkO43ZEk_-irzEtvUiQ-sNnikQ8,1234
|
| 199 |
+
rich/syntax.py,sha256=ytgeGUt91fdr8LaHKOdkaNMewrPRxgoci5mMd3MPE4I,36305
|
| 200 |
+
rich/table.py,sha256=6yv7wMLXZgOsGgzEDpKXpecXQOwcLBHNOn-MYcbo1Zk,40033
|
| 201 |
+
rich/terminal_theme.py,sha256=1j5-ufJfnvlAo5Qsi_ACZiXDmwMXzqgmFByObT9-yJY,3370
|
| 202 |
+
rich/text.py,sha256=t2J8iMquwR0BUUggm-cVNp30Wxw5M8fIF_p0jioYRV0,47655
|
| 203 |
+
rich/theme.py,sha256=biYZWd_Wu1KW8VtT7UsTQDrDU89RxAK5_Vz1y3ztGYI,3780
|
| 204 |
+
rich/themes.py,sha256=0xgTLozfabebYtcJtDdC5QkX5IVUEaviqDUJJh4YVFk,102
|
| 205 |
+
rich/traceback.py,sha256=TT03eLKEj5XapXFp9kgf0bBwNupIFrHquKxZtwBhz_8,37535
|
| 206 |
+
rich/tree.py,sha256=QoOwg424FkdwGfR8K0tZ6Q7qtzWNAUP_m4sFaYuG6nw,9391
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich-15.0.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: poetry-core 2.3.1
|
| 3 |
+
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Rich text and beautiful formatting in the terminal."""
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union
|
| 5 |
+
|
| 6 |
+
from ._extension import load_ipython_extension # noqa: F401
|
| 7 |
+
|
| 8 |
+
__all__ = ["get_console", "reconfigure", "print", "inspect", "print_json"]
|
| 9 |
+
|
| 10 |
+
if TYPE_CHECKING:
|
| 11 |
+
from .console import Console
|
| 12 |
+
|
| 13 |
+
# Global console used by alternative print
|
| 14 |
+
_console: Optional["Console"] = None
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
_IMPORT_CWD = os.path.abspath(os.getcwd())
|
| 18 |
+
except FileNotFoundError:
|
| 19 |
+
# Can happen if the cwd has been deleted
|
| 20 |
+
_IMPORT_CWD = ""
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def get_console() -> "Console":
|
| 24 |
+
"""Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,
|
| 25 |
+
and hasn't been explicitly given one.
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Console: A console instance.
|
| 29 |
+
"""
|
| 30 |
+
global _console
|
| 31 |
+
if _console is None:
|
| 32 |
+
from .console import Console
|
| 33 |
+
|
| 34 |
+
_console = Console()
|
| 35 |
+
|
| 36 |
+
return _console
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def reconfigure(*args: Any, **kwargs: Any) -> None:
|
| 40 |
+
"""Reconfigures the global console by replacing it with another.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
*args (Any): Positional arguments for the replacement :class:`~rich.console.Console`.
|
| 44 |
+
**kwargs (Any): Keyword arguments for the replacement :class:`~rich.console.Console`.
|
| 45 |
+
"""
|
| 46 |
+
from rich.console import Console
|
| 47 |
+
|
| 48 |
+
new_console = Console(*args, **kwargs)
|
| 49 |
+
_console = get_console()
|
| 50 |
+
_console.__dict__ = new_console.__dict__
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def print(
|
| 54 |
+
*objects: Any,
|
| 55 |
+
sep: str = " ",
|
| 56 |
+
end: str = "\n",
|
| 57 |
+
file: Optional[IO[str]] = None,
|
| 58 |
+
flush: bool = False,
|
| 59 |
+
) -> None:
|
| 60 |
+
r"""Print object(s) supplied via positional arguments.
|
| 61 |
+
This function has an identical signature to the built-in print.
|
| 62 |
+
For more advanced features, see the :class:`~rich.console.Console` class.
|
| 63 |
+
|
| 64 |
+
Args:
|
| 65 |
+
sep (str, optional): Separator between printed objects. Defaults to " ".
|
| 66 |
+
end (str, optional): Character to write at end of output. Defaults to "\\n".
|
| 67 |
+
file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
|
| 68 |
+
flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
from .console import Console
|
| 72 |
+
|
| 73 |
+
write_console = get_console() if file is None else Console(file=file)
|
| 74 |
+
return write_console.print(*objects, sep=sep, end=end)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def print_json(
|
| 78 |
+
json: Optional[str] = None,
|
| 79 |
+
*,
|
| 80 |
+
data: Any = None,
|
| 81 |
+
indent: Union[None, int, str] = 2,
|
| 82 |
+
highlight: bool = True,
|
| 83 |
+
skip_keys: bool = False,
|
| 84 |
+
ensure_ascii: bool = False,
|
| 85 |
+
check_circular: bool = True,
|
| 86 |
+
allow_nan: bool = True,
|
| 87 |
+
default: Optional[Callable[[Any], Any]] = None,
|
| 88 |
+
sort_keys: bool = False,
|
| 89 |
+
) -> None:
|
| 90 |
+
"""Pretty prints JSON. Output will be valid JSON.
|
| 91 |
+
|
| 92 |
+
Args:
|
| 93 |
+
json (str): A string containing JSON.
|
| 94 |
+
data (Any): If json is not supplied, then encode this data.
|
| 95 |
+
indent (int, optional): Number of spaces to indent. Defaults to 2.
|
| 96 |
+
highlight (bool, optional): Enable highlighting of output: Defaults to True.
|
| 97 |
+
skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
|
| 98 |
+
ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
|
| 99 |
+
check_circular (bool, optional): Check for circular references. Defaults to True.
|
| 100 |
+
allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
|
| 101 |
+
default (Callable, optional): A callable that converts values that can not be encoded
|
| 102 |
+
in to something that can be JSON encoded. Defaults to None.
|
| 103 |
+
sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
|
| 104 |
+
"""
|
| 105 |
+
|
| 106 |
+
get_console().print_json(
|
| 107 |
+
json,
|
| 108 |
+
data=data,
|
| 109 |
+
indent=indent,
|
| 110 |
+
highlight=highlight,
|
| 111 |
+
skip_keys=skip_keys,
|
| 112 |
+
ensure_ascii=ensure_ascii,
|
| 113 |
+
check_circular=check_circular,
|
| 114 |
+
allow_nan=allow_nan,
|
| 115 |
+
default=default,
|
| 116 |
+
sort_keys=sort_keys,
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def inspect(
|
| 121 |
+
obj: Any,
|
| 122 |
+
*,
|
| 123 |
+
console: Optional["Console"] = None,
|
| 124 |
+
title: Optional[str] = None,
|
| 125 |
+
help: bool = False,
|
| 126 |
+
methods: bool = False,
|
| 127 |
+
docs: bool = True,
|
| 128 |
+
private: bool = False,
|
| 129 |
+
dunder: bool = False,
|
| 130 |
+
sort: bool = True,
|
| 131 |
+
all: bool = False,
|
| 132 |
+
value: bool = True,
|
| 133 |
+
) -> None:
|
| 134 |
+
"""Inspect any Python object.
|
| 135 |
+
|
| 136 |
+
* inspect(<OBJECT>) to see summarized info.
|
| 137 |
+
* inspect(<OBJECT>, methods=True) to see methods.
|
| 138 |
+
* inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.
|
| 139 |
+
* inspect(<OBJECT>, private=True) to see private attributes (single underscore).
|
| 140 |
+
* inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.
|
| 141 |
+
* inspect(<OBJECT>, all=True) to see all attributes.
|
| 142 |
+
|
| 143 |
+
Args:
|
| 144 |
+
obj (Any): An object to inspect.
|
| 145 |
+
title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
|
| 146 |
+
help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
|
| 147 |
+
methods (bool, optional): Enable inspection of callables. Defaults to False.
|
| 148 |
+
docs (bool, optional): Also render doc strings. Defaults to True.
|
| 149 |
+
private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
|
| 150 |
+
dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
|
| 151 |
+
sort (bool, optional): Sort attributes alphabetically, callables at the top, leading and trailing underscores ignored. Defaults to True.
|
| 152 |
+
all (bool, optional): Show all attributes. Defaults to False.
|
| 153 |
+
value (bool, optional): Pretty print value. Defaults to True.
|
| 154 |
+
"""
|
| 155 |
+
_console = console or get_console()
|
| 156 |
+
from rich._inspect import Inspect
|
| 157 |
+
|
| 158 |
+
# Special case for inspect(inspect)
|
| 159 |
+
is_inspect = obj is inspect
|
| 160 |
+
|
| 161 |
+
_inspect = Inspect(
|
| 162 |
+
obj,
|
| 163 |
+
title=title,
|
| 164 |
+
help=is_inspect or help,
|
| 165 |
+
methods=is_inspect or methods,
|
| 166 |
+
docs=is_inspect or docs,
|
| 167 |
+
private=private,
|
| 168 |
+
dunder=dunder,
|
| 169 |
+
sort=sort,
|
| 170 |
+
all=all,
|
| 171 |
+
value=value,
|
| 172 |
+
)
|
| 173 |
+
_console.print(_inspect)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if __name__ == "__main__": # pragma: no cover
|
| 177 |
+
print("Hello, **World**")
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/__main__.py
ADDED
|
@@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import colorsys
|
| 2 |
+
import io
|
| 3 |
+
from time import process_time
|
| 4 |
+
|
| 5 |
+
from rich import box
|
| 6 |
+
from rich.color import Color
|
| 7 |
+
from rich.console import Console, ConsoleOptions, Group, RenderableType, RenderResult
|
| 8 |
+
from rich.markdown import Markdown
|
| 9 |
+
from rich.measure import Measurement
|
| 10 |
+
from rich.pretty import Pretty
|
| 11 |
+
from rich.segment import Segment
|
| 12 |
+
from rich.style import Style
|
| 13 |
+
from rich.syntax import Syntax
|
| 14 |
+
from rich.table import Table
|
| 15 |
+
from rich.text import Text
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ColorBox:
|
| 19 |
+
def __rich_console__(
|
| 20 |
+
self, console: Console, options: ConsoleOptions
|
| 21 |
+
) -> RenderResult:
|
| 22 |
+
for y in range(0, 5):
|
| 23 |
+
for x in range(options.max_width):
|
| 24 |
+
h = x / options.max_width
|
| 25 |
+
l = 0.1 + ((y / 5) * 0.7)
|
| 26 |
+
r1, g1, b1 = colorsys.hls_to_rgb(h, l, 1.0)
|
| 27 |
+
r2, g2, b2 = colorsys.hls_to_rgb(h, l + 0.7 / 10, 1.0)
|
| 28 |
+
bgcolor = Color.from_rgb(r1 * 255, g1 * 255, b1 * 255)
|
| 29 |
+
color = Color.from_rgb(r2 * 255, g2 * 255, b2 * 255)
|
| 30 |
+
yield Segment("▄", Style(color=color, bgcolor=bgcolor))
|
| 31 |
+
yield Segment.line()
|
| 32 |
+
|
| 33 |
+
def __rich_measure__(
|
| 34 |
+
self, console: "Console", options: ConsoleOptions
|
| 35 |
+
) -> Measurement:
|
| 36 |
+
return Measurement(1, options.max_width)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def make_test_card() -> Table:
|
| 40 |
+
"""Get a renderable that demonstrates a number of features."""
|
| 41 |
+
table = Table.grid(padding=1, pad_edge=True)
|
| 42 |
+
table.title = "Rich features"
|
| 43 |
+
table.add_column("Feature", no_wrap=True, justify="center", style="bold red")
|
| 44 |
+
table.add_column("Demonstration")
|
| 45 |
+
|
| 46 |
+
color_table = Table(
|
| 47 |
+
box=None,
|
| 48 |
+
expand=False,
|
| 49 |
+
show_header=False,
|
| 50 |
+
show_edge=False,
|
| 51 |
+
pad_edge=False,
|
| 52 |
+
)
|
| 53 |
+
color_table.add_row(
|
| 54 |
+
(
|
| 55 |
+
"✓ [bold green]4-bit color[/]\n"
|
| 56 |
+
"✓ [bold blue]8-bit color[/]\n"
|
| 57 |
+
"✓ [bold magenta]Truecolor (16.7 million)[/]\n"
|
| 58 |
+
"✓ [bold yellow]Dumb terminals[/]\n"
|
| 59 |
+
"✓ [bold cyan]Automatic color conversion"
|
| 60 |
+
),
|
| 61 |
+
ColorBox(),
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
table.add_row("Colors", color_table)
|
| 65 |
+
|
| 66 |
+
table.add_row(
|
| 67 |
+
"Styles",
|
| 68 |
+
"All ansi styles: [bold]bold[/], [dim]dim[/], [italic]italic[/italic], [underline]underline[/], [strike]strikethrough[/], [reverse]reverse[/], and even [blink]blink[/].",
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus."
|
| 72 |
+
lorem_table = Table.grid(padding=1, collapse_padding=True)
|
| 73 |
+
lorem_table.pad_edge = False
|
| 74 |
+
lorem_table.add_row(
|
| 75 |
+
Text(lorem, justify="left", style="green"),
|
| 76 |
+
Text(lorem, justify="center", style="yellow"),
|
| 77 |
+
Text(lorem, justify="right", style="blue"),
|
| 78 |
+
Text(lorem, justify="full", style="red"),
|
| 79 |
+
)
|
| 80 |
+
table.add_row(
|
| 81 |
+
"Text",
|
| 82 |
+
Group(
|
| 83 |
+
Text.from_markup(
|
| 84 |
+
"""Word wrap text. Justify [green]left[/], [yellow]center[/], [blue]right[/] or [red]full[/].\n"""
|
| 85 |
+
),
|
| 86 |
+
lorem_table,
|
| 87 |
+
),
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
def comparison(renderable1: RenderableType, renderable2: RenderableType) -> Table:
|
| 91 |
+
table = Table(show_header=False, pad_edge=False, box=None, expand=True)
|
| 92 |
+
table.add_column("1", ratio=1)
|
| 93 |
+
table.add_column("2", ratio=1)
|
| 94 |
+
table.add_row(renderable1, renderable2)
|
| 95 |
+
return table
|
| 96 |
+
|
| 97 |
+
table.add_row(
|
| 98 |
+
"Asian\nlanguage\nsupport",
|
| 99 |
+
":flag_for_china: 该库支持中文,日文和韩文文本!\n:flag_for_japan: ライブラリは中国語、日本語、韓国語のテキストをサポートしています\n:flag_for_south_korea: 이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다",
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
markup_example = (
|
| 103 |
+
"[bold magenta]Rich[/] supports a simple [i]bbcode[/i]-like [b]markup[/b] for [yellow]color[/], [underline]style[/], and emoji! "
|
| 104 |
+
":+1: :apple: :ant: :bear: :baguette_bread: :bus: "
|
| 105 |
+
)
|
| 106 |
+
table.add_row("Markup", markup_example)
|
| 107 |
+
|
| 108 |
+
example_table = Table(
|
| 109 |
+
show_edge=False,
|
| 110 |
+
show_header=True,
|
| 111 |
+
expand=False,
|
| 112 |
+
row_styles=["none", "dim"],
|
| 113 |
+
box=box.SIMPLE,
|
| 114 |
+
)
|
| 115 |
+
example_table.add_column("[green]Date", style="green", no_wrap=True)
|
| 116 |
+
example_table.add_column("[blue]Title", style="blue")
|
| 117 |
+
example_table.add_column(
|
| 118 |
+
"[cyan]Production Budget",
|
| 119 |
+
style="cyan",
|
| 120 |
+
justify="right",
|
| 121 |
+
no_wrap=True,
|
| 122 |
+
)
|
| 123 |
+
example_table.add_column(
|
| 124 |
+
"[magenta]Box Office",
|
| 125 |
+
style="magenta",
|
| 126 |
+
justify="right",
|
| 127 |
+
no_wrap=True,
|
| 128 |
+
)
|
| 129 |
+
example_table.add_row(
|
| 130 |
+
"Dec 20, 2019",
|
| 131 |
+
"Star Wars: The Rise of Skywalker",
|
| 132 |
+
"$275,000,000",
|
| 133 |
+
"$375,126,118",
|
| 134 |
+
)
|
| 135 |
+
example_table.add_row(
|
| 136 |
+
"May 25, 2018",
|
| 137 |
+
"[b]Solo[/]: A Star Wars Story",
|
| 138 |
+
"$275,000,000",
|
| 139 |
+
"$393,151,347",
|
| 140 |
+
)
|
| 141 |
+
example_table.add_row(
|
| 142 |
+
"Dec 15, 2017",
|
| 143 |
+
"Star Wars Ep. VIII: The Last Jedi",
|
| 144 |
+
"$262,000,000",
|
| 145 |
+
"[bold]$1,332,539,889[/bold]",
|
| 146 |
+
)
|
| 147 |
+
example_table.add_row(
|
| 148 |
+
"May 19, 1999",
|
| 149 |
+
"Star Wars Ep. [b]I[/b]: [i]The phantom Menace",
|
| 150 |
+
"$115,000,000",
|
| 151 |
+
"$1,027,044,677",
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
table.add_row("Tables", example_table)
|
| 155 |
+
|
| 156 |
+
code = '''\
|
| 157 |
+
def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 158 |
+
"""Iterate and generate a tuple with a flag for last value."""
|
| 159 |
+
iter_values = iter(values)
|
| 160 |
+
try:
|
| 161 |
+
previous_value = next(iter_values)
|
| 162 |
+
except StopIteration:
|
| 163 |
+
return
|
| 164 |
+
for value in iter_values:
|
| 165 |
+
yield False, previous_value
|
| 166 |
+
previous_value = value
|
| 167 |
+
yield True, previous_value'''
|
| 168 |
+
|
| 169 |
+
pretty_data = {
|
| 170 |
+
"foo": [
|
| 171 |
+
3.1427,
|
| 172 |
+
(
|
| 173 |
+
"Paul Atreides",
|
| 174 |
+
"Vladimir Harkonnen",
|
| 175 |
+
"Thufir Hawat",
|
| 176 |
+
),
|
| 177 |
+
],
|
| 178 |
+
"atomic": (False, True, None),
|
| 179 |
+
}
|
| 180 |
+
table.add_row(
|
| 181 |
+
"Syntax\nhighlighting\n&\npretty\nprinting",
|
| 182 |
+
comparison(
|
| 183 |
+
Syntax(code, "python3", line_numbers=True, indent_guides=True),
|
| 184 |
+
Pretty(pretty_data, indent_guides=True),
|
| 185 |
+
),
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
markdown_example = """\
|
| 189 |
+
# Markdown
|
| 190 |
+
|
| 191 |
+
Supports much of the *markdown* __syntax__!
|
| 192 |
+
|
| 193 |
+
- Headers
|
| 194 |
+
- Basic formatting: **bold**, *italic*, `code`
|
| 195 |
+
- Block quotes
|
| 196 |
+
- Lists, and more...
|
| 197 |
+
"""
|
| 198 |
+
table.add_row(
|
| 199 |
+
"Markdown", comparison("[cyan]" + markdown_example, Markdown(markdown_example))
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
table.add_row(
|
| 203 |
+
"+more!",
|
| 204 |
+
"""Progress bars, columns, styled logging handler, tracebacks, etc...""",
|
| 205 |
+
)
|
| 206 |
+
return table
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
if __name__ == "__main__": # pragma: no cover
|
| 210 |
+
from rich.panel import Panel
|
| 211 |
+
|
| 212 |
+
console = Console(
|
| 213 |
+
file=io.StringIO(),
|
| 214 |
+
force_terminal=True,
|
| 215 |
+
)
|
| 216 |
+
test_card = make_test_card()
|
| 217 |
+
|
| 218 |
+
# Print once to warm cache
|
| 219 |
+
start = process_time()
|
| 220 |
+
console.print(test_card)
|
| 221 |
+
pre_cache_taken = round((process_time() - start) * 1000.0, 1)
|
| 222 |
+
|
| 223 |
+
console.file = io.StringIO()
|
| 224 |
+
|
| 225 |
+
start = process_time()
|
| 226 |
+
console.print(test_card)
|
| 227 |
+
taken = round((process_time() - start) * 1000.0, 1)
|
| 228 |
+
|
| 229 |
+
c = Console(record=True)
|
| 230 |
+
c.print(test_card)
|
| 231 |
+
|
| 232 |
+
console = Console()
|
| 233 |
+
console.print(f"[dim]rendered in [not dim]{pre_cache_taken}ms[/] (cold cache)")
|
| 234 |
+
console.print(f"[dim]rendered in [not dim]{taken}ms[/] (warm cache)")
|
| 235 |
+
console.print()
|
| 236 |
+
console.print(
|
| 237 |
+
Panel(
|
| 238 |
+
"[b magenta]Hope you enjoy using Rich![/]\n\n"
|
| 239 |
+
"Consider sponsoring to ensure this project is maintained.\n\n"
|
| 240 |
+
"[cyan]https://github.com/sponsors/willmcgugan[/cyan]",
|
| 241 |
+
border_style="green",
|
| 242 |
+
title="Help ensure Rich is maintained",
|
| 243 |
+
padding=(1, 2),
|
| 244 |
+
)
|
| 245 |
+
)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_emoji_codes.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_emoji_replace.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Callable, Match, Optional
|
| 3 |
+
|
| 4 |
+
_ReStringMatch = Match[str] # regex match object
|
| 5 |
+
_ReSubCallable = Callable[[_ReStringMatch], str] # Callable invoked by re.sub
|
| 6 |
+
_EmojiSubMethod = Callable[[_ReSubCallable, str], str] # Sub method of a compiled re
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _emoji_replace(
|
| 10 |
+
text: str,
|
| 11 |
+
default_variant: Optional[str] = None,
|
| 12 |
+
_emoji_sub: _EmojiSubMethod = re.compile(r"(:(\S*?)(?:(?:\-)(emoji|text))?:)").sub,
|
| 13 |
+
) -> str:
|
| 14 |
+
"""Replace emoji code in text."""
|
| 15 |
+
from ._emoji_codes import EMOJI
|
| 16 |
+
|
| 17 |
+
get_emoji = EMOJI.__getitem__
|
| 18 |
+
variants = {"text": "\ufe0e", "emoji": "\ufe0f"}
|
| 19 |
+
get_variant = variants.get
|
| 20 |
+
default_variant_code = variants.get(default_variant, "") if default_variant else ""
|
| 21 |
+
|
| 22 |
+
def do_replace(match: Match[str]) -> str:
|
| 23 |
+
emoji_code, emoji_name, variant = match.groups()
|
| 24 |
+
try:
|
| 25 |
+
return get_emoji(emoji_name.lower()) + get_variant(
|
| 26 |
+
variant, default_variant_code
|
| 27 |
+
)
|
| 28 |
+
except KeyError:
|
| 29 |
+
return emoji_code
|
| 30 |
+
|
| 31 |
+
return _emoji_sub(do_replace, text)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_export_format.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CONSOLE_HTML_FORMAT = """\
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html>
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<style>
|
| 7 |
+
{stylesheet}
|
| 8 |
+
body {{
|
| 9 |
+
color: {foreground};
|
| 10 |
+
background-color: {background};
|
| 11 |
+
}}
|
| 12 |
+
</style>
|
| 13 |
+
</head>
|
| 14 |
+
<body>
|
| 15 |
+
<pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{code}</code></pre>
|
| 16 |
+
</body>
|
| 17 |
+
</html>
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
CONSOLE_SVG_FORMAT = """\
|
| 21 |
+
<svg class="rich-terminal" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
|
| 22 |
+
<!-- Generated with Rich https://www.textualize.io -->
|
| 23 |
+
<style>
|
| 24 |
+
|
| 25 |
+
@font-face {{
|
| 26 |
+
font-family: "Fira Code";
|
| 27 |
+
src: local("FiraCode-Regular"),
|
| 28 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
|
| 29 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
|
| 30 |
+
font-style: normal;
|
| 31 |
+
font-weight: 400;
|
| 32 |
+
}}
|
| 33 |
+
@font-face {{
|
| 34 |
+
font-family: "Fira Code";
|
| 35 |
+
src: local("FiraCode-Bold"),
|
| 36 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
|
| 37 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
|
| 38 |
+
font-style: bold;
|
| 39 |
+
font-weight: 700;
|
| 40 |
+
}}
|
| 41 |
+
|
| 42 |
+
.{unique_id}-matrix {{
|
| 43 |
+
font-family: Fira Code, monospace;
|
| 44 |
+
font-size: {char_height}px;
|
| 45 |
+
line-height: {line_height}px;
|
| 46 |
+
font-variant-east-asian: full-width;
|
| 47 |
+
}}
|
| 48 |
+
|
| 49 |
+
.{unique_id}-title {{
|
| 50 |
+
font-size: 18px;
|
| 51 |
+
font-weight: bold;
|
| 52 |
+
font-family: arial;
|
| 53 |
+
}}
|
| 54 |
+
|
| 55 |
+
{styles}
|
| 56 |
+
</style>
|
| 57 |
+
|
| 58 |
+
<defs>
|
| 59 |
+
<clipPath id="{unique_id}-clip-terminal">
|
| 60 |
+
<rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
|
| 61 |
+
</clipPath>
|
| 62 |
+
{lines}
|
| 63 |
+
</defs>
|
| 64 |
+
|
| 65 |
+
{chrome}
|
| 66 |
+
<g transform="translate({terminal_x}, {terminal_y})" clip-path="url(#{unique_id}-clip-terminal)">
|
| 67 |
+
{backgrounds}
|
| 68 |
+
<g class="{unique_id}-matrix">
|
| 69 |
+
{matrix}
|
| 70 |
+
</g>
|
| 71 |
+
</g>
|
| 72 |
+
</svg>
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
_SVG_FONT_FAMILY = "Rich Fira Code"
|
| 76 |
+
_SVG_CLASSES_PREFIX = "rich-svg"
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_extension.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def load_ipython_extension(ip: Any) -> None: # pragma: no cover
|
| 5 |
+
# prevent circular import
|
| 6 |
+
from rich.pretty import install
|
| 7 |
+
from rich.traceback import install as tr_install
|
| 8 |
+
|
| 9 |
+
install()
|
| 10 |
+
tr_install()
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_fileno.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import IO, Callable
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_fileno(file_like: IO[str]) -> int | None:
|
| 7 |
+
"""Get fileno() from a file, accounting for poorly implemented file-like objects.
|
| 8 |
+
|
| 9 |
+
Args:
|
| 10 |
+
file_like (IO): A file-like object.
|
| 11 |
+
|
| 12 |
+
Returns:
|
| 13 |
+
int | None: The result of fileno if available, or None if operation failed.
|
| 14 |
+
"""
|
| 15 |
+
fileno: Callable[[], int] | None = getattr(file_like, "fileno", None)
|
| 16 |
+
if fileno is not None:
|
| 17 |
+
try:
|
| 18 |
+
return fileno()
|
| 19 |
+
except Exception:
|
| 20 |
+
# `fileno` is documented as potentially raising a OSError
|
| 21 |
+
# Alas, from the issues, there are so many poorly implemented file-like objects,
|
| 22 |
+
# that `fileno()` can raise just about anything.
|
| 23 |
+
return None
|
| 24 |
+
return None
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_inspect.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
from inspect import cleandoc, getdoc, getfile, isclass, ismodule, signature
|
| 3 |
+
from typing import Any, Collection, Iterable, Optional, Tuple, Type, Union
|
| 4 |
+
|
| 5 |
+
from .console import Group, RenderableType
|
| 6 |
+
from .control import escape_control_codes
|
| 7 |
+
from .highlighter import ReprHighlighter
|
| 8 |
+
from .jupyter import JupyterMixin
|
| 9 |
+
from .panel import Panel
|
| 10 |
+
from .pretty import Pretty
|
| 11 |
+
from .table import Table
|
| 12 |
+
from .text import Text, TextType
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _first_paragraph(doc: str) -> str:
|
| 16 |
+
"""Get the first paragraph from a docstring."""
|
| 17 |
+
paragraph, _, _ = doc.partition("\n\n")
|
| 18 |
+
return paragraph
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class Inspect(JupyterMixin):
|
| 22 |
+
"""A renderable to inspect any Python Object.
|
| 23 |
+
|
| 24 |
+
Args:
|
| 25 |
+
obj (Any): An object to inspect.
|
| 26 |
+
title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
|
| 27 |
+
help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
|
| 28 |
+
methods (bool, optional): Enable inspection of callables. Defaults to False.
|
| 29 |
+
docs (bool, optional): Also render doc strings. Defaults to True.
|
| 30 |
+
private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
|
| 31 |
+
dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
|
| 32 |
+
sort (bool, optional): Sort attributes alphabetically, callables at the top, leading and trailing underscores ignored. Defaults to True.
|
| 33 |
+
all (bool, optional): Show all attributes. Defaults to False.
|
| 34 |
+
value (bool, optional): Pretty print value of object. Defaults to True.
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
def __init__(
|
| 38 |
+
self,
|
| 39 |
+
obj: Any,
|
| 40 |
+
*,
|
| 41 |
+
title: Optional[TextType] = None,
|
| 42 |
+
help: bool = False,
|
| 43 |
+
methods: bool = False,
|
| 44 |
+
docs: bool = True,
|
| 45 |
+
private: bool = False,
|
| 46 |
+
dunder: bool = False,
|
| 47 |
+
sort: bool = True,
|
| 48 |
+
all: bool = True,
|
| 49 |
+
value: bool = True,
|
| 50 |
+
) -> None:
|
| 51 |
+
self.highlighter = ReprHighlighter()
|
| 52 |
+
self.obj = obj
|
| 53 |
+
self.title = title or self._make_title(obj)
|
| 54 |
+
if all:
|
| 55 |
+
methods = private = dunder = True
|
| 56 |
+
self.help = help
|
| 57 |
+
self.methods = methods
|
| 58 |
+
self.docs = docs or help
|
| 59 |
+
self.private = private or dunder
|
| 60 |
+
self.dunder = dunder
|
| 61 |
+
self.sort = sort
|
| 62 |
+
self.value = value
|
| 63 |
+
|
| 64 |
+
def _make_title(self, obj: Any) -> Text:
|
| 65 |
+
"""Make a default title."""
|
| 66 |
+
title_str = (
|
| 67 |
+
str(obj)
|
| 68 |
+
if (isclass(obj) or callable(obj) or ismodule(obj))
|
| 69 |
+
else str(type(obj))
|
| 70 |
+
)
|
| 71 |
+
title_text = self.highlighter(title_str)
|
| 72 |
+
return title_text
|
| 73 |
+
|
| 74 |
+
def __rich__(self) -> Panel:
|
| 75 |
+
return Panel.fit(
|
| 76 |
+
Group(*self._render()),
|
| 77 |
+
title=self.title,
|
| 78 |
+
border_style="scope.border",
|
| 79 |
+
padding=(0, 1),
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
def _get_signature(self, name: str, obj: Any) -> Optional[Text]:
|
| 83 |
+
"""Get a signature for a callable."""
|
| 84 |
+
try:
|
| 85 |
+
_signature = str(signature(obj)) + ":"
|
| 86 |
+
except ValueError:
|
| 87 |
+
_signature = "(...)"
|
| 88 |
+
except TypeError:
|
| 89 |
+
return None
|
| 90 |
+
|
| 91 |
+
source_filename: Optional[str] = None
|
| 92 |
+
try:
|
| 93 |
+
source_filename = getfile(obj)
|
| 94 |
+
except (OSError, TypeError):
|
| 95 |
+
# OSError is raised if obj has no source file, e.g. when defined in REPL.
|
| 96 |
+
pass
|
| 97 |
+
|
| 98 |
+
callable_name = Text(name, style="inspect.callable")
|
| 99 |
+
if source_filename:
|
| 100 |
+
callable_name.stylize(f"link file://{source_filename}")
|
| 101 |
+
signature_text = self.highlighter(_signature)
|
| 102 |
+
|
| 103 |
+
qualname = name or getattr(obj, "__qualname__", name)
|
| 104 |
+
if not isinstance(qualname, str):
|
| 105 |
+
qualname = getattr(obj, "__name__", name)
|
| 106 |
+
if not isinstance(qualname, str):
|
| 107 |
+
qualname = name
|
| 108 |
+
|
| 109 |
+
# If obj is a module, there may be classes (which are callable) to display
|
| 110 |
+
if inspect.isclass(obj):
|
| 111 |
+
prefix = "class"
|
| 112 |
+
elif inspect.iscoroutinefunction(obj):
|
| 113 |
+
prefix = "async def"
|
| 114 |
+
else:
|
| 115 |
+
prefix = "def"
|
| 116 |
+
|
| 117 |
+
qual_signature = Text.assemble(
|
| 118 |
+
(f"{prefix} ", f"inspect.{prefix.replace(' ', '_')}"),
|
| 119 |
+
(qualname, "inspect.callable"),
|
| 120 |
+
signature_text,
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
return qual_signature
|
| 124 |
+
|
| 125 |
+
def _render(self) -> Iterable[RenderableType]:
|
| 126 |
+
"""Render object."""
|
| 127 |
+
|
| 128 |
+
def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
|
| 129 |
+
key, (_error, value) = item
|
| 130 |
+
return (callable(value), key.strip("_").lower())
|
| 131 |
+
|
| 132 |
+
def safe_getattr(attr_name: str) -> Tuple[Any, Any]:
|
| 133 |
+
"""Get attribute or any exception."""
|
| 134 |
+
try:
|
| 135 |
+
return (None, getattr(obj, attr_name))
|
| 136 |
+
except Exception as error:
|
| 137 |
+
return (error, None)
|
| 138 |
+
|
| 139 |
+
obj = self.obj
|
| 140 |
+
keys = dir(obj)
|
| 141 |
+
total_items = len(keys)
|
| 142 |
+
if not self.dunder:
|
| 143 |
+
keys = [key for key in keys if not key.startswith("__")]
|
| 144 |
+
if not self.private:
|
| 145 |
+
keys = [key for key in keys if not key.startswith("_")]
|
| 146 |
+
not_shown_count = total_items - len(keys)
|
| 147 |
+
items = [(key, safe_getattr(key)) for key in keys]
|
| 148 |
+
if self.sort:
|
| 149 |
+
items.sort(key=sort_items)
|
| 150 |
+
|
| 151 |
+
items_table = Table.grid(padding=(0, 1), expand=False)
|
| 152 |
+
items_table.add_column(justify="right")
|
| 153 |
+
add_row = items_table.add_row
|
| 154 |
+
highlighter = self.highlighter
|
| 155 |
+
|
| 156 |
+
if callable(obj):
|
| 157 |
+
signature = self._get_signature("", obj)
|
| 158 |
+
if signature is not None:
|
| 159 |
+
yield signature
|
| 160 |
+
yield ""
|
| 161 |
+
|
| 162 |
+
if self.docs:
|
| 163 |
+
_doc = self._get_formatted_doc(obj)
|
| 164 |
+
if _doc is not None:
|
| 165 |
+
doc_text = Text(_doc, style="inspect.help")
|
| 166 |
+
doc_text = highlighter(doc_text)
|
| 167 |
+
yield doc_text
|
| 168 |
+
yield ""
|
| 169 |
+
|
| 170 |
+
if self.value and not (isclass(obj) or callable(obj) or ismodule(obj)):
|
| 171 |
+
yield Panel(
|
| 172 |
+
Pretty(obj, indent_guides=True, max_length=10, max_string=60),
|
| 173 |
+
border_style="inspect.value.border",
|
| 174 |
+
)
|
| 175 |
+
yield ""
|
| 176 |
+
|
| 177 |
+
for key, (error, value) in items:
|
| 178 |
+
key_text = Text.assemble(
|
| 179 |
+
(
|
| 180 |
+
key,
|
| 181 |
+
"inspect.attr.dunder" if key.startswith("__") else "inspect.attr",
|
| 182 |
+
),
|
| 183 |
+
(" =", "inspect.equals"),
|
| 184 |
+
)
|
| 185 |
+
if error is not None:
|
| 186 |
+
warning = key_text.copy()
|
| 187 |
+
warning.stylize("inspect.error")
|
| 188 |
+
add_row(warning, highlighter(repr(error)))
|
| 189 |
+
continue
|
| 190 |
+
|
| 191 |
+
if callable(value):
|
| 192 |
+
if not self.methods:
|
| 193 |
+
continue
|
| 194 |
+
|
| 195 |
+
_signature_text = self._get_signature(key, value)
|
| 196 |
+
if _signature_text is None:
|
| 197 |
+
add_row(key_text, Pretty(value, highlighter=highlighter))
|
| 198 |
+
else:
|
| 199 |
+
if self.docs:
|
| 200 |
+
docs = self._get_formatted_doc(value)
|
| 201 |
+
if docs is not None:
|
| 202 |
+
_signature_text.append("\n" if "\n" in docs else " ")
|
| 203 |
+
doc = highlighter(docs)
|
| 204 |
+
doc.stylize("inspect.doc")
|
| 205 |
+
_signature_text.append(doc)
|
| 206 |
+
|
| 207 |
+
add_row(key_text, _signature_text)
|
| 208 |
+
else:
|
| 209 |
+
add_row(key_text, Pretty(value, highlighter=highlighter))
|
| 210 |
+
if items_table.row_count:
|
| 211 |
+
yield items_table
|
| 212 |
+
elif not_shown_count:
|
| 213 |
+
yield Text.from_markup(
|
| 214 |
+
f"[b cyan]{not_shown_count}[/][i] attribute(s) not shown.[/i] "
|
| 215 |
+
f"Run [b][magenta]inspect[/]([not b]inspect[/])[/b] for options."
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
def _get_formatted_doc(self, object_: Any) -> Optional[str]:
|
| 219 |
+
"""
|
| 220 |
+
Extract the docstring of an object, process it and returns it.
|
| 221 |
+
The processing consists in cleaning up the docstring's indentation,
|
| 222 |
+
taking only its 1st paragraph if `self.help` is not True,
|
| 223 |
+
and escape its control codes.
|
| 224 |
+
|
| 225 |
+
Args:
|
| 226 |
+
object_ (Any): the object to get the docstring from.
|
| 227 |
+
|
| 228 |
+
Returns:
|
| 229 |
+
Optional[str]: the processed docstring, or None if no docstring was found.
|
| 230 |
+
"""
|
| 231 |
+
docs = getdoc(object_)
|
| 232 |
+
if docs is None:
|
| 233 |
+
return None
|
| 234 |
+
docs = cleandoc(docs).strip()
|
| 235 |
+
if not self.help:
|
| 236 |
+
docs = _first_paragraph(docs)
|
| 237 |
+
return escape_control_codes(docs)
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def get_object_types_mro(obj: Union[object, Type[Any]]) -> Tuple[type, ...]:
|
| 241 |
+
"""Returns the MRO of an object's class, or of the object itself if it's a class."""
|
| 242 |
+
if not hasattr(obj, "__mro__"):
|
| 243 |
+
# N.B. we cannot use `if type(obj) is type` here because it doesn't work with
|
| 244 |
+
# some types of classes, such as the ones that use abc.ABCMeta.
|
| 245 |
+
obj = type(obj)
|
| 246 |
+
return getattr(obj, "__mro__", ())
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def get_object_types_mro_as_strings(obj: object) -> Collection[str]:
|
| 250 |
+
"""
|
| 251 |
+
Returns the MRO of an object's class as full qualified names, or of the object itself if it's a class.
|
| 252 |
+
|
| 253 |
+
Examples:
|
| 254 |
+
`object_types_mro_as_strings(JSONDecoder)` will return `['json.decoder.JSONDecoder', 'builtins.object']`
|
| 255 |
+
"""
|
| 256 |
+
return [
|
| 257 |
+
f'{getattr(type_, "__module__", "")}.{getattr(type_, "__qualname__", "")}'
|
| 258 |
+
for type_ in get_object_types_mro(obj)
|
| 259 |
+
]
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def is_object_one_of_types(
|
| 263 |
+
obj: object, fully_qualified_types_names: Collection[str]
|
| 264 |
+
) -> bool:
|
| 265 |
+
"""
|
| 266 |
+
Returns `True` if the given object's class (or the object itself, if it's a class) has one of the
|
| 267 |
+
fully qualified names in its MRO.
|
| 268 |
+
"""
|
| 269 |
+
for type_name in get_object_types_mro_as_strings(obj):
|
| 270 |
+
if type_name in fully_qualified_types_names:
|
| 271 |
+
return True
|
| 272 |
+
return False
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_log_render.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
from typing import Iterable, List, Optional, TYPE_CHECKING, Union, Callable
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
from .text import Text, TextType
|
| 6 |
+
|
| 7 |
+
if TYPE_CHECKING:
|
| 8 |
+
from .console import Console, ConsoleRenderable, RenderableType
|
| 9 |
+
from .table import Table
|
| 10 |
+
|
| 11 |
+
FormatTimeCallable = Callable[[datetime], Text]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class LogRender:
|
| 15 |
+
def __init__(
|
| 16 |
+
self,
|
| 17 |
+
show_time: bool = True,
|
| 18 |
+
show_level: bool = False,
|
| 19 |
+
show_path: bool = True,
|
| 20 |
+
time_format: Union[str, FormatTimeCallable] = "[%x %X]",
|
| 21 |
+
omit_repeated_times: bool = True,
|
| 22 |
+
level_width: Optional[int] = 8,
|
| 23 |
+
) -> None:
|
| 24 |
+
self.show_time = show_time
|
| 25 |
+
self.show_level = show_level
|
| 26 |
+
self.show_path = show_path
|
| 27 |
+
self.time_format = time_format
|
| 28 |
+
self.omit_repeated_times = omit_repeated_times
|
| 29 |
+
self.level_width = level_width
|
| 30 |
+
self._last_time: Optional[Text] = None
|
| 31 |
+
|
| 32 |
+
def __call__(
|
| 33 |
+
self,
|
| 34 |
+
console: "Console",
|
| 35 |
+
renderables: Iterable["ConsoleRenderable"],
|
| 36 |
+
log_time: Optional[datetime] = None,
|
| 37 |
+
time_format: Optional[Union[str, FormatTimeCallable]] = None,
|
| 38 |
+
level: TextType = "",
|
| 39 |
+
path: Optional[str] = None,
|
| 40 |
+
line_no: Optional[int] = None,
|
| 41 |
+
link_path: Optional[str] = None,
|
| 42 |
+
) -> "Table":
|
| 43 |
+
from .containers import Renderables
|
| 44 |
+
from .table import Table
|
| 45 |
+
|
| 46 |
+
output = Table.grid(padding=(0, 1))
|
| 47 |
+
output.expand = True
|
| 48 |
+
if self.show_time:
|
| 49 |
+
output.add_column(style="log.time")
|
| 50 |
+
if self.show_level:
|
| 51 |
+
output.add_column(style="log.level", width=self.level_width)
|
| 52 |
+
output.add_column(ratio=1, style="log.message", overflow="fold")
|
| 53 |
+
if self.show_path and path:
|
| 54 |
+
output.add_column(style="log.path")
|
| 55 |
+
row: List["RenderableType"] = []
|
| 56 |
+
if self.show_time:
|
| 57 |
+
log_time = log_time or console.get_datetime()
|
| 58 |
+
time_format = time_format or self.time_format
|
| 59 |
+
if callable(time_format):
|
| 60 |
+
log_time_display = time_format(log_time)
|
| 61 |
+
else:
|
| 62 |
+
log_time_display = Text(log_time.strftime(time_format))
|
| 63 |
+
if log_time_display == self._last_time and self.omit_repeated_times:
|
| 64 |
+
row.append(Text(" " * len(log_time_display)))
|
| 65 |
+
else:
|
| 66 |
+
row.append(log_time_display)
|
| 67 |
+
self._last_time = log_time_display
|
| 68 |
+
if self.show_level:
|
| 69 |
+
row.append(level)
|
| 70 |
+
|
| 71 |
+
row.append(Renderables(renderables))
|
| 72 |
+
if self.show_path and path:
|
| 73 |
+
path_text = Text()
|
| 74 |
+
path_text.append(
|
| 75 |
+
path, style=f"link file://{link_path}" if link_path else ""
|
| 76 |
+
)
|
| 77 |
+
if line_no:
|
| 78 |
+
path_text.append(":")
|
| 79 |
+
path_text.append(
|
| 80 |
+
f"{line_no}",
|
| 81 |
+
style=f"link file://{link_path}#{line_no}" if link_path else "",
|
| 82 |
+
)
|
| 83 |
+
row.append(path_text)
|
| 84 |
+
|
| 85 |
+
output.add_row(*row)
|
| 86 |
+
return output
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
if __name__ == "__main__": # pragma: no cover
|
| 90 |
+
from rich.console import Console
|
| 91 |
+
|
| 92 |
+
c = Console()
|
| 93 |
+
c.print("[on blue]Hello", justify="right")
|
| 94 |
+
c.log("[on blue]hello", justify="right")
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_loop.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Iterable, Tuple, TypeVar
|
| 2 |
+
|
| 3 |
+
T = TypeVar("T")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def loop_first(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 7 |
+
"""Iterate and generate a tuple with a flag for first value."""
|
| 8 |
+
iter_values = iter(values)
|
| 9 |
+
try:
|
| 10 |
+
value = next(iter_values)
|
| 11 |
+
except StopIteration:
|
| 12 |
+
return
|
| 13 |
+
yield True, value
|
| 14 |
+
for value in iter_values:
|
| 15 |
+
yield False, value
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 19 |
+
"""Iterate and generate a tuple with a flag for last value."""
|
| 20 |
+
iter_values = iter(values)
|
| 21 |
+
try:
|
| 22 |
+
previous_value = next(iter_values)
|
| 23 |
+
except StopIteration:
|
| 24 |
+
return
|
| 25 |
+
for value in iter_values:
|
| 26 |
+
yield False, previous_value
|
| 27 |
+
previous_value = value
|
| 28 |
+
yield True, previous_value
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def loop_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]:
|
| 32 |
+
"""Iterate and generate a tuple with a flag for first and last value."""
|
| 33 |
+
iter_values = iter(values)
|
| 34 |
+
try:
|
| 35 |
+
previous_value = next(iter_values)
|
| 36 |
+
except StopIteration:
|
| 37 |
+
return
|
| 38 |
+
first = True
|
| 39 |
+
for value in iter_values:
|
| 40 |
+
yield first, False, previous_value
|
| 41 |
+
first = False
|
| 42 |
+
previous_value = value
|
| 43 |
+
yield first, True, previous_value
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_null_file.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from types import TracebackType
|
| 2 |
+
from typing import IO, Iterable, Iterator, List, Optional, Type
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class NullFile(IO[str]):
|
| 6 |
+
def close(self) -> None:
|
| 7 |
+
pass
|
| 8 |
+
|
| 9 |
+
def isatty(self) -> bool:
|
| 10 |
+
return False
|
| 11 |
+
|
| 12 |
+
def read(self, __n: int = 1) -> str:
|
| 13 |
+
return ""
|
| 14 |
+
|
| 15 |
+
def readable(self) -> bool:
|
| 16 |
+
return False
|
| 17 |
+
|
| 18 |
+
def readline(self, __limit: int = 1) -> str:
|
| 19 |
+
return ""
|
| 20 |
+
|
| 21 |
+
def readlines(self, __hint: int = 1) -> List[str]:
|
| 22 |
+
return []
|
| 23 |
+
|
| 24 |
+
def seek(self, __offset: int, __whence: int = 1) -> int:
|
| 25 |
+
return 0
|
| 26 |
+
|
| 27 |
+
def seekable(self) -> bool:
|
| 28 |
+
return False
|
| 29 |
+
|
| 30 |
+
def tell(self) -> int:
|
| 31 |
+
return 0
|
| 32 |
+
|
| 33 |
+
def truncate(self, __size: Optional[int] = 1) -> int:
|
| 34 |
+
return 0
|
| 35 |
+
|
| 36 |
+
def writable(self) -> bool:
|
| 37 |
+
return False
|
| 38 |
+
|
| 39 |
+
def writelines(self, __lines: Iterable[str]) -> None:
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
def __next__(self) -> str:
|
| 43 |
+
return ""
|
| 44 |
+
|
| 45 |
+
def __iter__(self) -> Iterator[str]:
|
| 46 |
+
return iter([""])
|
| 47 |
+
|
| 48 |
+
def __enter__(self) -> IO[str]:
|
| 49 |
+
return self
|
| 50 |
+
|
| 51 |
+
def __exit__(
|
| 52 |
+
self,
|
| 53 |
+
__t: Optional[Type[BaseException]],
|
| 54 |
+
__value: Optional[BaseException],
|
| 55 |
+
__traceback: Optional[TracebackType],
|
| 56 |
+
) -> None:
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
def write(self, text: str) -> int:
|
| 60 |
+
return 0
|
| 61 |
+
|
| 62 |
+
def flush(self) -> None:
|
| 63 |
+
pass
|
| 64 |
+
|
| 65 |
+
def fileno(self) -> int:
|
| 66 |
+
return -1
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
NULL_FILE = NullFile()
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_palettes.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .palette import Palette
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# Taken from https://en.wikipedia.org/wiki/ANSI_escape_code (Windows 10 column)
|
| 5 |
+
WINDOWS_PALETTE = Palette(
|
| 6 |
+
[
|
| 7 |
+
(12, 12, 12),
|
| 8 |
+
(197, 15, 31),
|
| 9 |
+
(19, 161, 14),
|
| 10 |
+
(193, 156, 0),
|
| 11 |
+
(0, 55, 218),
|
| 12 |
+
(136, 23, 152),
|
| 13 |
+
(58, 150, 221),
|
| 14 |
+
(204, 204, 204),
|
| 15 |
+
(118, 118, 118),
|
| 16 |
+
(231, 72, 86),
|
| 17 |
+
(22, 198, 12),
|
| 18 |
+
(249, 241, 165),
|
| 19 |
+
(59, 120, 255),
|
| 20 |
+
(180, 0, 158),
|
| 21 |
+
(97, 214, 214),
|
| 22 |
+
(242, 242, 242),
|
| 23 |
+
]
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# # The standard ansi colors (including bright variants)
|
| 27 |
+
STANDARD_PALETTE = Palette(
|
| 28 |
+
[
|
| 29 |
+
(0, 0, 0),
|
| 30 |
+
(170, 0, 0),
|
| 31 |
+
(0, 170, 0),
|
| 32 |
+
(170, 85, 0),
|
| 33 |
+
(0, 0, 170),
|
| 34 |
+
(170, 0, 170),
|
| 35 |
+
(0, 170, 170),
|
| 36 |
+
(170, 170, 170),
|
| 37 |
+
(85, 85, 85),
|
| 38 |
+
(255, 85, 85),
|
| 39 |
+
(85, 255, 85),
|
| 40 |
+
(255, 255, 85),
|
| 41 |
+
(85, 85, 255),
|
| 42 |
+
(255, 85, 255),
|
| 43 |
+
(85, 255, 255),
|
| 44 |
+
(255, 255, 255),
|
| 45 |
+
]
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# The 256 color palette
|
| 50 |
+
EIGHT_BIT_PALETTE = Palette(
|
| 51 |
+
[
|
| 52 |
+
(0, 0, 0),
|
| 53 |
+
(128, 0, 0),
|
| 54 |
+
(0, 128, 0),
|
| 55 |
+
(128, 128, 0),
|
| 56 |
+
(0, 0, 128),
|
| 57 |
+
(128, 0, 128),
|
| 58 |
+
(0, 128, 128),
|
| 59 |
+
(192, 192, 192),
|
| 60 |
+
(128, 128, 128),
|
| 61 |
+
(255, 0, 0),
|
| 62 |
+
(0, 255, 0),
|
| 63 |
+
(255, 255, 0),
|
| 64 |
+
(0, 0, 255),
|
| 65 |
+
(255, 0, 255),
|
| 66 |
+
(0, 255, 255),
|
| 67 |
+
(255, 255, 255),
|
| 68 |
+
(0, 0, 0),
|
| 69 |
+
(0, 0, 95),
|
| 70 |
+
(0, 0, 135),
|
| 71 |
+
(0, 0, 175),
|
| 72 |
+
(0, 0, 215),
|
| 73 |
+
(0, 0, 255),
|
| 74 |
+
(0, 95, 0),
|
| 75 |
+
(0, 95, 95),
|
| 76 |
+
(0, 95, 135),
|
| 77 |
+
(0, 95, 175),
|
| 78 |
+
(0, 95, 215),
|
| 79 |
+
(0, 95, 255),
|
| 80 |
+
(0, 135, 0),
|
| 81 |
+
(0, 135, 95),
|
| 82 |
+
(0, 135, 135),
|
| 83 |
+
(0, 135, 175),
|
| 84 |
+
(0, 135, 215),
|
| 85 |
+
(0, 135, 255),
|
| 86 |
+
(0, 175, 0),
|
| 87 |
+
(0, 175, 95),
|
| 88 |
+
(0, 175, 135),
|
| 89 |
+
(0, 175, 175),
|
| 90 |
+
(0, 175, 215),
|
| 91 |
+
(0, 175, 255),
|
| 92 |
+
(0, 215, 0),
|
| 93 |
+
(0, 215, 95),
|
| 94 |
+
(0, 215, 135),
|
| 95 |
+
(0, 215, 175),
|
| 96 |
+
(0, 215, 215),
|
| 97 |
+
(0, 215, 255),
|
| 98 |
+
(0, 255, 0),
|
| 99 |
+
(0, 255, 95),
|
| 100 |
+
(0, 255, 135),
|
| 101 |
+
(0, 255, 175),
|
| 102 |
+
(0, 255, 215),
|
| 103 |
+
(0, 255, 255),
|
| 104 |
+
(95, 0, 0),
|
| 105 |
+
(95, 0, 95),
|
| 106 |
+
(95, 0, 135),
|
| 107 |
+
(95, 0, 175),
|
| 108 |
+
(95, 0, 215),
|
| 109 |
+
(95, 0, 255),
|
| 110 |
+
(95, 95, 0),
|
| 111 |
+
(95, 95, 95),
|
| 112 |
+
(95, 95, 135),
|
| 113 |
+
(95, 95, 175),
|
| 114 |
+
(95, 95, 215),
|
| 115 |
+
(95, 95, 255),
|
| 116 |
+
(95, 135, 0),
|
| 117 |
+
(95, 135, 95),
|
| 118 |
+
(95, 135, 135),
|
| 119 |
+
(95, 135, 175),
|
| 120 |
+
(95, 135, 215),
|
| 121 |
+
(95, 135, 255),
|
| 122 |
+
(95, 175, 0),
|
| 123 |
+
(95, 175, 95),
|
| 124 |
+
(95, 175, 135),
|
| 125 |
+
(95, 175, 175),
|
| 126 |
+
(95, 175, 215),
|
| 127 |
+
(95, 175, 255),
|
| 128 |
+
(95, 215, 0),
|
| 129 |
+
(95, 215, 95),
|
| 130 |
+
(95, 215, 135),
|
| 131 |
+
(95, 215, 175),
|
| 132 |
+
(95, 215, 215),
|
| 133 |
+
(95, 215, 255),
|
| 134 |
+
(95, 255, 0),
|
| 135 |
+
(95, 255, 95),
|
| 136 |
+
(95, 255, 135),
|
| 137 |
+
(95, 255, 175),
|
| 138 |
+
(95, 255, 215),
|
| 139 |
+
(95, 255, 255),
|
| 140 |
+
(135, 0, 0),
|
| 141 |
+
(135, 0, 95),
|
| 142 |
+
(135, 0, 135),
|
| 143 |
+
(135, 0, 175),
|
| 144 |
+
(135, 0, 215),
|
| 145 |
+
(135, 0, 255),
|
| 146 |
+
(135, 95, 0),
|
| 147 |
+
(135, 95, 95),
|
| 148 |
+
(135, 95, 135),
|
| 149 |
+
(135, 95, 175),
|
| 150 |
+
(135, 95, 215),
|
| 151 |
+
(135, 95, 255),
|
| 152 |
+
(135, 135, 0),
|
| 153 |
+
(135, 135, 95),
|
| 154 |
+
(135, 135, 135),
|
| 155 |
+
(135, 135, 175),
|
| 156 |
+
(135, 135, 215),
|
| 157 |
+
(135, 135, 255),
|
| 158 |
+
(135, 175, 0),
|
| 159 |
+
(135, 175, 95),
|
| 160 |
+
(135, 175, 135),
|
| 161 |
+
(135, 175, 175),
|
| 162 |
+
(135, 175, 215),
|
| 163 |
+
(135, 175, 255),
|
| 164 |
+
(135, 215, 0),
|
| 165 |
+
(135, 215, 95),
|
| 166 |
+
(135, 215, 135),
|
| 167 |
+
(135, 215, 175),
|
| 168 |
+
(135, 215, 215),
|
| 169 |
+
(135, 215, 255),
|
| 170 |
+
(135, 255, 0),
|
| 171 |
+
(135, 255, 95),
|
| 172 |
+
(135, 255, 135),
|
| 173 |
+
(135, 255, 175),
|
| 174 |
+
(135, 255, 215),
|
| 175 |
+
(135, 255, 255),
|
| 176 |
+
(175, 0, 0),
|
| 177 |
+
(175, 0, 95),
|
| 178 |
+
(175, 0, 135),
|
| 179 |
+
(175, 0, 175),
|
| 180 |
+
(175, 0, 215),
|
| 181 |
+
(175, 0, 255),
|
| 182 |
+
(175, 95, 0),
|
| 183 |
+
(175, 95, 95),
|
| 184 |
+
(175, 95, 135),
|
| 185 |
+
(175, 95, 175),
|
| 186 |
+
(175, 95, 215),
|
| 187 |
+
(175, 95, 255),
|
| 188 |
+
(175, 135, 0),
|
| 189 |
+
(175, 135, 95),
|
| 190 |
+
(175, 135, 135),
|
| 191 |
+
(175, 135, 175),
|
| 192 |
+
(175, 135, 215),
|
| 193 |
+
(175, 135, 255),
|
| 194 |
+
(175, 175, 0),
|
| 195 |
+
(175, 175, 95),
|
| 196 |
+
(175, 175, 135),
|
| 197 |
+
(175, 175, 175),
|
| 198 |
+
(175, 175, 215),
|
| 199 |
+
(175, 175, 255),
|
| 200 |
+
(175, 215, 0),
|
| 201 |
+
(175, 215, 95),
|
| 202 |
+
(175, 215, 135),
|
| 203 |
+
(175, 215, 175),
|
| 204 |
+
(175, 215, 215),
|
| 205 |
+
(175, 215, 255),
|
| 206 |
+
(175, 255, 0),
|
| 207 |
+
(175, 255, 95),
|
| 208 |
+
(175, 255, 135),
|
| 209 |
+
(175, 255, 175),
|
| 210 |
+
(175, 255, 215),
|
| 211 |
+
(175, 255, 255),
|
| 212 |
+
(215, 0, 0),
|
| 213 |
+
(215, 0, 95),
|
| 214 |
+
(215, 0, 135),
|
| 215 |
+
(215, 0, 175),
|
| 216 |
+
(215, 0, 215),
|
| 217 |
+
(215, 0, 255),
|
| 218 |
+
(215, 95, 0),
|
| 219 |
+
(215, 95, 95),
|
| 220 |
+
(215, 95, 135),
|
| 221 |
+
(215, 95, 175),
|
| 222 |
+
(215, 95, 215),
|
| 223 |
+
(215, 95, 255),
|
| 224 |
+
(215, 135, 0),
|
| 225 |
+
(215, 135, 95),
|
| 226 |
+
(215, 135, 135),
|
| 227 |
+
(215, 135, 175),
|
| 228 |
+
(215, 135, 215),
|
| 229 |
+
(215, 135, 255),
|
| 230 |
+
(215, 175, 0),
|
| 231 |
+
(215, 175, 95),
|
| 232 |
+
(215, 175, 135),
|
| 233 |
+
(215, 175, 175),
|
| 234 |
+
(215, 175, 215),
|
| 235 |
+
(215, 175, 255),
|
| 236 |
+
(215, 215, 0),
|
| 237 |
+
(215, 215, 95),
|
| 238 |
+
(215, 215, 135),
|
| 239 |
+
(215, 215, 175),
|
| 240 |
+
(215, 215, 215),
|
| 241 |
+
(215, 215, 255),
|
| 242 |
+
(215, 255, 0),
|
| 243 |
+
(215, 255, 95),
|
| 244 |
+
(215, 255, 135),
|
| 245 |
+
(215, 255, 175),
|
| 246 |
+
(215, 255, 215),
|
| 247 |
+
(215, 255, 255),
|
| 248 |
+
(255, 0, 0),
|
| 249 |
+
(255, 0, 95),
|
| 250 |
+
(255, 0, 135),
|
| 251 |
+
(255, 0, 175),
|
| 252 |
+
(255, 0, 215),
|
| 253 |
+
(255, 0, 255),
|
| 254 |
+
(255, 95, 0),
|
| 255 |
+
(255, 95, 95),
|
| 256 |
+
(255, 95, 135),
|
| 257 |
+
(255, 95, 175),
|
| 258 |
+
(255, 95, 215),
|
| 259 |
+
(255, 95, 255),
|
| 260 |
+
(255, 135, 0),
|
| 261 |
+
(255, 135, 95),
|
| 262 |
+
(255, 135, 135),
|
| 263 |
+
(255, 135, 175),
|
| 264 |
+
(255, 135, 215),
|
| 265 |
+
(255, 135, 255),
|
| 266 |
+
(255, 175, 0),
|
| 267 |
+
(255, 175, 95),
|
| 268 |
+
(255, 175, 135),
|
| 269 |
+
(255, 175, 175),
|
| 270 |
+
(255, 175, 215),
|
| 271 |
+
(255, 175, 255),
|
| 272 |
+
(255, 215, 0),
|
| 273 |
+
(255, 215, 95),
|
| 274 |
+
(255, 215, 135),
|
| 275 |
+
(255, 215, 175),
|
| 276 |
+
(255, 215, 215),
|
| 277 |
+
(255, 215, 255),
|
| 278 |
+
(255, 255, 0),
|
| 279 |
+
(255, 255, 95),
|
| 280 |
+
(255, 255, 135),
|
| 281 |
+
(255, 255, 175),
|
| 282 |
+
(255, 255, 215),
|
| 283 |
+
(255, 255, 255),
|
| 284 |
+
(8, 8, 8),
|
| 285 |
+
(18, 18, 18),
|
| 286 |
+
(28, 28, 28),
|
| 287 |
+
(38, 38, 38),
|
| 288 |
+
(48, 48, 48),
|
| 289 |
+
(58, 58, 58),
|
| 290 |
+
(68, 68, 68),
|
| 291 |
+
(78, 78, 78),
|
| 292 |
+
(88, 88, 88),
|
| 293 |
+
(98, 98, 98),
|
| 294 |
+
(108, 108, 108),
|
| 295 |
+
(118, 118, 118),
|
| 296 |
+
(128, 128, 128),
|
| 297 |
+
(138, 138, 138),
|
| 298 |
+
(148, 148, 148),
|
| 299 |
+
(158, 158, 158),
|
| 300 |
+
(168, 168, 168),
|
| 301 |
+
(178, 178, 178),
|
| 302 |
+
(188, 188, 188),
|
| 303 |
+
(198, 198, 198),
|
| 304 |
+
(208, 208, 208),
|
| 305 |
+
(218, 218, 218),
|
| 306 |
+
(228, 228, 228),
|
| 307 |
+
(238, 238, 238),
|
| 308 |
+
]
|
| 309 |
+
)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_pick.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def pick_bool(*values: Optional[bool]) -> bool:
|
| 5 |
+
"""Pick the first non-none bool or return the last value.
|
| 6 |
+
|
| 7 |
+
Args:
|
| 8 |
+
*values (bool): Any number of boolean or None values.
|
| 9 |
+
|
| 10 |
+
Returns:
|
| 11 |
+
bool: First non-none boolean.
|
| 12 |
+
"""
|
| 13 |
+
assert values, "1 or more values required"
|
| 14 |
+
for value in values:
|
| 15 |
+
if value is not None:
|
| 16 |
+
return value
|
| 17 |
+
return bool(value)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_ratio.py
ADDED
|
@@ -0,0 +1,153 @@
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class Edge(Protocol):
|
| 7 |
+
"""Any object that defines an edge (such as Layout)."""
|
| 8 |
+
|
| 9 |
+
size: Optional[int] = None
|
| 10 |
+
ratio: int = 1
|
| 11 |
+
minimum_size: int = 1
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def ratio_resolve(total: int, edges: Sequence[Edge]) -> List[int]:
|
| 15 |
+
"""Divide total space to satisfy size, ratio, and minimum_size, constraints.
|
| 16 |
+
|
| 17 |
+
The returned list of integers should add up to total in most cases, unless it is
|
| 18 |
+
impossible to satisfy all the constraints. For instance, if there are two edges
|
| 19 |
+
with a minimum size of 20 each and `total` is 30 then the returned list will be
|
| 20 |
+
greater than total. In practice, this would mean that a Layout object would
|
| 21 |
+
clip the rows that would overflow the screen height.
|
| 22 |
+
|
| 23 |
+
Args:
|
| 24 |
+
total (int): Total number of characters.
|
| 25 |
+
edges (List[Edge]): Edges within total space.
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
List[int]: Number of characters for each edge.
|
| 29 |
+
"""
|
| 30 |
+
# Size of edge or None for yet to be determined
|
| 31 |
+
sizes = [(edge.size or None) for edge in edges]
|
| 32 |
+
|
| 33 |
+
_Fraction = Fraction
|
| 34 |
+
|
| 35 |
+
# While any edges haven't been calculated
|
| 36 |
+
while None in sizes:
|
| 37 |
+
# Get flexible edges and index to map these back on to sizes list
|
| 38 |
+
flexible_edges = [
|
| 39 |
+
(index, edge)
|
| 40 |
+
for index, (size, edge) in enumerate(zip(sizes, edges))
|
| 41 |
+
if size is None
|
| 42 |
+
]
|
| 43 |
+
# Remaining space in total
|
| 44 |
+
remaining = total - sum(size or 0 for size in sizes)
|
| 45 |
+
if remaining <= 0:
|
| 46 |
+
# No room for flexible edges
|
| 47 |
+
return [
|
| 48 |
+
((edge.minimum_size or 1) if size is None else size)
|
| 49 |
+
for size, edge in zip(sizes, edges)
|
| 50 |
+
]
|
| 51 |
+
# Calculate number of characters in a ratio portion
|
| 52 |
+
portion = _Fraction(
|
| 53 |
+
remaining, sum((edge.ratio or 1) for _, edge in flexible_edges)
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# If any edges will be less than their minimum, replace size with the minimum
|
| 57 |
+
for index, edge in flexible_edges:
|
| 58 |
+
if portion * edge.ratio <= edge.minimum_size:
|
| 59 |
+
sizes[index] = edge.minimum_size
|
| 60 |
+
# New fixed size will invalidate calculations, so we need to repeat the process
|
| 61 |
+
break
|
| 62 |
+
else:
|
| 63 |
+
# Distribute flexible space and compensate for rounding error
|
| 64 |
+
# Since edge sizes can only be integers we need to add the remainder
|
| 65 |
+
# to the following line
|
| 66 |
+
remainder = _Fraction(0)
|
| 67 |
+
for index, edge in flexible_edges:
|
| 68 |
+
size, remainder = divmod(portion * edge.ratio + remainder, 1)
|
| 69 |
+
sizes[index] = size
|
| 70 |
+
break
|
| 71 |
+
# Sizes now contains integers only
|
| 72 |
+
return cast(List[int], sizes)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def ratio_reduce(
|
| 76 |
+
total: int, ratios: List[int], maximums: List[int], values: List[int]
|
| 77 |
+
) -> List[int]:
|
| 78 |
+
"""Divide an integer total in to parts based on ratios.
|
| 79 |
+
|
| 80 |
+
Args:
|
| 81 |
+
total (int): The total to divide.
|
| 82 |
+
ratios (List[int]): A list of integer ratios.
|
| 83 |
+
maximums (List[int]): List of maximums values for each slot.
|
| 84 |
+
values (List[int]): List of values
|
| 85 |
+
|
| 86 |
+
Returns:
|
| 87 |
+
List[int]: A list of integers guaranteed to sum to total.
|
| 88 |
+
"""
|
| 89 |
+
ratios = [ratio if _max else 0 for ratio, _max in zip(ratios, maximums)]
|
| 90 |
+
total_ratio = sum(ratios)
|
| 91 |
+
if not total_ratio:
|
| 92 |
+
return values[:]
|
| 93 |
+
total_remaining = total
|
| 94 |
+
result: List[int] = []
|
| 95 |
+
append = result.append
|
| 96 |
+
for ratio, maximum, value in zip(ratios, maximums, values):
|
| 97 |
+
if ratio and total_ratio > 0:
|
| 98 |
+
distributed = min(maximum, round(ratio * total_remaining / total_ratio))
|
| 99 |
+
append(value - distributed)
|
| 100 |
+
total_remaining -= distributed
|
| 101 |
+
total_ratio -= ratio
|
| 102 |
+
else:
|
| 103 |
+
append(value)
|
| 104 |
+
return result
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def ratio_distribute(
|
| 108 |
+
total: int, ratios: List[int], minimums: Optional[List[int]] = None
|
| 109 |
+
) -> List[int]:
|
| 110 |
+
"""Distribute an integer total in to parts based on ratios.
|
| 111 |
+
|
| 112 |
+
Args:
|
| 113 |
+
total (int): The total to divide.
|
| 114 |
+
ratios (List[int]): A list of integer ratios.
|
| 115 |
+
minimums (List[int]): List of minimum values for each slot.
|
| 116 |
+
|
| 117 |
+
Returns:
|
| 118 |
+
List[int]: A list of integers guaranteed to sum to total.
|
| 119 |
+
"""
|
| 120 |
+
if minimums:
|
| 121 |
+
ratios = [ratio if _min else 0 for ratio, _min in zip(ratios, minimums)]
|
| 122 |
+
total_ratio = sum(ratios)
|
| 123 |
+
assert total_ratio > 0, "Sum of ratios must be > 0"
|
| 124 |
+
|
| 125 |
+
total_remaining = total
|
| 126 |
+
distributed_total: List[int] = []
|
| 127 |
+
append = distributed_total.append
|
| 128 |
+
if minimums is None:
|
| 129 |
+
_minimums = [0] * len(ratios)
|
| 130 |
+
else:
|
| 131 |
+
_minimums = minimums
|
| 132 |
+
for ratio, minimum in zip(ratios, _minimums):
|
| 133 |
+
if total_ratio > 0:
|
| 134 |
+
distributed = max(minimum, ceil(ratio * total_remaining / total_ratio))
|
| 135 |
+
else:
|
| 136 |
+
distributed = total_remaining
|
| 137 |
+
append(distributed)
|
| 138 |
+
total_ratio -= ratio
|
| 139 |
+
total_remaining -= distributed
|
| 140 |
+
return distributed_total
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
if __name__ == "__main__":
|
| 144 |
+
from dataclasses import dataclass
|
| 145 |
+
|
| 146 |
+
@dataclass
|
| 147 |
+
class E:
|
| 148 |
+
size: Optional[int] = None
|
| 149 |
+
ratio: int = 1
|
| 150 |
+
minimum_size: int = 1
|
| 151 |
+
|
| 152 |
+
resolved = ratio_resolve(110, [E(None, 1, 1), E(None, 1, 1), E(None, 1, 1)])
|
| 153 |
+
print(sum(resolved))
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_spinners.py
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Spinners are from:
|
| 3 |
+
* cli-spinners:
|
| 4 |
+
MIT License
|
| 5 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
| 6 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 7 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 8 |
+
in the Software without restriction, including without limitation the rights to
|
| 9 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 10 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 11 |
+
subject to the following conditions:
|
| 12 |
+
The above copyright notice and this permission notice shall be included
|
| 13 |
+
in all copies or substantial portions of the Software.
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
| 15 |
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
| 16 |
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
| 17 |
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 18 |
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
| 19 |
+
IN THE SOFTWARE.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
SPINNERS = {
|
| 23 |
+
"dots": {
|
| 24 |
+
"interval": 80,
|
| 25 |
+
"frames": "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏",
|
| 26 |
+
},
|
| 27 |
+
"dots2": {"interval": 80, "frames": "⣾⣽⣻⢿⡿⣟⣯⣷"},
|
| 28 |
+
"dots3": {
|
| 29 |
+
"interval": 80,
|
| 30 |
+
"frames": "⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓",
|
| 31 |
+
},
|
| 32 |
+
"dots4": {
|
| 33 |
+
"interval": 80,
|
| 34 |
+
"frames": "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆",
|
| 35 |
+
},
|
| 36 |
+
"dots5": {
|
| 37 |
+
"interval": 80,
|
| 38 |
+
"frames": "⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋",
|
| 39 |
+
},
|
| 40 |
+
"dots6": {
|
| 41 |
+
"interval": 80,
|
| 42 |
+
"frames": "⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁",
|
| 43 |
+
},
|
| 44 |
+
"dots7": {
|
| 45 |
+
"interval": 80,
|
| 46 |
+
"frames": "⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈",
|
| 47 |
+
},
|
| 48 |
+
"dots8": {
|
| 49 |
+
"interval": 80,
|
| 50 |
+
"frames": "⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈",
|
| 51 |
+
},
|
| 52 |
+
"dots9": {"interval": 80, "frames": "⢹⢺⢼⣸⣇⡧⡗⡏"},
|
| 53 |
+
"dots10": {"interval": 80, "frames": "⢄⢂⢁⡁⡈⡐⡠"},
|
| 54 |
+
"dots11": {"interval": 100, "frames": "⠁⠂⠄⡀⢀⠠⠐⠈"},
|
| 55 |
+
"dots12": {
|
| 56 |
+
"interval": 80,
|
| 57 |
+
"frames": [
|
| 58 |
+
"⢀⠀",
|
| 59 |
+
"⡀⠀",
|
| 60 |
+
"⠄⠀",
|
| 61 |
+
"⢂⠀",
|
| 62 |
+
"⡂⠀",
|
| 63 |
+
"⠅⠀",
|
| 64 |
+
"⢃⠀",
|
| 65 |
+
"⡃⠀",
|
| 66 |
+
"⠍⠀",
|
| 67 |
+
"⢋⠀",
|
| 68 |
+
"⡋⠀",
|
| 69 |
+
"⠍⠁",
|
| 70 |
+
"⢋⠁",
|
| 71 |
+
"⡋⠁",
|
| 72 |
+
"⠍⠉",
|
| 73 |
+
"⠋⠉",
|
| 74 |
+
"⠋⠉",
|
| 75 |
+
"⠉⠙",
|
| 76 |
+
"⠉⠙",
|
| 77 |
+
"⠉⠩",
|
| 78 |
+
"⠈⢙",
|
| 79 |
+
"⠈⡙",
|
| 80 |
+
"⢈⠩",
|
| 81 |
+
"⡀⢙",
|
| 82 |
+
"⠄⡙",
|
| 83 |
+
"⢂⠩",
|
| 84 |
+
"⡂⢘",
|
| 85 |
+
"⠅⡘",
|
| 86 |
+
"⢃⠨",
|
| 87 |
+
"⡃⢐",
|
| 88 |
+
"⠍⡐",
|
| 89 |
+
"⢋⠠",
|
| 90 |
+
"⡋⢀",
|
| 91 |
+
"⠍⡁",
|
| 92 |
+
"⢋⠁",
|
| 93 |
+
"⡋⠁",
|
| 94 |
+
"⠍⠉",
|
| 95 |
+
"⠋⠉",
|
| 96 |
+
"⠋⠉",
|
| 97 |
+
"⠉⠙",
|
| 98 |
+
"⠉⠙",
|
| 99 |
+
"⠉⠩",
|
| 100 |
+
"⠈⢙",
|
| 101 |
+
"⠈⡙",
|
| 102 |
+
"⠈⠩",
|
| 103 |
+
"⠀⢙",
|
| 104 |
+
"⠀⡙",
|
| 105 |
+
"⠀⠩",
|
| 106 |
+
"⠀⢘",
|
| 107 |
+
"⠀⡘",
|
| 108 |
+
"⠀⠨",
|
| 109 |
+
"⠀⢐",
|
| 110 |
+
"⠀⡐",
|
| 111 |
+
"⠀⠠",
|
| 112 |
+
"⠀⢀",
|
| 113 |
+
"⠀⡀",
|
| 114 |
+
],
|
| 115 |
+
},
|
| 116 |
+
"dots8Bit": {
|
| 117 |
+
"interval": 80,
|
| 118 |
+
"frames": "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙"
|
| 119 |
+
"⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻"
|
| 120 |
+
"⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕"
|
| 121 |
+
"⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷"
|
| 122 |
+
"⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿",
|
| 123 |
+
},
|
| 124 |
+
"line": {"interval": 130, "frames": ["-", "\\", "|", "/"]},
|
| 125 |
+
"line2": {"interval": 100, "frames": "⠂-–—–-"},
|
| 126 |
+
"pipe": {"interval": 100, "frames": "┤┘┴└├┌┬┐"},
|
| 127 |
+
"simpleDots": {"interval": 400, "frames": [". ", ".. ", "...", " "]},
|
| 128 |
+
"simpleDotsScrolling": {
|
| 129 |
+
"interval": 200,
|
| 130 |
+
"frames": [". ", ".. ", "...", " ..", " .", " "],
|
| 131 |
+
},
|
| 132 |
+
"star": {"interval": 70, "frames": "✶✸✹✺✹✷"},
|
| 133 |
+
"star2": {"interval": 80, "frames": "+x*"},
|
| 134 |
+
"flip": {
|
| 135 |
+
"interval": 70,
|
| 136 |
+
"frames": "___-``'´-___",
|
| 137 |
+
},
|
| 138 |
+
"hamburger": {"interval": 100, "frames": "☱☲☴"},
|
| 139 |
+
"growVertical": {
|
| 140 |
+
"interval": 120,
|
| 141 |
+
"frames": "▁▃▄▅▆▇▆▅▄▃",
|
| 142 |
+
},
|
| 143 |
+
"growHorizontal": {
|
| 144 |
+
"interval": 120,
|
| 145 |
+
"frames": "▏▎▍▌▋▊▉▊▋▌▍▎",
|
| 146 |
+
},
|
| 147 |
+
"balloon": {"interval": 140, "frames": " .oO@* "},
|
| 148 |
+
"balloon2": {"interval": 120, "frames": ".oO°Oo."},
|
| 149 |
+
"noise": {"interval": 100, "frames": "▓▒░"},
|
| 150 |
+
"bounce": {"interval": 120, "frames": "⠁⠂⠄⠂"},
|
| 151 |
+
"boxBounce": {"interval": 120, "frames": "▖▘▝▗"},
|
| 152 |
+
"boxBounce2": {"interval": 100, "frames": "▌▀▐▄"},
|
| 153 |
+
"triangle": {"interval": 50, "frames": "◢◣◤◥"},
|
| 154 |
+
"arc": {"interval": 100, "frames": "◜◠◝◞◡◟"},
|
| 155 |
+
"circle": {"interval": 120, "frames": "◡⊙◠"},
|
| 156 |
+
"squareCorners": {"interval": 180, "frames": "◰◳◲◱"},
|
| 157 |
+
"circleQuarters": {"interval": 120, "frames": "◴◷◶◵"},
|
| 158 |
+
"circleHalves": {"interval": 50, "frames": "◐◓◑◒"},
|
| 159 |
+
"squish": {"interval": 100, "frames": "╫╪"},
|
| 160 |
+
"toggle": {"interval": 250, "frames": "⊶⊷"},
|
| 161 |
+
"toggle2": {"interval": 80, "frames": "▫▪"},
|
| 162 |
+
"toggle3": {"interval": 120, "frames": "□■"},
|
| 163 |
+
"toggle4": {"interval": 100, "frames": "■□▪▫"},
|
| 164 |
+
"toggle5": {"interval": 100, "frames": "▮▯"},
|
| 165 |
+
"toggle6": {"interval": 300, "frames": "ဝ၀"},
|
| 166 |
+
"toggle7": {"interval": 80, "frames": "⦾⦿"},
|
| 167 |
+
"toggle8": {"interval": 100, "frames": "◍◌"},
|
| 168 |
+
"toggle9": {"interval": 100, "frames": "◉◎"},
|
| 169 |
+
"toggle10": {"interval": 100, "frames": "㊂㊀㊁"},
|
| 170 |
+
"toggle11": {"interval": 50, "frames": "⧇⧆"},
|
| 171 |
+
"toggle12": {"interval": 120, "frames": "☗☖"},
|
| 172 |
+
"toggle13": {"interval": 80, "frames": "=*-"},
|
| 173 |
+
"arrow": {"interval": 100, "frames": "←↖↑↗→↘↓↙"},
|
| 174 |
+
"arrow2": {
|
| 175 |
+
"interval": 80,
|
| 176 |
+
"frames": ["⬆️ ", "↗️ ", "➡️ ", "↘️ ", "⬇️ ", "↙️ ", "⬅️ ", "↖️ "],
|
| 177 |
+
},
|
| 178 |
+
"arrow3": {
|
| 179 |
+
"interval": 120,
|
| 180 |
+
"frames": ["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"],
|
| 181 |
+
},
|
| 182 |
+
"bouncingBar": {
|
| 183 |
+
"interval": 80,
|
| 184 |
+
"frames": [
|
| 185 |
+
"[ ]",
|
| 186 |
+
"[= ]",
|
| 187 |
+
"[== ]",
|
| 188 |
+
"[=== ]",
|
| 189 |
+
"[ ===]",
|
| 190 |
+
"[ ==]",
|
| 191 |
+
"[ =]",
|
| 192 |
+
"[ ]",
|
| 193 |
+
"[ =]",
|
| 194 |
+
"[ ==]",
|
| 195 |
+
"[ ===]",
|
| 196 |
+
"[====]",
|
| 197 |
+
"[=== ]",
|
| 198 |
+
"[== ]",
|
| 199 |
+
"[= ]",
|
| 200 |
+
],
|
| 201 |
+
},
|
| 202 |
+
"bouncingBall": {
|
| 203 |
+
"interval": 80,
|
| 204 |
+
"frames": [
|
| 205 |
+
"( ● )",
|
| 206 |
+
"( ● )",
|
| 207 |
+
"( ● )",
|
| 208 |
+
"( ● )",
|
| 209 |
+
"( ●)",
|
| 210 |
+
"( ● )",
|
| 211 |
+
"( ● )",
|
| 212 |
+
"( ● )",
|
| 213 |
+
"( ● )",
|
| 214 |
+
"(● )",
|
| 215 |
+
],
|
| 216 |
+
},
|
| 217 |
+
"smiley": {"interval": 200, "frames": ["😄 ", "😝 "]},
|
| 218 |
+
"monkey": {"interval": 300, "frames": ["🙈 ", "🙈 ", "🙉 ", "🙊 "]},
|
| 219 |
+
"hearts": {"interval": 100, "frames": ["💛 ", "💙 ", "💜 ", "💚 ", "❤️ "]},
|
| 220 |
+
"clock": {
|
| 221 |
+
"interval": 100,
|
| 222 |
+
"frames": [
|
| 223 |
+
"🕛 ",
|
| 224 |
+
"🕐 ",
|
| 225 |
+
"🕑 ",
|
| 226 |
+
"🕒 ",
|
| 227 |
+
"🕓 ",
|
| 228 |
+
"🕔 ",
|
| 229 |
+
"🕕 ",
|
| 230 |
+
"🕖 ",
|
| 231 |
+
"🕗 ",
|
| 232 |
+
"🕘 ",
|
| 233 |
+
"🕙 ",
|
| 234 |
+
"🕚 ",
|
| 235 |
+
],
|
| 236 |
+
},
|
| 237 |
+
"earth": {"interval": 180, "frames": ["🌍 ", "🌎 ", "🌏 "]},
|
| 238 |
+
"material": {
|
| 239 |
+
"interval": 17,
|
| 240 |
+
"frames": [
|
| 241 |
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 242 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 243 |
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 244 |
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 245 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 246 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 247 |
+
"███████▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 248 |
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 249 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 250 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 251 |
+
"██████████▁▁▁▁▁▁▁▁▁▁",
|
| 252 |
+
"███████████▁▁▁▁▁▁▁▁▁",
|
| 253 |
+
"█████████████▁▁▁▁▁▁▁",
|
| 254 |
+
"██████████████▁▁▁▁▁▁",
|
| 255 |
+
"██████████████▁▁▁▁▁▁",
|
| 256 |
+
"▁██████████████▁▁▁▁▁",
|
| 257 |
+
"▁██████████████▁▁▁▁▁",
|
| 258 |
+
"▁██████████████▁▁▁▁▁",
|
| 259 |
+
"▁▁██████████████▁▁▁▁",
|
| 260 |
+
"▁▁▁██████████████▁▁▁",
|
| 261 |
+
"▁▁▁▁█████████████▁▁▁",
|
| 262 |
+
"▁▁▁▁██████████████▁▁",
|
| 263 |
+
"▁▁▁▁██████████████▁▁",
|
| 264 |
+
"▁▁▁▁▁██████████████▁",
|
| 265 |
+
"▁▁▁▁▁██████████████▁",
|
| 266 |
+
"▁▁▁▁▁██████████████▁",
|
| 267 |
+
"▁▁▁▁▁▁██████████████",
|
| 268 |
+
"▁▁▁▁▁▁██████████████",
|
| 269 |
+
"▁▁▁▁▁▁▁█████████████",
|
| 270 |
+
"▁▁▁▁▁▁▁█████████████",
|
| 271 |
+
"▁▁▁▁▁▁▁▁████████████",
|
| 272 |
+
"▁▁▁▁▁▁▁▁████████████",
|
| 273 |
+
"▁▁▁▁▁▁▁▁▁███████████",
|
| 274 |
+
"▁▁▁▁▁▁▁▁▁███████████",
|
| 275 |
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
| 276 |
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
| 277 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁████████",
|
| 278 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 279 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████",
|
| 280 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 281 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 282 |
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 283 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 284 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 285 |
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 286 |
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 287 |
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 288 |
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 289 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 290 |
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 291 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 292 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 293 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 294 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 295 |
+
"███████████▁▁▁▁▁▁▁▁▁",
|
| 296 |
+
"████████████▁▁▁▁▁▁▁▁",
|
| 297 |
+
"████████████▁▁▁▁▁▁▁▁",
|
| 298 |
+
"██████████████▁▁▁▁▁▁",
|
| 299 |
+
"██████████████▁▁▁▁▁▁",
|
| 300 |
+
"▁██████████████▁▁▁▁▁",
|
| 301 |
+
"▁██████████████▁▁▁▁▁",
|
| 302 |
+
"▁▁▁█████████████▁▁▁▁",
|
| 303 |
+
"▁▁▁▁▁████████████▁▁▁",
|
| 304 |
+
"▁▁▁▁▁████████████▁▁▁",
|
| 305 |
+
"▁▁▁▁▁▁███████████▁▁▁",
|
| 306 |
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
| 307 |
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
| 308 |
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
| 309 |
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
| 310 |
+
"▁▁▁▁▁▁▁▁▁▁█████████▁",
|
| 311 |
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
| 312 |
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
| 313 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
| 314 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
| 315 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 316 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 317 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 318 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 319 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 320 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 321 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 322 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 323 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 324 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 325 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 326 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 327 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 328 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 329 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 330 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 331 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 332 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 333 |
+
],
|
| 334 |
+
},
|
| 335 |
+
"moon": {
|
| 336 |
+
"interval": 80,
|
| 337 |
+
"frames": ["🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "],
|
| 338 |
+
},
|
| 339 |
+
"runner": {"interval": 140, "frames": ["🚶 ", "🏃 "]},
|
| 340 |
+
"pong": {
|
| 341 |
+
"interval": 80,
|
| 342 |
+
"frames": [
|
| 343 |
+
"▐⠂ ▌",
|
| 344 |
+
"▐⠈ ▌",
|
| 345 |
+
"▐ ⠂ ▌",
|
| 346 |
+
"▐ ⠠ ▌",
|
| 347 |
+
"▐ ⡀ ▌",
|
| 348 |
+
"▐ ⠠ ▌",
|
| 349 |
+
"▐ ⠂ ▌",
|
| 350 |
+
"▐ ⠈ ▌",
|
| 351 |
+
"▐ ⠂ ▌",
|
| 352 |
+
"▐ ⠠ ▌",
|
| 353 |
+
"▐ ⡀ ▌",
|
| 354 |
+
"▐ ⠠ ▌",
|
| 355 |
+
"▐ ⠂ ▌",
|
| 356 |
+
"▐ ⠈ ▌",
|
| 357 |
+
"▐ ⠂▌",
|
| 358 |
+
"▐ ⠠▌",
|
| 359 |
+
"▐ ⡀▌",
|
| 360 |
+
"▐ ⠠ ▌",
|
| 361 |
+
"▐ ⠂ ▌",
|
| 362 |
+
"▐ ⠈ ▌",
|
| 363 |
+
"▐ ⠂ ▌",
|
| 364 |
+
"▐ ⠠ ▌",
|
| 365 |
+
"▐ ⡀ ▌",
|
| 366 |
+
"▐ ⠠ ▌",
|
| 367 |
+
"▐ ⠂ ▌",
|
| 368 |
+
"▐ ⠈ ▌",
|
| 369 |
+
"▐ ⠂ ▌",
|
| 370 |
+
"▐ ⠠ ▌",
|
| 371 |
+
"▐ ⡀ ▌",
|
| 372 |
+
"▐⠠ ▌",
|
| 373 |
+
],
|
| 374 |
+
},
|
| 375 |
+
"shark": {
|
| 376 |
+
"interval": 120,
|
| 377 |
+
"frames": [
|
| 378 |
+
"▐|\\____________▌",
|
| 379 |
+
"▐_|\\___________▌",
|
| 380 |
+
"▐__|\\__________▌",
|
| 381 |
+
"▐___|\\_________▌",
|
| 382 |
+
"▐____|\\________▌",
|
| 383 |
+
"▐_____|\\_______▌",
|
| 384 |
+
"▐______|\\______▌",
|
| 385 |
+
"▐_______|\\_____▌",
|
| 386 |
+
"▐________|\\____▌",
|
| 387 |
+
"▐_________|\\___▌",
|
| 388 |
+
"▐__________|\\__▌",
|
| 389 |
+
"▐___________|\\_▌",
|
| 390 |
+
"▐____________|\\▌",
|
| 391 |
+
"▐____________/|▌",
|
| 392 |
+
"▐___________/|_▌",
|
| 393 |
+
"▐__________/|__▌",
|
| 394 |
+
"▐_________/|___▌",
|
| 395 |
+
"▐________/|____▌",
|
| 396 |
+
"▐_______/|_____▌",
|
| 397 |
+
"▐______/|______▌",
|
| 398 |
+
"▐_____/|_______▌",
|
| 399 |
+
"▐____/|________▌",
|
| 400 |
+
"▐___/|_________▌",
|
| 401 |
+
"▐__/|__________▌",
|
| 402 |
+
"▐_/|___________▌",
|
| 403 |
+
"▐/|____________▌",
|
| 404 |
+
],
|
| 405 |
+
},
|
| 406 |
+
"dqpb": {"interval": 100, "frames": "dqpb"},
|
| 407 |
+
"weather": {
|
| 408 |
+
"interval": 100,
|
| 409 |
+
"frames": [
|
| 410 |
+
"☀️ ",
|
| 411 |
+
"☀️ ",
|
| 412 |
+
"☀️ ",
|
| 413 |
+
"🌤 ",
|
| 414 |
+
"⛅️ ",
|
| 415 |
+
"🌥 ",
|
| 416 |
+
"☁️ ",
|
| 417 |
+
"🌧 ",
|
| 418 |
+
"🌨 ",
|
| 419 |
+
"🌧 ",
|
| 420 |
+
"🌨 ",
|
| 421 |
+
"🌧 ",
|
| 422 |
+
"🌨 ",
|
| 423 |
+
"⛈ ",
|
| 424 |
+
"🌨 ",
|
| 425 |
+
"🌧 ",
|
| 426 |
+
"🌨 ",
|
| 427 |
+
"☁️ ",
|
| 428 |
+
"🌥 ",
|
| 429 |
+
"⛅️ ",
|
| 430 |
+
"🌤 ",
|
| 431 |
+
"☀️ ",
|
| 432 |
+
"☀️ ",
|
| 433 |
+
],
|
| 434 |
+
},
|
| 435 |
+
"christmas": {"interval": 400, "frames": "🌲🎄"},
|
| 436 |
+
"grenade": {
|
| 437 |
+
"interval": 80,
|
| 438 |
+
"frames": [
|
| 439 |
+
"، ",
|
| 440 |
+
"′ ",
|
| 441 |
+
" ´ ",
|
| 442 |
+
" ‾ ",
|
| 443 |
+
" ⸌",
|
| 444 |
+
" ⸊",
|
| 445 |
+
" |",
|
| 446 |
+
" ⁎",
|
| 447 |
+
" ⁕",
|
| 448 |
+
" ෴ ",
|
| 449 |
+
" ⁓",
|
| 450 |
+
" ",
|
| 451 |
+
" ",
|
| 452 |
+
" ",
|
| 453 |
+
],
|
| 454 |
+
},
|
| 455 |
+
"point": {"interval": 125, "frames": ["∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"]},
|
| 456 |
+
"layer": {"interval": 150, "frames": "-=≡"},
|
| 457 |
+
"betaWave": {
|
| 458 |
+
"interval": 80,
|
| 459 |
+
"frames": [
|
| 460 |
+
"ρββββββ",
|
| 461 |
+
"βρβββββ",
|
| 462 |
+
"ββρββββ",
|
| 463 |
+
"βββρβββ",
|
| 464 |
+
"ββββρββ",
|
| 465 |
+
"βββββρβ",
|
| 466 |
+
"ββββββρ",
|
| 467 |
+
],
|
| 468 |
+
},
|
| 469 |
+
"aesthetic": {
|
| 470 |
+
"interval": 80,
|
| 471 |
+
"frames": [
|
| 472 |
+
"▰▱▱▱▱▱▱",
|
| 473 |
+
"▰▰▱▱▱▱▱",
|
| 474 |
+
"▰▰▰▱▱▱▱",
|
| 475 |
+
"▰▰▰▰▱▱▱",
|
| 476 |
+
"▰▰▰▰▰▱▱",
|
| 477 |
+
"▰▰▰▰▰▰▱",
|
| 478 |
+
"▰▰▰▰▰▰▰",
|
| 479 |
+
"▰▱▱▱▱▱▱",
|
| 480 |
+
],
|
| 481 |
+
},
|
| 482 |
+
}
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_stack.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, TypeVar
|
| 2 |
+
|
| 3 |
+
T = TypeVar("T")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class Stack(List[T]):
|
| 7 |
+
"""A small shim over builtin list."""
|
| 8 |
+
|
| 9 |
+
@property
|
| 10 |
+
def top(self) -> T:
|
| 11 |
+
"""Get top of stack."""
|
| 12 |
+
return self[-1]
|
| 13 |
+
|
| 14 |
+
def push(self, item: T) -> None:
|
| 15 |
+
"""Push an item on to the stack (append in stack nomenclature)."""
|
| 16 |
+
self.append(item)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_timer.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Timer context manager, only used in debug.
|
| 3 |
+
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from time import time
|
| 7 |
+
|
| 8 |
+
import contextlib
|
| 9 |
+
from typing import Generator
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@contextlib.contextmanager
|
| 13 |
+
def timer(subject: str = "time") -> Generator[None, None, None]:
|
| 14 |
+
"""print the elapsed time. (only used in debugging)"""
|
| 15 |
+
start = time()
|
| 16 |
+
yield
|
| 17 |
+
elapsed = time() - start
|
| 18 |
+
elapsed_ms = elapsed * 1000
|
| 19 |
+
print(f"{subject} elapsed {elapsed_ms:.1f}ms")
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_win32_console.py
ADDED
|
@@ -0,0 +1,661 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Light wrapper around the Win32 Console API - this module should only be imported on Windows
|
| 2 |
+
|
| 3 |
+
The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import ctypes
|
| 7 |
+
import sys
|
| 8 |
+
from typing import Any
|
| 9 |
+
|
| 10 |
+
windll: Any = None
|
| 11 |
+
if sys.platform == "win32":
|
| 12 |
+
windll = ctypes.LibraryLoader(ctypes.WinDLL)
|
| 13 |
+
else:
|
| 14 |
+
raise ImportError(f"{__name__} can only be imported on Windows")
|
| 15 |
+
|
| 16 |
+
import time
|
| 17 |
+
from ctypes import Structure, byref, wintypes
|
| 18 |
+
from typing import IO, NamedTuple, Type, cast
|
| 19 |
+
|
| 20 |
+
from rich.color import ColorSystem
|
| 21 |
+
from rich.style import Style
|
| 22 |
+
|
| 23 |
+
STDOUT = -11
|
| 24 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
|
| 25 |
+
|
| 26 |
+
COORD = wintypes._COORD
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class LegacyWindowsError(Exception):
|
| 30 |
+
pass
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class WindowsCoordinates(NamedTuple):
|
| 34 |
+
"""Coordinates in the Windows Console API are (y, x), not (x, y).
|
| 35 |
+
This class is intended to prevent that confusion.
|
| 36 |
+
Rows and columns are indexed from 0.
|
| 37 |
+
This class can be used in place of wintypes._COORD in arguments and argtypes.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
row: int
|
| 41 |
+
col: int
|
| 42 |
+
|
| 43 |
+
@classmethod
|
| 44 |
+
def from_param(cls, value: "WindowsCoordinates") -> COORD:
|
| 45 |
+
"""Converts a WindowsCoordinates into a wintypes _COORD structure.
|
| 46 |
+
This classmethod is internally called by ctypes to perform the conversion.
|
| 47 |
+
|
| 48 |
+
Args:
|
| 49 |
+
value (WindowsCoordinates): The input coordinates to convert.
|
| 50 |
+
|
| 51 |
+
Returns:
|
| 52 |
+
wintypes._COORD: The converted coordinates struct.
|
| 53 |
+
"""
|
| 54 |
+
return COORD(value.col, value.row)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
| 58 |
+
_fields_ = [
|
| 59 |
+
("dwSize", COORD),
|
| 60 |
+
("dwCursorPosition", COORD),
|
| 61 |
+
("wAttributes", wintypes.WORD),
|
| 62 |
+
("srWindow", wintypes.SMALL_RECT),
|
| 63 |
+
("dwMaximumWindowSize", COORD),
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class CONSOLE_CURSOR_INFO(ctypes.Structure):
|
| 68 |
+
_fields_ = [("dwSize", wintypes.DWORD), ("bVisible", wintypes.BOOL)]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
_GetStdHandle = windll.kernel32.GetStdHandle
|
| 72 |
+
_GetStdHandle.argtypes = [
|
| 73 |
+
wintypes.DWORD,
|
| 74 |
+
]
|
| 75 |
+
_GetStdHandle.restype = wintypes.HANDLE
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def GetStdHandle(handle: int = STDOUT) -> wintypes.HANDLE:
|
| 79 |
+
"""Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
|
| 80 |
+
|
| 81 |
+
Args:
|
| 82 |
+
handle (int): Integer identifier for the handle. Defaults to -11 (stdout).
|
| 83 |
+
|
| 84 |
+
Returns:
|
| 85 |
+
wintypes.HANDLE: The handle
|
| 86 |
+
"""
|
| 87 |
+
return cast(wintypes.HANDLE, _GetStdHandle(handle))
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
_GetConsoleMode = windll.kernel32.GetConsoleMode
|
| 91 |
+
_GetConsoleMode.argtypes = [wintypes.HANDLE, wintypes.LPDWORD]
|
| 92 |
+
_GetConsoleMode.restype = wintypes.BOOL
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def GetConsoleMode(std_handle: wintypes.HANDLE) -> int:
|
| 96 |
+
"""Retrieves the current input mode of a console's input buffer
|
| 97 |
+
or the current output mode of a console screen buffer.
|
| 98 |
+
|
| 99 |
+
Args:
|
| 100 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 101 |
+
|
| 102 |
+
Raises:
|
| 103 |
+
LegacyWindowsError: If any error occurs while calling the Windows console API.
|
| 104 |
+
|
| 105 |
+
Returns:
|
| 106 |
+
int: Value representing the current console mode as documented at
|
| 107 |
+
https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
console_mode = wintypes.DWORD()
|
| 111 |
+
success = bool(_GetConsoleMode(std_handle, console_mode))
|
| 112 |
+
if not success:
|
| 113 |
+
raise LegacyWindowsError("Unable to get legacy Windows Console Mode")
|
| 114 |
+
return console_mode.value
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
_FillConsoleOutputCharacterW = windll.kernel32.FillConsoleOutputCharacterW
|
| 118 |
+
_FillConsoleOutputCharacterW.argtypes = [
|
| 119 |
+
wintypes.HANDLE,
|
| 120 |
+
ctypes.c_char,
|
| 121 |
+
wintypes.DWORD,
|
| 122 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 123 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 124 |
+
]
|
| 125 |
+
_FillConsoleOutputCharacterW.restype = wintypes.BOOL
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def FillConsoleOutputCharacter(
|
| 129 |
+
std_handle: wintypes.HANDLE,
|
| 130 |
+
char: str,
|
| 131 |
+
length: int,
|
| 132 |
+
start: WindowsCoordinates,
|
| 133 |
+
) -> int:
|
| 134 |
+
"""Writes a character to the console screen buffer a specified number of times, beginning at the specified coordinates.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 138 |
+
char (str): The character to write. Must be a string of length 1.
|
| 139 |
+
length (int): The number of times to write the character.
|
| 140 |
+
start (WindowsCoordinates): The coordinates to start writing at.
|
| 141 |
+
|
| 142 |
+
Returns:
|
| 143 |
+
int: The number of characters written.
|
| 144 |
+
"""
|
| 145 |
+
character = ctypes.c_char(char.encode())
|
| 146 |
+
num_characters = wintypes.DWORD(length)
|
| 147 |
+
num_written = wintypes.DWORD(0)
|
| 148 |
+
_FillConsoleOutputCharacterW(
|
| 149 |
+
std_handle,
|
| 150 |
+
character,
|
| 151 |
+
num_characters,
|
| 152 |
+
start,
|
| 153 |
+
byref(num_written),
|
| 154 |
+
)
|
| 155 |
+
return num_written.value
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
|
| 159 |
+
_FillConsoleOutputAttribute.argtypes = [
|
| 160 |
+
wintypes.HANDLE,
|
| 161 |
+
wintypes.WORD,
|
| 162 |
+
wintypes.DWORD,
|
| 163 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 164 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 165 |
+
]
|
| 166 |
+
_FillConsoleOutputAttribute.restype = wintypes.BOOL
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def FillConsoleOutputAttribute(
|
| 170 |
+
std_handle: wintypes.HANDLE,
|
| 171 |
+
attributes: int,
|
| 172 |
+
length: int,
|
| 173 |
+
start: WindowsCoordinates,
|
| 174 |
+
) -> int:
|
| 175 |
+
"""Sets the character attributes for a specified number of character cells,
|
| 176 |
+
beginning at the specified coordinates in a screen buffer.
|
| 177 |
+
|
| 178 |
+
Args:
|
| 179 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 180 |
+
attributes (int): Integer value representing the foreground and background colours of the cells.
|
| 181 |
+
length (int): The number of cells to set the output attribute of.
|
| 182 |
+
start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set.
|
| 183 |
+
|
| 184 |
+
Returns:
|
| 185 |
+
int: The number of cells whose attributes were actually set.
|
| 186 |
+
"""
|
| 187 |
+
num_cells = wintypes.DWORD(length)
|
| 188 |
+
style_attrs = wintypes.WORD(attributes)
|
| 189 |
+
num_written = wintypes.DWORD(0)
|
| 190 |
+
_FillConsoleOutputAttribute(
|
| 191 |
+
std_handle, style_attrs, num_cells, start, byref(num_written)
|
| 192 |
+
)
|
| 193 |
+
return num_written.value
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
|
| 197 |
+
_SetConsoleTextAttribute.argtypes = [
|
| 198 |
+
wintypes.HANDLE,
|
| 199 |
+
wintypes.WORD,
|
| 200 |
+
]
|
| 201 |
+
_SetConsoleTextAttribute.restype = wintypes.BOOL
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def SetConsoleTextAttribute(
|
| 205 |
+
std_handle: wintypes.HANDLE, attributes: wintypes.WORD
|
| 206 |
+
) -> bool:
|
| 207 |
+
"""Set the colour attributes for all text written after this function is called.
|
| 208 |
+
|
| 209 |
+
Args:
|
| 210 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 211 |
+
attributes (int): Integer value representing the foreground and background colours.
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
Returns:
|
| 215 |
+
bool: True if the attribute was set successfully, otherwise False.
|
| 216 |
+
"""
|
| 217 |
+
return bool(_SetConsoleTextAttribute(std_handle, attributes))
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
|
| 221 |
+
_GetConsoleScreenBufferInfo.argtypes = [
|
| 222 |
+
wintypes.HANDLE,
|
| 223 |
+
ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO),
|
| 224 |
+
]
|
| 225 |
+
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def GetConsoleScreenBufferInfo(
|
| 229 |
+
std_handle: wintypes.HANDLE,
|
| 230 |
+
) -> CONSOLE_SCREEN_BUFFER_INFO:
|
| 231 |
+
"""Retrieves information about the specified console screen buffer.
|
| 232 |
+
|
| 233 |
+
Args:
|
| 234 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 235 |
+
|
| 236 |
+
Returns:
|
| 237 |
+
CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about
|
| 238 |
+
screen size, cursor position, colour attributes, and more."""
|
| 239 |
+
console_screen_buffer_info = CONSOLE_SCREEN_BUFFER_INFO()
|
| 240 |
+
_GetConsoleScreenBufferInfo(std_handle, byref(console_screen_buffer_info))
|
| 241 |
+
return console_screen_buffer_info
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
|
| 245 |
+
_SetConsoleCursorPosition.argtypes = [
|
| 246 |
+
wintypes.HANDLE,
|
| 247 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 248 |
+
]
|
| 249 |
+
_SetConsoleCursorPosition.restype = wintypes.BOOL
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def SetConsoleCursorPosition(
|
| 253 |
+
std_handle: wintypes.HANDLE, coords: WindowsCoordinates
|
| 254 |
+
) -> bool:
|
| 255 |
+
"""Set the position of the cursor in the console screen
|
| 256 |
+
|
| 257 |
+
Args:
|
| 258 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 259 |
+
coords (WindowsCoordinates): The coordinates to move the cursor to.
|
| 260 |
+
|
| 261 |
+
Returns:
|
| 262 |
+
bool: True if the function succeeds, otherwise False.
|
| 263 |
+
"""
|
| 264 |
+
return bool(_SetConsoleCursorPosition(std_handle, coords))
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
_GetConsoleCursorInfo = windll.kernel32.GetConsoleCursorInfo
|
| 268 |
+
_GetConsoleCursorInfo.argtypes = [
|
| 269 |
+
wintypes.HANDLE,
|
| 270 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 271 |
+
]
|
| 272 |
+
_GetConsoleCursorInfo.restype = wintypes.BOOL
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def GetConsoleCursorInfo(
|
| 276 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 277 |
+
) -> bool:
|
| 278 |
+
"""Get the cursor info - used to get cursor visibility and width
|
| 279 |
+
|
| 280 |
+
Args:
|
| 281 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 282 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information
|
| 283 |
+
about the console's cursor.
|
| 284 |
+
|
| 285 |
+
Returns:
|
| 286 |
+
bool: True if the function succeeds, otherwise False.
|
| 287 |
+
"""
|
| 288 |
+
return bool(_GetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
_SetConsoleCursorInfo = windll.kernel32.SetConsoleCursorInfo
|
| 292 |
+
_SetConsoleCursorInfo.argtypes = [
|
| 293 |
+
wintypes.HANDLE,
|
| 294 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 295 |
+
]
|
| 296 |
+
_SetConsoleCursorInfo.restype = wintypes.BOOL
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def SetConsoleCursorInfo(
|
| 300 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 301 |
+
) -> bool:
|
| 302 |
+
"""Set the cursor info - used for adjusting cursor visibility and width
|
| 303 |
+
|
| 304 |
+
Args:
|
| 305 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 306 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info.
|
| 307 |
+
|
| 308 |
+
Returns:
|
| 309 |
+
bool: True if the function succeeds, otherwise False.
|
| 310 |
+
"""
|
| 311 |
+
return bool(_SetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
_SetConsoleTitle = windll.kernel32.SetConsoleTitleW
|
| 315 |
+
_SetConsoleTitle.argtypes = [wintypes.LPCWSTR]
|
| 316 |
+
_SetConsoleTitle.restype = wintypes.BOOL
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
def SetConsoleTitle(title: str) -> bool:
|
| 320 |
+
"""Sets the title of the current console window
|
| 321 |
+
|
| 322 |
+
Args:
|
| 323 |
+
title (str): The new title of the console window.
|
| 324 |
+
|
| 325 |
+
Returns:
|
| 326 |
+
bool: True if the function succeeds, otherwise False.
|
| 327 |
+
"""
|
| 328 |
+
return bool(_SetConsoleTitle(title))
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
class LegacyWindowsTerm:
|
| 332 |
+
"""This class allows interaction with the legacy Windows Console API. It should only be used in the context
|
| 333 |
+
of environments where virtual terminal processing is not available. However, if it is used in a Windows environment,
|
| 334 |
+
the entire API should work.
|
| 335 |
+
|
| 336 |
+
Args:
|
| 337 |
+
file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout.
|
| 338 |
+
"""
|
| 339 |
+
|
| 340 |
+
BRIGHT_BIT = 8
|
| 341 |
+
|
| 342 |
+
# Indices are ANSI color numbers, values are the corresponding Windows Console API color numbers
|
| 343 |
+
ANSI_TO_WINDOWS = [
|
| 344 |
+
0, # black The Windows colours are defined in wincon.h as follows:
|
| 345 |
+
4, # red define FOREGROUND_BLUE 0x0001 -- 0000 0001
|
| 346 |
+
2, # green define FOREGROUND_GREEN 0x0002 -- 0000 0010
|
| 347 |
+
6, # yellow define FOREGROUND_RED 0x0004 -- 0000 0100
|
| 348 |
+
1, # blue define FOREGROUND_INTENSITY 0x0008 -- 0000 1000
|
| 349 |
+
5, # magenta define BACKGROUND_BLUE 0x0010 -- 0001 0000
|
| 350 |
+
3, # cyan define BACKGROUND_GREEN 0x0020 -- 0010 0000
|
| 351 |
+
7, # white define BACKGROUND_RED 0x0040 -- 0100 0000
|
| 352 |
+
8, # bright black (grey) define BACKGROUND_INTENSITY 0x0080 -- 1000 0000
|
| 353 |
+
12, # bright red
|
| 354 |
+
10, # bright green
|
| 355 |
+
14, # bright yellow
|
| 356 |
+
9, # bright blue
|
| 357 |
+
13, # bright magenta
|
| 358 |
+
11, # bright cyan
|
| 359 |
+
15, # bright white
|
| 360 |
+
]
|
| 361 |
+
|
| 362 |
+
def __init__(self, file: "IO[str]") -> None:
|
| 363 |
+
handle = GetStdHandle(STDOUT)
|
| 364 |
+
self._handle = handle
|
| 365 |
+
default_text = GetConsoleScreenBufferInfo(handle).wAttributes
|
| 366 |
+
self._default_text = default_text
|
| 367 |
+
|
| 368 |
+
self._default_fore = default_text & 7
|
| 369 |
+
self._default_back = (default_text >> 4) & 7
|
| 370 |
+
self._default_attrs = self._default_fore | (self._default_back << 4)
|
| 371 |
+
|
| 372 |
+
self._file = file
|
| 373 |
+
self.write = file.write
|
| 374 |
+
self.flush = file.flush
|
| 375 |
+
|
| 376 |
+
@property
|
| 377 |
+
def cursor_position(self) -> WindowsCoordinates:
|
| 378 |
+
"""Returns the current position of the cursor (0-based)
|
| 379 |
+
|
| 380 |
+
Returns:
|
| 381 |
+
WindowsCoordinates: The current cursor position.
|
| 382 |
+
"""
|
| 383 |
+
coord: COORD = GetConsoleScreenBufferInfo(self._handle).dwCursorPosition
|
| 384 |
+
return WindowsCoordinates(row=coord.Y, col=coord.X)
|
| 385 |
+
|
| 386 |
+
@property
|
| 387 |
+
def screen_size(self) -> WindowsCoordinates:
|
| 388 |
+
"""Returns the current size of the console screen buffer, in character columns and rows
|
| 389 |
+
|
| 390 |
+
Returns:
|
| 391 |
+
WindowsCoordinates: The width and height of the screen as WindowsCoordinates.
|
| 392 |
+
"""
|
| 393 |
+
screen_size: COORD = GetConsoleScreenBufferInfo(self._handle).dwSize
|
| 394 |
+
return WindowsCoordinates(row=screen_size.Y, col=screen_size.X)
|
| 395 |
+
|
| 396 |
+
def write_text(self, text: str) -> None:
|
| 397 |
+
"""Write text directly to the terminal without any modification of styles
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
text (str): The text to write to the console
|
| 401 |
+
"""
|
| 402 |
+
self.write(text)
|
| 403 |
+
self.flush()
|
| 404 |
+
|
| 405 |
+
def write_styled(self, text: str, style: Style) -> None:
|
| 406 |
+
"""Write styled text to the terminal.
|
| 407 |
+
|
| 408 |
+
Args:
|
| 409 |
+
text (str): The text to write
|
| 410 |
+
style (Style): The style of the text
|
| 411 |
+
"""
|
| 412 |
+
color = style.color
|
| 413 |
+
bgcolor = style.bgcolor
|
| 414 |
+
if style.reverse:
|
| 415 |
+
color, bgcolor = bgcolor, color
|
| 416 |
+
|
| 417 |
+
if color:
|
| 418 |
+
fore = color.downgrade(ColorSystem.WINDOWS).number
|
| 419 |
+
fore = fore if fore is not None else 7 # Default to ANSI 7: White
|
| 420 |
+
if style.bold:
|
| 421 |
+
fore = fore | self.BRIGHT_BIT
|
| 422 |
+
if style.dim:
|
| 423 |
+
fore = fore & ~self.BRIGHT_BIT
|
| 424 |
+
fore = self.ANSI_TO_WINDOWS[fore]
|
| 425 |
+
else:
|
| 426 |
+
fore = self._default_fore
|
| 427 |
+
|
| 428 |
+
if bgcolor:
|
| 429 |
+
back = bgcolor.downgrade(ColorSystem.WINDOWS).number
|
| 430 |
+
back = back if back is not None else 0 # Default to ANSI 0: Black
|
| 431 |
+
back = self.ANSI_TO_WINDOWS[back]
|
| 432 |
+
else:
|
| 433 |
+
back = self._default_back
|
| 434 |
+
|
| 435 |
+
assert fore is not None
|
| 436 |
+
assert back is not None
|
| 437 |
+
|
| 438 |
+
SetConsoleTextAttribute(
|
| 439 |
+
self._handle, attributes=ctypes.c_ushort(fore | (back << 4))
|
| 440 |
+
)
|
| 441 |
+
self.write_text(text)
|
| 442 |
+
SetConsoleTextAttribute(self._handle, attributes=self._default_text)
|
| 443 |
+
|
| 444 |
+
def move_cursor_to(self, new_position: WindowsCoordinates) -> None:
|
| 445 |
+
"""Set the position of the cursor
|
| 446 |
+
|
| 447 |
+
Args:
|
| 448 |
+
new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor.
|
| 449 |
+
"""
|
| 450 |
+
if new_position.col < 0 or new_position.row < 0:
|
| 451 |
+
return
|
| 452 |
+
SetConsoleCursorPosition(self._handle, coords=new_position)
|
| 453 |
+
|
| 454 |
+
def erase_line(self) -> None:
|
| 455 |
+
"""Erase all content on the line the cursor is currently located at"""
|
| 456 |
+
screen_size = self.screen_size
|
| 457 |
+
cursor_position = self.cursor_position
|
| 458 |
+
cells_to_erase = screen_size.col
|
| 459 |
+
start_coordinates = WindowsCoordinates(row=cursor_position.row, col=0)
|
| 460 |
+
FillConsoleOutputCharacter(
|
| 461 |
+
self._handle, " ", length=cells_to_erase, start=start_coordinates
|
| 462 |
+
)
|
| 463 |
+
FillConsoleOutputAttribute(
|
| 464 |
+
self._handle,
|
| 465 |
+
self._default_attrs,
|
| 466 |
+
length=cells_to_erase,
|
| 467 |
+
start=start_coordinates,
|
| 468 |
+
)
|
| 469 |
+
|
| 470 |
+
def erase_end_of_line(self) -> None:
|
| 471 |
+
"""Erase all content from the cursor position to the end of that line"""
|
| 472 |
+
cursor_position = self.cursor_position
|
| 473 |
+
cells_to_erase = self.screen_size.col - cursor_position.col
|
| 474 |
+
FillConsoleOutputCharacter(
|
| 475 |
+
self._handle, " ", length=cells_to_erase, start=cursor_position
|
| 476 |
+
)
|
| 477 |
+
FillConsoleOutputAttribute(
|
| 478 |
+
self._handle,
|
| 479 |
+
self._default_attrs,
|
| 480 |
+
length=cells_to_erase,
|
| 481 |
+
start=cursor_position,
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
def erase_start_of_line(self) -> None:
|
| 485 |
+
"""Erase all content from the cursor position to the start of that line"""
|
| 486 |
+
row, col = self.cursor_position
|
| 487 |
+
start = WindowsCoordinates(row, 0)
|
| 488 |
+
FillConsoleOutputCharacter(self._handle, " ", length=col, start=start)
|
| 489 |
+
FillConsoleOutputAttribute(
|
| 490 |
+
self._handle, self._default_attrs, length=col, start=start
|
| 491 |
+
)
|
| 492 |
+
|
| 493 |
+
def move_cursor_up(self) -> None:
|
| 494 |
+
"""Move the cursor up a single cell"""
|
| 495 |
+
cursor_position = self.cursor_position
|
| 496 |
+
SetConsoleCursorPosition(
|
| 497 |
+
self._handle,
|
| 498 |
+
coords=WindowsCoordinates(
|
| 499 |
+
row=cursor_position.row - 1, col=cursor_position.col
|
| 500 |
+
),
|
| 501 |
+
)
|
| 502 |
+
|
| 503 |
+
def move_cursor_down(self) -> None:
|
| 504 |
+
"""Move the cursor down a single cell"""
|
| 505 |
+
cursor_position = self.cursor_position
|
| 506 |
+
SetConsoleCursorPosition(
|
| 507 |
+
self._handle,
|
| 508 |
+
coords=WindowsCoordinates(
|
| 509 |
+
row=cursor_position.row + 1,
|
| 510 |
+
col=cursor_position.col,
|
| 511 |
+
),
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
def move_cursor_forward(self) -> None:
|
| 515 |
+
"""Move the cursor forward a single cell. Wrap to the next line if required."""
|
| 516 |
+
row, col = self.cursor_position
|
| 517 |
+
if col == self.screen_size.col - 1:
|
| 518 |
+
row += 1
|
| 519 |
+
col = 0
|
| 520 |
+
else:
|
| 521 |
+
col += 1
|
| 522 |
+
SetConsoleCursorPosition(
|
| 523 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 524 |
+
)
|
| 525 |
+
|
| 526 |
+
def move_cursor_to_column(self, column: int) -> None:
|
| 527 |
+
"""Move cursor to the column specified by the zero-based column index, staying on the same row
|
| 528 |
+
|
| 529 |
+
Args:
|
| 530 |
+
column (int): The zero-based column index to move the cursor to.
|
| 531 |
+
"""
|
| 532 |
+
row, _ = self.cursor_position
|
| 533 |
+
SetConsoleCursorPosition(self._handle, coords=WindowsCoordinates(row, column))
|
| 534 |
+
|
| 535 |
+
def move_cursor_backward(self) -> None:
|
| 536 |
+
"""Move the cursor backward a single cell. Wrap to the previous line if required."""
|
| 537 |
+
row, col = self.cursor_position
|
| 538 |
+
if col == 0:
|
| 539 |
+
row -= 1
|
| 540 |
+
col = self.screen_size.col - 1
|
| 541 |
+
else:
|
| 542 |
+
col -= 1
|
| 543 |
+
SetConsoleCursorPosition(
|
| 544 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
def hide_cursor(self) -> None:
|
| 548 |
+
"""Hide the cursor"""
|
| 549 |
+
current_cursor_size = self._get_cursor_size()
|
| 550 |
+
invisible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=0)
|
| 551 |
+
SetConsoleCursorInfo(self._handle, cursor_info=invisible_cursor)
|
| 552 |
+
|
| 553 |
+
def show_cursor(self) -> None:
|
| 554 |
+
"""Show the cursor"""
|
| 555 |
+
current_cursor_size = self._get_cursor_size()
|
| 556 |
+
visible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=1)
|
| 557 |
+
SetConsoleCursorInfo(self._handle, cursor_info=visible_cursor)
|
| 558 |
+
|
| 559 |
+
def set_title(self, title: str) -> None:
|
| 560 |
+
"""Set the title of the terminal window
|
| 561 |
+
|
| 562 |
+
Args:
|
| 563 |
+
title (str): The new title of the console window
|
| 564 |
+
"""
|
| 565 |
+
assert len(title) < 255, "Console title must be less than 255 characters"
|
| 566 |
+
SetConsoleTitle(title)
|
| 567 |
+
|
| 568 |
+
def _get_cursor_size(self) -> int:
|
| 569 |
+
"""Get the percentage of the character cell that is filled by the cursor"""
|
| 570 |
+
cursor_info = CONSOLE_CURSOR_INFO()
|
| 571 |
+
GetConsoleCursorInfo(self._handle, cursor_info=cursor_info)
|
| 572 |
+
return int(cursor_info.dwSize)
|
| 573 |
+
|
| 574 |
+
|
| 575 |
+
if __name__ == "__main__":
|
| 576 |
+
handle = GetStdHandle()
|
| 577 |
+
|
| 578 |
+
from rich.console import Console
|
| 579 |
+
|
| 580 |
+
console = Console()
|
| 581 |
+
|
| 582 |
+
term = LegacyWindowsTerm(sys.stdout)
|
| 583 |
+
term.set_title("Win32 Console Examples")
|
| 584 |
+
|
| 585 |
+
style = Style(color="black", bgcolor="red")
|
| 586 |
+
|
| 587 |
+
heading = Style.parse("black on green")
|
| 588 |
+
|
| 589 |
+
# Check colour output
|
| 590 |
+
console.rule("Checking colour output")
|
| 591 |
+
console.print("[on red]on red!")
|
| 592 |
+
console.print("[blue]blue!")
|
| 593 |
+
console.print("[yellow]yellow!")
|
| 594 |
+
console.print("[bold yellow]bold yellow!")
|
| 595 |
+
console.print("[bright_yellow]bright_yellow!")
|
| 596 |
+
console.print("[dim bright_yellow]dim bright_yellow!")
|
| 597 |
+
console.print("[italic cyan]italic cyan!")
|
| 598 |
+
console.print("[bold white on blue]bold white on blue!")
|
| 599 |
+
console.print("[reverse bold white on blue]reverse bold white on blue!")
|
| 600 |
+
console.print("[bold black on cyan]bold black on cyan!")
|
| 601 |
+
console.print("[black on green]black on green!")
|
| 602 |
+
console.print("[blue on green]blue on green!")
|
| 603 |
+
console.print("[white on black]white on black!")
|
| 604 |
+
console.print("[black on white]black on white!")
|
| 605 |
+
console.print("[#1BB152 on #DA812D]#1BB152 on #DA812D!")
|
| 606 |
+
|
| 607 |
+
# Check cursor movement
|
| 608 |
+
console.rule("Checking cursor movement")
|
| 609 |
+
console.print()
|
| 610 |
+
term.move_cursor_backward()
|
| 611 |
+
term.move_cursor_backward()
|
| 612 |
+
term.write_text("went back and wrapped to prev line")
|
| 613 |
+
time.sleep(1)
|
| 614 |
+
term.move_cursor_up()
|
| 615 |
+
term.write_text("we go up")
|
| 616 |
+
time.sleep(1)
|
| 617 |
+
term.move_cursor_down()
|
| 618 |
+
term.write_text("and down")
|
| 619 |
+
time.sleep(1)
|
| 620 |
+
term.move_cursor_up()
|
| 621 |
+
term.move_cursor_backward()
|
| 622 |
+
term.move_cursor_backward()
|
| 623 |
+
term.write_text("we went up and back 2")
|
| 624 |
+
time.sleep(1)
|
| 625 |
+
term.move_cursor_down()
|
| 626 |
+
term.move_cursor_backward()
|
| 627 |
+
term.move_cursor_backward()
|
| 628 |
+
term.write_text("we went down and back 2")
|
| 629 |
+
time.sleep(1)
|
| 630 |
+
|
| 631 |
+
# Check erasing of lines
|
| 632 |
+
term.hide_cursor()
|
| 633 |
+
console.print()
|
| 634 |
+
console.rule("Checking line erasing")
|
| 635 |
+
console.print("\n...Deleting to the start of the line...")
|
| 636 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 637 |
+
time.sleep(1)
|
| 638 |
+
term.move_cursor_to_column(16)
|
| 639 |
+
term.write_styled("<", Style.parse("black on red"))
|
| 640 |
+
term.move_cursor_backward()
|
| 641 |
+
time.sleep(1)
|
| 642 |
+
term.erase_start_of_line()
|
| 643 |
+
time.sleep(1)
|
| 644 |
+
|
| 645 |
+
console.print("\n\n...And to the end of the line...")
|
| 646 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 647 |
+
time.sleep(1)
|
| 648 |
+
|
| 649 |
+
term.move_cursor_to_column(16)
|
| 650 |
+
term.write_styled(">", Style.parse("black on red"))
|
| 651 |
+
time.sleep(1)
|
| 652 |
+
term.erase_end_of_line()
|
| 653 |
+
time.sleep(1)
|
| 654 |
+
|
| 655 |
+
console.print("\n\n...Now the whole line will be erased...")
|
| 656 |
+
term.write_styled("I'm going to disappear!", style=Style.parse("black on cyan"))
|
| 657 |
+
time.sleep(1)
|
| 658 |
+
term.erase_line()
|
| 659 |
+
|
| 660 |
+
term.show_cursor()
|
| 661 |
+
print("\n")
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_windows.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from dataclasses import dataclass
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@dataclass
|
| 6 |
+
class WindowsConsoleFeatures:
|
| 7 |
+
"""Windows features available."""
|
| 8 |
+
|
| 9 |
+
vt: bool = False
|
| 10 |
+
"""The console supports VT codes."""
|
| 11 |
+
truecolor: bool = False
|
| 12 |
+
"""The console supports truecolor."""
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
import ctypes
|
| 17 |
+
from ctypes import LibraryLoader
|
| 18 |
+
|
| 19 |
+
if sys.platform == "win32":
|
| 20 |
+
windll = LibraryLoader(ctypes.WinDLL)
|
| 21 |
+
else:
|
| 22 |
+
windll = None
|
| 23 |
+
raise ImportError("Not windows")
|
| 24 |
+
|
| 25 |
+
from rich._win32_console import (
|
| 26 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING,
|
| 27 |
+
GetConsoleMode,
|
| 28 |
+
GetStdHandle,
|
| 29 |
+
LegacyWindowsError,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
except (AttributeError, ImportError, ValueError):
|
| 33 |
+
# Fallback if we can't load the Windows DLL
|
| 34 |
+
def get_windows_console_features() -> WindowsConsoleFeatures:
|
| 35 |
+
features = WindowsConsoleFeatures()
|
| 36 |
+
return features
|
| 37 |
+
|
| 38 |
+
else:
|
| 39 |
+
|
| 40 |
+
def get_windows_console_features() -> WindowsConsoleFeatures:
|
| 41 |
+
"""Get windows console features.
|
| 42 |
+
|
| 43 |
+
Returns:
|
| 44 |
+
WindowsConsoleFeatures: An instance of WindowsConsoleFeatures.
|
| 45 |
+
"""
|
| 46 |
+
handle = GetStdHandle()
|
| 47 |
+
try:
|
| 48 |
+
console_mode = GetConsoleMode(handle)
|
| 49 |
+
success = True
|
| 50 |
+
except LegacyWindowsError:
|
| 51 |
+
console_mode = 0
|
| 52 |
+
success = False
|
| 53 |
+
vt = bool(success and console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
| 54 |
+
truecolor = False
|
| 55 |
+
if vt:
|
| 56 |
+
win_version = sys.getwindowsversion()
|
| 57 |
+
truecolor = win_version.major > 10 or (
|
| 58 |
+
win_version.major == 10 and win_version.build >= 15063
|
| 59 |
+
)
|
| 60 |
+
features = WindowsConsoleFeatures(vt=vt, truecolor=truecolor)
|
| 61 |
+
return features
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
if __name__ == "__main__":
|
| 65 |
+
import platform
|
| 66 |
+
|
| 67 |
+
features = get_windows_console_features()
|
| 68 |
+
from rich import print
|
| 69 |
+
|
| 70 |
+
print(f'platform="{platform.system()}"')
|
| 71 |
+
print(repr(features))
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_windows_renderer.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Iterable, Sequence, Tuple, cast
|
| 2 |
+
|
| 3 |
+
from rich._win32_console import LegacyWindowsTerm, WindowsCoordinates
|
| 4 |
+
from rich.segment import ControlCode, ControlType, Segment
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def legacy_windows_render(buffer: Iterable[Segment], term: LegacyWindowsTerm) -> None:
|
| 8 |
+
"""Makes appropriate Windows Console API calls based on the segments in the buffer.
|
| 9 |
+
|
| 10 |
+
Args:
|
| 11 |
+
buffer (Iterable[Segment]): Iterable of Segments to convert to Win32 API calls.
|
| 12 |
+
term (LegacyWindowsTerm): Used to call the Windows Console API.
|
| 13 |
+
"""
|
| 14 |
+
for text, style, control in buffer:
|
| 15 |
+
if not control:
|
| 16 |
+
if style:
|
| 17 |
+
term.write_styled(text, style)
|
| 18 |
+
else:
|
| 19 |
+
term.write_text(text)
|
| 20 |
+
else:
|
| 21 |
+
control_codes: Sequence[ControlCode] = control
|
| 22 |
+
for control_code in control_codes:
|
| 23 |
+
control_type = control_code[0]
|
| 24 |
+
if control_type == ControlType.CURSOR_MOVE_TO:
|
| 25 |
+
_, x, y = cast(Tuple[ControlType, int, int], control_code)
|
| 26 |
+
term.move_cursor_to(WindowsCoordinates(row=y - 1, col=x - 1))
|
| 27 |
+
elif control_type == ControlType.CARRIAGE_RETURN:
|
| 28 |
+
term.write_text("\r")
|
| 29 |
+
elif control_type == ControlType.HOME:
|
| 30 |
+
term.move_cursor_to(WindowsCoordinates(0, 0))
|
| 31 |
+
elif control_type == ControlType.CURSOR_UP:
|
| 32 |
+
term.move_cursor_up()
|
| 33 |
+
elif control_type == ControlType.CURSOR_DOWN:
|
| 34 |
+
term.move_cursor_down()
|
| 35 |
+
elif control_type == ControlType.CURSOR_FORWARD:
|
| 36 |
+
term.move_cursor_forward()
|
| 37 |
+
elif control_type == ControlType.CURSOR_BACKWARD:
|
| 38 |
+
term.move_cursor_backward()
|
| 39 |
+
elif control_type == ControlType.CURSOR_MOVE_TO_COLUMN:
|
| 40 |
+
_, column = cast(Tuple[ControlType, int], control_code)
|
| 41 |
+
term.move_cursor_to_column(column - 1)
|
| 42 |
+
elif control_type == ControlType.HIDE_CURSOR:
|
| 43 |
+
term.hide_cursor()
|
| 44 |
+
elif control_type == ControlType.SHOW_CURSOR:
|
| 45 |
+
term.show_cursor()
|
| 46 |
+
elif control_type == ControlType.ERASE_IN_LINE:
|
| 47 |
+
_, mode = cast(Tuple[ControlType, int], control_code)
|
| 48 |
+
if mode == 0:
|
| 49 |
+
term.erase_end_of_line()
|
| 50 |
+
elif mode == 1:
|
| 51 |
+
term.erase_start_of_line()
|
| 52 |
+
elif mode == 2:
|
| 53 |
+
term.erase_line()
|
| 54 |
+
elif control_type == ControlType.SET_WINDOW_TITLE:
|
| 55 |
+
_, title = cast(Tuple[ControlType, str], control_code)
|
| 56 |
+
term.set_title(title)
|
micromamba_root/envs/pytorch_env/Lib/site-packages/rich/_wrap.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import re
|
| 4 |
+
from typing import Iterable
|
| 5 |
+
|
| 6 |
+
from ._loop import loop_last
|
| 7 |
+
from .cells import cell_len, chop_cells
|
| 8 |
+
|
| 9 |
+
re_word = re.compile(r"\s*\S+\s*")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def words(text: str) -> Iterable[tuple[int, int, str]]:
|
| 13 |
+
"""Yields each word from the text as a tuple
|
| 14 |
+
containing (start_index, end_index, word). A "word" in this context may
|
| 15 |
+
include the actual word and any whitespace to the right.
|
| 16 |
+
"""
|
| 17 |
+
position = 0
|
| 18 |
+
word_match = re_word.match(text, position)
|
| 19 |
+
while word_match is not None:
|
| 20 |
+
start, end = word_match.span()
|
| 21 |
+
word = word_match.group(0)
|
| 22 |
+
yield start, end, word
|
| 23 |
+
word_match = re_word.match(text, end)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def divide_line(text: str, width: int, fold: bool = True) -> list[int]:
|
| 27 |
+
"""Given a string of text, and a width (measured in cells), return a list
|
| 28 |
+
of cell offsets which the string should be split at in order for it to fit
|
| 29 |
+
within the given width.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
text: The text to examine.
|
| 33 |
+
width: The available cell width.
|
| 34 |
+
fold: If True, words longer than `width` will be folded onto a new line.
|
| 35 |
+
|
| 36 |
+
Returns:
|
| 37 |
+
A list of indices to break the line at.
|
| 38 |
+
"""
|
| 39 |
+
break_positions: list[int] = [] # offsets to insert the breaks at
|
| 40 |
+
append = break_positions.append
|
| 41 |
+
cell_offset = 0
|
| 42 |
+
_cell_len = cell_len
|
| 43 |
+
|
| 44 |
+
for start, _end, word in words(text):
|
| 45 |
+
word_length = _cell_len(word.rstrip())
|
| 46 |
+
remaining_space = width - cell_offset
|
| 47 |
+
word_fits_remaining_space = remaining_space >= word_length
|
| 48 |
+
|
| 49 |
+
if word_fits_remaining_space:
|
| 50 |
+
# Simplest case - the word fits within the remaining width for this line.
|
| 51 |
+
cell_offset += _cell_len(word)
|
| 52 |
+
else:
|
| 53 |
+
# Not enough space remaining for this word on the current line.
|
| 54 |
+
if word_length > width:
|
| 55 |
+
# The word doesn't fit on any line, so we can't simply
|
| 56 |
+
# place it on the next line...
|
| 57 |
+
if fold:
|
| 58 |
+
# Fold the word across multiple lines.
|
| 59 |
+
folded_word = chop_cells(word, width=width)
|
| 60 |
+
for last, line in loop_last(folded_word):
|
| 61 |
+
if start:
|
| 62 |
+
append(start)
|
| 63 |
+
if last:
|
| 64 |
+
cell_offset = _cell_len(line)
|
| 65 |
+
else:
|
| 66 |
+
start += len(line)
|
| 67 |
+
else:
|
| 68 |
+
# Folding isn't allowed, so crop the word.
|
| 69 |
+
if start:
|
| 70 |
+
append(start)
|
| 71 |
+
cell_offset = _cell_len(word)
|
| 72 |
+
elif cell_offset and start:
|
| 73 |
+
# The word doesn't fit within the remaining space on the current
|
| 74 |
+
# line, but it *can* fit on to the next (empty) line.
|
| 75 |
+
append(start)
|
| 76 |
+
cell_offset = _cell_len(word)
|
| 77 |
+
|
| 78 |
+
return break_positions
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__ == "__main__": # pragma: no cover
|
| 82 |
+
from .console import Console
|
| 83 |
+
|
| 84 |
+
console = Console(width=10)
|
| 85 |
+
console.print("12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345")
|
| 86 |
+
print(chop_cells("abcdefghijklmnopqrstuvwxyz", 10))
|
| 87 |
+
|
| 88 |
+
console = Console(width=20)
|
| 89 |
+
console.rule()
|
| 90 |
+
console.print("TextualはPythonの高速アプリケーション開発フレームワークです")
|
| 91 |
+
|
| 92 |
+
console.rule()
|
| 93 |
+
console.print("アプリケーションは1670万色を使用でき")
|