Spaces:
Configuration error

Brettapps commited on
Commit
9c2b193
·
verified ·
1 Parent(s): d153a82

Upload folder using huggingface_hub (part 18)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/INSTALLER +1 -0
  3. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/METADATA +90 -0
  4. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/RECORD +850 -0
  5. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/REQUESTED +0 -0
  6. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/WHEEL +5 -0
  7. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/entry_points.txt +3 -0
  8. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/licenses/AUTHORS.txt +821 -0
  9. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/licenses/LICENSE.txt +20 -0
  10. .venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/top_level.txt +1 -0
  11. .venv/lib/python3.13/site-packages/pip/_vendor/rich/jupyter.py +101 -0
  12. .venv/lib/python3.13/site-packages/pip/_vendor/rich/layout.py +442 -0
  13. .venv/lib/python3.13/site-packages/pip/_vendor/rich/live.py +375 -0
  14. .venv/lib/python3.13/site-packages/pip/_vendor/rich/live_render.py +112 -0
  15. .venv/lib/python3.13/site-packages/pip/_vendor/rich/logging.py +297 -0
  16. .venv/lib/python3.13/site-packages/pip/_vendor/rich/markup.py +251 -0
  17. .venv/lib/python3.13/site-packages/pip/_vendor/rich/measure.py +151 -0
  18. .venv/lib/python3.13/site-packages/pip/_vendor/rich/padding.py +141 -0
  19. .venv/lib/python3.13/site-packages/pip/_vendor/rich/pager.py +34 -0
  20. .venv/lib/python3.13/site-packages/pip/_vendor/rich/palette.py +100 -0
  21. .venv/lib/python3.13/site-packages/pip/_vendor/rich/panel.py +318 -0
  22. .venv/lib/python3.13/site-packages/pip/_vendor/rich/pretty.py +1016 -0
  23. .venv/lib/python3.13/site-packages/pip/_vendor/rich/progress.py +1715 -0
  24. .venv/lib/python3.13/site-packages/pip/_vendor/rich/progress_bar.py +223 -0
  25. .venv/lib/python3.13/site-packages/pip/_vendor/rich/prompt.py +400 -0
  26. .venv/lib/python3.13/site-packages/pip/_vendor/rich/protocol.py +42 -0
  27. .venv/lib/python3.13/site-packages/pip/_vendor/rich/py.typed +0 -0
  28. .venv/lib/python3.13/site-packages/pip/_vendor/rich/region.py +10 -0
  29. .venv/lib/python3.13/site-packages/pip/_vendor/rich/repr.py +149 -0
  30. .venv/lib/python3.13/site-packages/pip/_vendor/rich/rule.py +130 -0
  31. .venv/lib/python3.13/site-packages/pip/_vendor/rich/scope.py +86 -0
  32. .venv/lib/python3.13/site-packages/pip/_vendor/rich/screen.py +54 -0
  33. .venv/lib/python3.13/site-packages/pip/_vendor/rich/segment.py +752 -0
  34. .venv/lib/python3.13/site-packages/pip/_vendor/rich/spinner.py +138 -0
  35. .venv/lib/python3.13/site-packages/pip/_vendor/rich/status.py +131 -0
  36. .venv/lib/python3.13/site-packages/pip/_vendor/rich/style.py +796 -0
  37. .venv/lib/python3.13/site-packages/pip/_vendor/rich/styled.py +42 -0
  38. .venv/lib/python3.13/site-packages/pip/_vendor/rich/syntax.py +966 -0
  39. .venv/lib/python3.13/site-packages/pip/_vendor/rich/table.py +1006 -0
  40. .venv/lib/python3.13/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
  41. .venv/lib/python3.13/site-packages/pip/_vendor/rich/text.py +1361 -0
  42. .venv/lib/python3.13/site-packages/pip/_vendor/rich/theme.py +115 -0
  43. .venv/lib/python3.13/site-packages/pip/_vendor/rich/themes.py +5 -0
  44. .venv/lib/python3.13/site-packages/pip/_vendor/rich/traceback.py +884 -0
  45. .venv/lib/python3.13/site-packages/pip/_vendor/rich/tree.py +257 -0
  46. .venv/lib/python3.13/site-packages/pip/_vendor/tomli/__init__.py +8 -0
  47. .venv/lib/python3.13/site-packages/pip/_vendor/tomli/_parser.py +770 -0
  48. .venv/lib/python3.13/site-packages/pip/_vendor/tomli/_re.py +112 -0
  49. .venv/lib/python3.13/site-packages/pip/_vendor/tomli/_types.py +10 -0
  50. .venv/lib/python3.13/site-packages/pip/_vendor/tomli/py.typed +1 -0
.gitattributes CHANGED
@@ -123,3 +123,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
123
  .venv/lib/python3.13/site-packages/pillow.libs/libwebp-51b0b3f7.so.7.2.0 filter=lfs diff=lfs merge=lfs -text
124
  .venv/lib/python3.13/site-packages/pillow.libs/libxcb-ad31f5a3.so.1.1.0 filter=lfs diff=lfs merge=lfs -text
125
  .venv/lib/python3.13/site-packages/pillow.libs/libzstd-44be1190.so.1.5.7 filter=lfs diff=lfs merge=lfs -text
 
 
123
  .venv/lib/python3.13/site-packages/pillow.libs/libwebp-51b0b3f7.so.7.2.0 filter=lfs diff=lfs merge=lfs -text
124
  .venv/lib/python3.13/site-packages/pillow.libs/libxcb-ad31f5a3.so.1.1.0 filter=lfs diff=lfs merge=lfs -text
125
  .venv/lib/python3.13/site-packages/pillow.libs/libzstd-44be1190.so.1.5.7 filter=lfs diff=lfs merge=lfs -text
126
+ .venv/lib/python3.13/site-packages/pydantic_core/_pydantic_core.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/METADATA ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: pip
3
+ Version: 25.1.1
4
+ Summary: The PyPA recommended tool for installing Python packages.
5
+ Author-email: The pip developers <distutils-sig@python.org>
6
+ License: MIT
7
+ Project-URL: Homepage, https://pip.pypa.io/
8
+ Project-URL: Documentation, https://pip.pypa.io
9
+ Project-URL: Source, https://github.com/pypa/pip
10
+ Project-URL: Changelog, https://pip.pypa.io/en/stable/news/
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Topic :: Software Development :: Build Tools
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/x-rst
27
+ License-File: LICENSE.txt
28
+ License-File: AUTHORS.txt
29
+ Dynamic: license-file
30
+
31
+ pip - The Python Package Installer
32
+ ==================================
33
+
34
+ .. |pypi-version| image:: https://img.shields.io/pypi/v/pip.svg
35
+ :target: https://pypi.org/project/pip/
36
+ :alt: PyPI
37
+
38
+ .. |python-versions| image:: https://img.shields.io/pypi/pyversions/pip
39
+ :target: https://pypi.org/project/pip
40
+ :alt: PyPI - Python Version
41
+
42
+ .. |docs-badge| image:: https://readthedocs.org/projects/pip/badge/?version=latest
43
+ :target: https://pip.pypa.io/en/latest
44
+ :alt: Documentation
45
+
46
+ |pypi-version| |python-versions| |docs-badge|
47
+
48
+ pip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.
49
+
50
+ Please take a look at our documentation for how to install and use pip:
51
+
52
+ * `Installation`_
53
+ * `Usage`_
54
+
55
+ We release updates regularly, with a new version every 3 months. Find more details in our documentation:
56
+
57
+ * `Release notes`_
58
+ * `Release process`_
59
+
60
+ If you find bugs, need help, or want to talk to the developers, please use our mailing lists or chat rooms:
61
+
62
+ * `Issue tracking`_
63
+ * `Discourse channel`_
64
+ * `User IRC`_
65
+
66
+ If you want to get involved head over to GitHub to get the source code, look at our development documentation and feel free to jump on the developer mailing lists and chat rooms:
67
+
68
+ * `GitHub page`_
69
+ * `Development documentation`_
70
+ * `Development IRC`_
71
+
72
+ Code of Conduct
73
+ ---------------
74
+
75
+ Everyone interacting in the pip project's codebases, issue trackers, chat
76
+ rooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.
77
+
78
+ .. _package installer: https://packaging.python.org/guides/tool-recommendations/
79
+ .. _Python Package Index: https://pypi.org
80
+ .. _Installation: https://pip.pypa.io/en/stable/installation/
81
+ .. _Usage: https://pip.pypa.io/en/stable/
82
+ .. _Release notes: https://pip.pypa.io/en/stable/news.html
83
+ .. _Release process: https://pip.pypa.io/en/latest/development/release-process/
84
+ .. _GitHub page: https://github.com/pypa/pip
85
+ .. _Development documentation: https://pip.pypa.io/en/latest/development
86
+ .. _Issue tracking: https://github.com/pypa/pip/issues
87
+ .. _Discourse channel: https://discuss.python.org/c/packaging
88
+ .. _User IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa
89
+ .. _Development IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa-dev
90
+ .. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/RECORD ADDED
@@ -0,0 +1,850 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ../../../bin/pip,sha256=D7IDpCcODzzTguIh60q9CVODdZLl9dETo1fKESn8tG4,273
2
+ ../../../bin/pip3,sha256=D7IDpCcODzzTguIh60q9CVODdZLl9dETo1fKESn8tG4,273
3
+ ../../../bin/pip3.13,sha256=D7IDpCcODzzTguIh60q9CVODdZLl9dETo1fKESn8tG4,273
4
+ pip-25.1.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
5
+ pip-25.1.1.dist-info/METADATA,sha256=QFxj1tLpk8hGWrgQLRhJYUpwo_1FqBr43OT0srIZcmU,3649
6
+ pip-25.1.1.dist-info/RECORD,,
7
+ pip-25.1.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pip-25.1.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
+ pip-25.1.1.dist-info/entry_points.txt,sha256=eeIjuzfnfR2PrhbjnbzFU6MnSS70kZLxwaHHq6M-bD0,87
10
+ pip-25.1.1.dist-info/licenses/AUTHORS.txt,sha256=YzDFTYpeYnwpmODDFTgyKZNKWcfdO10L5Ex_U6kJLRc,11223
11
+ pip-25.1.1.dist-info/licenses/LICENSE.txt,sha256=Y0MApmnUmurmWxLGxIySTFGkzfPR_whtw0VtyLyqIQQ,1093
12
+ pip-25.1.1.dist-info/top_level.txt,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
13
+ pip/__init__.py,sha256=zQQ7Na8YWi0IN86IUKEzDAJtyVpXdJXYDkQ536caUiQ,357
14
+ pip/__main__.py,sha256=WzbhHXTbSE6gBY19mNN9m4s5o_365LOvTYSgqgbdBhE,854
15
+ pip/__pip-runner__.py,sha256=JOoEZTwrtv7jRaXBkgSQKAE04yNyfFmGHxqpHiGHvL0,1450
16
+ pip/__pycache__/__init__.cpython-313.pyc,,
17
+ pip/__pycache__/__main__.cpython-313.pyc,,
18
+ pip/__pycache__/__pip-runner__.cpython-313.pyc,,
19
+ pip/_internal/__init__.py,sha256=MfcoOluDZ8QMCFYal04IqOJ9q6m2V7a0aOsnI-WOxUo,513
20
+ pip/_internal/__pycache__/__init__.cpython-313.pyc,,
21
+ pip/_internal/__pycache__/build_env.cpython-313.pyc,,
22
+ pip/_internal/__pycache__/cache.cpython-313.pyc,,
23
+ pip/_internal/__pycache__/configuration.cpython-313.pyc,,
24
+ pip/_internal/__pycache__/exceptions.cpython-313.pyc,,
25
+ pip/_internal/__pycache__/main.cpython-313.pyc,,
26
+ pip/_internal/__pycache__/pyproject.cpython-313.pyc,,
27
+ pip/_internal/__pycache__/self_outdated_check.cpython-313.pyc,,
28
+ pip/_internal/__pycache__/wheel_builder.cpython-313.pyc,,
29
+ pip/_internal/build_env.py,sha256=60_espLI9X3C2db3Ww2gIcyjNk2cAPNcc5gsVO4DOqg,10924
30
+ pip/_internal/cache.py,sha256=SjhJK1C6NbonrU4AyYXKTOH0CGOk5cJrYt60mRANnPM,10368
31
+ pip/_internal/cli/__init__.py,sha256=Iqg_tKA771XuMO1P4t_sDHnSKPzkUb9D0DqunAmw_ko,131
32
+ pip/_internal/cli/__pycache__/__init__.cpython-313.pyc,,
33
+ pip/_internal/cli/__pycache__/autocompletion.cpython-313.pyc,,
34
+ pip/_internal/cli/__pycache__/base_command.cpython-313.pyc,,
35
+ pip/_internal/cli/__pycache__/cmdoptions.cpython-313.pyc,,
36
+ pip/_internal/cli/__pycache__/command_context.cpython-313.pyc,,
37
+ pip/_internal/cli/__pycache__/index_command.cpython-313.pyc,,
38
+ pip/_internal/cli/__pycache__/main.cpython-313.pyc,,
39
+ pip/_internal/cli/__pycache__/main_parser.cpython-313.pyc,,
40
+ pip/_internal/cli/__pycache__/parser.cpython-313.pyc,,
41
+ pip/_internal/cli/__pycache__/progress_bars.cpython-313.pyc,,
42
+ pip/_internal/cli/__pycache__/req_command.cpython-313.pyc,,
43
+ pip/_internal/cli/__pycache__/spinners.cpython-313.pyc,,
44
+ pip/_internal/cli/__pycache__/status_codes.cpython-313.pyc,,
45
+ pip/_internal/cli/autocompletion.py,sha256=fs0Wy16Ga5tX1IZKvww5BDi7i5zyzfCPvu7cgXlgXys,6864
46
+ pip/_internal/cli/base_command.py,sha256=0A8YuJVJh2YyXU8pdW0eidLg1eklCW5cU01mpI-FAxA,8351
47
+ pip/_internal/cli/cmdoptions.py,sha256=VHJ-32dTF1X3iQz1jaVPt3JxksyZcCfGZ5qrStZmvTM,31908
48
+ pip/_internal/cli/command_context.py,sha256=RHgIPwtObh5KhMrd3YZTkl8zbVG-6Okml7YbFX4Ehg0,774
49
+ pip/_internal/cli/index_command.py,sha256=kplkusUgCZy75jNCo-etaDmSG8UvqcR2W50ALDdm6dk,5720
50
+ pip/_internal/cli/main.py,sha256=1bXC7uL3tdb_EZlGVKs6_TgzC9tlKU7zhAZsbZA-IzY,2816
51
+ pip/_internal/cli/main_parser.py,sha256=chZqNmCuO_JYt8ynBCumh4crURaRoXBZ0RxoSYQIwCw,4337
52
+ pip/_internal/cli/parser.py,sha256=VCMtduzECUV87KaHNu-xJ-wLNL82yT3x16V4XBxOAqI,10825
53
+ pip/_internal/cli/progress_bars.py,sha256=r9BD4T2-egcInB1Uh9Jjw3EP9F3INy5kZhGwSePm9jo,4435
54
+ pip/_internal/cli/req_command.py,sha256=1yfssBvnUKNer8D7iT3OHqdJJNdCqRhwDqUFWgieppk,12934
55
+ pip/_internal/cli/spinners.py,sha256=hIJ83GerdFgFCdobIA23Jggetegl_uC4Sp586nzFbPE,5118
56
+ pip/_internal/cli/status_codes.py,sha256=sEFHUaUJbqv8iArL3HAtcztWZmGOFX01hTesSytDEh0,116
57
+ pip/_internal/commands/__init__.py,sha256=3405KyFv4l0ruxeF69oosFanxNQcC_fHBGv7Rpt0PXg,4009
58
+ pip/_internal/commands/__pycache__/__init__.cpython-313.pyc,,
59
+ pip/_internal/commands/__pycache__/cache.cpython-313.pyc,,
60
+ pip/_internal/commands/__pycache__/check.cpython-313.pyc,,
61
+ pip/_internal/commands/__pycache__/completion.cpython-313.pyc,,
62
+ pip/_internal/commands/__pycache__/configuration.cpython-313.pyc,,
63
+ pip/_internal/commands/__pycache__/debug.cpython-313.pyc,,
64
+ pip/_internal/commands/__pycache__/download.cpython-313.pyc,,
65
+ pip/_internal/commands/__pycache__/freeze.cpython-313.pyc,,
66
+ pip/_internal/commands/__pycache__/hash.cpython-313.pyc,,
67
+ pip/_internal/commands/__pycache__/help.cpython-313.pyc,,
68
+ pip/_internal/commands/__pycache__/index.cpython-313.pyc,,
69
+ pip/_internal/commands/__pycache__/inspect.cpython-313.pyc,,
70
+ pip/_internal/commands/__pycache__/install.cpython-313.pyc,,
71
+ pip/_internal/commands/__pycache__/list.cpython-313.pyc,,
72
+ pip/_internal/commands/__pycache__/lock.cpython-313.pyc,,
73
+ pip/_internal/commands/__pycache__/search.cpython-313.pyc,,
74
+ pip/_internal/commands/__pycache__/show.cpython-313.pyc,,
75
+ pip/_internal/commands/__pycache__/uninstall.cpython-313.pyc,,
76
+ pip/_internal/commands/__pycache__/wheel.cpython-313.pyc,,
77
+ pip/_internal/commands/cache.py,sha256=IOezTicHjGE5sWdBx2nwPVgbjuJHM3s-BZEkpZLemuY,8107
78
+ pip/_internal/commands/check.py,sha256=Hr_4eiMd9cgVDgEvjtIdw915NmL7ROIWW8enkr8slPQ,2268
79
+ pip/_internal/commands/completion.py,sha256=W9QFQTPLjy2tPACJ_y3g9EgB1pbsh7pvCUX8ocuIdPg,4554
80
+ pip/_internal/commands/configuration.py,sha256=n98enwp6y0b5G6fiRQjaZo43FlJKYve_daMhN-4BRNc,9766
81
+ pip/_internal/commands/debug.py,sha256=DNDRgE9YsKrbYzU0s3VKi8rHtKF4X13CJ_br_8PUXO0,6797
82
+ pip/_internal/commands/download.py,sha256=0qB0nys6ZEPsog451lDsjL5Bx7Z97t-B80oFZKhpzKM,5273
83
+ pip/_internal/commands/freeze.py,sha256=i9LzK6tJDgtfShSrS38Gn6aCfFlj7K4ZZTMbBwZTPmA,3215
84
+ pip/_internal/commands/hash.py,sha256=EVVOuvGtoPEdFi8SNnmdqlCQrhCxV-kJsdwtdcCnXGQ,1703
85
+ pip/_internal/commands/help.py,sha256=gcc6QDkcgHMOuAn5UxaZwAStsRBrnGSn_yxjS57JIoM,1132
86
+ pip/_internal/commands/index.py,sha256=8UucFVwx6FmM8cNbaPY8iI5kZdV3f6jhqDa-S8aGgpg,5068
87
+ pip/_internal/commands/inspect.py,sha256=PGrY9TRTRCM3y5Ml8Bdk8DEOXquWRfscr4DRo1LOTPc,3189
88
+ pip/_internal/commands/install.py,sha256=SRsiLpead7A8bLdxMqxTAJM3sUFHtgN9zgBT98UQz5E,29757
89
+ pip/_internal/commands/list.py,sha256=3ciKAsDVrmmuUWQKDttrKeGv9N5Dk8lUli8G5Q6YzAE,13371
90
+ pip/_internal/commands/lock.py,sha256=bUYrryKa769UXM61imojoeVVgc_1ZHK-9a0hIJmmlCg,5941
91
+ pip/_internal/commands/search.py,sha256=IrfvxcRCSoZY9A5XAlCF1wtl_y2HPcXslQdHcjzwMNk,5784
92
+ pip/_internal/commands/show.py,sha256=Yh5rGYhR2Io5TkL0fFCMWE1VqqM4xhPHjhbdS3QgEac,8028
93
+ pip/_internal/commands/uninstall.py,sha256=7pOR7enK76gimyxQbzxcG1OsyLXL3DvX939xmM8Fvtg,3892
94
+ pip/_internal/commands/wheel.py,sha256=NEfaVF4f41VBNSn93RL8gkfCEDmdGhbP9xu_dE6cdUk,6346
95
+ pip/_internal/configuration.py,sha256=-KOok6jh3hFzXMPQFPJ1_EFjBpAsge-RSreQuLHLmzo,14005
96
+ pip/_internal/distributions/__init__.py,sha256=Hq6kt6gXBgjNit5hTTWLAzeCNOKoB-N0pGYSqehrli8,858
97
+ pip/_internal/distributions/__pycache__/__init__.cpython-313.pyc,,
98
+ pip/_internal/distributions/__pycache__/base.cpython-313.pyc,,
99
+ pip/_internal/distributions/__pycache__/installed.cpython-313.pyc,,
100
+ pip/_internal/distributions/__pycache__/sdist.cpython-313.pyc,,
101
+ pip/_internal/distributions/__pycache__/wheel.cpython-313.pyc,,
102
+ pip/_internal/distributions/base.py,sha256=QeB9qvKXDIjLdPBDE5fMgpfGqMMCr-govnuoQnGuiF8,1783
103
+ pip/_internal/distributions/installed.py,sha256=QinHFbWAQ8oE0pbD8MFZWkwlnfU1QYTccA1vnhrlYOU,842
104
+ pip/_internal/distributions/sdist.py,sha256=PlcP4a6-R6c98XnOM-b6Lkb3rsvh9iG4ok8shaanrzs,6751
105
+ pip/_internal/distributions/wheel.py,sha256=THBYfnv7VVt8mYhMYUtH13S1E7FDwtDyDfmUcl8ai0E,1317
106
+ pip/_internal/exceptions.py,sha256=wpE11H0e4L9G6AH70sRG149z82X7wX530HK-9eA_DIQ,28464
107
+ pip/_internal/index/__init__.py,sha256=tzwMH_fhQeubwMqHdSivasg1cRgTSbNg2CiMVnzMmyU,29
108
+ pip/_internal/index/__pycache__/__init__.cpython-313.pyc,,
109
+ pip/_internal/index/__pycache__/collector.cpython-313.pyc,,
110
+ pip/_internal/index/__pycache__/package_finder.cpython-313.pyc,,
111
+ pip/_internal/index/__pycache__/sources.cpython-313.pyc,,
112
+ pip/_internal/index/collector.py,sha256=RdPO0JLAlmyBWPAWYHPyRoGjz3GNAeTngCNkbGey_mE,16265
113
+ pip/_internal/index/package_finder.py,sha256=RohRzzLExoXl7QDdTiqyxIaQEcHUn6UNOr9KzC1vjL0,38446
114
+ pip/_internal/index/sources.py,sha256=lPBLK5Xiy8Q6IQMio26Wl7ocfZOKkgGklIBNyUJ23fI,8632
115
+ pip/_internal/locations/__init__.py,sha256=vvTMNxghT0aEXrSdqpNtuRDGx08bzJxfDAUUfQ0Vb0A,14309
116
+ pip/_internal/locations/__pycache__/__init__.cpython-313.pyc,,
117
+ pip/_internal/locations/__pycache__/_distutils.cpython-313.pyc,,
118
+ pip/_internal/locations/__pycache__/_sysconfig.cpython-313.pyc,,
119
+ pip/_internal/locations/__pycache__/base.cpython-313.pyc,,
120
+ pip/_internal/locations/_distutils.py,sha256=x6nyVLj7X11Y4khIdf-mFlxMl2FWadtVEgeb8upc_WI,6013
121
+ pip/_internal/locations/_sysconfig.py,sha256=IGzds60qsFneRogC-oeBaY7bEh3lPt_v47kMJChQXsU,7724
122
+ pip/_internal/locations/base.py,sha256=RQiPi1d4FVM2Bxk04dQhXZ2PqkeljEL2fZZ9SYqIQ78,2556
123
+ pip/_internal/main.py,sha256=r-UnUe8HLo5XFJz8inTcOOTiu_sxNhgHb6VwlGUllOI,340
124
+ pip/_internal/metadata/__init__.py,sha256=nGWuZvjQlIHudlMz_-bsUs2LDA2ZKNPGevZoEGcd64Y,5723
125
+ pip/_internal/metadata/__pycache__/__init__.cpython-313.pyc,,
126
+ pip/_internal/metadata/__pycache__/_json.cpython-313.pyc,,
127
+ pip/_internal/metadata/__pycache__/base.cpython-313.pyc,,
128
+ pip/_internal/metadata/__pycache__/pkg_resources.cpython-313.pyc,,
129
+ pip/_internal/metadata/_json.py,sha256=ezrIYazHCINM2QUk1eA9wEAMj3aeGWeDVgGalgUzKpc,2707
130
+ pip/_internal/metadata/base.py,sha256=jCbzdIc8MgWnPR4rfrvSQhSVzSoOyKOXhj3xe8BoG8c,25467
131
+ pip/_internal/metadata/importlib/__init__.py,sha256=jUUidoxnHcfITHHaAWG1G2i5fdBYklv_uJcjo2x7VYE,135
132
+ pip/_internal/metadata/importlib/__pycache__/__init__.cpython-313.pyc,,
133
+ pip/_internal/metadata/importlib/__pycache__/_compat.cpython-313.pyc,,
134
+ pip/_internal/metadata/importlib/__pycache__/_dists.cpython-313.pyc,,
135
+ pip/_internal/metadata/importlib/__pycache__/_envs.cpython-313.pyc,,
136
+ pip/_internal/metadata/importlib/_compat.py,sha256=c6av8sP8BBjAZuFSJow1iWfygUXNM3xRTCn5nqw6B9M,2796
137
+ pip/_internal/metadata/importlib/_dists.py,sha256=ftmYiyfUGUIjnVwt6W-Ijsimy5c28KgmXly5Q5IQ2P4,8279
138
+ pip/_internal/metadata/importlib/_envs.py,sha256=X63CkdAPJCYPhefYSLiQzPf9ijMXm5nL_A_Z68yp2-w,5297
139
+ pip/_internal/metadata/pkg_resources.py,sha256=U07ETAINSGeSRBfWUG93E4tZZbaW_f7PGzEqZN0hulc,10542
140
+ pip/_internal/models/__init__.py,sha256=AjmCEBxX_MH9f_jVjIGNCFJKYCYeSEe18yyvNx4uRKQ,62
141
+ pip/_internal/models/__pycache__/__init__.cpython-313.pyc,,
142
+ pip/_internal/models/__pycache__/candidate.cpython-313.pyc,,
143
+ pip/_internal/models/__pycache__/direct_url.cpython-313.pyc,,
144
+ pip/_internal/models/__pycache__/format_control.cpython-313.pyc,,
145
+ pip/_internal/models/__pycache__/index.cpython-313.pyc,,
146
+ pip/_internal/models/__pycache__/installation_report.cpython-313.pyc,,
147
+ pip/_internal/models/__pycache__/link.cpython-313.pyc,,
148
+ pip/_internal/models/__pycache__/pylock.cpython-313.pyc,,
149
+ pip/_internal/models/__pycache__/scheme.cpython-313.pyc,,
150
+ pip/_internal/models/__pycache__/search_scope.cpython-313.pyc,,
151
+ pip/_internal/models/__pycache__/selection_prefs.cpython-313.pyc,,
152
+ pip/_internal/models/__pycache__/target_python.cpython-313.pyc,,
153
+ pip/_internal/models/__pycache__/wheel.cpython-313.pyc,,
154
+ pip/_internal/models/candidate.py,sha256=zzgFRuw_kWPjKpGw7LC0ZUMD2CQ2EberUIYs8izjdCA,753
155
+ pip/_internal/models/direct_url.py,sha256=lJ1fIVTgk5UG5SzTNR0FpgSGAQjChlH-3otgiEJAhIs,6576
156
+ pip/_internal/models/format_control.py,sha256=wtsQqSK9HaUiNxQEuB-C62eVimw6G4_VQFxV9-_KDBE,2486
157
+ pip/_internal/models/index.py,sha256=tYnL8oxGi4aSNWur0mG8DAP7rC6yuha_MwJO8xw0crI,1030
158
+ pip/_internal/models/installation_report.py,sha256=zRVZoaz-2vsrezj_H3hLOhMZCK9c7TbzWgC-jOalD00,2818
159
+ pip/_internal/models/link.py,sha256=wIAgxhiu05ycLhbtAibknXX5L6X9ju_PPLVnMcvh9B4,21511
160
+ pip/_internal/models/pylock.py,sha256=n3-I26bf2v-Kn6qcx4ATB_Zel2SLhaUxZBmsMeGgYAo,6196
161
+ pip/_internal/models/scheme.py,sha256=PakmHJM3e8OOWSZFtfz1Az7f1meONJnkGuQxFlt3wBE,575
162
+ pip/_internal/models/search_scope.py,sha256=67NEnsYY84784S-MM7ekQuo9KXLH-7MzFntXjapvAo0,4531
163
+ pip/_internal/models/selection_prefs.py,sha256=qaFfDs3ciqoXPg6xx45N1jPLqccLJw4N0s4P0PyHTQ8,2015
164
+ pip/_internal/models/target_python.py,sha256=2XaH2rZ5ZF-K5wcJbEMGEl7SqrTToDDNkrtQ2v_v_-Q,4271
165
+ pip/_internal/models/wheel.py,sha256=10NUTXIRjf2P8oe1Wzolv8oUv7-YurrOduVFUIaDhdM,5506
166
+ pip/_internal/network/__init__.py,sha256=FMy06P__y6jMjUc8z3ZcQdKF-pmZ2zM14_vBeHPGhUI,49
167
+ pip/_internal/network/__pycache__/__init__.cpython-313.pyc,,
168
+ pip/_internal/network/__pycache__/auth.cpython-313.pyc,,
169
+ pip/_internal/network/__pycache__/cache.cpython-313.pyc,,
170
+ pip/_internal/network/__pycache__/download.cpython-313.pyc,,
171
+ pip/_internal/network/__pycache__/lazy_wheel.cpython-313.pyc,,
172
+ pip/_internal/network/__pycache__/session.cpython-313.pyc,,
173
+ pip/_internal/network/__pycache__/utils.cpython-313.pyc,,
174
+ pip/_internal/network/__pycache__/xmlrpc.cpython-313.pyc,,
175
+ pip/_internal/network/auth.py,sha256=D4gASjUrqoDFlSt6gQ767KAAjv6PUyJU0puDlhXNVRE,20809
176
+ pip/_internal/network/cache.py,sha256=JGYT-BUaSMdEBwII_K1UE6qyBItz7hzGkyLl_JRzkBY,4613
177
+ pip/_internal/network/download.py,sha256=6IdZyoERWIsXXFUFL_h_e_xi8Z0G0UlpkodPy8qKv2U,11078
178
+ pip/_internal/network/lazy_wheel.py,sha256=PBdoMoNQQIA84Fhgne38jWF52W4x_KtsHjxgv4dkRKA,7622
179
+ pip/_internal/network/session.py,sha256=msM4es16LmmNEYNkrYyg8fTc7gAHbKFltawfKP27LOI,18771
180
+ pip/_internal/network/utils.py,sha256=Inaxel-NxBu4PQWkjyErdnfewsFCcgHph7dzR1-FboY,4088
181
+ pip/_internal/network/xmlrpc.py,sha256=jW9oDSWamMld3iZOO9RbonVC8ZStkHyppCszoevkuJg,1837
182
+ pip/_internal/operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
183
+ pip/_internal/operations/__pycache__/__init__.cpython-313.pyc,,
184
+ pip/_internal/operations/__pycache__/check.cpython-313.pyc,,
185
+ pip/_internal/operations/__pycache__/freeze.cpython-313.pyc,,
186
+ pip/_internal/operations/__pycache__/prepare.cpython-313.pyc,,
187
+ pip/_internal/operations/build/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
188
+ pip/_internal/operations/build/__pycache__/__init__.cpython-313.pyc,,
189
+ pip/_internal/operations/build/__pycache__/build_tracker.cpython-313.pyc,,
190
+ pip/_internal/operations/build/__pycache__/metadata.cpython-313.pyc,,
191
+ pip/_internal/operations/build/__pycache__/metadata_editable.cpython-313.pyc,,
192
+ pip/_internal/operations/build/__pycache__/metadata_legacy.cpython-313.pyc,,
193
+ pip/_internal/operations/build/__pycache__/wheel.cpython-313.pyc,,
194
+ pip/_internal/operations/build/__pycache__/wheel_editable.cpython-313.pyc,,
195
+ pip/_internal/operations/build/__pycache__/wheel_legacy.cpython-313.pyc,,
196
+ pip/_internal/operations/build/build_tracker.py,sha256=-ARW_TcjHCOX7D2NUOGntB4Fgc6b4aolsXkAK6BWL7w,4774
197
+ pip/_internal/operations/build/metadata.py,sha256=INHaeiRfOiLYCXApfDNRo9Cw2xI4VwTc0KItvfdfOjk,1421
198
+ pip/_internal/operations/build/metadata_editable.py,sha256=oWudMsnjy4loO_Jy7g4N9nxsnaEX_iDlVRgCy7pu1rs,1509
199
+ pip/_internal/operations/build/metadata_legacy.py,sha256=wv8cFA0wTqF62Jlm9QwloYZsofOyQ7sWBBmvCcVvn1k,2189
200
+ pip/_internal/operations/build/wheel.py,sha256=sT12FBLAxDC6wyrDorh8kvcZ1jG5qInCRWzzP-UkJiQ,1075
201
+ pip/_internal/operations/build/wheel_editable.py,sha256=yOtoH6zpAkoKYEUtr8FhzrYnkNHQaQBjWQ2HYae1MQg,1417
202
+ pip/_internal/operations/build/wheel_legacy.py,sha256=KXpyGYoCQYcudXNZvohLXgWHaCk4Gf3z0dbS9ol4uu0,3620
203
+ pip/_internal/operations/check.py,sha256=4cnD_2eglsDe5s2CoYkxDt4HcRitTywzLMfTZ-tGQ4U,5911
204
+ pip/_internal/operations/freeze.py,sha256=1_M79jAQKnCxWr-KCCmHuVXOVFGaUJHmoWLfFzgh7K4,9843
205
+ pip/_internal/operations/install/__init__.py,sha256=ak-UETcQPKlFZaWoYKWu5QVXbpFBvg0sXc3i0O4vSYY,50
206
+ pip/_internal/operations/install/__pycache__/__init__.cpython-313.pyc,,
207
+ pip/_internal/operations/install/__pycache__/editable_legacy.cpython-313.pyc,,
208
+ pip/_internal/operations/install/__pycache__/wheel.cpython-313.pyc,,
209
+ pip/_internal/operations/install/editable_legacy.py,sha256=TI6wT8sLqDTprWZLYEOBOe7a6-1B9uwKb7kTBxLIaWY,1282
210
+ pip/_internal/operations/install/wheel.py,sha256=4NYSQ9ypl69iiduh5gUPCK3WNYqouTHZ0rMXoVgkiZw,27553
211
+ pip/_internal/operations/prepare.py,sha256=-i9dYwwJJjN7h6sZTabcz84tizgn7EAsY0sHnLAfs3Q,28363
212
+ pip/_internal/pyproject.py,sha256=GLJ6rWRS5_2noKdajohoLyDty57Z7QXhcUAYghmTnWc,7286
213
+ pip/_internal/req/__init__.py,sha256=dX2QGlfDwEqE5pLjOeM-f2qEgXFn6f2Vdi_zIHAYy1k,3096
214
+ pip/_internal/req/__pycache__/__init__.cpython-313.pyc,,
215
+ pip/_internal/req/__pycache__/constructors.cpython-313.pyc,,
216
+ pip/_internal/req/__pycache__/req_dependency_group.cpython-313.pyc,,
217
+ pip/_internal/req/__pycache__/req_file.cpython-313.pyc,,
218
+ pip/_internal/req/__pycache__/req_install.cpython-313.pyc,,
219
+ pip/_internal/req/__pycache__/req_set.cpython-313.pyc,,
220
+ pip/_internal/req/__pycache__/req_uninstall.cpython-313.pyc,,
221
+ pip/_internal/req/constructors.py,sha256=v1qzCN1mIldwx-nCrPc8JO4lxkm3Fv8M5RWvt8LISjc,18430
222
+ pip/_internal/req/req_dependency_group.py,sha256=5PGuZidqwDeTHZkP4tnNrlPrasfvJBONd1B5S0146zs,2677
223
+ pip/_internal/req/req_file.py,sha256=eys82McgaICOGic2UZRHjD720piKJPwmeSYdXlWwl6w,20234
224
+ pip/_internal/req/req_install.py,sha256=gMoFak9zrhjHlHaOQxPFheHKtIobppFgq1WrKel_nTE,35788
225
+ pip/_internal/req/req_set.py,sha256=j3esG0s6SzoVReX9rWn4rpYNtyET_fwxbwJPRimvRxo,2858
226
+ pip/_internal/req/req_uninstall.py,sha256=PQ6SyocDycUYsLAsTpjkbdwO_qjdo-y8BvQfZ5Avdrw,24075
227
+ pip/_internal/resolution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
228
+ pip/_internal/resolution/__pycache__/__init__.cpython-313.pyc,,
229
+ pip/_internal/resolution/__pycache__/base.cpython-313.pyc,,
230
+ pip/_internal/resolution/base.py,sha256=qlmh325SBVfvG6Me9gc5Nsh5sdwHBwzHBq6aEXtKsLA,583
231
+ pip/_internal/resolution/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
232
+ pip/_internal/resolution/legacy/__pycache__/__init__.cpython-313.pyc,,
233
+ pip/_internal/resolution/legacy/__pycache__/resolver.cpython-313.pyc,,
234
+ pip/_internal/resolution/legacy/resolver.py,sha256=3HZiJBRd1FTN6jQpI4qRO8-TbLYeIbUTS6PFvXnXs2w,24068
235
+ pip/_internal/resolution/resolvelib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
236
+ pip/_internal/resolution/resolvelib/__pycache__/__init__.cpython-313.pyc,,
237
+ pip/_internal/resolution/resolvelib/__pycache__/base.cpython-313.pyc,,
238
+ pip/_internal/resolution/resolvelib/__pycache__/candidates.cpython-313.pyc,,
239
+ pip/_internal/resolution/resolvelib/__pycache__/factory.cpython-313.pyc,,
240
+ pip/_internal/resolution/resolvelib/__pycache__/found_candidates.cpython-313.pyc,,
241
+ pip/_internal/resolution/resolvelib/__pycache__/provider.cpython-313.pyc,,
242
+ pip/_internal/resolution/resolvelib/__pycache__/reporter.cpython-313.pyc,,
243
+ pip/_internal/resolution/resolvelib/__pycache__/requirements.cpython-313.pyc,,
244
+ pip/_internal/resolution/resolvelib/__pycache__/resolver.cpython-313.pyc,,
245
+ pip/_internal/resolution/resolvelib/base.py,sha256=DCf669FsqyQY5uqXeePDHQY1e4QO-pBzWH8O0s9-K94,5023
246
+ pip/_internal/resolution/resolvelib/candidates.py,sha256=U3Qp83jhM_RiJviyrlPCijbps6wYO6VsTDaTnCf_B3o,20241
247
+ pip/_internal/resolution/resolvelib/factory.py,sha256=FCvHc9M8UJ_7iU63QtPiHuq_BmfdnBiMJ8WaDBJNFxk,32668
248
+ pip/_internal/resolution/resolvelib/found_candidates.py,sha256=6lAF_pLQ2_Z0CBOHIFxGp6NfvT1uwIpCui6e-GgI5tk,6000
249
+ pip/_internal/resolution/resolvelib/provider.py,sha256=8ptYOOjfa336D4FZ751EQHR0LDq8jJhIGJXDou8Cv8Y,11190
250
+ pip/_internal/resolution/resolvelib/reporter.py,sha256=EwJAHOjWZ8eTHQWss7zJjmQEj6ooP6oWSwwVXFtgpqQ,3260
251
+ pip/_internal/resolution/resolvelib/requirements.py,sha256=7JG4Z72e5Yk4vU0S5ulGvbqTy4FMQGYhY5zQhX9zTtY,8065
252
+ pip/_internal/resolution/resolvelib/resolver.py,sha256=9zcR4c7UZV1j2ILTmb68Ck_5HdvQvf4cmTBE2bWHkKg,12785
253
+ pip/_internal/self_outdated_check.py,sha256=1PFtttvLAeyCVR3tPoBq2sOlPD0IJ-KSqU6bc1HUk9c,8318
254
+ pip/_internal/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
255
+ pip/_internal/utils/__pycache__/__init__.cpython-313.pyc,,
256
+ pip/_internal/utils/__pycache__/_jaraco_text.cpython-313.pyc,,
257
+ pip/_internal/utils/__pycache__/_log.cpython-313.pyc,,
258
+ pip/_internal/utils/__pycache__/appdirs.cpython-313.pyc,,
259
+ pip/_internal/utils/__pycache__/compat.cpython-313.pyc,,
260
+ pip/_internal/utils/__pycache__/compatibility_tags.cpython-313.pyc,,
261
+ pip/_internal/utils/__pycache__/datetime.cpython-313.pyc,,
262
+ pip/_internal/utils/__pycache__/deprecation.cpython-313.pyc,,
263
+ pip/_internal/utils/__pycache__/direct_url_helpers.cpython-313.pyc,,
264
+ pip/_internal/utils/__pycache__/egg_link.cpython-313.pyc,,
265
+ pip/_internal/utils/__pycache__/entrypoints.cpython-313.pyc,,
266
+ pip/_internal/utils/__pycache__/filesystem.cpython-313.pyc,,
267
+ pip/_internal/utils/__pycache__/filetypes.cpython-313.pyc,,
268
+ pip/_internal/utils/__pycache__/glibc.cpython-313.pyc,,
269
+ pip/_internal/utils/__pycache__/hashes.cpython-313.pyc,,
270
+ pip/_internal/utils/__pycache__/logging.cpython-313.pyc,,
271
+ pip/_internal/utils/__pycache__/misc.cpython-313.pyc,,
272
+ pip/_internal/utils/__pycache__/packaging.cpython-313.pyc,,
273
+ pip/_internal/utils/__pycache__/retry.cpython-313.pyc,,
274
+ pip/_internal/utils/__pycache__/setuptools_build.cpython-313.pyc,,
275
+ pip/_internal/utils/__pycache__/subprocess.cpython-313.pyc,,
276
+ pip/_internal/utils/__pycache__/temp_dir.cpython-313.pyc,,
277
+ pip/_internal/utils/__pycache__/unpacking.cpython-313.pyc,,
278
+ pip/_internal/utils/__pycache__/urls.cpython-313.pyc,,
279
+ pip/_internal/utils/__pycache__/virtualenv.cpython-313.pyc,,
280
+ pip/_internal/utils/__pycache__/wheel.cpython-313.pyc,,
281
+ pip/_internal/utils/_jaraco_text.py,sha256=M15uUPIh5NpP1tdUGBxRau6q1ZAEtI8-XyLEETscFfE,3350
282
+ pip/_internal/utils/_log.py,sha256=-jHLOE_THaZz5BFcCnoSL9EYAtJ0nXem49s9of4jvKw,1015
283
+ pip/_internal/utils/appdirs.py,sha256=zrIISCn2QxlXYw-zJZZBTrFNTyy_0WNKiI-TOoN6wJo,1705
284
+ pip/_internal/utils/compat.py,sha256=ckkFveBiYQjRWjkNsajt_oWPS57tJvE8XxoC4OIYgCY,2399
285
+ pip/_internal/utils/compatibility_tags.py,sha256=q5W7IrNlqC5ke0AqWRG6aX5pimiqh--xuPCCNwCKPsU,6662
286
+ pip/_internal/utils/datetime.py,sha256=Gt29Ml4ToPSM88j54iu43WKtrU9A-moP4QmMiiqzedU,241
287
+ pip/_internal/utils/deprecation.py,sha256=k7Qg_UBAaaTdyq82YVARA6D7RmcGTXGv7fnfcgigj4Q,3707
288
+ pip/_internal/utils/direct_url_helpers.py,sha256=r2MRtkVDACv9AGqYODBUC9CjwgtsUU1s68hmgfCJMtA,3196
289
+ pip/_internal/utils/egg_link.py,sha256=0FePZoUYKv4RGQ2t6x7w5Z427wbA_Uo3WZnAkrgsuqo,2463
290
+ pip/_internal/utils/entrypoints.py,sha256=4CheZ81OBPPLb3Gn-X_WEPtllUibpwDVzlVQ4RFh7PM,3325
291
+ pip/_internal/utils/filesystem.py,sha256=ajvA-q4ocliW9kPp8Yquh-4vssXbu-UKbo5FV9V4X64,4950
292
+ pip/_internal/utils/filetypes.py,sha256=OCPzUxq3Aa6k_95MiI8DYgkOzutTs47fA-v-vYUJp9E,715
293
+ pip/_internal/utils/glibc.py,sha256=vUkWq_1pJuzcYNcGKLlQmABoUiisK8noYY1yc8Wq4w4,3734
294
+ pip/_internal/utils/hashes.py,sha256=XGGLL0AG8-RhWnyz87xF6MFZ--BKadHU35D47eApCKI,4972
295
+ pip/_internal/utils/logging.py,sha256=zMZK1NxfhM4QMGUyaU9q1grNuDhLSVbSkGCvZBKmaPw,12076
296
+ pip/_internal/utils/misc.py,sha256=DWnYxBUItjRp7hhxEg4ih6P6YpKrykM86dbi_EcU8SQ,23450
297
+ pip/_internal/utils/packaging.py,sha256=CjJOqLNENW-U88ojOllVL40f1ab2W2Bm3KHCavwNNfw,1603
298
+ pip/_internal/utils/retry.py,sha256=mhFbykXjhTnZfgzeuy-vl9c8nECnYn_CMtwNJX2tYzQ,1392
299
+ pip/_internal/utils/setuptools_build.py,sha256=J9EyRantVgu4V-xS_qfQy2mcPLVUM7A-227QdKGUZCA,4482
300
+ pip/_internal/utils/subprocess.py,sha256=EsvqSRiSMHF98T8Txmu6NLU3U--MpTTQjtNgKP0P--M,8988
301
+ pip/_internal/utils/temp_dir.py,sha256=5qOXe8M4JeY6vaFQM867d5zkp1bSwMZ-KT5jymmP0Zg,9310
302
+ pip/_internal/utils/unpacking.py,sha256=4yCqlRAI2zxl5tfxlnLoWLNcEn-k1c3vaet_oaJ42iI,11926
303
+ pip/_internal/utils/urls.py,sha256=qceSOZb5lbNDrHNsv7_S4L4Ytszja5NwPKUMnZHbYnM,1599
304
+ pip/_internal/utils/virtualenv.py,sha256=S6f7csYorRpiD6cvn3jISZYc3I8PJC43H5iMFpRAEDU,3456
305
+ pip/_internal/utils/wheel.py,sha256=MHObYn6d7VyZL10i-W1xoJZ2hT5-wB1WkII70AsYUE8,4493
306
+ pip/_internal/vcs/__init__.py,sha256=UAqvzpbi0VbZo3Ub6skEeZAw-ooIZR-zX_WpCbxyCoU,596
307
+ pip/_internal/vcs/__pycache__/__init__.cpython-313.pyc,,
308
+ pip/_internal/vcs/__pycache__/bazaar.cpython-313.pyc,,
309
+ pip/_internal/vcs/__pycache__/git.cpython-313.pyc,,
310
+ pip/_internal/vcs/__pycache__/mercurial.cpython-313.pyc,,
311
+ pip/_internal/vcs/__pycache__/subversion.cpython-313.pyc,,
312
+ pip/_internal/vcs/__pycache__/versioncontrol.cpython-313.pyc,,
313
+ pip/_internal/vcs/bazaar.py,sha256=EKStcQaKpNu0NK4p5Q10Oc4xb3DUxFw024XrJy40bFQ,3528
314
+ pip/_internal/vcs/git.py,sha256=3KLPrKsDL9xZchmz4H1Obo8fM2Fh8ChrhtDHWjbkj-I,18591
315
+ pip/_internal/vcs/mercurial.py,sha256=oULOhzJ2Uie-06d1omkL-_Gc6meGaUkyogvqG9ZCyPs,5249
316
+ pip/_internal/vcs/subversion.py,sha256=ddTugHBqHzV3ebKlU5QXHPN4gUqlyXbOx8q8NgXKvs8,11735
317
+ pip/_internal/vcs/versioncontrol.py,sha256=cvf_-hnTAjQLXJ3d17FMNhQfcO1AcKWUF10tfrYyP-c,22440
318
+ pip/_internal/wheel_builder.py,sha256=Z5Z2ANADbKdSHY9BHqw9zG5-1AxstO6YM6m9yLWe7Vw,11212
319
+ pip/_vendor/__init__.py,sha256=WzusPTGWIMeQQWSVJ0h2rafGkVTa9WKJ2HT-2-EoZrU,4907
320
+ pip/_vendor/__pycache__/__init__.cpython-313.pyc,,
321
+ pip/_vendor/__pycache__/typing_extensions.cpython-313.pyc,,
322
+ pip/_vendor/cachecontrol/__init__.py,sha256=x9ecUkiwNvAGfE3g0eaRx3VrJZnZWAluA2LRcvab3HQ,677
323
+ pip/_vendor/cachecontrol/__pycache__/__init__.cpython-313.pyc,,
324
+ pip/_vendor/cachecontrol/__pycache__/_cmd.cpython-313.pyc,,
325
+ pip/_vendor/cachecontrol/__pycache__/adapter.cpython-313.pyc,,
326
+ pip/_vendor/cachecontrol/__pycache__/cache.cpython-313.pyc,,
327
+ pip/_vendor/cachecontrol/__pycache__/controller.cpython-313.pyc,,
328
+ pip/_vendor/cachecontrol/__pycache__/filewrapper.cpython-313.pyc,,
329
+ pip/_vendor/cachecontrol/__pycache__/heuristics.cpython-313.pyc,,
330
+ pip/_vendor/cachecontrol/__pycache__/serialize.cpython-313.pyc,,
331
+ pip/_vendor/cachecontrol/__pycache__/wrapper.cpython-313.pyc,,
332
+ pip/_vendor/cachecontrol/_cmd.py,sha256=iist2EpzJvDVIhMAxXq8iFnTBsiZAd6iplxfmNboNyk,1737
333
+ pip/_vendor/cachecontrol/adapter.py,sha256=8y6rTPXOzVHmDKCW5CR9sivLVuDv-cpdGcZYdRWNaPw,6599
334
+ pip/_vendor/cachecontrol/cache.py,sha256=OXwv7Fn2AwnKNiahJHnjtvaKLndvVLv_-zO-ltlV9qI,1953
335
+ pip/_vendor/cachecontrol/caches/__init__.py,sha256=dtrrroK5BnADR1GWjCZ19aZ0tFsMfvFBtLQQU1sp_ag,303
336
+ pip/_vendor/cachecontrol/caches/__pycache__/__init__.cpython-313.pyc,,
337
+ pip/_vendor/cachecontrol/caches/__pycache__/file_cache.cpython-313.pyc,,
338
+ pip/_vendor/cachecontrol/caches/__pycache__/redis_cache.cpython-313.pyc,,
339
+ pip/_vendor/cachecontrol/caches/file_cache.py,sha256=d8upFmy_zwaCmlbWEVBlLXFddt8Zw8c5SFpxeOZsdfw,4117
340
+ pip/_vendor/cachecontrol/caches/redis_cache.py,sha256=9rmqwtYu_ljVkW6_oLqbC7EaX_a8YT_yLuna-eS0dgo,1386
341
+ pip/_vendor/cachecontrol/controller.py,sha256=cx0Hl8xLZgUuXuy78Gih9AYjCtqurmYjVJxyA4yWt7w,19101
342
+ pip/_vendor/cachecontrol/filewrapper.py,sha256=2ktXNPE0KqnyzF24aOsKCA58HQq1xeC6l2g6_zwjghc,4291
343
+ pip/_vendor/cachecontrol/heuristics.py,sha256=gqMXU8w0gQuEQiSdu3Yg-0vd9kW7nrWKbLca75rheGE,4881
344
+ pip/_vendor/cachecontrol/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
345
+ pip/_vendor/cachecontrol/serialize.py,sha256=HQd2IllQ05HzPkVLMXTF2uX5mjEQjDBkxCqUJUODpZk,5163
346
+ pip/_vendor/cachecontrol/wrapper.py,sha256=hsGc7g8QGQTT-4f8tgz3AM5qwScg6FO0BSdLSRdEvpU,1417
347
+ pip/_vendor/certifi/__init__.py,sha256=neIaAf7BM36ygmQCmy-ZsSyjnvjWghFeu13wwEAnjj0,94
348
+ pip/_vendor/certifi/__main__.py,sha256=1k3Cr95vCxxGRGDljrW3wMdpZdL3Nhf0u1n-k2qdsCY,255
349
+ pip/_vendor/certifi/__pycache__/__init__.cpython-313.pyc,,
350
+ pip/_vendor/certifi/__pycache__/__main__.cpython-313.pyc,,
351
+ pip/_vendor/certifi/__pycache__/core.cpython-313.pyc,,
352
+ pip/_vendor/certifi/cacert.pem,sha256=xVsh-Qf3-G1IrdCTVS-1ZRdJ_1-GBQjMu0I9bB-9gMc,297255
353
+ pip/_vendor/certifi/core.py,sha256=vHXkYJt_CVYbDuS-aPFRfDZu7RkKcP9ltm-DiL4Zo30,4738
354
+ pip/_vendor/certifi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
355
+ pip/_vendor/dependency_groups/__init__.py,sha256=C3OFu0NGwDzQ4LOmmSOFPsRSvkbBn-mdd4j_5YqJw-s,250
356
+ pip/_vendor/dependency_groups/__main__.py,sha256=UNTM7P5mfVtT7wDi9kOTXWgV3fu3e8bTrt1Qp1jvjKo,1709
357
+ pip/_vendor/dependency_groups/__pycache__/__init__.cpython-313.pyc,,
358
+ pip/_vendor/dependency_groups/__pycache__/__main__.cpython-313.pyc,,
359
+ pip/_vendor/dependency_groups/__pycache__/_implementation.cpython-313.pyc,,
360
+ pip/_vendor/dependency_groups/__pycache__/_lint_dependency_groups.cpython-313.pyc,,
361
+ pip/_vendor/dependency_groups/__pycache__/_pip_wrapper.cpython-313.pyc,,
362
+ pip/_vendor/dependency_groups/__pycache__/_toml_compat.cpython-313.pyc,,
363
+ pip/_vendor/dependency_groups/_implementation.py,sha256=Gqb2DlQELRakeHlKf6QtQSW0M-bcEomxHw4JsvID1ls,8041
364
+ pip/_vendor/dependency_groups/_lint_dependency_groups.py,sha256=yp-DDqKXtbkDTNa0ifa-FmOA8ra24lPZEXftW-R5AuI,1710
365
+ pip/_vendor/dependency_groups/_pip_wrapper.py,sha256=nuVW_w_ntVxpE26ELEvngMY0N04sFLsijXRyZZROFG8,1865
366
+ pip/_vendor/dependency_groups/_toml_compat.py,sha256=BHnXnFacm3DeolsA35GjI6qkDApvua-1F20kv3BfZWE,285
367
+ pip/_vendor/dependency_groups/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
368
+ pip/_vendor/distlib/__init__.py,sha256=dcwgYGYGQqAEawBXPDtIx80DO_3cOmFv8HTc8JMzknQ,625
369
+ pip/_vendor/distlib/__pycache__/__init__.cpython-313.pyc,,
370
+ pip/_vendor/distlib/__pycache__/compat.cpython-313.pyc,,
371
+ pip/_vendor/distlib/__pycache__/database.cpython-313.pyc,,
372
+ pip/_vendor/distlib/__pycache__/index.cpython-313.pyc,,
373
+ pip/_vendor/distlib/__pycache__/locators.cpython-313.pyc,,
374
+ pip/_vendor/distlib/__pycache__/manifest.cpython-313.pyc,,
375
+ pip/_vendor/distlib/__pycache__/markers.cpython-313.pyc,,
376
+ pip/_vendor/distlib/__pycache__/metadata.cpython-313.pyc,,
377
+ pip/_vendor/distlib/__pycache__/resources.cpython-313.pyc,,
378
+ pip/_vendor/distlib/__pycache__/scripts.cpython-313.pyc,,
379
+ pip/_vendor/distlib/__pycache__/util.cpython-313.pyc,,
380
+ pip/_vendor/distlib/__pycache__/version.cpython-313.pyc,,
381
+ pip/_vendor/distlib/__pycache__/wheel.cpython-313.pyc,,
382
+ pip/_vendor/distlib/compat.py,sha256=2jRSjRI4o-vlXeTK2BCGIUhkc6e9ZGhSsacRM5oseTw,41467
383
+ pip/_vendor/distlib/database.py,sha256=mHy_LxiXIsIVRb-T0-idBrVLw3Ffij5teHCpbjmJ9YU,51160
384
+ pip/_vendor/distlib/index.py,sha256=lTbw268rRhj8dw1sib3VZ_0EhSGgoJO3FKJzSFMOaeA,20797
385
+ pip/_vendor/distlib/locators.py,sha256=oBeAZpFuPQSY09MgNnLfQGGAXXvVO96BFpZyKMuK4tM,51026
386
+ pip/_vendor/distlib/manifest.py,sha256=3qfmAmVwxRqU1o23AlfXrQGZzh6g_GGzTAP_Hb9C5zQ,14168
387
+ pip/_vendor/distlib/markers.py,sha256=X6sDvkFGcYS8gUW8hfsWuKEKAqhQZAJ7iXOMLxRYjYk,5164
388
+ pip/_vendor/distlib/metadata.py,sha256=zil3sg2EUfLXVigljY2d_03IJt-JSs7nX-73fECMX2s,38724
389
+ pip/_vendor/distlib/resources.py,sha256=LwbPksc0A1JMbi6XnuPdMBUn83X7BPuFNWqPGEKI698,10820
390
+ pip/_vendor/distlib/scripts.py,sha256=BJliaDAZaVB7WAkwokgC3HXwLD2iWiHaVI50H7C6eG8,18608
391
+ pip/_vendor/distlib/util.py,sha256=vMPGvsS4j9hF6Y9k3Tyom1aaHLb0rFmZAEyzeAdel9w,66682
392
+ pip/_vendor/distlib/version.py,sha256=s5VIs8wBn0fxzGxWM_aA2ZZyx525HcZbMvcTlTyZ3Rg,23727
393
+ pip/_vendor/distlib/wheel.py,sha256=DFIVguEQHCdxnSdAO0dfFsgMcvVZitg7bCOuLwZ7A_s,43979
394
+ pip/_vendor/distro/__init__.py,sha256=2fHjF-SfgPvjyNZ1iHh_wjqWdR_Yo5ODHwZC0jLBPhc,981
395
+ pip/_vendor/distro/__main__.py,sha256=bu9d3TifoKciZFcqRBuygV3GSuThnVD_m2IK4cz96Vs,64
396
+ pip/_vendor/distro/__pycache__/__init__.cpython-313.pyc,,
397
+ pip/_vendor/distro/__pycache__/__main__.cpython-313.pyc,,
398
+ pip/_vendor/distro/__pycache__/distro.cpython-313.pyc,,
399
+ pip/_vendor/distro/distro.py,sha256=XqbefacAhDT4zr_trnbA15eY8vdK4GTghgmvUGrEM_4,49430
400
+ pip/_vendor/distro/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
401
+ pip/_vendor/idna/__init__.py,sha256=MPqNDLZbXqGaNdXxAFhiqFPKEQXju2jNQhCey6-5eJM,868
402
+ pip/_vendor/idna/__pycache__/__init__.cpython-313.pyc,,
403
+ pip/_vendor/idna/__pycache__/codec.cpython-313.pyc,,
404
+ pip/_vendor/idna/__pycache__/compat.cpython-313.pyc,,
405
+ pip/_vendor/idna/__pycache__/core.cpython-313.pyc,,
406
+ pip/_vendor/idna/__pycache__/idnadata.cpython-313.pyc,,
407
+ pip/_vendor/idna/__pycache__/intranges.cpython-313.pyc,,
408
+ pip/_vendor/idna/__pycache__/package_data.cpython-313.pyc,,
409
+ pip/_vendor/idna/__pycache__/uts46data.cpython-313.pyc,,
410
+ pip/_vendor/idna/codec.py,sha256=PEew3ItwzjW4hymbasnty2N2OXvNcgHB-JjrBuxHPYY,3422
411
+ pip/_vendor/idna/compat.py,sha256=RzLy6QQCdl9784aFhb2EX9EKGCJjg0P3PilGdeXXcx8,316
412
+ pip/_vendor/idna/core.py,sha256=YJYyAMnwiQEPjVC4-Fqu_p4CJ6yKKuDGmppBNQNQpFs,13239
413
+ pip/_vendor/idna/idnadata.py,sha256=W30GcIGvtOWYwAjZj4ZjuouUutC6ffgNuyjJy7fZ-lo,78306
414
+ pip/_vendor/idna/intranges.py,sha256=amUtkdhYcQG8Zr-CoMM_kVRacxkivC1WgxN1b63KKdU,1898
415
+ pip/_vendor/idna/package_data.py,sha256=q59S3OXsc5VI8j6vSD0sGBMyk6zZ4vWFREE88yCJYKs,21
416
+ pip/_vendor/idna/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
417
+ pip/_vendor/idna/uts46data.py,sha256=rt90K9J40gUSwppDPCrhjgi5AA6pWM65dEGRSf6rIhM,239289
418
+ pip/_vendor/msgpack/__init__.py,sha256=reRaiOtEzSjPnr7TpxjgIvbfln5pV66FhricAs2eC-g,1109
419
+ pip/_vendor/msgpack/__pycache__/__init__.cpython-313.pyc,,
420
+ pip/_vendor/msgpack/__pycache__/exceptions.cpython-313.pyc,,
421
+ pip/_vendor/msgpack/__pycache__/ext.cpython-313.pyc,,
422
+ pip/_vendor/msgpack/__pycache__/fallback.cpython-313.pyc,,
423
+ pip/_vendor/msgpack/exceptions.py,sha256=dCTWei8dpkrMsQDcjQk74ATl9HsIBH0ybt8zOPNqMYc,1081
424
+ pip/_vendor/msgpack/ext.py,sha256=kteJv03n9tYzd5oo3xYopVTo4vRaAxonBQQJhXohZZo,5726
425
+ pip/_vendor/msgpack/fallback.py,sha256=0g1Pzp0vtmBEmJ5w9F3s_-JMVURP8RS4G1cc5TRaAsI,32390
426
+ pip/_vendor/packaging/__init__.py,sha256=_0cDiPVf2S-bNfVmZguxxzmrIYWlyASxpqph4qsJWUc,494
427
+ pip/_vendor/packaging/__pycache__/__init__.cpython-313.pyc,,
428
+ pip/_vendor/packaging/__pycache__/_elffile.cpython-313.pyc,,
429
+ pip/_vendor/packaging/__pycache__/_manylinux.cpython-313.pyc,,
430
+ pip/_vendor/packaging/__pycache__/_musllinux.cpython-313.pyc,,
431
+ pip/_vendor/packaging/__pycache__/_parser.cpython-313.pyc,,
432
+ pip/_vendor/packaging/__pycache__/_structures.cpython-313.pyc,,
433
+ pip/_vendor/packaging/__pycache__/_tokenizer.cpython-313.pyc,,
434
+ pip/_vendor/packaging/__pycache__/markers.cpython-313.pyc,,
435
+ pip/_vendor/packaging/__pycache__/metadata.cpython-313.pyc,,
436
+ pip/_vendor/packaging/__pycache__/requirements.cpython-313.pyc,,
437
+ pip/_vendor/packaging/__pycache__/specifiers.cpython-313.pyc,,
438
+ pip/_vendor/packaging/__pycache__/tags.cpython-313.pyc,,
439
+ pip/_vendor/packaging/__pycache__/utils.cpython-313.pyc,,
440
+ pip/_vendor/packaging/__pycache__/version.cpython-313.pyc,,
441
+ pip/_vendor/packaging/_elffile.py,sha256=UkrbDtW7aeq3qqoAfU16ojyHZ1xsTvGke_WqMTKAKd0,3286
442
+ pip/_vendor/packaging/_manylinux.py,sha256=t4y_-dTOcfr36gLY-ztiOpxxJFGO2ikC11HgfysGxiM,9596
443
+ pip/_vendor/packaging/_musllinux.py,sha256=p9ZqNYiOItGee8KcZFeHF_YcdhVwGHdK6r-8lgixvGQ,2694
444
+ pip/_vendor/packaging/_parser.py,sha256=gYfnj0pRHflVc4RHZit13KNTyN9iiVcU2RUCGi22BwM,10221
445
+ pip/_vendor/packaging/_structures.py,sha256=q3eVNmbWJGG_S0Dit_S3Ao8qQqz_5PYTXFAKBZe5yr4,1431
446
+ pip/_vendor/packaging/_tokenizer.py,sha256=OYzt7qKxylOAJ-q0XyK1qAycyPRYLfMPdGQKRXkZWyI,5310
447
+ pip/_vendor/packaging/licenses/__init__.py,sha256=3bx-gryo4sRv5LsrwApouy65VIs3u6irSORJzALkrzU,5727
448
+ pip/_vendor/packaging/licenses/__pycache__/__init__.cpython-313.pyc,,
449
+ pip/_vendor/packaging/licenses/__pycache__/_spdx.cpython-313.pyc,,
450
+ pip/_vendor/packaging/licenses/_spdx.py,sha256=oAm1ztPFwlsmCKe7lAAsv_OIOfS1cWDu9bNBkeu-2ns,48398
451
+ pip/_vendor/packaging/markers.py,sha256=P0we27jm1xUzgGMJxBjtUFCIWeBxTsMeJTOJ6chZmAY,12049
452
+ pip/_vendor/packaging/metadata.py,sha256=8IZErqQQnNm53dZZuYq4FGU4_dpyinMeH1QFBIWIkfE,34739
453
+ pip/_vendor/packaging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
454
+ pip/_vendor/packaging/requirements.py,sha256=gYyRSAdbrIyKDY66ugIDUQjRMvxkH2ALioTmX3tnL6o,2947
455
+ pip/_vendor/packaging/specifiers.py,sha256=yc9D_MycJEmwUpZvcs1OZL9HfiNFmyw0RZaeHRNHkPw,40079
456
+ pip/_vendor/packaging/tags.py,sha256=41s97W9Zatrq2Ed7Rc3qeBDaHe8pKKvYq2mGjwahfXk,22745
457
+ pip/_vendor/packaging/utils.py,sha256=0F3Hh9OFuRgrhTgGZUl5K22Fv1YP2tZl1z_2gO6kJiA,5050
458
+ pip/_vendor/packaging/version.py,sha256=oiHqzTUv_p12hpjgsLDVcaF5hT7pDaSOViUNMD4GTW0,16688
459
+ pip/_vendor/pkg_resources/__init__.py,sha256=jrhDRbOubP74QuPXxd7U7Po42PH2l-LZ2XfcO7llpZ4,124463
460
+ pip/_vendor/pkg_resources/__pycache__/__init__.cpython-313.pyc,,
461
+ pip/_vendor/platformdirs/__init__.py,sha256=UfeSHWl8AeTtbOBOoHAxK4dODOWkZtfy-m_i7cWdJ8c,22344
462
+ pip/_vendor/platformdirs/__main__.py,sha256=jBJ8zb7Mpx5ebcqF83xrpO94MaeCpNGHVf9cvDN2JLg,1505
463
+ pip/_vendor/platformdirs/__pycache__/__init__.cpython-313.pyc,,
464
+ pip/_vendor/platformdirs/__pycache__/__main__.cpython-313.pyc,,
465
+ pip/_vendor/platformdirs/__pycache__/android.cpython-313.pyc,,
466
+ pip/_vendor/platformdirs/__pycache__/api.cpython-313.pyc,,
467
+ pip/_vendor/platformdirs/__pycache__/macos.cpython-313.pyc,,
468
+ pip/_vendor/platformdirs/__pycache__/unix.cpython-313.pyc,,
469
+ pip/_vendor/platformdirs/__pycache__/version.cpython-313.pyc,,
470
+ pip/_vendor/platformdirs/__pycache__/windows.cpython-313.pyc,,
471
+ pip/_vendor/platformdirs/android.py,sha256=r0DshVBf-RO1jXJGX8C4Til7F1XWt-bkdWMgmvEiaYg,9013
472
+ pip/_vendor/platformdirs/api.py,sha256=U9EzI3EYxcXWUCtIGRllqrcN99i2LSY1mq2-GtsUwEQ,9277
473
+ pip/_vendor/platformdirs/macos.py,sha256=UlbyFZ8Rzu3xndCqQEHrfsYTeHwYdFap1Ioz-yxveT4,6154
474
+ pip/_vendor/platformdirs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
475
+ pip/_vendor/platformdirs/unix.py,sha256=WZmkUA--L3JNRGmz32s35YfoD3ica6xKIPdCV_HhLcs,10458
476
+ pip/_vendor/platformdirs/version.py,sha256=0fnw4ljascx7O5PfIeZ2yj6w3pAkqwp099vDcivxuvY,511
477
+ pip/_vendor/platformdirs/windows.py,sha256=IFpiohUBwxPtCzlyKwNtxyW4Jk8haa6W8o59mfrDXVo,10125
478
+ pip/_vendor/pygments/__init__.py,sha256=qMm7-KYqNpMrmjymZaqfH-_9iJtjnexAKodkb9G5D5g,2983
479
+ pip/_vendor/pygments/__main__.py,sha256=WrndpSe6i1ckX_SQ1KaxD9CTKGzD0EuCOFxcbwFpoLU,353
480
+ pip/_vendor/pygments/__pycache__/__init__.cpython-313.pyc,,
481
+ pip/_vendor/pygments/__pycache__/__main__.cpython-313.pyc,,
482
+ pip/_vendor/pygments/__pycache__/console.cpython-313.pyc,,
483
+ pip/_vendor/pygments/__pycache__/filter.cpython-313.pyc,,
484
+ pip/_vendor/pygments/__pycache__/formatter.cpython-313.pyc,,
485
+ pip/_vendor/pygments/__pycache__/lexer.cpython-313.pyc,,
486
+ pip/_vendor/pygments/__pycache__/modeline.cpython-313.pyc,,
487
+ pip/_vendor/pygments/__pycache__/plugin.cpython-313.pyc,,
488
+ pip/_vendor/pygments/__pycache__/regexopt.cpython-313.pyc,,
489
+ pip/_vendor/pygments/__pycache__/scanner.cpython-313.pyc,,
490
+ pip/_vendor/pygments/__pycache__/sphinxext.cpython-313.pyc,,
491
+ pip/_vendor/pygments/__pycache__/style.cpython-313.pyc,,
492
+ pip/_vendor/pygments/__pycache__/token.cpython-313.pyc,,
493
+ pip/_vendor/pygments/__pycache__/unistring.cpython-313.pyc,,
494
+ pip/_vendor/pygments/__pycache__/util.cpython-313.pyc,,
495
+ pip/_vendor/pygments/console.py,sha256=AagDWqwea2yBWf10KC9ptBgMpMjxKp8yABAmh-NQOVk,1718
496
+ pip/_vendor/pygments/filter.py,sha256=YLtpTnZiu07nY3oK9nfR6E9Y1FBHhP5PX8gvkJWcfag,1910
497
+ pip/_vendor/pygments/filters/__init__.py,sha256=4U4jtA0X3iP83uQnB9-TI-HDSw8E8y8zMYHa0UjbbaI,40392
498
+ pip/_vendor/pygments/filters/__pycache__/__init__.cpython-313.pyc,,
499
+ pip/_vendor/pygments/formatter.py,sha256=KZQMmyo_xkOIkQG8g66LYEkBh1bx7a0HyGCBcvhI9Ew,4390
500
+ pip/_vendor/pygments/formatters/__init__.py,sha256=KTwBmnXlaopJhQDOemVHYHskiDghuq-08YtP6xPNJPg,5385
501
+ pip/_vendor/pygments/formatters/__pycache__/__init__.cpython-313.pyc,,
502
+ pip/_vendor/pygments/formatters/__pycache__/_mapping.cpython-313.pyc,,
503
+ pip/_vendor/pygments/formatters/_mapping.py,sha256=1Cw37FuQlNacnxRKmtlPX4nyLoX9_ttko5ZwscNUZZ4,4176
504
+ pip/_vendor/pygments/lexer.py,sha256=_kBrOJ_NT5Tl0IVM0rA9c8eysP6_yrlGzEQI0eVYB-A,35349
505
+ pip/_vendor/pygments/lexers/__init__.py,sha256=wbIME35GH7bI1B9rNPJFqWT-ij_RApZDYPUlZycaLzA,12115
506
+ pip/_vendor/pygments/lexers/__pycache__/__init__.cpython-313.pyc,,
507
+ pip/_vendor/pygments/lexers/__pycache__/_mapping.cpython-313.pyc,,
508
+ pip/_vendor/pygments/lexers/__pycache__/python.cpython-313.pyc,,
509
+ pip/_vendor/pygments/lexers/_mapping.py,sha256=l4tCXM8e9aPC2BD6sjIr0deT-J-z5tHgCwL-p1fS0PE,77602
510
+ pip/_vendor/pygments/lexers/python.py,sha256=vxjn1cOHclIKJKxoyiBsQTY65GHbkZtZRuKQ2AVCKaw,53853
511
+ pip/_vendor/pygments/modeline.py,sha256=K5eSkR8GS1r5OkXXTHOcV0aM_6xpk9eWNEIAW-OOJ2g,1005
512
+ pip/_vendor/pygments/plugin.py,sha256=tPx0rJCTIZ9ioRgLNYG4pifCbAwTRUZddvLw-NfAk2w,1891
513
+ pip/_vendor/pygments/regexopt.py,sha256=wXaP9Gjp_hKAdnICqoDkRxAOQJSc4v3X6mcxx3z-TNs,3072
514
+ pip/_vendor/pygments/scanner.py,sha256=nNcETRR1tRuiTaHmHSTTECVYFPcLf6mDZu1e4u91A9E,3092
515
+ pip/_vendor/pygments/sphinxext.py,sha256=5x7Zh9YlU6ISJ31dMwduiaanb5dWZnKg3MyEQsseNnQ,7981
516
+ pip/_vendor/pygments/style.py,sha256=PlOZqlsnTVd58RGy50vkA2cXQ_lP5bF5EGMEBTno6DA,6420
517
+ pip/_vendor/pygments/styles/__init__.py,sha256=x9ebctfyvCAFpMTlMJ5YxwcNYBzjgq6zJaKkNm78r4M,2042
518
+ pip/_vendor/pygments/styles/__pycache__/__init__.cpython-313.pyc,,
519
+ pip/_vendor/pygments/styles/__pycache__/_mapping.cpython-313.pyc,,
520
+ pip/_vendor/pygments/styles/_mapping.py,sha256=6lovFUE29tz6EsV3XYY4hgozJ7q1JL7cfO3UOlgnS8w,3312
521
+ pip/_vendor/pygments/token.py,sha256=WbdWGhYm_Vosb0DDxW9lHNPgITXfWTsQmHt6cy9RbcM,6226
522
+ pip/_vendor/pygments/unistring.py,sha256=al-_rBemRuGvinsrM6atNsHTmJ6DUbw24q2O2Ru1cBc,63208
523
+ pip/_vendor/pygments/util.py,sha256=oRtSpiAo5jM9ulntkvVbgXUdiAW57jnuYGB7t9fYuhc,10031
524
+ pip/_vendor/pyproject_hooks/__init__.py,sha256=cPB_a9LXz5xvsRbX1o2qyAdjLatZJdQ_Lc5McNX-X7Y,691
525
+ pip/_vendor/pyproject_hooks/__pycache__/__init__.cpython-313.pyc,,
526
+ pip/_vendor/pyproject_hooks/__pycache__/_impl.cpython-313.pyc,,
527
+ pip/_vendor/pyproject_hooks/_impl.py,sha256=jY-raxnmyRyB57ruAitrJRUzEexuAhGTpgMygqx67Z4,14936
528
+ pip/_vendor/pyproject_hooks/_in_process/__init__.py,sha256=MJNPpfIxcO-FghxpBbxkG1rFiQf6HOUbV4U5mq0HFns,557
529
+ pip/_vendor/pyproject_hooks/_in_process/__pycache__/__init__.cpython-313.pyc,,
530
+ pip/_vendor/pyproject_hooks/_in_process/__pycache__/_in_process.cpython-313.pyc,,
531
+ pip/_vendor/pyproject_hooks/_in_process/_in_process.py,sha256=qcXMhmx__MIJq10gGHW3mA4Tl8dy8YzHMccwnNoKlw0,12216
532
+ pip/_vendor/pyproject_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
533
+ pip/_vendor/requests/__init__.py,sha256=HlB_HzhrzGtfD_aaYUwUh1zWXLZ75_YCLyit75d0Vz8,5057
534
+ pip/_vendor/requests/__pycache__/__init__.cpython-313.pyc,,
535
+ pip/_vendor/requests/__pycache__/__version__.cpython-313.pyc,,
536
+ pip/_vendor/requests/__pycache__/_internal_utils.cpython-313.pyc,,
537
+ pip/_vendor/requests/__pycache__/adapters.cpython-313.pyc,,
538
+ pip/_vendor/requests/__pycache__/api.cpython-313.pyc,,
539
+ pip/_vendor/requests/__pycache__/auth.cpython-313.pyc,,
540
+ pip/_vendor/requests/__pycache__/certs.cpython-313.pyc,,
541
+ pip/_vendor/requests/__pycache__/compat.cpython-313.pyc,,
542
+ pip/_vendor/requests/__pycache__/cookies.cpython-313.pyc,,
543
+ pip/_vendor/requests/__pycache__/exceptions.cpython-313.pyc,,
544
+ pip/_vendor/requests/__pycache__/help.cpython-313.pyc,,
545
+ pip/_vendor/requests/__pycache__/hooks.cpython-313.pyc,,
546
+ pip/_vendor/requests/__pycache__/models.cpython-313.pyc,,
547
+ pip/_vendor/requests/__pycache__/packages.cpython-313.pyc,,
548
+ pip/_vendor/requests/__pycache__/sessions.cpython-313.pyc,,
549
+ pip/_vendor/requests/__pycache__/status_codes.cpython-313.pyc,,
550
+ pip/_vendor/requests/__pycache__/structures.cpython-313.pyc,,
551
+ pip/_vendor/requests/__pycache__/utils.cpython-313.pyc,,
552
+ pip/_vendor/requests/__version__.py,sha256=FVfglgZmNQnmYPXpOohDU58F5EUb_-VnSTaAesS187g,435
553
+ pip/_vendor/requests/_internal_utils.py,sha256=nMQymr4hs32TqVo5AbCrmcJEhvPUh7xXlluyqwslLiQ,1495
554
+ pip/_vendor/requests/adapters.py,sha256=J7VeVxKBvawbtlX2DERVo05J9BXTcWYLMHNd1Baa-bk,27607
555
+ pip/_vendor/requests/api.py,sha256=_Zb9Oa7tzVIizTKwFrPjDEY9ejtm_OnSRERnADxGsQs,6449
556
+ pip/_vendor/requests/auth.py,sha256=kF75tqnLctZ9Mf_hm9TZIj4cQWnN5uxRz8oWsx5wmR0,10186
557
+ pip/_vendor/requests/certs.py,sha256=kHDlkK_beuHXeMPc5jta2wgl8gdKeUWt5f2nTDVrvt8,441
558
+ pip/_vendor/requests/compat.py,sha256=Mo9f9xZpefod8Zm-n9_StJcVTmwSukXR2p3IQyyVXvU,1485
559
+ pip/_vendor/requests/cookies.py,sha256=bNi-iqEj4NPZ00-ob-rHvzkvObzN3lEpgw3g6paS3Xw,18590
560
+ pip/_vendor/requests/exceptions.py,sha256=D1wqzYWne1mS2rU43tP9CeN1G7QAy7eqL9o1god6Ejw,4272
561
+ pip/_vendor/requests/help.py,sha256=hRKaf9u0G7fdwrqMHtF3oG16RKktRf6KiwtSq2Fo1_0,3813
562
+ pip/_vendor/requests/hooks.py,sha256=CiuysiHA39V5UfcCBXFIx83IrDpuwfN9RcTUgv28ftQ,733
563
+ pip/_vendor/requests/models.py,sha256=x4K4CmH-lC0l2Kb-iPfMN4dRXxHEcbOaEWBL_i09AwI,35483
564
+ pip/_vendor/requests/packages.py,sha256=_ZQDCJTJ8SP3kVWunSqBsRZNPzj2c1WFVqbdr08pz3U,1057
565
+ pip/_vendor/requests/sessions.py,sha256=ykTI8UWGSltOfH07HKollH7kTBGw4WhiBVaQGmckTw4,30495
566
+ pip/_vendor/requests/status_codes.py,sha256=iJUAeA25baTdw-6PfD0eF4qhpINDJRJI-yaMqxs4LEI,4322
567
+ pip/_vendor/requests/structures.py,sha256=-IbmhVz06S-5aPSZuUthZ6-6D9XOjRuTXHOabY041XM,2912
568
+ pip/_vendor/requests/utils.py,sha256=L79vnFbzJ3SFLKtJwpoWe41Tozi3RlZv94pY1TFIyow,33631
569
+ pip/_vendor/resolvelib/__init__.py,sha256=4LcBWHMH317EKEkpV5XLVnqiU1lrmCiygjsADuCgz4s,541
570
+ pip/_vendor/resolvelib/__pycache__/__init__.cpython-313.pyc,,
571
+ pip/_vendor/resolvelib/__pycache__/providers.cpython-313.pyc,,
572
+ pip/_vendor/resolvelib/__pycache__/reporters.cpython-313.pyc,,
573
+ pip/_vendor/resolvelib/__pycache__/structs.cpython-313.pyc,,
574
+ pip/_vendor/resolvelib/providers.py,sha256=pIWJbIdJJ9GFtNbtwTH0Ia43Vj6hYCEJj2DOLue15FM,8914
575
+ pip/_vendor/resolvelib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
576
+ pip/_vendor/resolvelib/reporters.py,sha256=8BNa7G9cKW4Lie4BhDhd7Z57J_Vlb1CYPGSgVN2erMA,2038
577
+ pip/_vendor/resolvelib/resolvers/__init__.py,sha256=GMYuhrbSsYTIjOij0tuJKLvlk6UXmp3nXQetn2sOvpQ,640
578
+ pip/_vendor/resolvelib/resolvers/__pycache__/__init__.cpython-313.pyc,,
579
+ pip/_vendor/resolvelib/resolvers/__pycache__/abstract.cpython-313.pyc,,
580
+ pip/_vendor/resolvelib/resolvers/__pycache__/criterion.cpython-313.pyc,,
581
+ pip/_vendor/resolvelib/resolvers/__pycache__/exceptions.cpython-313.pyc,,
582
+ pip/_vendor/resolvelib/resolvers/__pycache__/resolution.cpython-313.pyc,,
583
+ pip/_vendor/resolvelib/resolvers/abstract.py,sha256=jZOBVigE4PUub9i3F-bTvBwaIXX8S9EU3CGASBvFqEU,1558
584
+ pip/_vendor/resolvelib/resolvers/criterion.py,sha256=lcmZGv5sKHOnFD_RzZwvlGSj19MeA-5rCMpdf2Sgw7Y,1768
585
+ pip/_vendor/resolvelib/resolvers/exceptions.py,sha256=ln_jaQtgLlRUSFY627yiHG2gD7AgaXzRKaElFVh7fDQ,1768
586
+ pip/_vendor/resolvelib/resolvers/resolution.py,sha256=yQegMuOmlzAElLLpgD-k6NbPDMCQf29rWhiFC26OdkM,20671
587
+ pip/_vendor/resolvelib/structs.py,sha256=pu-EJiR2IBITr2SQeNPRa0rXhjlStfmO_GEgAhr3004,6420
588
+ pip/_vendor/rich/__init__.py,sha256=dRxjIL-SbFVY0q3IjSMrfgBTHrm1LZDgLOygVBwiYZc,6090
589
+ pip/_vendor/rich/__main__.py,sha256=eO7Cq8JnrgG8zVoeImiAs92q3hXNMIfp0w5lMsO7Q2Y,8477
590
+ pip/_vendor/rich/__pycache__/__init__.cpython-313.pyc,,
591
+ pip/_vendor/rich/__pycache__/__main__.cpython-313.pyc,,
592
+ pip/_vendor/rich/__pycache__/_cell_widths.cpython-313.pyc,,
593
+ pip/_vendor/rich/__pycache__/_emoji_codes.cpython-313.pyc,,
594
+ pip/_vendor/rich/__pycache__/_emoji_replace.cpython-313.pyc,,
595
+ pip/_vendor/rich/__pycache__/_export_format.cpython-313.pyc,,
596
+ pip/_vendor/rich/__pycache__/_extension.cpython-313.pyc,,
597
+ pip/_vendor/rich/__pycache__/_fileno.cpython-313.pyc,,
598
+ pip/_vendor/rich/__pycache__/_inspect.cpython-313.pyc,,
599
+ pip/_vendor/rich/__pycache__/_log_render.cpython-313.pyc,,
600
+ pip/_vendor/rich/__pycache__/_loop.cpython-313.pyc,,
601
+ pip/_vendor/rich/__pycache__/_null_file.cpython-313.pyc,,
602
+ pip/_vendor/rich/__pycache__/_palettes.cpython-313.pyc,,
603
+ pip/_vendor/rich/__pycache__/_pick.cpython-313.pyc,,
604
+ pip/_vendor/rich/__pycache__/_ratio.cpython-313.pyc,,
605
+ pip/_vendor/rich/__pycache__/_spinners.cpython-313.pyc,,
606
+ pip/_vendor/rich/__pycache__/_stack.cpython-313.pyc,,
607
+ pip/_vendor/rich/__pycache__/_timer.cpython-313.pyc,,
608
+ pip/_vendor/rich/__pycache__/_win32_console.cpython-313.pyc,,
609
+ pip/_vendor/rich/__pycache__/_windows.cpython-313.pyc,,
610
+ pip/_vendor/rich/__pycache__/_windows_renderer.cpython-313.pyc,,
611
+ pip/_vendor/rich/__pycache__/_wrap.cpython-313.pyc,,
612
+ pip/_vendor/rich/__pycache__/abc.cpython-313.pyc,,
613
+ pip/_vendor/rich/__pycache__/align.cpython-313.pyc,,
614
+ pip/_vendor/rich/__pycache__/ansi.cpython-313.pyc,,
615
+ pip/_vendor/rich/__pycache__/bar.cpython-313.pyc,,
616
+ pip/_vendor/rich/__pycache__/box.cpython-313.pyc,,
617
+ pip/_vendor/rich/__pycache__/cells.cpython-313.pyc,,
618
+ pip/_vendor/rich/__pycache__/color.cpython-313.pyc,,
619
+ pip/_vendor/rich/__pycache__/color_triplet.cpython-313.pyc,,
620
+ pip/_vendor/rich/__pycache__/columns.cpython-313.pyc,,
621
+ pip/_vendor/rich/__pycache__/console.cpython-313.pyc,,
622
+ pip/_vendor/rich/__pycache__/constrain.cpython-313.pyc,,
623
+ pip/_vendor/rich/__pycache__/containers.cpython-313.pyc,,
624
+ pip/_vendor/rich/__pycache__/control.cpython-313.pyc,,
625
+ pip/_vendor/rich/__pycache__/default_styles.cpython-313.pyc,,
626
+ pip/_vendor/rich/__pycache__/diagnose.cpython-313.pyc,,
627
+ pip/_vendor/rich/__pycache__/emoji.cpython-313.pyc,,
628
+ pip/_vendor/rich/__pycache__/errors.cpython-313.pyc,,
629
+ pip/_vendor/rich/__pycache__/file_proxy.cpython-313.pyc,,
630
+ pip/_vendor/rich/__pycache__/filesize.cpython-313.pyc,,
631
+ pip/_vendor/rich/__pycache__/highlighter.cpython-313.pyc,,
632
+ pip/_vendor/rich/__pycache__/json.cpython-313.pyc,,
633
+ pip/_vendor/rich/__pycache__/jupyter.cpython-313.pyc,,
634
+ pip/_vendor/rich/__pycache__/layout.cpython-313.pyc,,
635
+ pip/_vendor/rich/__pycache__/live.cpython-313.pyc,,
636
+ pip/_vendor/rich/__pycache__/live_render.cpython-313.pyc,,
637
+ pip/_vendor/rich/__pycache__/logging.cpython-313.pyc,,
638
+ pip/_vendor/rich/__pycache__/markup.cpython-313.pyc,,
639
+ pip/_vendor/rich/__pycache__/measure.cpython-313.pyc,,
640
+ pip/_vendor/rich/__pycache__/padding.cpython-313.pyc,,
641
+ pip/_vendor/rich/__pycache__/pager.cpython-313.pyc,,
642
+ pip/_vendor/rich/__pycache__/palette.cpython-313.pyc,,
643
+ pip/_vendor/rich/__pycache__/panel.cpython-313.pyc,,
644
+ pip/_vendor/rich/__pycache__/pretty.cpython-313.pyc,,
645
+ pip/_vendor/rich/__pycache__/progress.cpython-313.pyc,,
646
+ pip/_vendor/rich/__pycache__/progress_bar.cpython-313.pyc,,
647
+ pip/_vendor/rich/__pycache__/prompt.cpython-313.pyc,,
648
+ pip/_vendor/rich/__pycache__/protocol.cpython-313.pyc,,
649
+ pip/_vendor/rich/__pycache__/region.cpython-313.pyc,,
650
+ pip/_vendor/rich/__pycache__/repr.cpython-313.pyc,,
651
+ pip/_vendor/rich/__pycache__/rule.cpython-313.pyc,,
652
+ pip/_vendor/rich/__pycache__/scope.cpython-313.pyc,,
653
+ pip/_vendor/rich/__pycache__/screen.cpython-313.pyc,,
654
+ pip/_vendor/rich/__pycache__/segment.cpython-313.pyc,,
655
+ pip/_vendor/rich/__pycache__/spinner.cpython-313.pyc,,
656
+ pip/_vendor/rich/__pycache__/status.cpython-313.pyc,,
657
+ pip/_vendor/rich/__pycache__/style.cpython-313.pyc,,
658
+ pip/_vendor/rich/__pycache__/styled.cpython-313.pyc,,
659
+ pip/_vendor/rich/__pycache__/syntax.cpython-313.pyc,,
660
+ pip/_vendor/rich/__pycache__/table.cpython-313.pyc,,
661
+ pip/_vendor/rich/__pycache__/terminal_theme.cpython-313.pyc,,
662
+ pip/_vendor/rich/__pycache__/text.cpython-313.pyc,,
663
+ pip/_vendor/rich/__pycache__/theme.cpython-313.pyc,,
664
+ pip/_vendor/rich/__pycache__/themes.cpython-313.pyc,,
665
+ pip/_vendor/rich/__pycache__/traceback.cpython-313.pyc,,
666
+ pip/_vendor/rich/__pycache__/tree.cpython-313.pyc,,
667
+ pip/_vendor/rich/_cell_widths.py,sha256=fbmeyetEdHjzE_Vx2l1uK7tnPOhMs2X1lJfO3vsKDpA,10209
668
+ pip/_vendor/rich/_emoji_codes.py,sha256=hu1VL9nbVdppJrVoijVshRlcRRe_v3dju3Mmd2sKZdY,140235
669
+ pip/_vendor/rich/_emoji_replace.py,sha256=n-kcetsEUx2ZUmhQrfeMNc-teeGhpuSQ5F8VPBsyvDo,1064
670
+ pip/_vendor/rich/_export_format.py,sha256=RI08pSrm5tBSzPMvnbTqbD9WIalaOoN5d4M1RTmLq1Y,2128
671
+ pip/_vendor/rich/_extension.py,sha256=Xt47QacCKwYruzjDi-gOBq724JReDj9Cm9xUi5fr-34,265
672
+ pip/_vendor/rich/_fileno.py,sha256=HWZxP5C2ajMbHryvAQZseflVfQoGzsKOHzKGsLD8ynQ,799
673
+ pip/_vendor/rich/_inspect.py,sha256=QM05lEFnFoTaFqpnbx-zBEI6k8oIKrD3cvjEOQNhKig,9655
674
+ pip/_vendor/rich/_log_render.py,sha256=1ByI0PA1ZpxZY3CGJOK54hjlq4X-Bz_boIjIqCd8Kns,3225
675
+ pip/_vendor/rich/_loop.py,sha256=hV_6CLdoPm0va22Wpw4zKqM0RYsz3TZxXj0PoS-9eDQ,1236
676
+ pip/_vendor/rich/_null_file.py,sha256=ADGKp1yt-k70FMKV6tnqCqecB-rSJzp-WQsD7LPL-kg,1394
677
+ pip/_vendor/rich/_palettes.py,sha256=cdev1JQKZ0JvlguV9ipHgznTdnvlIzUFDBb0It2PzjI,7063
678
+ pip/_vendor/rich/_pick.py,sha256=evDt8QN4lF5CiwrUIXlOJCntitBCOsI3ZLPEIAVRLJU,423
679
+ pip/_vendor/rich/_ratio.py,sha256=Zt58apszI6hAAcXPpgdWKpu3c31UBWebOeR4mbyptvU,5471
680
+ pip/_vendor/rich/_spinners.py,sha256=U2r1_g_1zSjsjiUdAESc2iAMc3i4ri_S8PYP6kQ5z1I,19919
681
+ pip/_vendor/rich/_stack.py,sha256=-C8OK7rxn3sIUdVwxZBBpeHhIzX0eI-VM3MemYfaXm0,351
682
+ pip/_vendor/rich/_timer.py,sha256=zelxbT6oPFZnNrwWPpc1ktUeAT-Vc4fuFcRZLQGLtMI,417
683
+ pip/_vendor/rich/_win32_console.py,sha256=BSaDRIMwBLITn_m0mTRLPqME5q-quGdSMuYMpYeYJwc,22755
684
+ pip/_vendor/rich/_windows.py,sha256=aBwaD_S56SbgopIvayVmpk0Y28uwY2C5Bab1wl3Bp-I,1925
685
+ pip/_vendor/rich/_windows_renderer.py,sha256=t74ZL3xuDCP3nmTp9pH1L5LiI2cakJuQRQleHCJerlk,2783
686
+ pip/_vendor/rich/_wrap.py,sha256=FlSsom5EX0LVkA3KWy34yHnCfLtqX-ZIepXKh-70rpc,3404
687
+ pip/_vendor/rich/abc.py,sha256=ON-E-ZqSSheZ88VrKX2M3PXpFbGEUUZPMa_Af0l-4f0,890
688
+ pip/_vendor/rich/align.py,sha256=Rh-3adnDaN1Ao07EjR2PhgE62PGLPgO8SMwJBku1urQ,10469
689
+ pip/_vendor/rich/ansi.py,sha256=Avs1LHbSdcyOvDOdpELZUoULcBiYewY76eNBp6uFBhs,6921
690
+ pip/_vendor/rich/bar.py,sha256=ldbVHOzKJOnflVNuv1xS7g6dLX2E3wMnXkdPbpzJTcs,3263
691
+ pip/_vendor/rich/box.py,sha256=nr5fYIUghB_iUCEq6y0Z3LlCT8gFPDrzN9u2kn7tJl4,10831
692
+ pip/_vendor/rich/cells.py,sha256=KrQkj5-LghCCpJLSNQIyAZjndc4bnEqOEmi5YuZ9UCY,5130
693
+ pip/_vendor/rich/color.py,sha256=3HSULVDj7qQkXUdFWv78JOiSZzfy5y1nkcYhna296V0,18211
694
+ pip/_vendor/rich/color_triplet.py,sha256=3lhQkdJbvWPoLDO-AnYImAWmJvV5dlgYNCVZ97ORaN4,1054
695
+ pip/_vendor/rich/columns.py,sha256=HUX0KcMm9dsKNi11fTbiM_h2iDtl8ySCaVcxlalEzq8,7131
696
+ pip/_vendor/rich/console.py,sha256=_RJizBQIn9qxr4Ln7Q_SC5N9ekPWPAxH0KGVxsgg69Y,100565
697
+ pip/_vendor/rich/constrain.py,sha256=1VIPuC8AgtKWrcncQrjBdYqA3JVWysu6jZo1rrh7c7Q,1288
698
+ pip/_vendor/rich/containers.py,sha256=c_56TxcedGYqDepHBMTuZdUIijitAQgnox-Qde0Z1qo,5502
699
+ pip/_vendor/rich/control.py,sha256=DSkHTUQLorfSERAKE_oTAEUFefZnZp4bQb4q8rHbKws,6630
700
+ pip/_vendor/rich/default_styles.py,sha256=khQFqqaoDs3bprMqWpHw8nO5UpG2DN6QtuTd6LzZwYc,8257
701
+ pip/_vendor/rich/diagnose.py,sha256=WNPjU2pEdrPICJ24KOaTD_hzP839qArpmF1JIM5x_EQ,998
702
+ pip/_vendor/rich/emoji.py,sha256=omTF9asaAnsM4yLY94eR_9dgRRSm1lHUszX20D1yYCQ,2501
703
+ pip/_vendor/rich/errors.py,sha256=5pP3Kc5d4QJ_c0KFsxrfyhjiPVe7J1zOqSFbFAzcV-Y,642
704
+ pip/_vendor/rich/file_proxy.py,sha256=Tl9THMDZ-Pk5Wm8sI1gGg_U5DhusmxD-FZ0fUbcU0W0,1683
705
+ pip/_vendor/rich/filesize.py,sha256=_iz9lIpRgvW7MNSeCZnLg-HwzbP4GETg543WqD8SFs0,2484
706
+ pip/_vendor/rich/highlighter.py,sha256=G_sn-8DKjM1sEjLG_oc4ovkWmiUpWvj8bXi0yed2LnY,9586
707
+ pip/_vendor/rich/json.py,sha256=vVEoKdawoJRjAFayPwXkMBPLy7RSTs-f44wSQDR2nJ0,5031
708
+ pip/_vendor/rich/jupyter.py,sha256=QyoKoE_8IdCbrtiSHp9TsTSNyTHY0FO5whE7jOTd9UE,3252
709
+ pip/_vendor/rich/layout.py,sha256=ajkSFAtEVv9EFTcFs-w4uZfft7nEXhNzL7ZVdgrT5rI,14004
710
+ pip/_vendor/rich/live.py,sha256=DhzAPEnjTxQuq9_0Y2xh2MUwQcP_aGPkenLfKETslwM,14270
711
+ pip/_vendor/rich/live_render.py,sha256=zJtB471jGziBtEwxc54x12wEQtH4BuQr1SA8v9kU82w,3666
712
+ pip/_vendor/rich/logging.py,sha256=ZgpKMMBY_BuMAI_BYzo-UtXak6t5oH9VK8m9Q2Lm0f4,12458
713
+ pip/_vendor/rich/markup.py,sha256=3euGKP5s41NCQwaSjTnJxus5iZMHjxpIM0W6fCxra38,8451
714
+ pip/_vendor/rich/measure.py,sha256=HmrIJX8sWRTHbgh8MxEay_83VkqNW_70s8aKP5ZcYI8,5305
715
+ pip/_vendor/rich/padding.py,sha256=KVEI3tOwo9sgK1YNSuH__M1_jUWmLZwRVV_KmOtVzyM,4908
716
+ pip/_vendor/rich/pager.py,sha256=SO_ETBFKbg3n_AgOzXm41Sv36YxXAyI3_R-KOY2_uSc,828
717
+ pip/_vendor/rich/palette.py,sha256=lInvR1ODDT2f3UZMfL1grq7dY_pDdKHw4bdUgOGaM4Y,3396
718
+ pip/_vendor/rich/panel.py,sha256=SUDaa3z4MU7vIjzvbi0SXuc6BslDzADwdY1AX4TbTdY,11225
719
+ pip/_vendor/rich/pretty.py,sha256=gy3S72u4FRg2ytoo7N1ZDWDIvB4unbzd5iUGdgm-8fc,36391
720
+ pip/_vendor/rich/progress.py,sha256=MtmCjTk5zYU_XtRHxRHTAEHG6hF9PeF7EMWbEPleIC0,60357
721
+ pip/_vendor/rich/progress_bar.py,sha256=mZTPpJUwcfcdgQCTTz3kyY-fc79ddLwtx6Ghhxfo064,8162
722
+ pip/_vendor/rich/prompt.py,sha256=l0RhQU-0UVTV9e08xW1BbIj0Jq2IXyChX4lC0lFNzt4,12447
723
+ pip/_vendor/rich/protocol.py,sha256=5hHHDDNHckdk8iWH5zEbi-zuIVSF5hbU2jIo47R7lTE,1391
724
+ pip/_vendor/rich/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
725
+ pip/_vendor/rich/region.py,sha256=rNT9xZrVZTYIXZC0NYn41CJQwYNbR-KecPOxTgQvB8Y,166
726
+ pip/_vendor/rich/repr.py,sha256=5MZJZmONgC6kud-QW-_m1okXwL2aR6u6y-pUcUCJz28,4431
727
+ pip/_vendor/rich/rule.py,sha256=0fNaS_aERa3UMRc3T5WMpN_sumtDxfaor2y3of1ftBk,4602
728
+ pip/_vendor/rich/scope.py,sha256=TMUU8qo17thyqQCPqjDLYpg_UU1k5qVd-WwiJvnJVas,2843
729
+ pip/_vendor/rich/screen.py,sha256=YoeReESUhx74grqb0mSSb9lghhysWmFHYhsbMVQjXO8,1591
730
+ pip/_vendor/rich/segment.py,sha256=otnKeKGEV-WRlQVosfJVeFDcDxAKHpvJ_hLzSu5lumM,24743
731
+ pip/_vendor/rich/spinner.py,sha256=PT5qgXPG3ZpqRj7n3EZQ6NW56mx3ldZqZCU7gEMyZk4,4364
732
+ pip/_vendor/rich/status.py,sha256=kkPph3YeAZBo-X-4wPp8gTqZyU466NLwZBA4PZTTewo,4424
733
+ pip/_vendor/rich/style.py,sha256=xpj4uMBZMtuNuNomfUiamigl3p1sDvTCZwrG1tcTVeg,27059
734
+ pip/_vendor/rich/styled.py,sha256=eZNnzGrI4ki_54pgY3Oj0T-x3lxdXTYh4_ryDB24wBU,1258
735
+ pip/_vendor/rich/syntax.py,sha256=qqAnEUZ4K57Po81_5RBxnsuU4KRzSdvDPAhKw8ma_3E,35763
736
+ pip/_vendor/rich/table.py,sha256=ZmT7V7MMCOYKw7TGY9SZLyYDf6JdM-WVf07FdVuVhTI,40049
737
+ pip/_vendor/rich/terminal_theme.py,sha256=1j5-ufJfnvlAo5Qsi_ACZiXDmwMXzqgmFByObT9-yJY,3370
738
+ pip/_vendor/rich/text.py,sha256=AO7JPCz6-gaN1thVLXMBntEmDPVYFgFNG1oM61_sanU,47552
739
+ pip/_vendor/rich/theme.py,sha256=oNyhXhGagtDlbDye3tVu3esWOWk0vNkuxFw-_unlaK0,3771
740
+ pip/_vendor/rich/themes.py,sha256=0xgTLozfabebYtcJtDdC5QkX5IVUEaviqDUJJh4YVFk,102
741
+ pip/_vendor/rich/traceback.py,sha256=ZA8Q67DyP5a_stpIh6GPf9IiXj_s3dAhDIr6Zbfkahk,35170
742
+ pip/_vendor/rich/tree.py,sha256=yWnQ6rAvRGJ3qZGqBrxS2SW2TKBTNrP0SdY8QxOFPuw,9451
743
+ pip/_vendor/tomli/__init__.py,sha256=PhNw_eyLgdn7McJ6nrAN8yIm3dXC75vr1sVGVVwDSpA,314
744
+ pip/_vendor/tomli/__pycache__/__init__.cpython-313.pyc,,
745
+ pip/_vendor/tomli/__pycache__/_parser.cpython-313.pyc,,
746
+ pip/_vendor/tomli/__pycache__/_re.cpython-313.pyc,,
747
+ pip/_vendor/tomli/__pycache__/_types.cpython-313.pyc,,
748
+ pip/_vendor/tomli/_parser.py,sha256=9w8LG0jB7fwmZZWB0vVXbeejDHcl4ANIJxB2scEnDlA,25591
749
+ pip/_vendor/tomli/_re.py,sha256=sh4sBDRgO94KJZwNIrgdcyV_qQast50YvzOAUGpRDKA,3171
750
+ pip/_vendor/tomli/_types.py,sha256=-GTG2VUqkpxwMqzmVO4F7ybKddIbAnuAHXfmWQcTi3Q,254
751
+ pip/_vendor/tomli/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
752
+ pip/_vendor/tomli_w/__init__.py,sha256=0F8yDtXx3Uunhm874KrAcP76srsM98y7WyHQwCulZbo,169
753
+ pip/_vendor/tomli_w/__pycache__/__init__.cpython-313.pyc,,
754
+ pip/_vendor/tomli_w/__pycache__/_writer.cpython-313.pyc,,
755
+ pip/_vendor/tomli_w/_writer.py,sha256=dsifFS2xYf1i76mmRyfz9y125xC7Z_HQ845ZKhJsYXs,6961
756
+ pip/_vendor/tomli_w/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
757
+ pip/_vendor/truststore/__init__.py,sha256=2wRSVijjRzPLVXUzWqvdZLNsEOhDfopKLd2EKAYLwKU,1320
758
+ pip/_vendor/truststore/__pycache__/__init__.cpython-313.pyc,,
759
+ pip/_vendor/truststore/__pycache__/_api.cpython-313.pyc,,
760
+ pip/_vendor/truststore/__pycache__/_macos.cpython-313.pyc,,
761
+ pip/_vendor/truststore/__pycache__/_openssl.cpython-313.pyc,,
762
+ pip/_vendor/truststore/__pycache__/_ssl_constants.cpython-313.pyc,,
763
+ pip/_vendor/truststore/__pycache__/_windows.cpython-313.pyc,,
764
+ pip/_vendor/truststore/_api.py,sha256=40I0ojO2DnITiHvOnUYvJ1bfQMBKHOkci14noNxEnCs,11246
765
+ pip/_vendor/truststore/_macos.py,sha256=nZlLkOmszUE0g6ryRwBVGY5COzPyudcsiJtDWarM5LQ,20503
766
+ pip/_vendor/truststore/_openssl.py,sha256=LLUZ7ZGaio-i5dpKKjKCSeSufmn6T8pi9lDcFnvSyq0,2324
767
+ pip/_vendor/truststore/_ssl_constants.py,sha256=NUD4fVKdSD02ri7-db0tnO0VqLP9aHuzmStcW7tAl08,1130
768
+ pip/_vendor/truststore/_windows.py,sha256=rAHyKYD8M7t-bXfG8VgOVa3TpfhVhbt4rZQlO45YuP8,17993
769
+ pip/_vendor/truststore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
770
+ pip/_vendor/typing_extensions.py,sha256=ipKHUPtZCqL6c-HfvGl-9t0opsXcSL72y4GYjyJXs_g,172702
771
+ pip/_vendor/urllib3/__init__.py,sha256=iXLcYiJySn0GNbWOOZDDApgBL1JgP44EZ8i1760S8Mc,3333
772
+ pip/_vendor/urllib3/__pycache__/__init__.cpython-313.pyc,,
773
+ pip/_vendor/urllib3/__pycache__/_collections.cpython-313.pyc,,
774
+ pip/_vendor/urllib3/__pycache__/_version.cpython-313.pyc,,
775
+ pip/_vendor/urllib3/__pycache__/connection.cpython-313.pyc,,
776
+ pip/_vendor/urllib3/__pycache__/connectionpool.cpython-313.pyc,,
777
+ pip/_vendor/urllib3/__pycache__/exceptions.cpython-313.pyc,,
778
+ pip/_vendor/urllib3/__pycache__/fields.cpython-313.pyc,,
779
+ pip/_vendor/urllib3/__pycache__/filepost.cpython-313.pyc,,
780
+ pip/_vendor/urllib3/__pycache__/poolmanager.cpython-313.pyc,,
781
+ pip/_vendor/urllib3/__pycache__/request.cpython-313.pyc,,
782
+ pip/_vendor/urllib3/__pycache__/response.cpython-313.pyc,,
783
+ pip/_vendor/urllib3/_collections.py,sha256=pyASJJhW7wdOpqJj9QJA8FyGRfr8E8uUUhqUvhF0728,11372
784
+ pip/_vendor/urllib3/_version.py,sha256=t9wGB6ooOTXXgiY66K1m6BZS1CJyXHAU8EoWDTe6Shk,64
785
+ pip/_vendor/urllib3/connection.py,sha256=ttIA909BrbTUzwkqEe_TzZVh4JOOj7g61Ysei2mrwGg,20314
786
+ pip/_vendor/urllib3/connectionpool.py,sha256=e2eiAwNbFNCKxj4bwDKNK-w7HIdSz3OmMxU_TIt-evQ,40408
787
+ pip/_vendor/urllib3/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
788
+ pip/_vendor/urllib3/contrib/__pycache__/__init__.cpython-313.pyc,,
789
+ pip/_vendor/urllib3/contrib/__pycache__/_appengine_environ.cpython-313.pyc,,
790
+ pip/_vendor/urllib3/contrib/__pycache__/appengine.cpython-313.pyc,,
791
+ pip/_vendor/urllib3/contrib/__pycache__/ntlmpool.cpython-313.pyc,,
792
+ pip/_vendor/urllib3/contrib/__pycache__/pyopenssl.cpython-313.pyc,,
793
+ pip/_vendor/urllib3/contrib/__pycache__/securetransport.cpython-313.pyc,,
794
+ pip/_vendor/urllib3/contrib/__pycache__/socks.cpython-313.pyc,,
795
+ pip/_vendor/urllib3/contrib/_appengine_environ.py,sha256=bDbyOEhW2CKLJcQqAKAyrEHN-aklsyHFKq6vF8ZFsmk,957
796
+ pip/_vendor/urllib3/contrib/_securetransport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
797
+ pip/_vendor/urllib3/contrib/_securetransport/__pycache__/__init__.cpython-313.pyc,,
798
+ pip/_vendor/urllib3/contrib/_securetransport/__pycache__/bindings.cpython-313.pyc,,
799
+ pip/_vendor/urllib3/contrib/_securetransport/__pycache__/low_level.cpython-313.pyc,,
800
+ pip/_vendor/urllib3/contrib/_securetransport/bindings.py,sha256=4Xk64qIkPBt09A5q-RIFUuDhNc9mXilVapm7WnYnzRw,17632
801
+ pip/_vendor/urllib3/contrib/_securetransport/low_level.py,sha256=B2JBB2_NRP02xK6DCa1Pa9IuxrPwxzDzZbixQkb7U9M,13922
802
+ pip/_vendor/urllib3/contrib/appengine.py,sha256=VR68eAVE137lxTgjBDwCna5UiBZTOKa01Aj_-5BaCz4,11036
803
+ pip/_vendor/urllib3/contrib/ntlmpool.py,sha256=NlfkW7WMdW8ziqudopjHoW299og1BTWi0IeIibquFwk,4528
804
+ pip/_vendor/urllib3/contrib/pyopenssl.py,sha256=hDJh4MhyY_p-oKlFcYcQaVQRDv6GMmBGuW9yjxyeejM,17081
805
+ pip/_vendor/urllib3/contrib/securetransport.py,sha256=Fef1IIUUFHqpevzXiDPbIGkDKchY2FVKeVeLGR1Qq3g,34446
806
+ pip/_vendor/urllib3/contrib/socks.py,sha256=aRi9eWXo9ZEb95XUxef4Z21CFlnnjbEiAo9HOseoMt4,7097
807
+ pip/_vendor/urllib3/exceptions.py,sha256=0Mnno3KHTNfXRfY7638NufOPkUb6mXOm-Lqj-4x2w8A,8217
808
+ pip/_vendor/urllib3/fields.py,sha256=kvLDCg_JmH1lLjUUEY_FLS8UhY7hBvDPuVETbY8mdrM,8579
809
+ pip/_vendor/urllib3/filepost.py,sha256=5b_qqgRHVlL7uLtdAYBzBh-GHmU5AfJVt_2N0XS3PeY,2440
810
+ pip/_vendor/urllib3/packages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
811
+ pip/_vendor/urllib3/packages/__pycache__/__init__.cpython-313.pyc,,
812
+ pip/_vendor/urllib3/packages/__pycache__/six.cpython-313.pyc,,
813
+ pip/_vendor/urllib3/packages/backports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
814
+ pip/_vendor/urllib3/packages/backports/__pycache__/__init__.cpython-313.pyc,,
815
+ pip/_vendor/urllib3/packages/backports/__pycache__/makefile.cpython-313.pyc,,
816
+ pip/_vendor/urllib3/packages/backports/__pycache__/weakref_finalize.cpython-313.pyc,,
817
+ pip/_vendor/urllib3/packages/backports/makefile.py,sha256=nbzt3i0agPVP07jqqgjhaYjMmuAi_W5E0EywZivVO8E,1417
818
+ pip/_vendor/urllib3/packages/backports/weakref_finalize.py,sha256=tRCal5OAhNSRyb0DhHp-38AtIlCsRP8BxF3NX-6rqIA,5343
819
+ pip/_vendor/urllib3/packages/six.py,sha256=b9LM0wBXv7E7SrbCjAm4wwN-hrH-iNxv18LgWNMMKPo,34665
820
+ pip/_vendor/urllib3/poolmanager.py,sha256=aWyhXRtNO4JUnCSVVqKTKQd8EXTvUm1VN9pgs2bcONo,19990
821
+ pip/_vendor/urllib3/request.py,sha256=YTWFNr7QIwh7E1W9dde9LM77v2VWTJ5V78XuTTw7D1A,6691
822
+ pip/_vendor/urllib3/response.py,sha256=fmDJAFkG71uFTn-sVSTh2Iw0WmcXQYqkbRjihvwBjU8,30641
823
+ pip/_vendor/urllib3/util/__init__.py,sha256=JEmSmmqqLyaw8P51gUImZh8Gwg9i1zSe-DoqAitn2nc,1155
824
+ pip/_vendor/urllib3/util/__pycache__/__init__.cpython-313.pyc,,
825
+ pip/_vendor/urllib3/util/__pycache__/connection.cpython-313.pyc,,
826
+ pip/_vendor/urllib3/util/__pycache__/proxy.cpython-313.pyc,,
827
+ pip/_vendor/urllib3/util/__pycache__/queue.cpython-313.pyc,,
828
+ pip/_vendor/urllib3/util/__pycache__/request.cpython-313.pyc,,
829
+ pip/_vendor/urllib3/util/__pycache__/response.cpython-313.pyc,,
830
+ pip/_vendor/urllib3/util/__pycache__/retry.cpython-313.pyc,,
831
+ pip/_vendor/urllib3/util/__pycache__/ssl_.cpython-313.pyc,,
832
+ pip/_vendor/urllib3/util/__pycache__/ssl_match_hostname.cpython-313.pyc,,
833
+ pip/_vendor/urllib3/util/__pycache__/ssltransport.cpython-313.pyc,,
834
+ pip/_vendor/urllib3/util/__pycache__/timeout.cpython-313.pyc,,
835
+ pip/_vendor/urllib3/util/__pycache__/url.cpython-313.pyc,,
836
+ pip/_vendor/urllib3/util/__pycache__/wait.cpython-313.pyc,,
837
+ pip/_vendor/urllib3/util/connection.py,sha256=5Lx2B1PW29KxBn2T0xkN1CBgRBa3gGVJBKoQoRogEVk,4901
838
+ pip/_vendor/urllib3/util/proxy.py,sha256=zUvPPCJrp6dOF0N4GAVbOcl6o-4uXKSrGiTkkr5vUS4,1605
839
+ pip/_vendor/urllib3/util/queue.py,sha256=nRgX8_eX-_VkvxoX096QWoz8Ps0QHUAExILCY_7PncM,498
840
+ pip/_vendor/urllib3/util/request.py,sha256=C0OUt2tcU6LRiQJ7YYNP9GvPrSvl7ziIBekQ-5nlBZk,3997
841
+ pip/_vendor/urllib3/util/response.py,sha256=GJpg3Egi9qaJXRwBh5wv-MNuRWan5BIu40oReoxWP28,3510
842
+ pip/_vendor/urllib3/util/retry.py,sha256=6ENvOZ8PBDzh8kgixpql9lIrb2dxH-k7ZmBanJF2Ng4,22050
843
+ pip/_vendor/urllib3/util/ssl_.py,sha256=QDuuTxPSCj1rYtZ4xpD7Ux-r20TD50aHyqKyhQ7Bq4A,17460
844
+ pip/_vendor/urllib3/util/ssl_match_hostname.py,sha256=Ir4cZVEjmAk8gUAIHWSi7wtOO83UCYABY2xFD1Ql_WA,5758
845
+ pip/_vendor/urllib3/util/ssltransport.py,sha256=NA-u5rMTrDFDFC8QzRKUEKMG0561hOD4qBTr3Z4pv6E,6895
846
+ pip/_vendor/urllib3/util/timeout.py,sha256=cwq4dMk87mJHSBktK1miYJ-85G-3T3RmT20v7SFCpno,10168
847
+ pip/_vendor/urllib3/util/url.py,sha256=lCAE7M5myA8EDdW0sJuyyZhVB9K_j38ljWhHAnFaWoE,14296
848
+ pip/_vendor/urllib3/util/wait.py,sha256=fOX0_faozG2P7iVojQoE1mbydweNyTcm-hXEfFrTtLI,5403
849
+ pip/_vendor/vendor.txt,sha256=Fym1hhuw75IJOl33NPi5nIJJc66DioBSUWrVRIVtRUE,373
850
+ pip/py.typed,sha256=EBVvvPRTn_eIpz5e5QztSCdrMX7Qwd7VP93RSoIlZ2I,286
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/REQUESTED ADDED
File without changes
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/entry_points.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [console_scripts]
2
+ pip = pip._internal.cli.main:main
3
+ pip3 = pip._internal.cli.main:main
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/licenses/AUTHORS.txt ADDED
@@ -0,0 +1,821 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @Switch01
2
+ A_Rog
3
+ Aakanksha Agrawal
4
+ Abhinav Sagar
5
+ ABHYUDAY PRATAP SINGH
6
+ abs51295
7
+ AceGentile
8
+ Adam Chainz
9
+ Adam Tse
10
+ Adam Turner
11
+ Adam Wentz
12
+ admin
13
+ Adolfo Ochagavía
14
+ Adrien Morison
15
+ Agus
16
+ ahayrapetyan
17
+ Ahilya
18
+ AinsworthK
19
+ Akash Srivastava
20
+ Alan Yee
21
+ Albert Tugushev
22
+ Albert-Guan
23
+ albertg
24
+ Alberto Sottile
25
+ Aleks Bunin
26
+ Ales Erjavec
27
+ Alethea Flowers
28
+ Alex Gaynor
29
+ Alex Grönholm
30
+ Alex Hedges
31
+ Alex Loosley
32
+ Alex Morega
33
+ Alex Stachowiak
34
+ Alexander Regueiro
35
+ Alexander Shtyrov
36
+ Alexandre Conrad
37
+ Alexey Popravka
38
+ Aleš Erjavec
39
+ Alli
40
+ Ami Fischman
41
+ Ananya Maiti
42
+ Anatoly Techtonik
43
+ Anders Kaseorg
44
+ Andre Aguiar
45
+ Andreas Lutro
46
+ Andrei Geacar
47
+ Andrew Gaul
48
+ Andrew Shymanel
49
+ Andrey Bienkowski
50
+ Andrey Bulgakov
51
+ Andrés Delfino
52
+ Andy Freeland
53
+ Andy Kluger
54
+ Ani Hayrapetyan
55
+ Aniruddha Basak
56
+ Anish Tambe
57
+ Anrs Hu
58
+ Anthony Sottile
59
+ Antoine Musso
60
+ Anton Ovchinnikov
61
+ Anton Patrushev
62
+ Anton Zelenov
63
+ Antonio Alvarado Hernandez
64
+ Antony Lee
65
+ Antti Kaihola
66
+ Anubhav Patel
67
+ Anudit Nagar
68
+ Anuj Godase
69
+ AQNOUCH Mohammed
70
+ AraHaan
71
+ arena
72
+ arenasys
73
+ Arindam Choudhury
74
+ Armin Ronacher
75
+ Arnon Yaari
76
+ Artem
77
+ Arun Babu Neelicattu
78
+ Ashley Manton
79
+ Ashwin Ramaswami
80
+ atse
81
+ Atsushi Odagiri
82
+ Avinash Karhana
83
+ Avner Cohen
84
+ Awit (Ah-Wit) Ghirmai
85
+ Baptiste Mispelon
86
+ Barney Gale
87
+ barneygale
88
+ Bartek Ogryczak
89
+ Bastian Venthur
90
+ Ben Bodenmiller
91
+ Ben Darnell
92
+ Ben Hoyt
93
+ Ben Mares
94
+ Ben Rosser
95
+ Bence Nagy
96
+ Benjamin Peterson
97
+ Benjamin VanEvery
98
+ Benoit Pierre
99
+ Berker Peksag
100
+ Bernard
101
+ Bernard Tyers
102
+ Bernardo B. Marques
103
+ Bernhard M. Wiedemann
104
+ Bertil Hatt
105
+ Bhavam Vidyarthi
106
+ Blazej Michalik
107
+ Bogdan Opanchuk
108
+ BorisZZZ
109
+ Brad Erickson
110
+ Bradley Ayers
111
+ Bradley Reynolds
112
+ Branch Vincent
113
+ Brandon L. Reiss
114
+ Brandt Bucher
115
+ Brannon Dorsey
116
+ Brett Randall
117
+ Brett Rosen
118
+ Brian Cristante
119
+ Brian Rosner
120
+ briantracy
121
+ BrownTruck
122
+ Bruno Oliveira
123
+ Bruno Renié
124
+ Bruno S
125
+ Bstrdsmkr
126
+ Buck Golemon
127
+ burrows
128
+ Bussonnier Matthias
129
+ bwoodsend
130
+ c22
131
+ Caleb Brown
132
+ Caleb Martinez
133
+ Calvin Smith
134
+ Carl Meyer
135
+ Carlos Liam
136
+ Carol Willing
137
+ Carter Thayer
138
+ Cass
139
+ Chandrasekhar Atina
140
+ Charlie Marsh
141
+ charwick
142
+ Chih-Hsuan Yen
143
+ Chris Brinker
144
+ Chris Hunt
145
+ Chris Jerdonek
146
+ Chris Kuehl
147
+ Chris Markiewicz
148
+ Chris McDonough
149
+ Chris Pawley
150
+ Chris Pryer
151
+ Chris Wolfe
152
+ Christian Clauss
153
+ Christian Heimes
154
+ Christian Oudard
155
+ Christoph Reiter
156
+ Christopher Hunt
157
+ Christopher Snyder
158
+ chrysle
159
+ cjc7373
160
+ Clark Boylan
161
+ Claudio Jolowicz
162
+ Clay McClure
163
+ Cody
164
+ Cody Soyland
165
+ Colin Watson
166
+ Collin Anderson
167
+ Connor Osborn
168
+ Cooper Lees
169
+ Cooper Ry Lees
170
+ Cory Benfield
171
+ Cory Wright
172
+ Craig Kerstiens
173
+ Cristian Sorinel
174
+ Cristina
175
+ Cristina Muñoz
176
+ ctg123
177
+ Curtis Doty
178
+ cytolentino
179
+ Daan De Meyer
180
+ Dale
181
+ Damian
182
+ Damian Quiroga
183
+ Damian Shaw
184
+ Dan Black
185
+ Dan Savilonis
186
+ Dan Sully
187
+ Dane Hillard
188
+ daniel
189
+ Daniel Collins
190
+ Daniel Hahler
191
+ Daniel Holth
192
+ Daniel Jost
193
+ Daniel Katz
194
+ Daniel Shaulov
195
+ Daniele Esposti
196
+ Daniele Nicolodi
197
+ Daniele Procida
198
+ Daniil Konovalenko
199
+ Danny Hermes
200
+ Danny McClanahan
201
+ Darren Kavanagh
202
+ Dav Clark
203
+ Dave Abrahams
204
+ Dave Jones
205
+ David Aguilar
206
+ David Black
207
+ David Bordeynik
208
+ David Caro
209
+ David D Lowe
210
+ David Evans
211
+ David Hewitt
212
+ David Linke
213
+ David Poggi
214
+ David Poznik
215
+ David Pursehouse
216
+ David Runge
217
+ David Tucker
218
+ David Wales
219
+ Davidovich
220
+ ddelange
221
+ Deepak Sharma
222
+ Deepyaman Datta
223
+ Denise Yu
224
+ dependabot[bot]
225
+ derwolfe
226
+ Desetude
227
+ developer
228
+ Devesh Kumar Singh
229
+ devsagul
230
+ Diego Caraballo
231
+ Diego Ramirez
232
+ DiegoCaraballo
233
+ Dimitri Merejkowsky
234
+ Dimitri Papadopoulos
235
+ Dimitri Papadopoulos Orfanos
236
+ Dirk Stolle
237
+ Dmitry Gladkov
238
+ Dmitry Volodin
239
+ Domen Kožar
240
+ Dominic Davis-Foster
241
+ Donald Stufft
242
+ Dongweiming
243
+ doron zarhi
244
+ Dos Moonen
245
+ Douglas Thor
246
+ DrFeathers
247
+ Dustin Ingram
248
+ Dustin Rodrigues
249
+ Dwayne Bailey
250
+ Ed Morley
251
+ Edgar Ramírez
252
+ Edgar Ramírez Mondragón
253
+ Ee Durbin
254
+ Efflam Lemaillet
255
+ efflamlemaillet
256
+ Eitan Adler
257
+ ekristina
258
+ elainechan
259
+ Eli Schwartz
260
+ Elisha Hollander
261
+ Ellen Marie Dash
262
+ Emil Burzo
263
+ Emil Styrke
264
+ Emmanuel Arias
265
+ Endoh Takanao
266
+ enoch
267
+ Erdinc Mutlu
268
+ Eric Cousineau
269
+ Eric Gillingham
270
+ Eric Hanchrow
271
+ Eric Hopper
272
+ Erik M. Bray
273
+ Erik Rose
274
+ Erwin Janssen
275
+ Eugene Vereshchagin
276
+ everdimension
277
+ Federico
278
+ Felipe Peter
279
+ Felix Yan
280
+ fiber-space
281
+ Filip Kokosiński
282
+ Filipe Laíns
283
+ Finn Womack
284
+ finnagin
285
+ Flavio Amurrio
286
+ Florian Briand
287
+ Florian Rathgeber
288
+ Francesco
289
+ Francesco Montesano
290
+ Fredrik Orderud
291
+ Fredrik Roubert
292
+ Frost Ming
293
+ Gabriel Curio
294
+ Gabriel de Perthuis
295
+ Garry Polley
296
+ gavin
297
+ gdanielson
298
+ Geoffrey Sneddon
299
+ George Margaritis
300
+ George Song
301
+ Georgi Valkov
302
+ Georgy Pchelkin
303
+ ghost
304
+ Giftlin Rajaiah
305
+ gizmoguy1
306
+ gkdoc
307
+ Godefroid Chapelle
308
+ Gopinath M
309
+ GOTO Hayato
310
+ gousaiyang
311
+ gpiks
312
+ Greg Roodt
313
+ Greg Ward
314
+ Guilherme Espada
315
+ Guillaume Seguin
316
+ gutsytechster
317
+ Guy Rozendorn
318
+ Guy Tuval
319
+ gzpan123
320
+ Hanjun Kim
321
+ Hari Charan
322
+ Harsh Vardhan
323
+ harupy
324
+ Harutaka Kawamura
325
+ hauntsaninja
326
+ Henrich Hartzer
327
+ Henry Schreiner
328
+ Herbert Pfennig
329
+ Holly Stotelmyer
330
+ Honnix
331
+ Hsiaoming Yang
332
+ Hugo Lopes Tavares
333
+ Hugo van Kemenade
334
+ Hugues Bruant
335
+ Hynek Schlawack
336
+ Ian Bicking
337
+ Ian Cordasco
338
+ Ian Lee
339
+ Ian Stapleton Cordasco
340
+ Ian Wienand
341
+ Igor Kuzmitshov
342
+ Igor Sobreira
343
+ Ikko Ashimine
344
+ Ilan Schnell
345
+ Illia Volochii
346
+ Ilya Baryshev
347
+ Inada Naoki
348
+ Ionel Cristian Mărieș
349
+ Ionel Maries Cristian
350
+ Itamar Turner-Trauring
351
+ iTrooz
352
+ Ivan Pozdeev
353
+ J. Nick Koston
354
+ Jacob Kim
355
+ Jacob Walls
356
+ Jaime Sanz
357
+ Jake Lishman
358
+ jakirkham
359
+ Jakub Kuczys
360
+ Jakub Stasiak
361
+ Jakub Vysoky
362
+ Jakub Wilk
363
+ James Cleveland
364
+ James Curtin
365
+ James Firth
366
+ James Gerity
367
+ James Polley
368
+ Jan Pokorný
369
+ Jannis Leidel
370
+ Jarek Potiuk
371
+ jarondl
372
+ Jason Curtis
373
+ Jason R. Coombs
374
+ JasonMo
375
+ JasonMo1
376
+ Jay Graves
377
+ Jean Abou Samra
378
+ Jean-Christophe Fillion-Robin
379
+ Jeff Barber
380
+ Jeff Dairiki
381
+ Jeff Widman
382
+ Jelmer Vernooij
383
+ jenix21
384
+ Jeremy Fleischman
385
+ Jeremy Stanley
386
+ Jeremy Zafran
387
+ Jesse Rittner
388
+ Jiashuo Li
389
+ Jim Fisher
390
+ Jim Garrison
391
+ Jinzhe Zeng
392
+ Jiun Bae
393
+ Jivan Amara
394
+ Joa
395
+ Joe Bylund
396
+ Joe Michelini
397
+ Johannes Altmanninger
398
+ John Paton
399
+ John Sirois
400
+ John T. Wodder II
401
+ John-Scott Atlakson
402
+ johnthagen
403
+ Jon Banafato
404
+ Jon Dufresne
405
+ Jon Parise
406
+ Jonas Nockert
407
+ Jonathan Herbert
408
+ Joonatan Partanen
409
+ Joost Molenaar
410
+ Jorge Niedbalski
411
+ Joseph Bylund
412
+ Joseph Long
413
+ Josh Bronson
414
+ Josh Cannon
415
+ Josh Hansen
416
+ Josh Schneier
417
+ Joshua
418
+ JoshuaPerdue
419
+ Juan Luis Cano Rodríguez
420
+ Juanjo Bazán
421
+ Judah Rand
422
+ Julian Berman
423
+ Julian Gethmann
424
+ Julien Demoor
425
+ July Tikhonov
426
+ Jussi Kukkonen
427
+ Justin van Heek
428
+ jwg4
429
+ Jyrki Pulliainen
430
+ Kai Chen
431
+ Kai Mueller
432
+ Kamal Bin Mustafa
433
+ Karolina Surma
434
+ kasium
435
+ kaustav haldar
436
+ keanemind
437
+ Keith Maxwell
438
+ Kelsey Hightower
439
+ Kenneth Belitzky
440
+ Kenneth Reitz
441
+ Kevin Burke
442
+ Kevin Carter
443
+ Kevin Frommelt
444
+ Kevin R Patterson
445
+ Kexuan Sun
446
+ Kit Randel
447
+ Klaas van Schelven
448
+ KOLANICH
449
+ konstin
450
+ kpinc
451
+ Krishan Bhasin
452
+ Krishna Oza
453
+ Kumar McMillan
454
+ Kuntal Majumder
455
+ Kurt McKee
456
+ Kyle Persohn
457
+ lakshmanaram
458
+ Laszlo Kiss-Kollar
459
+ Laurent Bristiel
460
+ Laurent LAPORTE
461
+ Laurie O
462
+ Laurie Opperman
463
+ layday
464
+ Leon Sasson
465
+ Lev Givon
466
+ Lincoln de Sousa
467
+ Lipis
468
+ lorddavidiii
469
+ Loren Carvalho
470
+ Lucas Cimon
471
+ Ludovic Gasc
472
+ Luis Medel
473
+ Lukas Geiger
474
+ Lukas Juhrich
475
+ Luke Macken
476
+ Luo Jiebin
477
+ luojiebin
478
+ luz.paz
479
+ László Kiss Kollár
480
+ M00nL1ght
481
+ Malcolm Smith
482
+ Marc Abramowitz
483
+ Marc Tamlyn
484
+ Marcus Smith
485
+ Mariatta
486
+ Mark Kohler
487
+ Mark McLoughlin
488
+ Mark Williams
489
+ Markus Hametner
490
+ Martey Dodoo
491
+ Martin Fischer
492
+ Martin Häcker
493
+ Martin Pavlasek
494
+ Masaki
495
+ Masklinn
496
+ Matej Stuchlik
497
+ Mathew Jennings
498
+ Mathieu Bridon
499
+ Mathieu Kniewallner
500
+ Matt Bacchi
501
+ Matt Good
502
+ Matt Maker
503
+ Matt Robenolt
504
+ Matt Wozniski
505
+ matthew
506
+ Matthew Einhorn
507
+ Matthew Feickert
508
+ Matthew Gilliard
509
+ Matthew Hughes
510
+ Matthew Iversen
511
+ Matthew Treinish
512
+ Matthew Trumbell
513
+ Matthew Willson
514
+ Matthias Bussonnier
515
+ mattip
516
+ Maurits van Rees
517
+ Max W Chase
518
+ Maxim Kurnikov
519
+ Maxime Rouyrre
520
+ mayeut
521
+ mbaluna
522
+ Md Sujauddin Sekh
523
+ mdebi
524
+ memoselyk
525
+ meowmeowcat
526
+ Michael
527
+ Michael Aquilina
528
+ Michael E. Karpeles
529
+ Michael Klich
530
+ Michael Mintz
531
+ Michael Williamson
532
+ michaelpacer
533
+ Michał Górny
534
+ Mickaël Schoentgen
535
+ Miguel Araujo Perez
536
+ Mihir Singh
537
+ Mike
538
+ Mike Hendricks
539
+ Min RK
540
+ MinRK
541
+ Miro Hrončok
542
+ Monica Baluna
543
+ montefra
544
+ Monty Taylor
545
+ morotti
546
+ mrKazzila
547
+ Muha Ajjan
548
+ Nadav Wexler
549
+ Nahuel Ambrosini
550
+ Nate Coraor
551
+ Nate Prewitt
552
+ Nathan Houghton
553
+ Nathaniel J. Smith
554
+ Nehal J Wani
555
+ Neil Botelho
556
+ Nguyễn Gia Phong
557
+ Nicholas Serra
558
+ Nick Coghlan
559
+ Nick Stenning
560
+ Nick Timkovich
561
+ Nicolas Bock
562
+ Nicole Harris
563
+ Nikhil Benesch
564
+ Nikhil Ladha
565
+ Nikita Chepanov
566
+ Nikolay Korolev
567
+ Nipunn Koorapati
568
+ Nitesh Sharma
569
+ Niyas Sait
570
+ Noah
571
+ Noah Gorny
572
+ Nowell Strite
573
+ NtaleGrey
574
+ nucccc
575
+ nvdv
576
+ OBITORASU
577
+ Ofek Lev
578
+ ofrinevo
579
+ Oleg Burnaev
580
+ Oliver Freund
581
+ Oliver Jeeves
582
+ Oliver Mannion
583
+ Oliver Tonnhofer
584
+ Olivier Girardot
585
+ Olivier Grisel
586
+ Ollie Rutherfurd
587
+ OMOTO Kenji
588
+ Omry Yadan
589
+ onlinejudge95
590
+ Oren Held
591
+ Oscar Benjamin
592
+ Oz N Tiram
593
+ Pachwenko
594
+ Patrick Dubroy
595
+ Patrick Jenkins
596
+ Patrick Lawson
597
+ patricktokeeffe
598
+ Patrik Kopkan
599
+ Paul Ganssle
600
+ Paul Kehrer
601
+ Paul Moore
602
+ Paul Nasrat
603
+ Paul Oswald
604
+ Paul van der Linden
605
+ Paulus Schoutsen
606
+ Pavel Safronov
607
+ Pavithra Eswaramoorthy
608
+ Pawel Jasinski
609
+ Paweł Szramowski
610
+ Pekka Klärck
611
+ Peter Gessler
612
+ Peter Lisák
613
+ Peter Shen
614
+ Peter Waller
615
+ Petr Viktorin
616
+ petr-tik
617
+ Phaneendra Chiruvella
618
+ Phil Elson
619
+ Phil Freo
620
+ Phil Pennock
621
+ Phil Whelan
622
+ Philip Jägenstedt
623
+ Philip Molloy
624
+ Philippe Ombredanne
625
+ Pi Delport
626
+ Pierre-Yves Rofes
627
+ Pieter Degroote
628
+ pip
629
+ Prabakaran Kumaresshan
630
+ Prabhjyotsing Surjit Singh Sodhi
631
+ Prabhu Marappan
632
+ Pradyun Gedam
633
+ Prashant Sharma
634
+ Pratik Mallya
635
+ pre-commit-ci[bot]
636
+ Preet Thakkar
637
+ Preston Holmes
638
+ Przemek Wrzos
639
+ Pulkit Goyal
640
+ q0w
641
+ Qiangning Hong
642
+ Qiming Xu
643
+ Quentin Lee
644
+ Quentin Pradet
645
+ R. David Murray
646
+ Rafael Caricio
647
+ Ralf Schmitt
648
+ Ran Benita
649
+ Randy Döring
650
+ Razzi Abuissa
651
+ rdb
652
+ Reece Dunham
653
+ Remi Rampin
654
+ Rene Dudfield
655
+ Riccardo Magliocchetti
656
+ Riccardo Schirone
657
+ Richard Jones
658
+ Richard Si
659
+ Ricky Ng-Adam
660
+ Rishi
661
+ rmorotti
662
+ RobberPhex
663
+ Robert Collins
664
+ Robert McGibbon
665
+ Robert Pollak
666
+ Robert T. McGibbon
667
+ robin elisha robinson
668
+ Roey Berman
669
+ Rohan Jain
670
+ Roman Bogorodskiy
671
+ Roman Donchenko
672
+ Romuald Brunet
673
+ ronaudinho
674
+ Ronny Pfannschmidt
675
+ Rory McCann
676
+ Ross Brattain
677
+ Roy Wellington Ⅳ
678
+ Ruairidh MacLeod
679
+ Russell Keith-Magee
680
+ Ryan Shepherd
681
+ Ryan Wooden
682
+ ryneeverett
683
+ S. Guliaev
684
+ Sachi King
685
+ Salvatore Rinchiera
686
+ sandeepkiran-js
687
+ Sander Van Balen
688
+ Savio Jomton
689
+ schlamar
690
+ Scott Kitterman
691
+ Sean
692
+ seanj
693
+ Sebastian Jordan
694
+ Sebastian Schaetz
695
+ Segev Finer
696
+ SeongSoo Cho
697
+ Sergey Vasilyev
698
+ Seth Michael Larson
699
+ Seth Woodworth
700
+ Shahar Epstein
701
+ Shantanu
702
+ shenxianpeng
703
+ shireenrao
704
+ Shivansh-007
705
+ Shixian Sheng
706
+ Shlomi Fish
707
+ Shovan Maity
708
+ Simeon Visser
709
+ Simon Cross
710
+ Simon Pichugin
711
+ sinoroc
712
+ sinscary
713
+ snook92
714
+ socketubs
715
+ Sorin Sbarnea
716
+ Srinivas Nyayapati
717
+ Srishti Hegde
718
+ Stavros Korokithakis
719
+ Stefan Scherfke
720
+ Stefano Rivera
721
+ Stephan Erb
722
+ Stephen Rosen
723
+ stepshal
724
+ Steve (Gadget) Barnes
725
+ Steve Barnes
726
+ Steve Dower
727
+ Steve Kowalik
728
+ Steven Myint
729
+ Steven Silvester
730
+ stonebig
731
+ studioj
732
+ Stéphane Bidoul
733
+ Stéphane Bidoul (ACSONE)
734
+ Stéphane Klein
735
+ Sumana Harihareswara
736
+ Surbhi Sharma
737
+ Sviatoslav Sydorenko
738
+ Sviatoslav Sydorenko (Святослав Сидоренко)
739
+ Swat009
740
+ Sylvain
741
+ Takayuki SHIMIZUKAWA
742
+ Taneli Hukkinen
743
+ tbeswick
744
+ Thiago
745
+ Thijs Triemstra
746
+ Thomas Fenzl
747
+ Thomas Grainger
748
+ Thomas Guettler
749
+ Thomas Johansson
750
+ Thomas Kluyver
751
+ Thomas Smith
752
+ Thomas VINCENT
753
+ Tim D. Smith
754
+ Tim Gates
755
+ Tim Harder
756
+ Tim Heap
757
+ tim smith
758
+ tinruufu
759
+ Tobias Hermann
760
+ Tom Forbes
761
+ Tom Freudenheim
762
+ Tom V
763
+ Tomas Hrnciar
764
+ Tomas Orsava
765
+ Tomer Chachamu
766
+ Tommi Enenkel | AnB
767
+ Tomáš Hrnčiar
768
+ Tony Beswick
769
+ Tony Narlock
770
+ Tony Zhaocheng Tan
771
+ TonyBeswick
772
+ toonarmycaptain
773
+ Toshio Kuratomi
774
+ toxinu
775
+ Travis Swicegood
776
+ Tushar Sadhwani
777
+ Tzu-ping Chung
778
+ Valentin Haenel
779
+ Victor Stinner
780
+ victorvpaulo
781
+ Vikram - Google
782
+ Viktor Szépe
783
+ Ville Skyttä
784
+ Vinay Sajip
785
+ Vincent Philippon
786
+ Vinicyus Macedo
787
+ Vipul Kumar
788
+ Vitaly Babiy
789
+ Vladimir Fokow
790
+ Vladimir Rutsky
791
+ W. Trevor King
792
+ Wil Tan
793
+ Wilfred Hughes
794
+ William Edwards
795
+ William ML Leslie
796
+ William T Olson
797
+ William Woodruff
798
+ Wilson Mo
799
+ wim glenn
800
+ Winson Luk
801
+ Wolfgang Maier
802
+ Wu Zhenyu
803
+ XAMES3
804
+ Xavier Fernandez
805
+ Xianpeng Shen
806
+ xoviat
807
+ xtreak
808
+ YAMAMOTO Takashi
809
+ Yen Chi Hsuan
810
+ Yeray Diaz Diaz
811
+ Yoval P
812
+ Yu Jian
813
+ Yuan Jing Vincent Yan
814
+ Yusuke Hayashi
815
+ Zearin
816
+ Zhiping Deng
817
+ ziebam
818
+ Zvezdan Petkovic
819
+ Łukasz Langa
820
+ Роман Донченко
821
+ Семён Марьясин
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/licenses/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2008-present The pip developers (see AUTHORS.txt file)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.venv/lib/python3.13/site-packages/pip-25.1.1.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
.venv/lib/python3.13/site-packages/pip/_vendor/rich/jupyter.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence
2
+
3
+ if TYPE_CHECKING:
4
+ from pip._vendor.rich.console import ConsoleRenderable
5
+
6
+ from . import get_console
7
+ from .segment import Segment
8
+ from .terminal_theme import DEFAULT_TERMINAL_THEME
9
+
10
+ if TYPE_CHECKING:
11
+ from pip._vendor.rich.console import ConsoleRenderable
12
+
13
+ JUPYTER_HTML_FORMAT = """\
14
+ <pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">{code}</pre>
15
+ """
16
+
17
+
18
+ class JupyterRenderable:
19
+ """A shim to write html to Jupyter notebook."""
20
+
21
+ def __init__(self, html: str, text: str) -> None:
22
+ self.html = html
23
+ self.text = text
24
+
25
+ def _repr_mimebundle_(
26
+ self, include: Sequence[str], exclude: Sequence[str], **kwargs: Any
27
+ ) -> Dict[str, str]:
28
+ data = {"text/plain": self.text, "text/html": self.html}
29
+ if include:
30
+ data = {k: v for (k, v) in data.items() if k in include}
31
+ if exclude:
32
+ data = {k: v for (k, v) in data.items() if k not in exclude}
33
+ return data
34
+
35
+
36
+ class JupyterMixin:
37
+ """Add to an Rich renderable to make it render in Jupyter notebook."""
38
+
39
+ __slots__ = ()
40
+
41
+ def _repr_mimebundle_(
42
+ self: "ConsoleRenderable",
43
+ include: Sequence[str],
44
+ exclude: Sequence[str],
45
+ **kwargs: Any,
46
+ ) -> Dict[str, str]:
47
+ console = get_console()
48
+ segments = list(console.render(self, console.options))
49
+ html = _render_segments(segments)
50
+ text = console._render_buffer(segments)
51
+ data = {"text/plain": text, "text/html": html}
52
+ if include:
53
+ data = {k: v for (k, v) in data.items() if k in include}
54
+ if exclude:
55
+ data = {k: v for (k, v) in data.items() if k not in exclude}
56
+ return data
57
+
58
+
59
+ def _render_segments(segments: Iterable[Segment]) -> str:
60
+ def escape(text: str) -> str:
61
+ """Escape html."""
62
+ return text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
63
+
64
+ fragments: List[str] = []
65
+ append_fragment = fragments.append
66
+ theme = DEFAULT_TERMINAL_THEME
67
+ for text, style, control in Segment.simplify(segments):
68
+ if control:
69
+ continue
70
+ text = escape(text)
71
+ if style:
72
+ rule = style.get_html_style(theme)
73
+ text = f'<span style="{rule}">{text}</span>' if rule else text
74
+ if style.link:
75
+ text = f'<a href="{style.link}" target="_blank">{text}</a>'
76
+ append_fragment(text)
77
+
78
+ code = "".join(fragments)
79
+ html = JUPYTER_HTML_FORMAT.format(code=code)
80
+
81
+ return html
82
+
83
+
84
+ def display(segments: Iterable[Segment], text: str) -> None:
85
+ """Render segments to Jupyter."""
86
+ html = _render_segments(segments)
87
+ jupyter_renderable = JupyterRenderable(html, text)
88
+ try:
89
+ from IPython.display import display as ipython_display
90
+
91
+ ipython_display(jupyter_renderable)
92
+ except ModuleNotFoundError:
93
+ # Handle the case where the Console has force_jupyter=True,
94
+ # but IPython is not installed.
95
+ pass
96
+
97
+
98
+ def print(*args: Any, **kwargs: Any) -> None:
99
+ """Proxy for Console print."""
100
+ console = get_console()
101
+ return console.print(*args, **kwargs)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/layout.py ADDED
@@ -0,0 +1,442 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ from itertools import islice
3
+ from operator import itemgetter
4
+ from threading import RLock
5
+ from typing import (
6
+ TYPE_CHECKING,
7
+ Dict,
8
+ Iterable,
9
+ List,
10
+ NamedTuple,
11
+ Optional,
12
+ Sequence,
13
+ Tuple,
14
+ Union,
15
+ )
16
+
17
+ from ._ratio import ratio_resolve
18
+ from .align import Align
19
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
20
+ from .highlighter import ReprHighlighter
21
+ from .panel import Panel
22
+ from .pretty import Pretty
23
+ from .region import Region
24
+ from .repr import Result, rich_repr
25
+ from .segment import Segment
26
+ from .style import StyleType
27
+
28
+ if TYPE_CHECKING:
29
+ from pip._vendor.rich.tree import Tree
30
+
31
+
32
+ class LayoutRender(NamedTuple):
33
+ """An individual layout render."""
34
+
35
+ region: Region
36
+ render: List[List[Segment]]
37
+
38
+
39
+ RegionMap = Dict["Layout", Region]
40
+ RenderMap = Dict["Layout", LayoutRender]
41
+
42
+
43
+ class LayoutError(Exception):
44
+ """Layout related error."""
45
+
46
+
47
+ class NoSplitter(LayoutError):
48
+ """Requested splitter does not exist."""
49
+
50
+
51
+ class _Placeholder:
52
+ """An internal renderable used as a Layout placeholder."""
53
+
54
+ highlighter = ReprHighlighter()
55
+
56
+ def __init__(self, layout: "Layout", style: StyleType = "") -> None:
57
+ self.layout = layout
58
+ self.style = style
59
+
60
+ def __rich_console__(
61
+ self, console: Console, options: ConsoleOptions
62
+ ) -> RenderResult:
63
+ width = options.max_width
64
+ height = options.height or options.size.height
65
+ layout = self.layout
66
+ title = (
67
+ f"{layout.name!r} ({width} x {height})"
68
+ if layout.name
69
+ else f"({width} x {height})"
70
+ )
71
+ yield Panel(
72
+ Align.center(Pretty(layout), vertical="middle"),
73
+ style=self.style,
74
+ title=self.highlighter(title),
75
+ border_style="blue",
76
+ height=height,
77
+ )
78
+
79
+
80
+ class Splitter(ABC):
81
+ """Base class for a splitter."""
82
+
83
+ name: str = ""
84
+
85
+ @abstractmethod
86
+ def get_tree_icon(self) -> str:
87
+ """Get the icon (emoji) used in layout.tree"""
88
+
89
+ @abstractmethod
90
+ def divide(
91
+ self, children: Sequence["Layout"], region: Region
92
+ ) -> Iterable[Tuple["Layout", Region]]:
93
+ """Divide a region amongst several child layouts.
94
+
95
+ Args:
96
+ children (Sequence(Layout)): A number of child layouts.
97
+ region (Region): A rectangular region to divide.
98
+ """
99
+
100
+
101
+ class RowSplitter(Splitter):
102
+ """Split a layout region in to rows."""
103
+
104
+ name = "row"
105
+
106
+ def get_tree_icon(self) -> str:
107
+ return "[layout.tree.row]⬌"
108
+
109
+ def divide(
110
+ self, children: Sequence["Layout"], region: Region
111
+ ) -> Iterable[Tuple["Layout", Region]]:
112
+ x, y, width, height = region
113
+ render_widths = ratio_resolve(width, children)
114
+ offset = 0
115
+ _Region = Region
116
+ for child, child_width in zip(children, render_widths):
117
+ yield child, _Region(x + offset, y, child_width, height)
118
+ offset += child_width
119
+
120
+
121
+ class ColumnSplitter(Splitter):
122
+ """Split a layout region in to columns."""
123
+
124
+ name = "column"
125
+
126
+ def get_tree_icon(self) -> str:
127
+ return "[layout.tree.column]⬍"
128
+
129
+ def divide(
130
+ self, children: Sequence["Layout"], region: Region
131
+ ) -> Iterable[Tuple["Layout", Region]]:
132
+ x, y, width, height = region
133
+ render_heights = ratio_resolve(height, children)
134
+ offset = 0
135
+ _Region = Region
136
+ for child, child_height in zip(children, render_heights):
137
+ yield child, _Region(x, y + offset, width, child_height)
138
+ offset += child_height
139
+
140
+
141
+ @rich_repr
142
+ class Layout:
143
+ """A renderable to divide a fixed height in to rows or columns.
144
+
145
+ Args:
146
+ renderable (RenderableType, optional): Renderable content, or None for placeholder. Defaults to None.
147
+ name (str, optional): Optional identifier for Layout. Defaults to None.
148
+ size (int, optional): Optional fixed size of layout. Defaults to None.
149
+ minimum_size (int, optional): Minimum size of layout. Defaults to 1.
150
+ ratio (int, optional): Optional ratio for flexible layout. Defaults to 1.
151
+ visible (bool, optional): Visibility of layout. Defaults to True.
152
+ """
153
+
154
+ splitters = {"row": RowSplitter, "column": ColumnSplitter}
155
+
156
+ def __init__(
157
+ self,
158
+ renderable: Optional[RenderableType] = None,
159
+ *,
160
+ name: Optional[str] = None,
161
+ size: Optional[int] = None,
162
+ minimum_size: int = 1,
163
+ ratio: int = 1,
164
+ visible: bool = True,
165
+ ) -> None:
166
+ self._renderable = renderable or _Placeholder(self)
167
+ self.size = size
168
+ self.minimum_size = minimum_size
169
+ self.ratio = ratio
170
+ self.name = name
171
+ self.visible = visible
172
+ self.splitter: Splitter = self.splitters["column"]()
173
+ self._children: List[Layout] = []
174
+ self._render_map: RenderMap = {}
175
+ self._lock = RLock()
176
+
177
+ def __rich_repr__(self) -> Result:
178
+ yield "name", self.name, None
179
+ yield "size", self.size, None
180
+ yield "minimum_size", self.minimum_size, 1
181
+ yield "ratio", self.ratio, 1
182
+
183
+ @property
184
+ def renderable(self) -> RenderableType:
185
+ """Layout renderable."""
186
+ return self if self._children else self._renderable
187
+
188
+ @property
189
+ def children(self) -> List["Layout"]:
190
+ """Gets (visible) layout children."""
191
+ return [child for child in self._children if child.visible]
192
+
193
+ @property
194
+ def map(self) -> RenderMap:
195
+ """Get a map of the last render."""
196
+ return self._render_map
197
+
198
+ def get(self, name: str) -> Optional["Layout"]:
199
+ """Get a named layout, or None if it doesn't exist.
200
+
201
+ Args:
202
+ name (str): Name of layout.
203
+
204
+ Returns:
205
+ Optional[Layout]: Layout instance or None if no layout was found.
206
+ """
207
+ if self.name == name:
208
+ return self
209
+ else:
210
+ for child in self._children:
211
+ named_layout = child.get(name)
212
+ if named_layout is not None:
213
+ return named_layout
214
+ return None
215
+
216
+ def __getitem__(self, name: str) -> "Layout":
217
+ layout = self.get(name)
218
+ if layout is None:
219
+ raise KeyError(f"No layout with name {name!r}")
220
+ return layout
221
+
222
+ @property
223
+ def tree(self) -> "Tree":
224
+ """Get a tree renderable to show layout structure."""
225
+ from pip._vendor.rich.styled import Styled
226
+ from pip._vendor.rich.table import Table
227
+ from pip._vendor.rich.tree import Tree
228
+
229
+ def summary(layout: "Layout") -> Table:
230
+ icon = layout.splitter.get_tree_icon()
231
+
232
+ table = Table.grid(padding=(0, 1, 0, 0))
233
+
234
+ text: RenderableType = (
235
+ Pretty(layout) if layout.visible else Styled(Pretty(layout), "dim")
236
+ )
237
+ table.add_row(icon, text)
238
+ _summary = table
239
+ return _summary
240
+
241
+ layout = self
242
+ tree = Tree(
243
+ summary(layout),
244
+ guide_style=f"layout.tree.{layout.splitter.name}",
245
+ highlight=True,
246
+ )
247
+
248
+ def recurse(tree: "Tree", layout: "Layout") -> None:
249
+ for child in layout._children:
250
+ recurse(
251
+ tree.add(
252
+ summary(child),
253
+ guide_style=f"layout.tree.{child.splitter.name}",
254
+ ),
255
+ child,
256
+ )
257
+
258
+ recurse(tree, self)
259
+ return tree
260
+
261
+ def split(
262
+ self,
263
+ *layouts: Union["Layout", RenderableType],
264
+ splitter: Union[Splitter, str] = "column",
265
+ ) -> None:
266
+ """Split the layout in to multiple sub-layouts.
267
+
268
+ Args:
269
+ *layouts (Layout): Positional arguments should be (sub) Layout instances.
270
+ splitter (Union[Splitter, str]): Splitter instance or name of splitter.
271
+ """
272
+ _layouts = [
273
+ layout if isinstance(layout, Layout) else Layout(layout)
274
+ for layout in layouts
275
+ ]
276
+ try:
277
+ self.splitter = (
278
+ splitter
279
+ if isinstance(splitter, Splitter)
280
+ else self.splitters[splitter]()
281
+ )
282
+ except KeyError:
283
+ raise NoSplitter(f"No splitter called {splitter!r}")
284
+ self._children[:] = _layouts
285
+
286
+ def add_split(self, *layouts: Union["Layout", RenderableType]) -> None:
287
+ """Add a new layout(s) to existing split.
288
+
289
+ Args:
290
+ *layouts (Union[Layout, RenderableType]): Positional arguments should be renderables or (sub) Layout instances.
291
+
292
+ """
293
+ _layouts = (
294
+ layout if isinstance(layout, Layout) else Layout(layout)
295
+ for layout in layouts
296
+ )
297
+ self._children.extend(_layouts)
298
+
299
+ def split_row(self, *layouts: Union["Layout", RenderableType]) -> None:
300
+ """Split the layout in to a row (layouts side by side).
301
+
302
+ Args:
303
+ *layouts (Layout): Positional arguments should be (sub) Layout instances.
304
+ """
305
+ self.split(*layouts, splitter="row")
306
+
307
+ def split_column(self, *layouts: Union["Layout", RenderableType]) -> None:
308
+ """Split the layout in to a column (layouts stacked on top of each other).
309
+
310
+ Args:
311
+ *layouts (Layout): Positional arguments should be (sub) Layout instances.
312
+ """
313
+ self.split(*layouts, splitter="column")
314
+
315
+ def unsplit(self) -> None:
316
+ """Reset splits to initial state."""
317
+ del self._children[:]
318
+
319
+ def update(self, renderable: RenderableType) -> None:
320
+ """Update renderable.
321
+
322
+ Args:
323
+ renderable (RenderableType): New renderable object.
324
+ """
325
+ with self._lock:
326
+ self._renderable = renderable
327
+
328
+ def refresh_screen(self, console: "Console", layout_name: str) -> None:
329
+ """Refresh a sub-layout.
330
+
331
+ Args:
332
+ console (Console): Console instance where Layout is to be rendered.
333
+ layout_name (str): Name of layout.
334
+ """
335
+ with self._lock:
336
+ layout = self[layout_name]
337
+ region, _lines = self._render_map[layout]
338
+ (x, y, width, height) = region
339
+ lines = console.render_lines(
340
+ layout, console.options.update_dimensions(width, height)
341
+ )
342
+ self._render_map[layout] = LayoutRender(region, lines)
343
+ console.update_screen_lines(lines, x, y)
344
+
345
+ def _make_region_map(self, width: int, height: int) -> RegionMap:
346
+ """Create a dict that maps layout on to Region."""
347
+ stack: List[Tuple[Layout, Region]] = [(self, Region(0, 0, width, height))]
348
+ push = stack.append
349
+ pop = stack.pop
350
+ layout_regions: List[Tuple[Layout, Region]] = []
351
+ append_layout_region = layout_regions.append
352
+ while stack:
353
+ append_layout_region(pop())
354
+ layout, region = layout_regions[-1]
355
+ children = layout.children
356
+ if children:
357
+ for child_and_region in layout.splitter.divide(children, region):
358
+ push(child_and_region)
359
+
360
+ region_map = {
361
+ layout: region
362
+ for layout, region in sorted(layout_regions, key=itemgetter(1))
363
+ }
364
+ return region_map
365
+
366
+ def render(self, console: Console, options: ConsoleOptions) -> RenderMap:
367
+ """Render the sub_layouts.
368
+
369
+ Args:
370
+ console (Console): Console instance.
371
+ options (ConsoleOptions): Console options.
372
+
373
+ Returns:
374
+ RenderMap: A dict that maps Layout on to a tuple of Region, lines
375
+ """
376
+ render_width = options.max_width
377
+ render_height = options.height or console.height
378
+ region_map = self._make_region_map(render_width, render_height)
379
+ layout_regions = [
380
+ (layout, region)
381
+ for layout, region in region_map.items()
382
+ if not layout.children
383
+ ]
384
+ render_map: Dict["Layout", "LayoutRender"] = {}
385
+ render_lines = console.render_lines
386
+ update_dimensions = options.update_dimensions
387
+
388
+ for layout, region in layout_regions:
389
+ lines = render_lines(
390
+ layout.renderable, update_dimensions(region.width, region.height)
391
+ )
392
+ render_map[layout] = LayoutRender(region, lines)
393
+ return render_map
394
+
395
+ def __rich_console__(
396
+ self, console: Console, options: ConsoleOptions
397
+ ) -> RenderResult:
398
+ with self._lock:
399
+ width = options.max_width or console.width
400
+ height = options.height or console.height
401
+ render_map = self.render(console, options.update_dimensions(width, height))
402
+ self._render_map = render_map
403
+ layout_lines: List[List[Segment]] = [[] for _ in range(height)]
404
+ _islice = islice
405
+ for region, lines in render_map.values():
406
+ _x, y, _layout_width, layout_height = region
407
+ for row, line in zip(
408
+ _islice(layout_lines, y, y + layout_height), lines
409
+ ):
410
+ row.extend(line)
411
+
412
+ new_line = Segment.line()
413
+ for layout_row in layout_lines:
414
+ yield from layout_row
415
+ yield new_line
416
+
417
+
418
+ if __name__ == "__main__":
419
+ from pip._vendor.rich.console import Console
420
+
421
+ console = Console()
422
+ layout = Layout()
423
+
424
+ layout.split_column(
425
+ Layout(name="header", size=3),
426
+ Layout(ratio=1, name="main"),
427
+ Layout(size=10, name="footer"),
428
+ )
429
+
430
+ layout["main"].split_row(Layout(name="side"), Layout(name="body", ratio=2))
431
+
432
+ layout["body"].split_row(Layout(name="content", ratio=2), Layout(name="s2"))
433
+
434
+ layout["s2"].split_column(
435
+ Layout(name="top"), Layout(name="middle"), Layout(name="bottom")
436
+ )
437
+
438
+ layout["side"].split_column(Layout(layout.tree, name="left1"), Layout(name="left2"))
439
+
440
+ layout["content"].update("foo")
441
+
442
+ console.print(layout)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/live.py ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from threading import Event, RLock, Thread
3
+ from types import TracebackType
4
+ from typing import IO, Any, Callable, List, Optional, TextIO, Type, cast
5
+
6
+ from . import get_console
7
+ from .console import Console, ConsoleRenderable, RenderableType, RenderHook
8
+ from .control import Control
9
+ from .file_proxy import FileProxy
10
+ from .jupyter import JupyterMixin
11
+ from .live_render import LiveRender, VerticalOverflowMethod
12
+ from .screen import Screen
13
+ from .text import Text
14
+
15
+
16
+ class _RefreshThread(Thread):
17
+ """A thread that calls refresh() at regular intervals."""
18
+
19
+ def __init__(self, live: "Live", refresh_per_second: float) -> None:
20
+ self.live = live
21
+ self.refresh_per_second = refresh_per_second
22
+ self.done = Event()
23
+ super().__init__(daemon=True)
24
+
25
+ def stop(self) -> None:
26
+ self.done.set()
27
+
28
+ def run(self) -> None:
29
+ while not self.done.wait(1 / self.refresh_per_second):
30
+ with self.live._lock:
31
+ if not self.done.is_set():
32
+ self.live.refresh()
33
+
34
+
35
+ class Live(JupyterMixin, RenderHook):
36
+ """Renders an auto-updating live display of any given renderable.
37
+
38
+ Args:
39
+ renderable (RenderableType, optional): The renderable to live display. Defaults to displaying nothing.
40
+ console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout.
41
+ screen (bool, optional): Enable alternate screen mode. Defaults to False.
42
+ auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()` or `update()` with refresh flag. Defaults to True
43
+ refresh_per_second (float, optional): Number of times per second to refresh the live display. Defaults to 4.
44
+ transient (bool, optional): Clear the renderable on exit (has no effect when screen=True). Defaults to False.
45
+ redirect_stdout (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
46
+ redirect_stderr (bool, optional): Enable redirection of stderr. Defaults to True.
47
+ vertical_overflow (VerticalOverflowMethod, optional): How to handle renderable when it is too tall for the console. Defaults to "ellipsis".
48
+ get_renderable (Callable[[], RenderableType], optional): Optional callable to get renderable. Defaults to None.
49
+ """
50
+
51
+ def __init__(
52
+ self,
53
+ renderable: Optional[RenderableType] = None,
54
+ *,
55
+ console: Optional[Console] = None,
56
+ screen: bool = False,
57
+ auto_refresh: bool = True,
58
+ refresh_per_second: float = 4,
59
+ transient: bool = False,
60
+ redirect_stdout: bool = True,
61
+ redirect_stderr: bool = True,
62
+ vertical_overflow: VerticalOverflowMethod = "ellipsis",
63
+ get_renderable: Optional[Callable[[], RenderableType]] = None,
64
+ ) -> None:
65
+ assert refresh_per_second > 0, "refresh_per_second must be > 0"
66
+ self._renderable = renderable
67
+ self.console = console if console is not None else get_console()
68
+ self._screen = screen
69
+ self._alt_screen = False
70
+
71
+ self._redirect_stdout = redirect_stdout
72
+ self._redirect_stderr = redirect_stderr
73
+ self._restore_stdout: Optional[IO[str]] = None
74
+ self._restore_stderr: Optional[IO[str]] = None
75
+
76
+ self._lock = RLock()
77
+ self.ipy_widget: Optional[Any] = None
78
+ self.auto_refresh = auto_refresh
79
+ self._started: bool = False
80
+ self.transient = True if screen else transient
81
+
82
+ self._refresh_thread: Optional[_RefreshThread] = None
83
+ self.refresh_per_second = refresh_per_second
84
+
85
+ self.vertical_overflow = vertical_overflow
86
+ self._get_renderable = get_renderable
87
+ self._live_render = LiveRender(
88
+ self.get_renderable(), vertical_overflow=vertical_overflow
89
+ )
90
+
91
+ @property
92
+ def is_started(self) -> bool:
93
+ """Check if live display has been started."""
94
+ return self._started
95
+
96
+ def get_renderable(self) -> RenderableType:
97
+ renderable = (
98
+ self._get_renderable()
99
+ if self._get_renderable is not None
100
+ else self._renderable
101
+ )
102
+ return renderable or ""
103
+
104
+ def start(self, refresh: bool = False) -> None:
105
+ """Start live rendering display.
106
+
107
+ Args:
108
+ refresh (bool, optional): Also refresh. Defaults to False.
109
+ """
110
+ with self._lock:
111
+ if self._started:
112
+ return
113
+ self.console.set_live(self)
114
+ self._started = True
115
+ if self._screen:
116
+ self._alt_screen = self.console.set_alt_screen(True)
117
+ self.console.show_cursor(False)
118
+ self._enable_redirect_io()
119
+ self.console.push_render_hook(self)
120
+ if refresh:
121
+ try:
122
+ self.refresh()
123
+ except Exception:
124
+ # If refresh fails, we want to stop the redirection of sys.stderr,
125
+ # so the error stacktrace is properly displayed in the terminal.
126
+ # (or, if the code that calls Rich captures the exception and wants to display something,
127
+ # let this be displayed in the terminal).
128
+ self.stop()
129
+ raise
130
+ if self.auto_refresh:
131
+ self._refresh_thread = _RefreshThread(self, self.refresh_per_second)
132
+ self._refresh_thread.start()
133
+
134
+ def stop(self) -> None:
135
+ """Stop live rendering display."""
136
+ with self._lock:
137
+ if not self._started:
138
+ return
139
+ self.console.clear_live()
140
+ self._started = False
141
+
142
+ if self.auto_refresh and self._refresh_thread is not None:
143
+ self._refresh_thread.stop()
144
+ self._refresh_thread = None
145
+ # allow it to fully render on the last even if overflow
146
+ self.vertical_overflow = "visible"
147
+ with self.console:
148
+ try:
149
+ if not self._alt_screen and not self.console.is_jupyter:
150
+ self.refresh()
151
+ finally:
152
+ self._disable_redirect_io()
153
+ self.console.pop_render_hook()
154
+ if not self._alt_screen and self.console.is_terminal:
155
+ self.console.line()
156
+ self.console.show_cursor(True)
157
+ if self._alt_screen:
158
+ self.console.set_alt_screen(False)
159
+
160
+ if self.transient and not self._alt_screen:
161
+ self.console.control(self._live_render.restore_cursor())
162
+ if self.ipy_widget is not None and self.transient:
163
+ self.ipy_widget.close() # pragma: no cover
164
+
165
+ def __enter__(self) -> "Live":
166
+ self.start(refresh=self._renderable is not None)
167
+ return self
168
+
169
+ def __exit__(
170
+ self,
171
+ exc_type: Optional[Type[BaseException]],
172
+ exc_val: Optional[BaseException],
173
+ exc_tb: Optional[TracebackType],
174
+ ) -> None:
175
+ self.stop()
176
+
177
+ def _enable_redirect_io(self) -> None:
178
+ """Enable redirecting of stdout / stderr."""
179
+ if self.console.is_terminal or self.console.is_jupyter:
180
+ if self._redirect_stdout and not isinstance(sys.stdout, FileProxy):
181
+ self._restore_stdout = sys.stdout
182
+ sys.stdout = cast("TextIO", FileProxy(self.console, sys.stdout))
183
+ if self._redirect_stderr and not isinstance(sys.stderr, FileProxy):
184
+ self._restore_stderr = sys.stderr
185
+ sys.stderr = cast("TextIO", FileProxy(self.console, sys.stderr))
186
+
187
+ def _disable_redirect_io(self) -> None:
188
+ """Disable redirecting of stdout / stderr."""
189
+ if self._restore_stdout:
190
+ sys.stdout = cast("TextIO", self._restore_stdout)
191
+ self._restore_stdout = None
192
+ if self._restore_stderr:
193
+ sys.stderr = cast("TextIO", self._restore_stderr)
194
+ self._restore_stderr = None
195
+
196
+ @property
197
+ def renderable(self) -> RenderableType:
198
+ """Get the renderable that is being displayed
199
+
200
+ Returns:
201
+ RenderableType: Displayed renderable.
202
+ """
203
+ renderable = self.get_renderable()
204
+ return Screen(renderable) if self._alt_screen else renderable
205
+
206
+ def update(self, renderable: RenderableType, *, refresh: bool = False) -> None:
207
+ """Update the renderable that is being displayed
208
+
209
+ Args:
210
+ renderable (RenderableType): New renderable to use.
211
+ refresh (bool, optional): Refresh the display. Defaults to False.
212
+ """
213
+ if isinstance(renderable, str):
214
+ renderable = self.console.render_str(renderable)
215
+ with self._lock:
216
+ self._renderable = renderable
217
+ if refresh:
218
+ self.refresh()
219
+
220
+ def refresh(self) -> None:
221
+ """Update the display of the Live Render."""
222
+ with self._lock:
223
+ self._live_render.set_renderable(self.renderable)
224
+ if self.console.is_jupyter: # pragma: no cover
225
+ try:
226
+ from IPython.display import display
227
+ from ipywidgets import Output
228
+ except ImportError:
229
+ import warnings
230
+
231
+ warnings.warn('install "ipywidgets" for Jupyter support')
232
+ else:
233
+ if self.ipy_widget is None:
234
+ self.ipy_widget = Output()
235
+ display(self.ipy_widget)
236
+
237
+ with self.ipy_widget:
238
+ self.ipy_widget.clear_output(wait=True)
239
+ self.console.print(self._live_render.renderable)
240
+ elif self.console.is_terminal and not self.console.is_dumb_terminal:
241
+ with self.console:
242
+ self.console.print(Control())
243
+ elif (
244
+ not self._started and not self.transient
245
+ ): # if it is finished allow files or dumb-terminals to see final result
246
+ with self.console:
247
+ self.console.print(Control())
248
+
249
+ def process_renderables(
250
+ self, renderables: List[ConsoleRenderable]
251
+ ) -> List[ConsoleRenderable]:
252
+ """Process renderables to restore cursor and display progress."""
253
+ self._live_render.vertical_overflow = self.vertical_overflow
254
+ if self.console.is_interactive:
255
+ # lock needs acquiring as user can modify live_render renderable at any time unlike in Progress.
256
+ with self._lock:
257
+ reset = (
258
+ Control.home()
259
+ if self._alt_screen
260
+ else self._live_render.position_cursor()
261
+ )
262
+ renderables = [reset, *renderables, self._live_render]
263
+ elif (
264
+ not self._started and not self.transient
265
+ ): # if it is finished render the final output for files or dumb_terminals
266
+ renderables = [*renderables, self._live_render]
267
+
268
+ return renderables
269
+
270
+
271
+ if __name__ == "__main__": # pragma: no cover
272
+ import random
273
+ import time
274
+ from itertools import cycle
275
+ from typing import Dict, List, Tuple
276
+
277
+ from .align import Align
278
+ from .console import Console
279
+ from .live import Live as Live
280
+ from .panel import Panel
281
+ from .rule import Rule
282
+ from .syntax import Syntax
283
+ from .table import Table
284
+
285
+ console = Console()
286
+
287
+ syntax = Syntax(
288
+ '''def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
289
+ """Iterate and generate a tuple with a flag for last value."""
290
+ iter_values = iter(values)
291
+ try:
292
+ previous_value = next(iter_values)
293
+ except StopIteration:
294
+ return
295
+ for value in iter_values:
296
+ yield False, previous_value
297
+ previous_value = value
298
+ yield True, previous_value''',
299
+ "python",
300
+ line_numbers=True,
301
+ )
302
+
303
+ table = Table("foo", "bar", "baz")
304
+ table.add_row("1", "2", "3")
305
+
306
+ progress_renderables = [
307
+ "You can make the terminal shorter and taller to see the live table hide"
308
+ "Text may be printed while the progress bars are rendering.",
309
+ Panel("In fact, [i]any[/i] renderable will work"),
310
+ "Such as [magenta]tables[/]...",
311
+ table,
312
+ "Pretty printed structures...",
313
+ {"type": "example", "text": "Pretty printed"},
314
+ "Syntax...",
315
+ syntax,
316
+ Rule("Give it a try!"),
317
+ ]
318
+
319
+ examples = cycle(progress_renderables)
320
+
321
+ exchanges = [
322
+ "SGD",
323
+ "MYR",
324
+ "EUR",
325
+ "USD",
326
+ "AUD",
327
+ "JPY",
328
+ "CNH",
329
+ "HKD",
330
+ "CAD",
331
+ "INR",
332
+ "DKK",
333
+ "GBP",
334
+ "RUB",
335
+ "NZD",
336
+ "MXN",
337
+ "IDR",
338
+ "TWD",
339
+ "THB",
340
+ "VND",
341
+ ]
342
+ with Live(console=console) as live_table:
343
+ exchange_rate_dict: Dict[Tuple[str, str], float] = {}
344
+
345
+ for index in range(100):
346
+ select_exchange = exchanges[index % len(exchanges)]
347
+
348
+ for exchange in exchanges:
349
+ if exchange == select_exchange:
350
+ continue
351
+ time.sleep(0.4)
352
+ if random.randint(0, 10) < 1:
353
+ console.log(next(examples))
354
+ exchange_rate_dict[(select_exchange, exchange)] = 200 / (
355
+ (random.random() * 320) + 1
356
+ )
357
+ if len(exchange_rate_dict) > len(exchanges) - 1:
358
+ exchange_rate_dict.pop(list(exchange_rate_dict.keys())[0])
359
+ table = Table(title="Exchange Rates")
360
+
361
+ table.add_column("Source Currency")
362
+ table.add_column("Destination Currency")
363
+ table.add_column("Exchange Rate")
364
+
365
+ for (source, dest), exchange_rate in exchange_rate_dict.items():
366
+ table.add_row(
367
+ source,
368
+ dest,
369
+ Text(
370
+ f"{exchange_rate:.4f}",
371
+ style="red" if exchange_rate < 1.0 else "green",
372
+ ),
373
+ )
374
+
375
+ live_table.update(Align.center(table))
.venv/lib/python3.13/site-packages/pip/_vendor/rich/live_render.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from typing import Optional, Tuple
3
+
4
+ if sys.version_info >= (3, 8):
5
+ from typing import Literal
6
+ else:
7
+ from pip._vendor.typing_extensions import Literal # pragma: no cover
8
+
9
+
10
+ from ._loop import loop_last
11
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
12
+ from .control import Control
13
+ from .segment import ControlType, Segment
14
+ from .style import StyleType
15
+ from .text import Text
16
+
17
+ VerticalOverflowMethod = Literal["crop", "ellipsis", "visible"]
18
+
19
+
20
+ class LiveRender:
21
+ """Creates a renderable that may be updated.
22
+
23
+ Args:
24
+ renderable (RenderableType): Any renderable object.
25
+ style (StyleType, optional): An optional style to apply to the renderable. Defaults to "".
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ renderable: RenderableType,
31
+ style: StyleType = "",
32
+ vertical_overflow: VerticalOverflowMethod = "ellipsis",
33
+ ) -> None:
34
+ self.renderable = renderable
35
+ self.style = style
36
+ self.vertical_overflow = vertical_overflow
37
+ self._shape: Optional[Tuple[int, int]] = None
38
+
39
+ def set_renderable(self, renderable: RenderableType) -> None:
40
+ """Set a new renderable.
41
+
42
+ Args:
43
+ renderable (RenderableType): Any renderable object, including str.
44
+ """
45
+ self.renderable = renderable
46
+
47
+ def position_cursor(self) -> Control:
48
+ """Get control codes to move cursor to beginning of live render.
49
+
50
+ Returns:
51
+ Control: A control instance that may be printed.
52
+ """
53
+ if self._shape is not None:
54
+ _, height = self._shape
55
+ return Control(
56
+ ControlType.CARRIAGE_RETURN,
57
+ (ControlType.ERASE_IN_LINE, 2),
58
+ *(
59
+ (
60
+ (ControlType.CURSOR_UP, 1),
61
+ (ControlType.ERASE_IN_LINE, 2),
62
+ )
63
+ * (height - 1)
64
+ )
65
+ )
66
+ return Control()
67
+
68
+ def restore_cursor(self) -> Control:
69
+ """Get control codes to clear the render and restore the cursor to its previous position.
70
+
71
+ Returns:
72
+ Control: A Control instance that may be printed.
73
+ """
74
+ if self._shape is not None:
75
+ _, height = self._shape
76
+ return Control(
77
+ ControlType.CARRIAGE_RETURN,
78
+ *((ControlType.CURSOR_UP, 1), (ControlType.ERASE_IN_LINE, 2)) * height
79
+ )
80
+ return Control()
81
+
82
+ def __rich_console__(
83
+ self, console: Console, options: ConsoleOptions
84
+ ) -> RenderResult:
85
+ renderable = self.renderable
86
+ style = console.get_style(self.style)
87
+ lines = console.render_lines(renderable, options, style=style, pad=False)
88
+ shape = Segment.get_shape(lines)
89
+
90
+ _, height = shape
91
+ if height > options.size.height:
92
+ if self.vertical_overflow == "crop":
93
+ lines = lines[: options.size.height]
94
+ shape = Segment.get_shape(lines)
95
+ elif self.vertical_overflow == "ellipsis":
96
+ lines = lines[: (options.size.height - 1)]
97
+ overflow_text = Text(
98
+ "...",
99
+ overflow="crop",
100
+ justify="center",
101
+ end="",
102
+ style="live.ellipsis",
103
+ )
104
+ lines.append(list(console.render(overflow_text)))
105
+ shape = Segment.get_shape(lines)
106
+ self._shape = shape
107
+
108
+ new_line = Segment.line()
109
+ for last, line in loop_last(lines):
110
+ yield from line
111
+ if not last:
112
+ yield new_line
.venv/lib/python3.13/site-packages/pip/_vendor/rich/logging.py ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from datetime import datetime
3
+ from logging import Handler, LogRecord
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+ from typing import ClassVar, Iterable, List, Optional, Type, Union
7
+
8
+ from pip._vendor.rich._null_file import NullFile
9
+
10
+ from . import get_console
11
+ from ._log_render import FormatTimeCallable, LogRender
12
+ from .console import Console, ConsoleRenderable
13
+ from .highlighter import Highlighter, ReprHighlighter
14
+ from .text import Text
15
+ from .traceback import Traceback
16
+
17
+
18
+ class RichHandler(Handler):
19
+ """A logging handler that renders output with Rich. The time / level / message and file are displayed in columns.
20
+ The level is color coded, and the message is syntax highlighted.
21
+
22
+ Note:
23
+ Be careful when enabling console markup in log messages if you have configured logging for libraries not
24
+ under your control. If a dependency writes messages containing square brackets, it may not produce the intended output.
25
+
26
+ Args:
27
+ level (Union[int, str], optional): Log level. Defaults to logging.NOTSET.
28
+ console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.
29
+ Default will use a global console instance writing to stdout.
30
+ show_time (bool, optional): Show a column for the time. Defaults to True.
31
+ omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True.
32
+ show_level (bool, optional): Show a column for the level. Defaults to True.
33
+ show_path (bool, optional): Show the path to the original log call. Defaults to True.
34
+ enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.
35
+ highlighter (Highlighter, optional): Highlighter to style log messages, or None to use ReprHighlighter. Defaults to None.
36
+ markup (bool, optional): Enable console markup in log messages. Defaults to False.
37
+ rich_tracebacks (bool, optional): Enable rich tracebacks with syntax highlighting and formatting. Defaults to False.
38
+ tracebacks_width (Optional[int], optional): Number of characters used to render tracebacks, or None for full width. Defaults to None.
39
+ tracebacks_code_width (int, optional): Number of code characters used to render tracebacks, or None for full width. Defaults to 88.
40
+ tracebacks_extra_lines (int, optional): Additional lines of code to render tracebacks, or None for full width. Defaults to None.
41
+ tracebacks_theme (str, optional): Override pygments theme used in traceback.
42
+ tracebacks_word_wrap (bool, optional): Enable word wrapping of long tracebacks lines. Defaults to True.
43
+ tracebacks_show_locals (bool, optional): Enable display of locals in tracebacks. Defaults to False.
44
+ tracebacks_suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
45
+ tracebacks_max_frames (int, optional): Optional maximum number of frames returned by traceback.
46
+ locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
47
+ Defaults to 10.
48
+ locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
49
+ log_time_format (Union[str, TimeFormatterCallable], optional): If ``log_time`` is enabled, either string for strftime or callable that formats the time. Defaults to "[%x %X] ".
50
+ keywords (List[str], optional): List of words to highlight instead of ``RichHandler.KEYWORDS``.
51
+ """
52
+
53
+ KEYWORDS: ClassVar[Optional[List[str]]] = [
54
+ "GET",
55
+ "POST",
56
+ "HEAD",
57
+ "PUT",
58
+ "DELETE",
59
+ "OPTIONS",
60
+ "TRACE",
61
+ "PATCH",
62
+ ]
63
+ HIGHLIGHTER_CLASS: ClassVar[Type[Highlighter]] = ReprHighlighter
64
+
65
+ def __init__(
66
+ self,
67
+ level: Union[int, str] = logging.NOTSET,
68
+ console: Optional[Console] = None,
69
+ *,
70
+ show_time: bool = True,
71
+ omit_repeated_times: bool = True,
72
+ show_level: bool = True,
73
+ show_path: bool = True,
74
+ enable_link_path: bool = True,
75
+ highlighter: Optional[Highlighter] = None,
76
+ markup: bool = False,
77
+ rich_tracebacks: bool = False,
78
+ tracebacks_width: Optional[int] = None,
79
+ tracebacks_code_width: int = 88,
80
+ tracebacks_extra_lines: int = 3,
81
+ tracebacks_theme: Optional[str] = None,
82
+ tracebacks_word_wrap: bool = True,
83
+ tracebacks_show_locals: bool = False,
84
+ tracebacks_suppress: Iterable[Union[str, ModuleType]] = (),
85
+ tracebacks_max_frames: int = 100,
86
+ locals_max_length: int = 10,
87
+ locals_max_string: int = 80,
88
+ log_time_format: Union[str, FormatTimeCallable] = "[%x %X]",
89
+ keywords: Optional[List[str]] = None,
90
+ ) -> None:
91
+ super().__init__(level=level)
92
+ self.console = console or get_console()
93
+ self.highlighter = highlighter or self.HIGHLIGHTER_CLASS()
94
+ self._log_render = LogRender(
95
+ show_time=show_time,
96
+ show_level=show_level,
97
+ show_path=show_path,
98
+ time_format=log_time_format,
99
+ omit_repeated_times=omit_repeated_times,
100
+ level_width=None,
101
+ )
102
+ self.enable_link_path = enable_link_path
103
+ self.markup = markup
104
+ self.rich_tracebacks = rich_tracebacks
105
+ self.tracebacks_width = tracebacks_width
106
+ self.tracebacks_extra_lines = tracebacks_extra_lines
107
+ self.tracebacks_theme = tracebacks_theme
108
+ self.tracebacks_word_wrap = tracebacks_word_wrap
109
+ self.tracebacks_show_locals = tracebacks_show_locals
110
+ self.tracebacks_suppress = tracebacks_suppress
111
+ self.tracebacks_max_frames = tracebacks_max_frames
112
+ self.tracebacks_code_width = tracebacks_code_width
113
+ self.locals_max_length = locals_max_length
114
+ self.locals_max_string = locals_max_string
115
+ self.keywords = keywords
116
+
117
+ def get_level_text(self, record: LogRecord) -> Text:
118
+ """Get the level name from the record.
119
+
120
+ Args:
121
+ record (LogRecord): LogRecord instance.
122
+
123
+ Returns:
124
+ Text: A tuple of the style and level name.
125
+ """
126
+ level_name = record.levelname
127
+ level_text = Text.styled(
128
+ level_name.ljust(8), f"logging.level.{level_name.lower()}"
129
+ )
130
+ return level_text
131
+
132
+ def emit(self, record: LogRecord) -> None:
133
+ """Invoked by logging."""
134
+ message = self.format(record)
135
+ traceback = None
136
+ if (
137
+ self.rich_tracebacks
138
+ and record.exc_info
139
+ and record.exc_info != (None, None, None)
140
+ ):
141
+ exc_type, exc_value, exc_traceback = record.exc_info
142
+ assert exc_type is not None
143
+ assert exc_value is not None
144
+ traceback = Traceback.from_exception(
145
+ exc_type,
146
+ exc_value,
147
+ exc_traceback,
148
+ width=self.tracebacks_width,
149
+ code_width=self.tracebacks_code_width,
150
+ extra_lines=self.tracebacks_extra_lines,
151
+ theme=self.tracebacks_theme,
152
+ word_wrap=self.tracebacks_word_wrap,
153
+ show_locals=self.tracebacks_show_locals,
154
+ locals_max_length=self.locals_max_length,
155
+ locals_max_string=self.locals_max_string,
156
+ suppress=self.tracebacks_suppress,
157
+ max_frames=self.tracebacks_max_frames,
158
+ )
159
+ message = record.getMessage()
160
+ if self.formatter:
161
+ record.message = record.getMessage()
162
+ formatter = self.formatter
163
+ if hasattr(formatter, "usesTime") and formatter.usesTime():
164
+ record.asctime = formatter.formatTime(record, formatter.datefmt)
165
+ message = formatter.formatMessage(record)
166
+
167
+ message_renderable = self.render_message(record, message)
168
+ log_renderable = self.render(
169
+ record=record, traceback=traceback, message_renderable=message_renderable
170
+ )
171
+ if isinstance(self.console.file, NullFile):
172
+ # Handles pythonw, where stdout/stderr are null, and we return NullFile
173
+ # instance from Console.file. In this case, we still want to make a log record
174
+ # even though we won't be writing anything to a file.
175
+ self.handleError(record)
176
+ else:
177
+ try:
178
+ self.console.print(log_renderable)
179
+ except Exception:
180
+ self.handleError(record)
181
+
182
+ def render_message(self, record: LogRecord, message: str) -> "ConsoleRenderable":
183
+ """Render message text in to Text.
184
+
185
+ Args:
186
+ record (LogRecord): logging Record.
187
+ message (str): String containing log message.
188
+
189
+ Returns:
190
+ ConsoleRenderable: Renderable to display log message.
191
+ """
192
+ use_markup = getattr(record, "markup", self.markup)
193
+ message_text = Text.from_markup(message) if use_markup else Text(message)
194
+
195
+ highlighter = getattr(record, "highlighter", self.highlighter)
196
+ if highlighter:
197
+ message_text = highlighter(message_text)
198
+
199
+ if self.keywords is None:
200
+ self.keywords = self.KEYWORDS
201
+
202
+ if self.keywords:
203
+ message_text.highlight_words(self.keywords, "logging.keyword")
204
+
205
+ return message_text
206
+
207
+ def render(
208
+ self,
209
+ *,
210
+ record: LogRecord,
211
+ traceback: Optional[Traceback],
212
+ message_renderable: "ConsoleRenderable",
213
+ ) -> "ConsoleRenderable":
214
+ """Render log for display.
215
+
216
+ Args:
217
+ record (LogRecord): logging Record.
218
+ traceback (Optional[Traceback]): Traceback instance or None for no Traceback.
219
+ message_renderable (ConsoleRenderable): Renderable (typically Text) containing log message contents.
220
+
221
+ Returns:
222
+ ConsoleRenderable: Renderable to display log.
223
+ """
224
+ path = Path(record.pathname).name
225
+ level = self.get_level_text(record)
226
+ time_format = None if self.formatter is None else self.formatter.datefmt
227
+ log_time = datetime.fromtimestamp(record.created)
228
+
229
+ log_renderable = self._log_render(
230
+ self.console,
231
+ [message_renderable] if not traceback else [message_renderable, traceback],
232
+ log_time=log_time,
233
+ time_format=time_format,
234
+ level=level,
235
+ path=path,
236
+ line_no=record.lineno,
237
+ link_path=record.pathname if self.enable_link_path else None,
238
+ )
239
+ return log_renderable
240
+
241
+
242
+ if __name__ == "__main__": # pragma: no cover
243
+ from time import sleep
244
+
245
+ FORMAT = "%(message)s"
246
+ # FORMAT = "%(asctime)-15s - %(levelname)s - %(message)s"
247
+ logging.basicConfig(
248
+ level="NOTSET",
249
+ format=FORMAT,
250
+ datefmt="[%X]",
251
+ handlers=[RichHandler(rich_tracebacks=True, tracebacks_show_locals=True)],
252
+ )
253
+ log = logging.getLogger("rich")
254
+
255
+ log.info("Server starting...")
256
+ log.info("Listening on http://127.0.0.1:8080")
257
+ sleep(1)
258
+
259
+ log.info("GET /index.html 200 1298")
260
+ log.info("GET /imgs/backgrounds/back1.jpg 200 54386")
261
+ log.info("GET /css/styles.css 200 54386")
262
+ log.warning("GET /favicon.ico 404 242")
263
+ sleep(1)
264
+
265
+ log.debug(
266
+ "JSONRPC request\n--> %r\n<-- %r",
267
+ {
268
+ "version": "1.1",
269
+ "method": "confirmFruitPurchase",
270
+ "params": [["apple", "orange", "mangoes", "pomelo"], 1.123],
271
+ "id": "194521489",
272
+ },
273
+ {"version": "1.1", "result": True, "error": None, "id": "194521489"},
274
+ )
275
+ log.debug(
276
+ "Loading configuration file /adasd/asdasd/qeqwe/qwrqwrqwr/sdgsdgsdg/werwerwer/dfgerert/ertertert/ertetert/werwerwer"
277
+ )
278
+ log.error("Unable to find 'pomelo' in database!")
279
+ log.info("POST /jsonrpc/ 200 65532")
280
+ log.info("POST /admin/ 401 42234")
281
+ log.warning("password was rejected for admin site.")
282
+
283
+ def divide() -> None:
284
+ number = 1
285
+ divisor = 0
286
+ foos = ["foo"] * 100
287
+ log.debug("in divide")
288
+ try:
289
+ number / divisor
290
+ except:
291
+ log.exception("An error of some kind occurred!")
292
+
293
+ divide()
294
+ sleep(1)
295
+ log.critical("Out of memory!")
296
+ log.info("Server exited with code=-1")
297
+ log.info("[bold]EXITING...[/bold]", extra=dict(markup=True))
.venv/lib/python3.13/site-packages/pip/_vendor/rich/markup.py ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from ast import literal_eval
3
+ from operator import attrgetter
4
+ from typing import Callable, Iterable, List, Match, NamedTuple, Optional, Tuple, Union
5
+
6
+ from ._emoji_replace import _emoji_replace
7
+ from .emoji import EmojiVariant
8
+ from .errors import MarkupError
9
+ from .style import Style
10
+ from .text import Span, Text
11
+
12
+ RE_TAGS = re.compile(
13
+ r"""((\\*)\[([a-z#/@][^[]*?)])""",
14
+ re.VERBOSE,
15
+ )
16
+
17
+ RE_HANDLER = re.compile(r"^([\w.]*?)(\(.*?\))?$")
18
+
19
+
20
+ class Tag(NamedTuple):
21
+ """A tag in console markup."""
22
+
23
+ name: str
24
+ """The tag name. e.g. 'bold'."""
25
+ parameters: Optional[str]
26
+ """Any additional parameters after the name."""
27
+
28
+ def __str__(self) -> str:
29
+ return (
30
+ self.name if self.parameters is None else f"{self.name} {self.parameters}"
31
+ )
32
+
33
+ @property
34
+ def markup(self) -> str:
35
+ """Get the string representation of this tag."""
36
+ return (
37
+ f"[{self.name}]"
38
+ if self.parameters is None
39
+ else f"[{self.name}={self.parameters}]"
40
+ )
41
+
42
+
43
+ _ReStringMatch = Match[str] # regex match object
44
+ _ReSubCallable = Callable[[_ReStringMatch], str] # Callable invoked by re.sub
45
+ _EscapeSubMethod = Callable[[_ReSubCallable, str], str] # Sub method of a compiled re
46
+
47
+
48
+ def escape(
49
+ markup: str,
50
+ _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#/@][^[]*?])").sub,
51
+ ) -> str:
52
+ """Escapes text so that it won't be interpreted as markup.
53
+
54
+ Args:
55
+ markup (str): Content to be inserted in to markup.
56
+
57
+ Returns:
58
+ str: Markup with square brackets escaped.
59
+ """
60
+
61
+ def escape_backslashes(match: Match[str]) -> str:
62
+ """Called by re.sub replace matches."""
63
+ backslashes, text = match.groups()
64
+ return f"{backslashes}{backslashes}\\{text}"
65
+
66
+ markup = _escape(escape_backslashes, markup)
67
+ if markup.endswith("\\") and not markup.endswith("\\\\"):
68
+ return markup + "\\"
69
+
70
+ return markup
71
+
72
+
73
+ def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
74
+ """Parse markup in to an iterable of tuples of (position, text, tag).
75
+
76
+ Args:
77
+ markup (str): A string containing console markup
78
+
79
+ """
80
+ position = 0
81
+ _divmod = divmod
82
+ _Tag = Tag
83
+ for match in RE_TAGS.finditer(markup):
84
+ full_text, escapes, tag_text = match.groups()
85
+ start, end = match.span()
86
+ if start > position:
87
+ yield start, markup[position:start], None
88
+ if escapes:
89
+ backslashes, escaped = _divmod(len(escapes), 2)
90
+ if backslashes:
91
+ # Literal backslashes
92
+ yield start, "\\" * backslashes, None
93
+ start += backslashes * 2
94
+ if escaped:
95
+ # Escape of tag
96
+ yield start, full_text[len(escapes) :], None
97
+ position = end
98
+ continue
99
+ text, equals, parameters = tag_text.partition("=")
100
+ yield start, None, _Tag(text, parameters if equals else None)
101
+ position = end
102
+ if position < len(markup):
103
+ yield position, markup[position:], None
104
+
105
+
106
+ def render(
107
+ markup: str,
108
+ style: Union[str, Style] = "",
109
+ emoji: bool = True,
110
+ emoji_variant: Optional[EmojiVariant] = None,
111
+ ) -> Text:
112
+ """Render console markup in to a Text instance.
113
+
114
+ Args:
115
+ markup (str): A string containing console markup.
116
+ style: (Union[str, Style]): The style to use.
117
+ emoji (bool, optional): Also render emoji code. Defaults to True.
118
+ emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None.
119
+
120
+
121
+ Raises:
122
+ MarkupError: If there is a syntax error in the markup.
123
+
124
+ Returns:
125
+ Text: A test instance.
126
+ """
127
+ emoji_replace = _emoji_replace
128
+ if "[" not in markup:
129
+ return Text(
130
+ emoji_replace(markup, default_variant=emoji_variant) if emoji else markup,
131
+ style=style,
132
+ )
133
+ text = Text(style=style)
134
+ append = text.append
135
+ normalize = Style.normalize
136
+
137
+ style_stack: List[Tuple[int, Tag]] = []
138
+ pop = style_stack.pop
139
+
140
+ spans: List[Span] = []
141
+ append_span = spans.append
142
+
143
+ _Span = Span
144
+ _Tag = Tag
145
+
146
+ def pop_style(style_name: str) -> Tuple[int, Tag]:
147
+ """Pop tag matching given style name."""
148
+ for index, (_, tag) in enumerate(reversed(style_stack), 1):
149
+ if tag.name == style_name:
150
+ return pop(-index)
151
+ raise KeyError(style_name)
152
+
153
+ for position, plain_text, tag in _parse(markup):
154
+ if plain_text is not None:
155
+ # Handle open brace escapes, where the brace is not part of a tag.
156
+ plain_text = plain_text.replace("\\[", "[")
157
+ append(emoji_replace(plain_text) if emoji else plain_text)
158
+ elif tag is not None:
159
+ if tag.name.startswith("/"): # Closing tag
160
+ style_name = tag.name[1:].strip()
161
+
162
+ if style_name: # explicit close
163
+ style_name = normalize(style_name)
164
+ try:
165
+ start, open_tag = pop_style(style_name)
166
+ except KeyError:
167
+ raise MarkupError(
168
+ f"closing tag '{tag.markup}' at position {position} doesn't match any open tag"
169
+ ) from None
170
+ else: # implicit close
171
+ try:
172
+ start, open_tag = pop()
173
+ except IndexError:
174
+ raise MarkupError(
175
+ f"closing tag '[/]' at position {position} has nothing to close"
176
+ ) from None
177
+
178
+ if open_tag.name.startswith("@"):
179
+ if open_tag.parameters:
180
+ handler_name = ""
181
+ parameters = open_tag.parameters.strip()
182
+ handler_match = RE_HANDLER.match(parameters)
183
+ if handler_match is not None:
184
+ handler_name, match_parameters = handler_match.groups()
185
+ parameters = (
186
+ "()" if match_parameters is None else match_parameters
187
+ )
188
+
189
+ try:
190
+ meta_params = literal_eval(parameters)
191
+ except SyntaxError as error:
192
+ raise MarkupError(
193
+ f"error parsing {parameters!r} in {open_tag.parameters!r}; {error.msg}"
194
+ )
195
+ except Exception as error:
196
+ raise MarkupError(
197
+ f"error parsing {open_tag.parameters!r}; {error}"
198
+ ) from None
199
+
200
+ if handler_name:
201
+ meta_params = (
202
+ handler_name,
203
+ meta_params
204
+ if isinstance(meta_params, tuple)
205
+ else (meta_params,),
206
+ )
207
+
208
+ else:
209
+ meta_params = ()
210
+
211
+ append_span(
212
+ _Span(
213
+ start, len(text), Style(meta={open_tag.name: meta_params})
214
+ )
215
+ )
216
+ else:
217
+ append_span(_Span(start, len(text), str(open_tag)))
218
+
219
+ else: # Opening tag
220
+ normalized_tag = _Tag(normalize(tag.name), tag.parameters)
221
+ style_stack.append((len(text), normalized_tag))
222
+
223
+ text_length = len(text)
224
+ while style_stack:
225
+ start, tag = style_stack.pop()
226
+ style = str(tag)
227
+ if style:
228
+ append_span(_Span(start, text_length, style))
229
+
230
+ text.spans = sorted(spans[::-1], key=attrgetter("start"))
231
+ return text
232
+
233
+
234
+ if __name__ == "__main__": # pragma: no cover
235
+ MARKUP = [
236
+ "[red]Hello World[/red]",
237
+ "[magenta]Hello [b]World[/b]",
238
+ "[bold]Bold[italic] bold and italic [/bold]italic[/italic]",
239
+ "Click [link=https://www.willmcgugan.com]here[/link] to visit my Blog",
240
+ ":warning-emoji: [bold red blink] DANGER![/]",
241
+ ]
242
+
243
+ from pip._vendor.rich import print
244
+ from pip._vendor.rich.table import Table
245
+
246
+ grid = Table("Markup", "Result", padding=(0, 1))
247
+
248
+ for markup in MARKUP:
249
+ grid.add_row(Text(markup), markup)
250
+
251
+ print(grid)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/measure.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from operator import itemgetter
2
+ from typing import TYPE_CHECKING, Callable, NamedTuple, Optional, Sequence
3
+
4
+ from . import errors
5
+ from .protocol import is_renderable, rich_cast
6
+
7
+ if TYPE_CHECKING:
8
+ from .console import Console, ConsoleOptions, RenderableType
9
+
10
+
11
+ class Measurement(NamedTuple):
12
+ """Stores the minimum and maximum widths (in characters) required to render an object."""
13
+
14
+ minimum: int
15
+ """Minimum number of cells required to render."""
16
+ maximum: int
17
+ """Maximum number of cells required to render."""
18
+
19
+ @property
20
+ def span(self) -> int:
21
+ """Get difference between maximum and minimum."""
22
+ return self.maximum - self.minimum
23
+
24
+ def normalize(self) -> "Measurement":
25
+ """Get measurement that ensures that minimum <= maximum and minimum >= 0
26
+
27
+ Returns:
28
+ Measurement: A normalized measurement.
29
+ """
30
+ minimum, maximum = self
31
+ minimum = min(max(0, minimum), maximum)
32
+ return Measurement(max(0, minimum), max(0, max(minimum, maximum)))
33
+
34
+ def with_maximum(self, width: int) -> "Measurement":
35
+ """Get a RenderableWith where the widths are <= width.
36
+
37
+ Args:
38
+ width (int): Maximum desired width.
39
+
40
+ Returns:
41
+ Measurement: New Measurement object.
42
+ """
43
+ minimum, maximum = self
44
+ return Measurement(min(minimum, width), min(maximum, width))
45
+
46
+ def with_minimum(self, width: int) -> "Measurement":
47
+ """Get a RenderableWith where the widths are >= width.
48
+
49
+ Args:
50
+ width (int): Minimum desired width.
51
+
52
+ Returns:
53
+ Measurement: New Measurement object.
54
+ """
55
+ minimum, maximum = self
56
+ width = max(0, width)
57
+ return Measurement(max(minimum, width), max(maximum, width))
58
+
59
+ def clamp(
60
+ self, min_width: Optional[int] = None, max_width: Optional[int] = None
61
+ ) -> "Measurement":
62
+ """Clamp a measurement within the specified range.
63
+
64
+ Args:
65
+ min_width (int): Minimum desired width, or ``None`` for no minimum. Defaults to None.
66
+ max_width (int): Maximum desired width, or ``None`` for no maximum. Defaults to None.
67
+
68
+ Returns:
69
+ Measurement: New Measurement object.
70
+ """
71
+ measurement = self
72
+ if min_width is not None:
73
+ measurement = measurement.with_minimum(min_width)
74
+ if max_width is not None:
75
+ measurement = measurement.with_maximum(max_width)
76
+ return measurement
77
+
78
+ @classmethod
79
+ def get(
80
+ cls, console: "Console", options: "ConsoleOptions", renderable: "RenderableType"
81
+ ) -> "Measurement":
82
+ """Get a measurement for a renderable.
83
+
84
+ Args:
85
+ console (~rich.console.Console): Console instance.
86
+ options (~rich.console.ConsoleOptions): Console options.
87
+ renderable (RenderableType): An object that may be rendered with Rich.
88
+
89
+ Raises:
90
+ errors.NotRenderableError: If the object is not renderable.
91
+
92
+ Returns:
93
+ Measurement: Measurement object containing range of character widths required to render the object.
94
+ """
95
+ _max_width = options.max_width
96
+ if _max_width < 1:
97
+ return Measurement(0, 0)
98
+ if isinstance(renderable, str):
99
+ renderable = console.render_str(
100
+ renderable, markup=options.markup, highlight=False
101
+ )
102
+ renderable = rich_cast(renderable)
103
+ if is_renderable(renderable):
104
+ get_console_width: Optional[
105
+ Callable[["Console", "ConsoleOptions"], "Measurement"]
106
+ ] = getattr(renderable, "__rich_measure__", None)
107
+ if get_console_width is not None:
108
+ render_width = (
109
+ get_console_width(console, options)
110
+ .normalize()
111
+ .with_maximum(_max_width)
112
+ )
113
+ if render_width.maximum < 1:
114
+ return Measurement(0, 0)
115
+ return render_width.normalize()
116
+ else:
117
+ return Measurement(0, _max_width)
118
+ else:
119
+ raise errors.NotRenderableError(
120
+ f"Unable to get render width for {renderable!r}; "
121
+ "a str, Segment, or object with __rich_console__ method is required"
122
+ )
123
+
124
+
125
+ def measure_renderables(
126
+ console: "Console",
127
+ options: "ConsoleOptions",
128
+ renderables: Sequence["RenderableType"],
129
+ ) -> "Measurement":
130
+ """Get a measurement that would fit a number of renderables.
131
+
132
+ Args:
133
+ console (~rich.console.Console): Console instance.
134
+ options (~rich.console.ConsoleOptions): Console options.
135
+ renderables (Iterable[RenderableType]): One or more renderable objects.
136
+
137
+ Returns:
138
+ Measurement: Measurement object containing range of character widths required to
139
+ contain all given renderables.
140
+ """
141
+ if not renderables:
142
+ return Measurement(0, 0)
143
+ get_measurement = Measurement.get
144
+ measurements = [
145
+ get_measurement(console, options, renderable) for renderable in renderables
146
+ ]
147
+ measured_width = Measurement(
148
+ max(measurements, key=itemgetter(0)).minimum,
149
+ max(measurements, key=itemgetter(1)).maximum,
150
+ )
151
+ return measured_width
.venv/lib/python3.13/site-packages/pip/_vendor/rich/padding.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TYPE_CHECKING, List, Optional, Tuple, Union
2
+
3
+ if TYPE_CHECKING:
4
+ from .console import (
5
+ Console,
6
+ ConsoleOptions,
7
+ RenderableType,
8
+ RenderResult,
9
+ )
10
+
11
+ from .jupyter import JupyterMixin
12
+ from .measure import Measurement
13
+ from .segment import Segment
14
+ from .style import Style
15
+
16
+ PaddingDimensions = Union[int, Tuple[int], Tuple[int, int], Tuple[int, int, int, int]]
17
+
18
+
19
+ class Padding(JupyterMixin):
20
+ """Draw space around content.
21
+
22
+ Example:
23
+ >>> print(Padding("Hello", (2, 4), style="on blue"))
24
+
25
+ Args:
26
+ renderable (RenderableType): String or other renderable.
27
+ pad (Union[int, Tuple[int]]): Padding for top, right, bottom, and left borders.
28
+ May be specified with 1, 2, or 4 integers (CSS style).
29
+ style (Union[str, Style], optional): Style for padding characters. Defaults to "none".
30
+ expand (bool, optional): Expand padding to fit available width. Defaults to True.
31
+ """
32
+
33
+ def __init__(
34
+ self,
35
+ renderable: "RenderableType",
36
+ pad: "PaddingDimensions" = (0, 0, 0, 0),
37
+ *,
38
+ style: Union[str, Style] = "none",
39
+ expand: bool = True,
40
+ ):
41
+ self.renderable = renderable
42
+ self.top, self.right, self.bottom, self.left = self.unpack(pad)
43
+ self.style = style
44
+ self.expand = expand
45
+
46
+ @classmethod
47
+ def indent(cls, renderable: "RenderableType", level: int) -> "Padding":
48
+ """Make padding instance to render an indent.
49
+
50
+ Args:
51
+ renderable (RenderableType): String or other renderable.
52
+ level (int): Number of characters to indent.
53
+
54
+ Returns:
55
+ Padding: A Padding instance.
56
+ """
57
+
58
+ return Padding(renderable, pad=(0, 0, 0, level), expand=False)
59
+
60
+ @staticmethod
61
+ def unpack(pad: "PaddingDimensions") -> Tuple[int, int, int, int]:
62
+ """Unpack padding specified in CSS style."""
63
+ if isinstance(pad, int):
64
+ return (pad, pad, pad, pad)
65
+ if len(pad) == 1:
66
+ _pad = pad[0]
67
+ return (_pad, _pad, _pad, _pad)
68
+ if len(pad) == 2:
69
+ pad_top, pad_right = pad
70
+ return (pad_top, pad_right, pad_top, pad_right)
71
+ if len(pad) == 4:
72
+ top, right, bottom, left = pad
73
+ return (top, right, bottom, left)
74
+ raise ValueError(f"1, 2 or 4 integers required for padding; {len(pad)} given")
75
+
76
+ def __repr__(self) -> str:
77
+ return f"Padding({self.renderable!r}, ({self.top},{self.right},{self.bottom},{self.left}))"
78
+
79
+ def __rich_console__(
80
+ self, console: "Console", options: "ConsoleOptions"
81
+ ) -> "RenderResult":
82
+ style = console.get_style(self.style)
83
+ if self.expand:
84
+ width = options.max_width
85
+ else:
86
+ width = min(
87
+ Measurement.get(console, options, self.renderable).maximum
88
+ + self.left
89
+ + self.right,
90
+ options.max_width,
91
+ )
92
+ render_options = options.update_width(width - self.left - self.right)
93
+ if render_options.height is not None:
94
+ render_options = render_options.update_height(
95
+ height=render_options.height - self.top - self.bottom
96
+ )
97
+ lines = console.render_lines(
98
+ self.renderable, render_options, style=style, pad=True
99
+ )
100
+ _Segment = Segment
101
+
102
+ left = _Segment(" " * self.left, style) if self.left else None
103
+ right = (
104
+ [_Segment(f'{" " * self.right}', style), _Segment.line()]
105
+ if self.right
106
+ else [_Segment.line()]
107
+ )
108
+ blank_line: Optional[List[Segment]] = None
109
+ if self.top:
110
+ blank_line = [_Segment(f'{" " * width}\n', style)]
111
+ yield from blank_line * self.top
112
+ if left:
113
+ for line in lines:
114
+ yield left
115
+ yield from line
116
+ yield from right
117
+ else:
118
+ for line in lines:
119
+ yield from line
120
+ yield from right
121
+ if self.bottom:
122
+ blank_line = blank_line or [_Segment(f'{" " * width}\n', style)]
123
+ yield from blank_line * self.bottom
124
+
125
+ def __rich_measure__(
126
+ self, console: "Console", options: "ConsoleOptions"
127
+ ) -> "Measurement":
128
+ max_width = options.max_width
129
+ extra_width = self.left + self.right
130
+ if max_width - extra_width < 1:
131
+ return Measurement(max_width, max_width)
132
+ measure_min, measure_max = Measurement.get(console, options, self.renderable)
133
+ measurement = Measurement(measure_min + extra_width, measure_max + extra_width)
134
+ measurement = measurement.with_maximum(max_width)
135
+ return measurement
136
+
137
+
138
+ if __name__ == "__main__": # pragma: no cover
139
+ from pip._vendor.rich import print
140
+
141
+ print(Padding("Hello, World", (2, 4), style="on blue"))
.venv/lib/python3.13/site-packages/pip/_vendor/rich/pager.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+
5
+ class Pager(ABC):
6
+ """Base class for a pager."""
7
+
8
+ @abstractmethod
9
+ def show(self, content: str) -> None:
10
+ """Show content in pager.
11
+
12
+ Args:
13
+ content (str): Content to be displayed.
14
+ """
15
+
16
+
17
+ class SystemPager(Pager):
18
+ """Uses the pager installed on the system."""
19
+
20
+ def _pager(self, content: str) -> Any: #  pragma: no cover
21
+ return __import__("pydoc").pager(content)
22
+
23
+ def show(self, content: str) -> None:
24
+ """Use the same pager used by pydoc."""
25
+ self._pager(content)
26
+
27
+
28
+ if __name__ == "__main__": # pragma: no cover
29
+ from .__main__ import make_test_card
30
+ from .console import Console
31
+
32
+ console = Console()
33
+ with console.pager(styles=True):
34
+ console.print(make_test_card())
.venv/lib/python3.13/site-packages/pip/_vendor/rich/palette.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from math import sqrt
2
+ from functools import lru_cache
3
+ from typing import Sequence, Tuple, TYPE_CHECKING
4
+
5
+ from .color_triplet import ColorTriplet
6
+
7
+ if TYPE_CHECKING:
8
+ from pip._vendor.rich.table import Table
9
+
10
+
11
+ class Palette:
12
+ """A palette of available colors."""
13
+
14
+ def __init__(self, colors: Sequence[Tuple[int, int, int]]):
15
+ self._colors = colors
16
+
17
+ def __getitem__(self, number: int) -> ColorTriplet:
18
+ return ColorTriplet(*self._colors[number])
19
+
20
+ def __rich__(self) -> "Table":
21
+ from pip._vendor.rich.color import Color
22
+ from pip._vendor.rich.style import Style
23
+ from pip._vendor.rich.text import Text
24
+ from pip._vendor.rich.table import Table
25
+
26
+ table = Table(
27
+ "index",
28
+ "RGB",
29
+ "Color",
30
+ title="Palette",
31
+ caption=f"{len(self._colors)} colors",
32
+ highlight=True,
33
+ caption_justify="right",
34
+ )
35
+ for index, color in enumerate(self._colors):
36
+ table.add_row(
37
+ str(index),
38
+ repr(color),
39
+ Text(" " * 16, style=Style(bgcolor=Color.from_rgb(*color))),
40
+ )
41
+ return table
42
+
43
+ # This is somewhat inefficient and needs caching
44
+ @lru_cache(maxsize=1024)
45
+ def match(self, color: Tuple[int, int, int]) -> int:
46
+ """Find a color from a palette that most closely matches a given color.
47
+
48
+ Args:
49
+ color (Tuple[int, int, int]): RGB components in range 0 > 255.
50
+
51
+ Returns:
52
+ int: Index of closes matching color.
53
+ """
54
+ red1, green1, blue1 = color
55
+ _sqrt = sqrt
56
+ get_color = self._colors.__getitem__
57
+
58
+ def get_color_distance(index: int) -> float:
59
+ """Get the distance to a color."""
60
+ red2, green2, blue2 = get_color(index)
61
+ red_mean = (red1 + red2) // 2
62
+ red = red1 - red2
63
+ green = green1 - green2
64
+ blue = blue1 - blue2
65
+ return _sqrt(
66
+ (((512 + red_mean) * red * red) >> 8)
67
+ + 4 * green * green
68
+ + (((767 - red_mean) * blue * blue) >> 8)
69
+ )
70
+
71
+ min_index = min(range(len(self._colors)), key=get_color_distance)
72
+ return min_index
73
+
74
+
75
+ if __name__ == "__main__": # pragma: no cover
76
+ import colorsys
77
+ from typing import Iterable
78
+ from pip._vendor.rich.color import Color
79
+ from pip._vendor.rich.console import Console, ConsoleOptions
80
+ from pip._vendor.rich.segment import Segment
81
+ from pip._vendor.rich.style import Style
82
+
83
+ class ColorBox:
84
+ def __rich_console__(
85
+ self, console: Console, options: ConsoleOptions
86
+ ) -> Iterable[Segment]:
87
+ height = console.size.height - 3
88
+ for y in range(0, height):
89
+ for x in range(options.max_width):
90
+ h = x / options.max_width
91
+ l = y / (height + 1)
92
+ r1, g1, b1 = colorsys.hls_to_rgb(h, l, 1.0)
93
+ r2, g2, b2 = colorsys.hls_to_rgb(h, l + (1 / height / 2), 1.0)
94
+ bgcolor = Color.from_rgb(r1 * 255, g1 * 255, b1 * 255)
95
+ color = Color.from_rgb(r2 * 255, g2 * 255, b2 * 255)
96
+ yield Segment("▄", Style(color=color, bgcolor=bgcolor))
97
+ yield Segment.line()
98
+
99
+ console = Console()
100
+ console.print(ColorBox())
.venv/lib/python3.13/site-packages/pip/_vendor/rich/panel.py ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TYPE_CHECKING, Optional
2
+
3
+ from .align import AlignMethod
4
+ from .box import ROUNDED, Box
5
+ from .cells import cell_len
6
+ from .jupyter import JupyterMixin
7
+ from .measure import Measurement, measure_renderables
8
+ from .padding import Padding, PaddingDimensions
9
+ from .segment import Segment
10
+ from .style import Style, StyleType
11
+ from .text import Text, TextType
12
+
13
+ if TYPE_CHECKING:
14
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
15
+
16
+
17
+ class Panel(JupyterMixin):
18
+ """A console renderable that draws a border around its contents.
19
+
20
+ Example:
21
+ >>> console.print(Panel("Hello, World!"))
22
+
23
+ Args:
24
+ renderable (RenderableType): A console renderable object.
25
+ box (Box): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED.
26
+ title (Optional[TextType], optional): Optional title displayed in panel header. Defaults to None.
27
+ title_align (AlignMethod, optional): Alignment of title. Defaults to "center".
28
+ subtitle (Optional[TextType], optional): Optional subtitle displayed in panel footer. Defaults to None.
29
+ subtitle_align (AlignMethod, optional): Alignment of subtitle. Defaults to "center".
30
+ safe_box (bool, optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
31
+ expand (bool, optional): If True the panel will stretch to fill the console width, otherwise it will be sized to fit the contents. Defaults to True.
32
+ style (str, optional): The style of the panel (border and contents). Defaults to "none".
33
+ border_style (str, optional): The style of the border. Defaults to "none".
34
+ width (Optional[int], optional): Optional width of panel. Defaults to None to auto-detect.
35
+ height (Optional[int], optional): Optional height of panel. Defaults to None to auto-detect.
36
+ padding (Optional[PaddingDimensions]): Optional padding around renderable. Defaults to 0.
37
+ highlight (bool, optional): Enable automatic highlighting of panel title (if str). Defaults to False.
38
+ """
39
+
40
+ def __init__(
41
+ self,
42
+ renderable: "RenderableType",
43
+ box: Box = ROUNDED,
44
+ *,
45
+ title: Optional[TextType] = None,
46
+ title_align: AlignMethod = "center",
47
+ subtitle: Optional[TextType] = None,
48
+ subtitle_align: AlignMethod = "center",
49
+ safe_box: Optional[bool] = None,
50
+ expand: bool = True,
51
+ style: StyleType = "none",
52
+ border_style: StyleType = "none",
53
+ width: Optional[int] = None,
54
+ height: Optional[int] = None,
55
+ padding: PaddingDimensions = (0, 1),
56
+ highlight: bool = False,
57
+ ) -> None:
58
+ self.renderable = renderable
59
+ self.box = box
60
+ self.title = title
61
+ self.title_align: AlignMethod = title_align
62
+ self.subtitle = subtitle
63
+ self.subtitle_align = subtitle_align
64
+ self.safe_box = safe_box
65
+ self.expand = expand
66
+ self.style = style
67
+ self.border_style = border_style
68
+ self.width = width
69
+ self.height = height
70
+ self.padding = padding
71
+ self.highlight = highlight
72
+
73
+ @classmethod
74
+ def fit(
75
+ cls,
76
+ renderable: "RenderableType",
77
+ box: Box = ROUNDED,
78
+ *,
79
+ title: Optional[TextType] = None,
80
+ title_align: AlignMethod = "center",
81
+ subtitle: Optional[TextType] = None,
82
+ subtitle_align: AlignMethod = "center",
83
+ safe_box: Optional[bool] = None,
84
+ style: StyleType = "none",
85
+ border_style: StyleType = "none",
86
+ width: Optional[int] = None,
87
+ height: Optional[int] = None,
88
+ padding: PaddingDimensions = (0, 1),
89
+ highlight: bool = False,
90
+ ) -> "Panel":
91
+ """An alternative constructor that sets expand=False."""
92
+ return cls(
93
+ renderable,
94
+ box,
95
+ title=title,
96
+ title_align=title_align,
97
+ subtitle=subtitle,
98
+ subtitle_align=subtitle_align,
99
+ safe_box=safe_box,
100
+ style=style,
101
+ border_style=border_style,
102
+ width=width,
103
+ height=height,
104
+ padding=padding,
105
+ highlight=highlight,
106
+ expand=False,
107
+ )
108
+
109
+ @property
110
+ def _title(self) -> Optional[Text]:
111
+ if self.title:
112
+ title_text = (
113
+ Text.from_markup(self.title)
114
+ if isinstance(self.title, str)
115
+ else self.title.copy()
116
+ )
117
+ title_text.end = ""
118
+ title_text.plain = title_text.plain.replace("\n", " ")
119
+ title_text.no_wrap = True
120
+ title_text.expand_tabs()
121
+ title_text.pad(1)
122
+ return title_text
123
+ return None
124
+
125
+ @property
126
+ def _subtitle(self) -> Optional[Text]:
127
+ if self.subtitle:
128
+ subtitle_text = (
129
+ Text.from_markup(self.subtitle)
130
+ if isinstance(self.subtitle, str)
131
+ else self.subtitle.copy()
132
+ )
133
+ subtitle_text.end = ""
134
+ subtitle_text.plain = subtitle_text.plain.replace("\n", " ")
135
+ subtitle_text.no_wrap = True
136
+ subtitle_text.expand_tabs()
137
+ subtitle_text.pad(1)
138
+ return subtitle_text
139
+ return None
140
+
141
+ def __rich_console__(
142
+ self, console: "Console", options: "ConsoleOptions"
143
+ ) -> "RenderResult":
144
+ _padding = Padding.unpack(self.padding)
145
+ renderable = (
146
+ Padding(self.renderable, _padding) if any(_padding) else self.renderable
147
+ )
148
+ style = console.get_style(self.style)
149
+ partial_border_style = console.get_style(self.border_style)
150
+ border_style = style + partial_border_style
151
+ width = (
152
+ options.max_width
153
+ if self.width is None
154
+ else min(options.max_width, self.width)
155
+ )
156
+
157
+ safe_box: bool = console.safe_box if self.safe_box is None else self.safe_box
158
+ box = self.box.substitute(options, safe=safe_box)
159
+
160
+ def align_text(
161
+ text: Text, width: int, align: str, character: str, style: Style
162
+ ) -> Text:
163
+ """Gets new aligned text.
164
+
165
+ Args:
166
+ text (Text): Title or subtitle text.
167
+ width (int): Desired width.
168
+ align (str): Alignment.
169
+ character (str): Character for alignment.
170
+ style (Style): Border style
171
+
172
+ Returns:
173
+ Text: New text instance
174
+ """
175
+ text = text.copy()
176
+ text.truncate(width)
177
+ excess_space = width - cell_len(text.plain)
178
+ if text.style:
179
+ text.stylize(console.get_style(text.style))
180
+
181
+ if excess_space:
182
+ if align == "left":
183
+ return Text.assemble(
184
+ text,
185
+ (character * excess_space, style),
186
+ no_wrap=True,
187
+ end="",
188
+ )
189
+ elif align == "center":
190
+ left = excess_space // 2
191
+ return Text.assemble(
192
+ (character * left, style),
193
+ text,
194
+ (character * (excess_space - left), style),
195
+ no_wrap=True,
196
+ end="",
197
+ )
198
+ else:
199
+ return Text.assemble(
200
+ (character * excess_space, style),
201
+ text,
202
+ no_wrap=True,
203
+ end="",
204
+ )
205
+ return text
206
+
207
+ title_text = self._title
208
+ if title_text is not None:
209
+ title_text.stylize_before(partial_border_style)
210
+
211
+ child_width = (
212
+ width - 2
213
+ if self.expand
214
+ else console.measure(
215
+ renderable, options=options.update_width(width - 2)
216
+ ).maximum
217
+ )
218
+ child_height = self.height or options.height or None
219
+ if child_height:
220
+ child_height -= 2
221
+ if title_text is not None:
222
+ child_width = min(
223
+ options.max_width - 2, max(child_width, title_text.cell_len + 2)
224
+ )
225
+
226
+ width = child_width + 2
227
+ child_options = options.update(
228
+ width=child_width, height=child_height, highlight=self.highlight
229
+ )
230
+ lines = console.render_lines(renderable, child_options, style=style)
231
+
232
+ line_start = Segment(box.mid_left, border_style)
233
+ line_end = Segment(f"{box.mid_right}", border_style)
234
+ new_line = Segment.line()
235
+ if title_text is None or width <= 4:
236
+ yield Segment(box.get_top([width - 2]), border_style)
237
+ else:
238
+ title_text = align_text(
239
+ title_text,
240
+ width - 4,
241
+ self.title_align,
242
+ box.top,
243
+ border_style,
244
+ )
245
+ yield Segment(box.top_left + box.top, border_style)
246
+ yield from console.render(title_text, child_options.update_width(width - 4))
247
+ yield Segment(box.top + box.top_right, border_style)
248
+
249
+ yield new_line
250
+ for line in lines:
251
+ yield line_start
252
+ yield from line
253
+ yield line_end
254
+ yield new_line
255
+
256
+ subtitle_text = self._subtitle
257
+ if subtitle_text is not None:
258
+ subtitle_text.stylize_before(partial_border_style)
259
+
260
+ if subtitle_text is None or width <= 4:
261
+ yield Segment(box.get_bottom([width - 2]), border_style)
262
+ else:
263
+ subtitle_text = align_text(
264
+ subtitle_text,
265
+ width - 4,
266
+ self.subtitle_align,
267
+ box.bottom,
268
+ border_style,
269
+ )
270
+ yield Segment(box.bottom_left + box.bottom, border_style)
271
+ yield from console.render(
272
+ subtitle_text, child_options.update_width(width - 4)
273
+ )
274
+ yield Segment(box.bottom + box.bottom_right, border_style)
275
+
276
+ yield new_line
277
+
278
+ def __rich_measure__(
279
+ self, console: "Console", options: "ConsoleOptions"
280
+ ) -> "Measurement":
281
+ _title = self._title
282
+ _, right, _, left = Padding.unpack(self.padding)
283
+ padding = left + right
284
+ renderables = [self.renderable, _title] if _title else [self.renderable]
285
+
286
+ if self.width is None:
287
+ width = (
288
+ measure_renderables(
289
+ console,
290
+ options.update_width(options.max_width - padding - 2),
291
+ renderables,
292
+ ).maximum
293
+ + padding
294
+ + 2
295
+ )
296
+ else:
297
+ width = self.width
298
+ return Measurement(width, width)
299
+
300
+
301
+ if __name__ == "__main__": # pragma: no cover
302
+ from .console import Console
303
+
304
+ c = Console()
305
+
306
+ from .box import DOUBLE, ROUNDED
307
+ from .padding import Padding
308
+
309
+ p = Panel(
310
+ "Hello, World!",
311
+ title="rich.Panel",
312
+ style="white on blue",
313
+ box=DOUBLE,
314
+ padding=1,
315
+ )
316
+
317
+ c.print()
318
+ c.print(p)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/pretty.py ADDED
@@ -0,0 +1,1016 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import builtins
2
+ import collections
3
+ import dataclasses
4
+ import inspect
5
+ import os
6
+ import reprlib
7
+ import sys
8
+ from array import array
9
+ from collections import Counter, UserDict, UserList, defaultdict, deque
10
+ from dataclasses import dataclass, fields, is_dataclass
11
+ from inspect import isclass
12
+ from itertools import islice
13
+ from types import MappingProxyType
14
+ from typing import (
15
+ TYPE_CHECKING,
16
+ Any,
17
+ Callable,
18
+ DefaultDict,
19
+ Deque,
20
+ Dict,
21
+ Iterable,
22
+ List,
23
+ Optional,
24
+ Sequence,
25
+ Set,
26
+ Tuple,
27
+ Union,
28
+ )
29
+
30
+ from pip._vendor.rich.repr import RichReprResult
31
+
32
+ try:
33
+ import attr as _attr_module
34
+
35
+ _has_attrs = hasattr(_attr_module, "ib")
36
+ except ImportError: # pragma: no cover
37
+ _has_attrs = False
38
+
39
+ from . import get_console
40
+ from ._loop import loop_last
41
+ from ._pick import pick_bool
42
+ from .abc import RichRenderable
43
+ from .cells import cell_len
44
+ from .highlighter import ReprHighlighter
45
+ from .jupyter import JupyterMixin, JupyterRenderable
46
+ from .measure import Measurement
47
+ from .text import Text
48
+
49
+ if TYPE_CHECKING:
50
+ from .console import (
51
+ Console,
52
+ ConsoleOptions,
53
+ HighlighterType,
54
+ JustifyMethod,
55
+ OverflowMethod,
56
+ RenderResult,
57
+ )
58
+
59
+
60
+ def _is_attr_object(obj: Any) -> bool:
61
+ """Check if an object was created with attrs module."""
62
+ return _has_attrs and _attr_module.has(type(obj))
63
+
64
+
65
+ def _get_attr_fields(obj: Any) -> Sequence["_attr_module.Attribute[Any]"]:
66
+ """Get fields for an attrs object."""
67
+ return _attr_module.fields(type(obj)) if _has_attrs else []
68
+
69
+
70
+ def _is_dataclass_repr(obj: object) -> bool:
71
+ """Check if an instance of a dataclass contains the default repr.
72
+
73
+ Args:
74
+ obj (object): A dataclass instance.
75
+
76
+ Returns:
77
+ bool: True if the default repr is used, False if there is a custom repr.
78
+ """
79
+ # Digging in to a lot of internals here
80
+ # Catching all exceptions in case something is missing on a non CPython implementation
81
+ try:
82
+ return obj.__repr__.__code__.co_filename in (
83
+ dataclasses.__file__,
84
+ reprlib.__file__,
85
+ )
86
+ except Exception: # pragma: no coverage
87
+ return False
88
+
89
+
90
+ _dummy_namedtuple = collections.namedtuple("_dummy_namedtuple", [])
91
+
92
+
93
+ def _has_default_namedtuple_repr(obj: object) -> bool:
94
+ """Check if an instance of namedtuple contains the default repr
95
+
96
+ Args:
97
+ obj (object): A namedtuple
98
+
99
+ Returns:
100
+ bool: True if the default repr is used, False if there's a custom repr.
101
+ """
102
+ obj_file = None
103
+ try:
104
+ obj_file = inspect.getfile(obj.__repr__)
105
+ except (OSError, TypeError):
106
+ # OSError handles case where object is defined in __main__ scope, e.g. REPL - no filename available.
107
+ # TypeError trapped defensively, in case of object without filename slips through.
108
+ pass
109
+ default_repr_file = inspect.getfile(_dummy_namedtuple.__repr__)
110
+ return obj_file == default_repr_file
111
+
112
+
113
+ def _ipy_display_hook(
114
+ value: Any,
115
+ console: Optional["Console"] = None,
116
+ overflow: "OverflowMethod" = "ignore",
117
+ crop: bool = False,
118
+ indent_guides: bool = False,
119
+ max_length: Optional[int] = None,
120
+ max_string: Optional[int] = None,
121
+ max_depth: Optional[int] = None,
122
+ expand_all: bool = False,
123
+ ) -> Union[str, None]:
124
+ # needed here to prevent circular import:
125
+ from .console import ConsoleRenderable
126
+
127
+ # always skip rich generated jupyter renderables or None values
128
+ if _safe_isinstance(value, JupyterRenderable) or value is None:
129
+ return None
130
+
131
+ console = console or get_console()
132
+
133
+ with console.capture() as capture:
134
+ # certain renderables should start on a new line
135
+ if _safe_isinstance(value, ConsoleRenderable):
136
+ console.line()
137
+ console.print(
138
+ (
139
+ value
140
+ if _safe_isinstance(value, RichRenderable)
141
+ else Pretty(
142
+ value,
143
+ overflow=overflow,
144
+ indent_guides=indent_guides,
145
+ max_length=max_length,
146
+ max_string=max_string,
147
+ max_depth=max_depth,
148
+ expand_all=expand_all,
149
+ margin=12,
150
+ )
151
+ ),
152
+ crop=crop,
153
+ new_line_start=True,
154
+ end="",
155
+ )
156
+ # strip trailing newline, not usually part of a text repr
157
+ # I'm not sure if this should be prevented at a lower level
158
+ return capture.get().rstrip("\n")
159
+
160
+
161
+ def _safe_isinstance(
162
+ obj: object, class_or_tuple: Union[type, Tuple[type, ...]]
163
+ ) -> bool:
164
+ """isinstance can fail in rare cases, for example types with no __class__"""
165
+ try:
166
+ return isinstance(obj, class_or_tuple)
167
+ except Exception:
168
+ return False
169
+
170
+
171
+ def install(
172
+ console: Optional["Console"] = None,
173
+ overflow: "OverflowMethod" = "ignore",
174
+ crop: bool = False,
175
+ indent_guides: bool = False,
176
+ max_length: Optional[int] = None,
177
+ max_string: Optional[int] = None,
178
+ max_depth: Optional[int] = None,
179
+ expand_all: bool = False,
180
+ ) -> None:
181
+ """Install automatic pretty printing in the Python REPL.
182
+
183
+ Args:
184
+ console (Console, optional): Console instance or ``None`` to use global console. Defaults to None.
185
+ overflow (Optional[OverflowMethod], optional): Overflow method. Defaults to "ignore".
186
+ crop (Optional[bool], optional): Enable cropping of long lines. Defaults to False.
187
+ indent_guides (bool, optional): Enable indentation guides. Defaults to False.
188
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
189
+ Defaults to None.
190
+ max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
191
+ max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None.
192
+ expand_all (bool, optional): Expand all containers. Defaults to False.
193
+ max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
194
+ """
195
+ from pip._vendor.rich import get_console
196
+
197
+ console = console or get_console()
198
+ assert console is not None
199
+
200
+ def display_hook(value: Any) -> None:
201
+ """Replacement sys.displayhook which prettifies objects with Rich."""
202
+ if value is not None:
203
+ assert console is not None
204
+ builtins._ = None # type: ignore[attr-defined]
205
+ console.print(
206
+ (
207
+ value
208
+ if _safe_isinstance(value, RichRenderable)
209
+ else Pretty(
210
+ value,
211
+ overflow=overflow,
212
+ indent_guides=indent_guides,
213
+ max_length=max_length,
214
+ max_string=max_string,
215
+ max_depth=max_depth,
216
+ expand_all=expand_all,
217
+ )
218
+ ),
219
+ crop=crop,
220
+ )
221
+ builtins._ = value # type: ignore[attr-defined]
222
+
223
+ try:
224
+ ip = get_ipython() # type: ignore[name-defined]
225
+ except NameError:
226
+ sys.displayhook = display_hook
227
+ else:
228
+ from IPython.core.formatters import BaseFormatter
229
+
230
+ class RichFormatter(BaseFormatter): # type: ignore[misc]
231
+ pprint: bool = True
232
+
233
+ def __call__(self, value: Any) -> Any:
234
+ if self.pprint:
235
+ return _ipy_display_hook(
236
+ value,
237
+ console=get_console(),
238
+ overflow=overflow,
239
+ indent_guides=indent_guides,
240
+ max_length=max_length,
241
+ max_string=max_string,
242
+ max_depth=max_depth,
243
+ expand_all=expand_all,
244
+ )
245
+ else:
246
+ return repr(value)
247
+
248
+ # replace plain text formatter with rich formatter
249
+ rich_formatter = RichFormatter()
250
+ ip.display_formatter.formatters["text/plain"] = rich_formatter
251
+
252
+
253
+ class Pretty(JupyterMixin):
254
+ """A rich renderable that pretty prints an object.
255
+
256
+ Args:
257
+ _object (Any): An object to pretty print.
258
+ highlighter (HighlighterType, optional): Highlighter object to apply to result, or None for ReprHighlighter. Defaults to None.
259
+ indent_size (int, optional): Number of spaces in indent. Defaults to 4.
260
+ justify (JustifyMethod, optional): Justify method, or None for default. Defaults to None.
261
+ overflow (OverflowMethod, optional): Overflow method, or None for default. Defaults to None.
262
+ no_wrap (Optional[bool], optional): Disable word wrapping. Defaults to False.
263
+ indent_guides (bool, optional): Enable indentation guides. Defaults to False.
264
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
265
+ Defaults to None.
266
+ max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
267
+ max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None.
268
+ expand_all (bool, optional): Expand all containers. Defaults to False.
269
+ margin (int, optional): Subtrace a margin from width to force containers to expand earlier. Defaults to 0.
270
+ insert_line (bool, optional): Insert a new line if the output has multiple new lines. Defaults to False.
271
+ """
272
+
273
+ def __init__(
274
+ self,
275
+ _object: Any,
276
+ highlighter: Optional["HighlighterType"] = None,
277
+ *,
278
+ indent_size: int = 4,
279
+ justify: Optional["JustifyMethod"] = None,
280
+ overflow: Optional["OverflowMethod"] = None,
281
+ no_wrap: Optional[bool] = False,
282
+ indent_guides: bool = False,
283
+ max_length: Optional[int] = None,
284
+ max_string: Optional[int] = None,
285
+ max_depth: Optional[int] = None,
286
+ expand_all: bool = False,
287
+ margin: int = 0,
288
+ insert_line: bool = False,
289
+ ) -> None:
290
+ self._object = _object
291
+ self.highlighter = highlighter or ReprHighlighter()
292
+ self.indent_size = indent_size
293
+ self.justify: Optional["JustifyMethod"] = justify
294
+ self.overflow: Optional["OverflowMethod"] = overflow
295
+ self.no_wrap = no_wrap
296
+ self.indent_guides = indent_guides
297
+ self.max_length = max_length
298
+ self.max_string = max_string
299
+ self.max_depth = max_depth
300
+ self.expand_all = expand_all
301
+ self.margin = margin
302
+ self.insert_line = insert_line
303
+
304
+ def __rich_console__(
305
+ self, console: "Console", options: "ConsoleOptions"
306
+ ) -> "RenderResult":
307
+ pretty_str = pretty_repr(
308
+ self._object,
309
+ max_width=options.max_width - self.margin,
310
+ indent_size=self.indent_size,
311
+ max_length=self.max_length,
312
+ max_string=self.max_string,
313
+ max_depth=self.max_depth,
314
+ expand_all=self.expand_all,
315
+ )
316
+ pretty_text = Text.from_ansi(
317
+ pretty_str,
318
+ justify=self.justify or options.justify,
319
+ overflow=self.overflow or options.overflow,
320
+ no_wrap=pick_bool(self.no_wrap, options.no_wrap),
321
+ style="pretty",
322
+ )
323
+ pretty_text = (
324
+ self.highlighter(pretty_text)
325
+ if pretty_text
326
+ else Text(
327
+ f"{type(self._object)}.__repr__ returned empty string",
328
+ style="dim italic",
329
+ )
330
+ )
331
+ if self.indent_guides and not options.ascii_only:
332
+ pretty_text = pretty_text.with_indent_guides(
333
+ self.indent_size, style="repr.indent"
334
+ )
335
+ if self.insert_line and "\n" in pretty_text:
336
+ yield ""
337
+ yield pretty_text
338
+
339
+ def __rich_measure__(
340
+ self, console: "Console", options: "ConsoleOptions"
341
+ ) -> "Measurement":
342
+ pretty_str = pretty_repr(
343
+ self._object,
344
+ max_width=options.max_width,
345
+ indent_size=self.indent_size,
346
+ max_length=self.max_length,
347
+ max_string=self.max_string,
348
+ max_depth=self.max_depth,
349
+ expand_all=self.expand_all,
350
+ )
351
+ text_width = (
352
+ max(cell_len(line) for line in pretty_str.splitlines()) if pretty_str else 0
353
+ )
354
+ return Measurement(text_width, text_width)
355
+
356
+
357
+ def _get_braces_for_defaultdict(_object: DefaultDict[Any, Any]) -> Tuple[str, str, str]:
358
+ return (
359
+ f"defaultdict({_object.default_factory!r}, {{",
360
+ "})",
361
+ f"defaultdict({_object.default_factory!r}, {{}})",
362
+ )
363
+
364
+
365
+ def _get_braces_for_deque(_object: Deque[Any]) -> Tuple[str, str, str]:
366
+ if _object.maxlen is None:
367
+ return ("deque([", "])", "deque()")
368
+ return (
369
+ "deque([",
370
+ f"], maxlen={_object.maxlen})",
371
+ f"deque(maxlen={_object.maxlen})",
372
+ )
373
+
374
+
375
+ def _get_braces_for_array(_object: "array[Any]") -> Tuple[str, str, str]:
376
+ return (f"array({_object.typecode!r}, [", "])", f"array({_object.typecode!r})")
377
+
378
+
379
+ _BRACES: Dict[type, Callable[[Any], Tuple[str, str, str]]] = {
380
+ os._Environ: lambda _object: ("environ({", "})", "environ({})"),
381
+ array: _get_braces_for_array,
382
+ defaultdict: _get_braces_for_defaultdict,
383
+ Counter: lambda _object: ("Counter({", "})", "Counter()"),
384
+ deque: _get_braces_for_deque,
385
+ dict: lambda _object: ("{", "}", "{}"),
386
+ UserDict: lambda _object: ("{", "}", "{}"),
387
+ frozenset: lambda _object: ("frozenset({", "})", "frozenset()"),
388
+ list: lambda _object: ("[", "]", "[]"),
389
+ UserList: lambda _object: ("[", "]", "[]"),
390
+ set: lambda _object: ("{", "}", "set()"),
391
+ tuple: lambda _object: ("(", ")", "()"),
392
+ MappingProxyType: lambda _object: ("mappingproxy({", "})", "mappingproxy({})"),
393
+ }
394
+ _CONTAINERS = tuple(_BRACES.keys())
395
+ _MAPPING_CONTAINERS = (dict, os._Environ, MappingProxyType, UserDict)
396
+
397
+
398
+ def is_expandable(obj: Any) -> bool:
399
+ """Check if an object may be expanded by pretty print."""
400
+ return (
401
+ _safe_isinstance(obj, _CONTAINERS)
402
+ or (is_dataclass(obj))
403
+ or (hasattr(obj, "__rich_repr__"))
404
+ or _is_attr_object(obj)
405
+ ) and not isclass(obj)
406
+
407
+
408
+ @dataclass
409
+ class Node:
410
+ """A node in a repr tree. May be atomic or a container."""
411
+
412
+ key_repr: str = ""
413
+ value_repr: str = ""
414
+ open_brace: str = ""
415
+ close_brace: str = ""
416
+ empty: str = ""
417
+ last: bool = False
418
+ is_tuple: bool = False
419
+ is_namedtuple: bool = False
420
+ children: Optional[List["Node"]] = None
421
+ key_separator: str = ": "
422
+ separator: str = ", "
423
+
424
+ def iter_tokens(self) -> Iterable[str]:
425
+ """Generate tokens for this node."""
426
+ if self.key_repr:
427
+ yield self.key_repr
428
+ yield self.key_separator
429
+ if self.value_repr:
430
+ yield self.value_repr
431
+ elif self.children is not None:
432
+ if self.children:
433
+ yield self.open_brace
434
+ if self.is_tuple and not self.is_namedtuple and len(self.children) == 1:
435
+ yield from self.children[0].iter_tokens()
436
+ yield ","
437
+ else:
438
+ for child in self.children:
439
+ yield from child.iter_tokens()
440
+ if not child.last:
441
+ yield self.separator
442
+ yield self.close_brace
443
+ else:
444
+ yield self.empty
445
+
446
+ def check_length(self, start_length: int, max_length: int) -> bool:
447
+ """Check the length fits within a limit.
448
+
449
+ Args:
450
+ start_length (int): Starting length of the line (indent, prefix, suffix).
451
+ max_length (int): Maximum length.
452
+
453
+ Returns:
454
+ bool: True if the node can be rendered within max length, otherwise False.
455
+ """
456
+ total_length = start_length
457
+ for token in self.iter_tokens():
458
+ total_length += cell_len(token)
459
+ if total_length > max_length:
460
+ return False
461
+ return True
462
+
463
+ def __str__(self) -> str:
464
+ repr_text = "".join(self.iter_tokens())
465
+ return repr_text
466
+
467
+ def render(
468
+ self, max_width: int = 80, indent_size: int = 4, expand_all: bool = False
469
+ ) -> str:
470
+ """Render the node to a pretty repr.
471
+
472
+ Args:
473
+ max_width (int, optional): Maximum width of the repr. Defaults to 80.
474
+ indent_size (int, optional): Size of indents. Defaults to 4.
475
+ expand_all (bool, optional): Expand all levels. Defaults to False.
476
+
477
+ Returns:
478
+ str: A repr string of the original object.
479
+ """
480
+ lines = [_Line(node=self, is_root=True)]
481
+ line_no = 0
482
+ while line_no < len(lines):
483
+ line = lines[line_no]
484
+ if line.expandable and not line.expanded:
485
+ if expand_all or not line.check_length(max_width):
486
+ lines[line_no : line_no + 1] = line.expand(indent_size)
487
+ line_no += 1
488
+
489
+ repr_str = "\n".join(str(line) for line in lines)
490
+ return repr_str
491
+
492
+
493
+ @dataclass
494
+ class _Line:
495
+ """A line in repr output."""
496
+
497
+ parent: Optional["_Line"] = None
498
+ is_root: bool = False
499
+ node: Optional[Node] = None
500
+ text: str = ""
501
+ suffix: str = ""
502
+ whitespace: str = ""
503
+ expanded: bool = False
504
+ last: bool = False
505
+
506
+ @property
507
+ def expandable(self) -> bool:
508
+ """Check if the line may be expanded."""
509
+ return bool(self.node is not None and self.node.children)
510
+
511
+ def check_length(self, max_length: int) -> bool:
512
+ """Check this line fits within a given number of cells."""
513
+ start_length = (
514
+ len(self.whitespace) + cell_len(self.text) + cell_len(self.suffix)
515
+ )
516
+ assert self.node is not None
517
+ return self.node.check_length(start_length, max_length)
518
+
519
+ def expand(self, indent_size: int) -> Iterable["_Line"]:
520
+ """Expand this line by adding children on their own line."""
521
+ node = self.node
522
+ assert node is not None
523
+ whitespace = self.whitespace
524
+ assert node.children
525
+ if node.key_repr:
526
+ new_line = yield _Line(
527
+ text=f"{node.key_repr}{node.key_separator}{node.open_brace}",
528
+ whitespace=whitespace,
529
+ )
530
+ else:
531
+ new_line = yield _Line(text=node.open_brace, whitespace=whitespace)
532
+ child_whitespace = self.whitespace + " " * indent_size
533
+ tuple_of_one = node.is_tuple and len(node.children) == 1
534
+ for last, child in loop_last(node.children):
535
+ separator = "," if tuple_of_one else node.separator
536
+ line = _Line(
537
+ parent=new_line,
538
+ node=child,
539
+ whitespace=child_whitespace,
540
+ suffix=separator,
541
+ last=last and not tuple_of_one,
542
+ )
543
+ yield line
544
+
545
+ yield _Line(
546
+ text=node.close_brace,
547
+ whitespace=whitespace,
548
+ suffix=self.suffix,
549
+ last=self.last,
550
+ )
551
+
552
+ def __str__(self) -> str:
553
+ if self.last:
554
+ return f"{self.whitespace}{self.text}{self.node or ''}"
555
+ else:
556
+ return (
557
+ f"{self.whitespace}{self.text}{self.node or ''}{self.suffix.rstrip()}"
558
+ )
559
+
560
+
561
+ def _is_namedtuple(obj: Any) -> bool:
562
+ """Checks if an object is most likely a namedtuple. It is possible
563
+ to craft an object that passes this check and isn't a namedtuple, but
564
+ there is only a minuscule chance of this happening unintentionally.
565
+
566
+ Args:
567
+ obj (Any): The object to test
568
+
569
+ Returns:
570
+ bool: True if the object is a namedtuple. False otherwise.
571
+ """
572
+ try:
573
+ fields = getattr(obj, "_fields", None)
574
+ except Exception:
575
+ # Being very defensive - if we cannot get the attr then its not a namedtuple
576
+ return False
577
+ return isinstance(obj, tuple) and isinstance(fields, tuple)
578
+
579
+
580
+ def traverse(
581
+ _object: Any,
582
+ max_length: Optional[int] = None,
583
+ max_string: Optional[int] = None,
584
+ max_depth: Optional[int] = None,
585
+ ) -> Node:
586
+ """Traverse object and generate a tree.
587
+
588
+ Args:
589
+ _object (Any): Object to be traversed.
590
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
591
+ Defaults to None.
592
+ max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
593
+ Defaults to None.
594
+ max_depth (int, optional): Maximum depth of data structures, or None for no maximum.
595
+ Defaults to None.
596
+
597
+ Returns:
598
+ Node: The root of a tree structure which can be used to render a pretty repr.
599
+ """
600
+
601
+ def to_repr(obj: Any) -> str:
602
+ """Get repr string for an object, but catch errors."""
603
+ if (
604
+ max_string is not None
605
+ and _safe_isinstance(obj, (bytes, str))
606
+ and len(obj) > max_string
607
+ ):
608
+ truncated = len(obj) - max_string
609
+ obj_repr = f"{obj[:max_string]!r}+{truncated}"
610
+ else:
611
+ try:
612
+ obj_repr = repr(obj)
613
+ except Exception as error:
614
+ obj_repr = f"<repr-error {str(error)!r}>"
615
+ return obj_repr
616
+
617
+ visited_ids: Set[int] = set()
618
+ push_visited = visited_ids.add
619
+ pop_visited = visited_ids.remove
620
+
621
+ def _traverse(obj: Any, root: bool = False, depth: int = 0) -> Node:
622
+ """Walk the object depth first."""
623
+
624
+ obj_id = id(obj)
625
+ if obj_id in visited_ids:
626
+ # Recursion detected
627
+ return Node(value_repr="...")
628
+
629
+ obj_type = type(obj)
630
+ children: List[Node]
631
+ reached_max_depth = max_depth is not None and depth >= max_depth
632
+
633
+ def iter_rich_args(rich_args: Any) -> Iterable[Union[Any, Tuple[str, Any]]]:
634
+ for arg in rich_args:
635
+ if _safe_isinstance(arg, tuple):
636
+ if len(arg) == 3:
637
+ key, child, default = arg
638
+ if default == child:
639
+ continue
640
+ yield key, child
641
+ elif len(arg) == 2:
642
+ key, child = arg
643
+ yield key, child
644
+ elif len(arg) == 1:
645
+ yield arg[0]
646
+ else:
647
+ yield arg
648
+
649
+ try:
650
+ fake_attributes = hasattr(
651
+ obj, "awehoi234_wdfjwljet234_234wdfoijsdfmmnxpi492"
652
+ )
653
+ except Exception:
654
+ fake_attributes = False
655
+
656
+ rich_repr_result: Optional[RichReprResult] = None
657
+ if not fake_attributes:
658
+ try:
659
+ if hasattr(obj, "__rich_repr__") and not isclass(obj):
660
+ rich_repr_result = obj.__rich_repr__()
661
+ except Exception:
662
+ pass
663
+
664
+ if rich_repr_result is not None:
665
+ push_visited(obj_id)
666
+ angular = getattr(obj.__rich_repr__, "angular", False)
667
+ args = list(iter_rich_args(rich_repr_result))
668
+ class_name = obj.__class__.__name__
669
+
670
+ if args:
671
+ children = []
672
+ append = children.append
673
+
674
+ if reached_max_depth:
675
+ if angular:
676
+ node = Node(value_repr=f"<{class_name}...>")
677
+ else:
678
+ node = Node(value_repr=f"{class_name}(...)")
679
+ else:
680
+ if angular:
681
+ node = Node(
682
+ open_brace=f"<{class_name} ",
683
+ close_brace=">",
684
+ children=children,
685
+ last=root,
686
+ separator=" ",
687
+ )
688
+ else:
689
+ node = Node(
690
+ open_brace=f"{class_name}(",
691
+ close_brace=")",
692
+ children=children,
693
+ last=root,
694
+ )
695
+ for last, arg in loop_last(args):
696
+ if _safe_isinstance(arg, tuple):
697
+ key, child = arg
698
+ child_node = _traverse(child, depth=depth + 1)
699
+ child_node.last = last
700
+ child_node.key_repr = key
701
+ child_node.key_separator = "="
702
+ append(child_node)
703
+ else:
704
+ child_node = _traverse(arg, depth=depth + 1)
705
+ child_node.last = last
706
+ append(child_node)
707
+ else:
708
+ node = Node(
709
+ value_repr=f"<{class_name}>" if angular else f"{class_name}()",
710
+ children=[],
711
+ last=root,
712
+ )
713
+ pop_visited(obj_id)
714
+ elif _is_attr_object(obj) and not fake_attributes:
715
+ push_visited(obj_id)
716
+ children = []
717
+ append = children.append
718
+
719
+ attr_fields = _get_attr_fields(obj)
720
+ if attr_fields:
721
+ if reached_max_depth:
722
+ node = Node(value_repr=f"{obj.__class__.__name__}(...)")
723
+ else:
724
+ node = Node(
725
+ open_brace=f"{obj.__class__.__name__}(",
726
+ close_brace=")",
727
+ children=children,
728
+ last=root,
729
+ )
730
+
731
+ def iter_attrs() -> (
732
+ Iterable[Tuple[str, Any, Optional[Callable[[Any], str]]]]
733
+ ):
734
+ """Iterate over attr fields and values."""
735
+ for attr in attr_fields:
736
+ if attr.repr:
737
+ try:
738
+ value = getattr(obj, attr.name)
739
+ except Exception as error:
740
+ # Can happen, albeit rarely
741
+ yield (attr.name, error, None)
742
+ else:
743
+ yield (
744
+ attr.name,
745
+ value,
746
+ attr.repr if callable(attr.repr) else None,
747
+ )
748
+
749
+ for last, (name, value, repr_callable) in loop_last(iter_attrs()):
750
+ if repr_callable:
751
+ child_node = Node(value_repr=str(repr_callable(value)))
752
+ else:
753
+ child_node = _traverse(value, depth=depth + 1)
754
+ child_node.last = last
755
+ child_node.key_repr = name
756
+ child_node.key_separator = "="
757
+ append(child_node)
758
+ else:
759
+ node = Node(
760
+ value_repr=f"{obj.__class__.__name__}()", children=[], last=root
761
+ )
762
+ pop_visited(obj_id)
763
+ elif (
764
+ is_dataclass(obj)
765
+ and not _safe_isinstance(obj, type)
766
+ and not fake_attributes
767
+ and _is_dataclass_repr(obj)
768
+ ):
769
+ push_visited(obj_id)
770
+ children = []
771
+ append = children.append
772
+ if reached_max_depth:
773
+ node = Node(value_repr=f"{obj.__class__.__name__}(...)")
774
+ else:
775
+ node = Node(
776
+ open_brace=f"{obj.__class__.__name__}(",
777
+ close_brace=")",
778
+ children=children,
779
+ last=root,
780
+ empty=f"{obj.__class__.__name__}()",
781
+ )
782
+
783
+ for last, field in loop_last(
784
+ field
785
+ for field in fields(obj)
786
+ if field.repr and hasattr(obj, field.name)
787
+ ):
788
+ child_node = _traverse(getattr(obj, field.name), depth=depth + 1)
789
+ child_node.key_repr = field.name
790
+ child_node.last = last
791
+ child_node.key_separator = "="
792
+ append(child_node)
793
+
794
+ pop_visited(obj_id)
795
+ elif _is_namedtuple(obj) and _has_default_namedtuple_repr(obj):
796
+ push_visited(obj_id)
797
+ class_name = obj.__class__.__name__
798
+ if reached_max_depth:
799
+ # If we've reached the max depth, we still show the class name, but not its contents
800
+ node = Node(
801
+ value_repr=f"{class_name}(...)",
802
+ )
803
+ else:
804
+ children = []
805
+ append = children.append
806
+ node = Node(
807
+ open_brace=f"{class_name}(",
808
+ close_brace=")",
809
+ children=children,
810
+ empty=f"{class_name}()",
811
+ )
812
+ for last, (key, value) in loop_last(obj._asdict().items()):
813
+ child_node = _traverse(value, depth=depth + 1)
814
+ child_node.key_repr = key
815
+ child_node.last = last
816
+ child_node.key_separator = "="
817
+ append(child_node)
818
+ pop_visited(obj_id)
819
+ elif _safe_isinstance(obj, _CONTAINERS):
820
+ for container_type in _CONTAINERS:
821
+ if _safe_isinstance(obj, container_type):
822
+ obj_type = container_type
823
+ break
824
+
825
+ push_visited(obj_id)
826
+
827
+ open_brace, close_brace, empty = _BRACES[obj_type](obj)
828
+
829
+ if reached_max_depth:
830
+ node = Node(value_repr=f"{open_brace}...{close_brace}")
831
+ elif obj_type.__repr__ != type(obj).__repr__:
832
+ node = Node(value_repr=to_repr(obj), last=root)
833
+ elif obj:
834
+ children = []
835
+ node = Node(
836
+ open_brace=open_brace,
837
+ close_brace=close_brace,
838
+ children=children,
839
+ last=root,
840
+ )
841
+ append = children.append
842
+ num_items = len(obj)
843
+ last_item_index = num_items - 1
844
+
845
+ if _safe_isinstance(obj, _MAPPING_CONTAINERS):
846
+ iter_items = iter(obj.items())
847
+ if max_length is not None:
848
+ iter_items = islice(iter_items, max_length)
849
+ for index, (key, child) in enumerate(iter_items):
850
+ child_node = _traverse(child, depth=depth + 1)
851
+ child_node.key_repr = to_repr(key)
852
+ child_node.last = index == last_item_index
853
+ append(child_node)
854
+ else:
855
+ iter_values = iter(obj)
856
+ if max_length is not None:
857
+ iter_values = islice(iter_values, max_length)
858
+ for index, child in enumerate(iter_values):
859
+ child_node = _traverse(child, depth=depth + 1)
860
+ child_node.last = index == last_item_index
861
+ append(child_node)
862
+ if max_length is not None and num_items > max_length:
863
+ append(Node(value_repr=f"... +{num_items - max_length}", last=True))
864
+ else:
865
+ node = Node(empty=empty, children=[], last=root)
866
+
867
+ pop_visited(obj_id)
868
+ else:
869
+ node = Node(value_repr=to_repr(obj), last=root)
870
+ node.is_tuple = type(obj) == tuple
871
+ node.is_namedtuple = _is_namedtuple(obj)
872
+ return node
873
+
874
+ node = _traverse(_object, root=True)
875
+ return node
876
+
877
+
878
+ def pretty_repr(
879
+ _object: Any,
880
+ *,
881
+ max_width: int = 80,
882
+ indent_size: int = 4,
883
+ max_length: Optional[int] = None,
884
+ max_string: Optional[int] = None,
885
+ max_depth: Optional[int] = None,
886
+ expand_all: bool = False,
887
+ ) -> str:
888
+ """Prettify repr string by expanding on to new lines to fit within a given width.
889
+
890
+ Args:
891
+ _object (Any): Object to repr.
892
+ max_width (int, optional): Desired maximum width of repr string. Defaults to 80.
893
+ indent_size (int, optional): Number of spaces to indent. Defaults to 4.
894
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
895
+ Defaults to None.
896
+ max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
897
+ Defaults to None.
898
+ max_depth (int, optional): Maximum depth of nested data structure, or None for no depth.
899
+ Defaults to None.
900
+ expand_all (bool, optional): Expand all containers regardless of available width. Defaults to False.
901
+
902
+ Returns:
903
+ str: A possibly multi-line representation of the object.
904
+ """
905
+
906
+ if _safe_isinstance(_object, Node):
907
+ node = _object
908
+ else:
909
+ node = traverse(
910
+ _object, max_length=max_length, max_string=max_string, max_depth=max_depth
911
+ )
912
+ repr_str: str = node.render(
913
+ max_width=max_width, indent_size=indent_size, expand_all=expand_all
914
+ )
915
+ return repr_str
916
+
917
+
918
+ def pprint(
919
+ _object: Any,
920
+ *,
921
+ console: Optional["Console"] = None,
922
+ indent_guides: bool = True,
923
+ max_length: Optional[int] = None,
924
+ max_string: Optional[int] = None,
925
+ max_depth: Optional[int] = None,
926
+ expand_all: bool = False,
927
+ ) -> None:
928
+ """A convenience function for pretty printing.
929
+
930
+ Args:
931
+ _object (Any): Object to pretty print.
932
+ console (Console, optional): Console instance, or None to use default. Defaults to None.
933
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
934
+ Defaults to None.
935
+ max_string (int, optional): Maximum length of strings before truncating, or None to disable. Defaults to None.
936
+ max_depth (int, optional): Maximum depth for nested data structures, or None for unlimited depth. Defaults to None.
937
+ indent_guides (bool, optional): Enable indentation guides. Defaults to True.
938
+ expand_all (bool, optional): Expand all containers. Defaults to False.
939
+ """
940
+ _console = get_console() if console is None else console
941
+ _console.print(
942
+ Pretty(
943
+ _object,
944
+ max_length=max_length,
945
+ max_string=max_string,
946
+ max_depth=max_depth,
947
+ indent_guides=indent_guides,
948
+ expand_all=expand_all,
949
+ overflow="ignore",
950
+ ),
951
+ soft_wrap=True,
952
+ )
953
+
954
+
955
+ if __name__ == "__main__": # pragma: no cover
956
+
957
+ class BrokenRepr:
958
+ def __repr__(self) -> str:
959
+ 1 / 0
960
+ return "this will fail"
961
+
962
+ from typing import NamedTuple
963
+
964
+ class StockKeepingUnit(NamedTuple):
965
+ name: str
966
+ description: str
967
+ price: float
968
+ category: str
969
+ reviews: List[str]
970
+
971
+ d = defaultdict(int)
972
+ d["foo"] = 5
973
+ data = {
974
+ "foo": [
975
+ 1,
976
+ "Hello World!",
977
+ 100.123,
978
+ 323.232,
979
+ 432324.0,
980
+ {5, 6, 7, (1, 2, 3, 4), 8},
981
+ ],
982
+ "bar": frozenset({1, 2, 3}),
983
+ "defaultdict": defaultdict(
984
+ list, {"crumble": ["apple", "rhubarb", "butter", "sugar", "flour"]}
985
+ ),
986
+ "counter": Counter(
987
+ [
988
+ "apple",
989
+ "orange",
990
+ "pear",
991
+ "kumquat",
992
+ "kumquat",
993
+ "durian" * 100,
994
+ ]
995
+ ),
996
+ "atomic": (False, True, None),
997
+ "namedtuple": StockKeepingUnit(
998
+ "Sparkling British Spring Water",
999
+ "Carbonated spring water",
1000
+ 0.9,
1001
+ "water",
1002
+ ["its amazing!", "its terrible!"],
1003
+ ),
1004
+ "Broken": BrokenRepr(),
1005
+ }
1006
+ data["foo"].append(data) # type: ignore[attr-defined]
1007
+
1008
+ from pip._vendor.rich import print
1009
+
1010
+ print(Pretty(data, indent_guides=True, max_string=20))
1011
+
1012
+ class Thing:
1013
+ def __repr__(self) -> str:
1014
+ return "Hello\x1b[38;5;239m World!"
1015
+
1016
+ print(Pretty(Thing()))
.venv/lib/python3.13/site-packages/pip/_vendor/rich/progress.py ADDED
@@ -0,0 +1,1715 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ import sys
3
+ import typing
4
+ import warnings
5
+ from abc import ABC, abstractmethod
6
+ from collections import deque
7
+ from dataclasses import dataclass, field
8
+ from datetime import timedelta
9
+ from io import RawIOBase, UnsupportedOperation
10
+ from math import ceil
11
+ from mmap import mmap
12
+ from operator import length_hint
13
+ from os import PathLike, stat
14
+ from threading import Event, RLock, Thread
15
+ from types import TracebackType
16
+ from typing import (
17
+ Any,
18
+ BinaryIO,
19
+ Callable,
20
+ ContextManager,
21
+ Deque,
22
+ Dict,
23
+ Generic,
24
+ Iterable,
25
+ List,
26
+ NamedTuple,
27
+ NewType,
28
+ Optional,
29
+ Sequence,
30
+ TextIO,
31
+ Tuple,
32
+ Type,
33
+ TypeVar,
34
+ Union,
35
+ )
36
+
37
+ if sys.version_info >= (3, 8):
38
+ from typing import Literal
39
+ else:
40
+ from pip._vendor.typing_extensions import Literal # pragma: no cover
41
+
42
+ if sys.version_info >= (3, 11):
43
+ from typing import Self
44
+ else:
45
+ from pip._vendor.typing_extensions import Self # pragma: no cover
46
+
47
+ from . import filesize, get_console
48
+ from .console import Console, Group, JustifyMethod, RenderableType
49
+ from .highlighter import Highlighter
50
+ from .jupyter import JupyterMixin
51
+ from .live import Live
52
+ from .progress_bar import ProgressBar
53
+ from .spinner import Spinner
54
+ from .style import StyleType
55
+ from .table import Column, Table
56
+ from .text import Text, TextType
57
+
58
+ TaskID = NewType("TaskID", int)
59
+
60
+ ProgressType = TypeVar("ProgressType")
61
+
62
+ GetTimeCallable = Callable[[], float]
63
+
64
+
65
+ _I = typing.TypeVar("_I", TextIO, BinaryIO)
66
+
67
+
68
+ class _TrackThread(Thread):
69
+ """A thread to periodically update progress."""
70
+
71
+ def __init__(self, progress: "Progress", task_id: "TaskID", update_period: float):
72
+ self.progress = progress
73
+ self.task_id = task_id
74
+ self.update_period = update_period
75
+ self.done = Event()
76
+
77
+ self.completed = 0
78
+ super().__init__(daemon=True)
79
+
80
+ def run(self) -> None:
81
+ task_id = self.task_id
82
+ advance = self.progress.advance
83
+ update_period = self.update_period
84
+ last_completed = 0
85
+ wait = self.done.wait
86
+ while not wait(update_period) and self.progress.live.is_started:
87
+ completed = self.completed
88
+ if last_completed != completed:
89
+ advance(task_id, completed - last_completed)
90
+ last_completed = completed
91
+
92
+ self.progress.update(self.task_id, completed=self.completed, refresh=True)
93
+
94
+ def __enter__(self) -> "_TrackThread":
95
+ self.start()
96
+ return self
97
+
98
+ def __exit__(
99
+ self,
100
+ exc_type: Optional[Type[BaseException]],
101
+ exc_val: Optional[BaseException],
102
+ exc_tb: Optional[TracebackType],
103
+ ) -> None:
104
+ self.done.set()
105
+ self.join()
106
+
107
+
108
+ def track(
109
+ sequence: Union[Sequence[ProgressType], Iterable[ProgressType]],
110
+ description: str = "Working...",
111
+ total: Optional[float] = None,
112
+ completed: int = 0,
113
+ auto_refresh: bool = True,
114
+ console: Optional[Console] = None,
115
+ transient: bool = False,
116
+ get_time: Optional[Callable[[], float]] = None,
117
+ refresh_per_second: float = 10,
118
+ style: StyleType = "bar.back",
119
+ complete_style: StyleType = "bar.complete",
120
+ finished_style: StyleType = "bar.finished",
121
+ pulse_style: StyleType = "bar.pulse",
122
+ update_period: float = 0.1,
123
+ disable: bool = False,
124
+ show_speed: bool = True,
125
+ ) -> Iterable[ProgressType]:
126
+ """Track progress by iterating over a sequence.
127
+
128
+ Args:
129
+ sequence (Iterable[ProgressType]): A sequence (must support "len") you wish to iterate over.
130
+ description (str, optional): Description of task show next to progress bar. Defaults to "Working".
131
+ total: (float, optional): Total number of steps. Default is len(sequence).
132
+ completed (int, optional): Number of steps completed so far. Defaults to 0.
133
+ auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
134
+ transient: (bool, optional): Clear the progress on exit. Defaults to False.
135
+ console (Console, optional): Console to write to. Default creates internal Console instance.
136
+ refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
137
+ style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
138
+ complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
139
+ finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
140
+ pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
141
+ update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.
142
+ disable (bool, optional): Disable display of progress.
143
+ show_speed (bool, optional): Show speed if total isn't known. Defaults to True.
144
+ Returns:
145
+ Iterable[ProgressType]: An iterable of the values in the sequence.
146
+
147
+ """
148
+
149
+ columns: List["ProgressColumn"] = (
150
+ [TextColumn("[progress.description]{task.description}")] if description else []
151
+ )
152
+ columns.extend(
153
+ (
154
+ BarColumn(
155
+ style=style,
156
+ complete_style=complete_style,
157
+ finished_style=finished_style,
158
+ pulse_style=pulse_style,
159
+ ),
160
+ TaskProgressColumn(show_speed=show_speed),
161
+ TimeRemainingColumn(elapsed_when_finished=True),
162
+ )
163
+ )
164
+ progress = Progress(
165
+ *columns,
166
+ auto_refresh=auto_refresh,
167
+ console=console,
168
+ transient=transient,
169
+ get_time=get_time,
170
+ refresh_per_second=refresh_per_second or 10,
171
+ disable=disable,
172
+ )
173
+
174
+ with progress:
175
+ yield from progress.track(
176
+ sequence,
177
+ total=total,
178
+ completed=completed,
179
+ description=description,
180
+ update_period=update_period,
181
+ )
182
+
183
+
184
+ class _Reader(RawIOBase, BinaryIO):
185
+ """A reader that tracks progress while it's being read from."""
186
+
187
+ def __init__(
188
+ self,
189
+ handle: BinaryIO,
190
+ progress: "Progress",
191
+ task: TaskID,
192
+ close_handle: bool = True,
193
+ ) -> None:
194
+ self.handle = handle
195
+ self.progress = progress
196
+ self.task = task
197
+ self.close_handle = close_handle
198
+ self._closed = False
199
+
200
+ def __enter__(self) -> "_Reader":
201
+ self.handle.__enter__()
202
+ return self
203
+
204
+ def __exit__(
205
+ self,
206
+ exc_type: Optional[Type[BaseException]],
207
+ exc_val: Optional[BaseException],
208
+ exc_tb: Optional[TracebackType],
209
+ ) -> None:
210
+ self.close()
211
+
212
+ def __iter__(self) -> BinaryIO:
213
+ return self
214
+
215
+ def __next__(self) -> bytes:
216
+ line = next(self.handle)
217
+ self.progress.advance(self.task, advance=len(line))
218
+ return line
219
+
220
+ @property
221
+ def closed(self) -> bool:
222
+ return self._closed
223
+
224
+ def fileno(self) -> int:
225
+ return self.handle.fileno()
226
+
227
+ def isatty(self) -> bool:
228
+ return self.handle.isatty()
229
+
230
+ @property
231
+ def mode(self) -> str:
232
+ return self.handle.mode
233
+
234
+ @property
235
+ def name(self) -> str:
236
+ return self.handle.name
237
+
238
+ def readable(self) -> bool:
239
+ return self.handle.readable()
240
+
241
+ def seekable(self) -> bool:
242
+ return self.handle.seekable()
243
+
244
+ def writable(self) -> bool:
245
+ return False
246
+
247
+ def read(self, size: int = -1) -> bytes:
248
+ block = self.handle.read(size)
249
+ self.progress.advance(self.task, advance=len(block))
250
+ return block
251
+
252
+ def readinto(self, b: Union[bytearray, memoryview, mmap]): # type: ignore[no-untyped-def, override]
253
+ n = self.handle.readinto(b) # type: ignore[attr-defined]
254
+ self.progress.advance(self.task, advance=n)
255
+ return n
256
+
257
+ def readline(self, size: int = -1) -> bytes: # type: ignore[override]
258
+ line = self.handle.readline(size)
259
+ self.progress.advance(self.task, advance=len(line))
260
+ return line
261
+
262
+ def readlines(self, hint: int = -1) -> List[bytes]:
263
+ lines = self.handle.readlines(hint)
264
+ self.progress.advance(self.task, advance=sum(map(len, lines)))
265
+ return lines
266
+
267
+ def close(self) -> None:
268
+ if self.close_handle:
269
+ self.handle.close()
270
+ self._closed = True
271
+
272
+ def seek(self, offset: int, whence: int = 0) -> int:
273
+ pos = self.handle.seek(offset, whence)
274
+ self.progress.update(self.task, completed=pos)
275
+ return pos
276
+
277
+ def tell(self) -> int:
278
+ return self.handle.tell()
279
+
280
+ def write(self, s: Any) -> int:
281
+ raise UnsupportedOperation("write")
282
+
283
+ def writelines(self, lines: Iterable[Any]) -> None:
284
+ raise UnsupportedOperation("writelines")
285
+
286
+
287
+ class _ReadContext(ContextManager[_I], Generic[_I]):
288
+ """A utility class to handle a context for both a reader and a progress."""
289
+
290
+ def __init__(self, progress: "Progress", reader: _I) -> None:
291
+ self.progress = progress
292
+ self.reader: _I = reader
293
+
294
+ def __enter__(self) -> _I:
295
+ self.progress.start()
296
+ return self.reader.__enter__()
297
+
298
+ def __exit__(
299
+ self,
300
+ exc_type: Optional[Type[BaseException]],
301
+ exc_val: Optional[BaseException],
302
+ exc_tb: Optional[TracebackType],
303
+ ) -> None:
304
+ self.progress.stop()
305
+ self.reader.__exit__(exc_type, exc_val, exc_tb)
306
+
307
+
308
+ def wrap_file(
309
+ file: BinaryIO,
310
+ total: int,
311
+ *,
312
+ description: str = "Reading...",
313
+ auto_refresh: bool = True,
314
+ console: Optional[Console] = None,
315
+ transient: bool = False,
316
+ get_time: Optional[Callable[[], float]] = None,
317
+ refresh_per_second: float = 10,
318
+ style: StyleType = "bar.back",
319
+ complete_style: StyleType = "bar.complete",
320
+ finished_style: StyleType = "bar.finished",
321
+ pulse_style: StyleType = "bar.pulse",
322
+ disable: bool = False,
323
+ ) -> ContextManager[BinaryIO]:
324
+ """Read bytes from a file while tracking progress.
325
+
326
+ Args:
327
+ file (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
328
+ total (int): Total number of bytes to read.
329
+ description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
330
+ auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
331
+ transient: (bool, optional): Clear the progress on exit. Defaults to False.
332
+ console (Console, optional): Console to write to. Default creates internal Console instance.
333
+ refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
334
+ style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
335
+ complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
336
+ finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
337
+ pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
338
+ disable (bool, optional): Disable display of progress.
339
+ Returns:
340
+ ContextManager[BinaryIO]: A context manager yielding a progress reader.
341
+
342
+ """
343
+
344
+ columns: List["ProgressColumn"] = (
345
+ [TextColumn("[progress.description]{task.description}")] if description else []
346
+ )
347
+ columns.extend(
348
+ (
349
+ BarColumn(
350
+ style=style,
351
+ complete_style=complete_style,
352
+ finished_style=finished_style,
353
+ pulse_style=pulse_style,
354
+ ),
355
+ DownloadColumn(),
356
+ TimeRemainingColumn(),
357
+ )
358
+ )
359
+ progress = Progress(
360
+ *columns,
361
+ auto_refresh=auto_refresh,
362
+ console=console,
363
+ transient=transient,
364
+ get_time=get_time,
365
+ refresh_per_second=refresh_per_second or 10,
366
+ disable=disable,
367
+ )
368
+
369
+ reader = progress.wrap_file(file, total=total, description=description)
370
+ return _ReadContext(progress, reader)
371
+
372
+
373
+ @typing.overload
374
+ def open(
375
+ file: Union[str, "PathLike[str]", bytes],
376
+ mode: Union[Literal["rt"], Literal["r"]],
377
+ buffering: int = -1,
378
+ encoding: Optional[str] = None,
379
+ errors: Optional[str] = None,
380
+ newline: Optional[str] = None,
381
+ *,
382
+ total: Optional[int] = None,
383
+ description: str = "Reading...",
384
+ auto_refresh: bool = True,
385
+ console: Optional[Console] = None,
386
+ transient: bool = False,
387
+ get_time: Optional[Callable[[], float]] = None,
388
+ refresh_per_second: float = 10,
389
+ style: StyleType = "bar.back",
390
+ complete_style: StyleType = "bar.complete",
391
+ finished_style: StyleType = "bar.finished",
392
+ pulse_style: StyleType = "bar.pulse",
393
+ disable: bool = False,
394
+ ) -> ContextManager[TextIO]:
395
+ pass
396
+
397
+
398
+ @typing.overload
399
+ def open(
400
+ file: Union[str, "PathLike[str]", bytes],
401
+ mode: Literal["rb"],
402
+ buffering: int = -1,
403
+ encoding: Optional[str] = None,
404
+ errors: Optional[str] = None,
405
+ newline: Optional[str] = None,
406
+ *,
407
+ total: Optional[int] = None,
408
+ description: str = "Reading...",
409
+ auto_refresh: bool = True,
410
+ console: Optional[Console] = None,
411
+ transient: bool = False,
412
+ get_time: Optional[Callable[[], float]] = None,
413
+ refresh_per_second: float = 10,
414
+ style: StyleType = "bar.back",
415
+ complete_style: StyleType = "bar.complete",
416
+ finished_style: StyleType = "bar.finished",
417
+ pulse_style: StyleType = "bar.pulse",
418
+ disable: bool = False,
419
+ ) -> ContextManager[BinaryIO]:
420
+ pass
421
+
422
+
423
+ def open(
424
+ file: Union[str, "PathLike[str]", bytes],
425
+ mode: Union[Literal["rb"], Literal["rt"], Literal["r"]] = "r",
426
+ buffering: int = -1,
427
+ encoding: Optional[str] = None,
428
+ errors: Optional[str] = None,
429
+ newline: Optional[str] = None,
430
+ *,
431
+ total: Optional[int] = None,
432
+ description: str = "Reading...",
433
+ auto_refresh: bool = True,
434
+ console: Optional[Console] = None,
435
+ transient: bool = False,
436
+ get_time: Optional[Callable[[], float]] = None,
437
+ refresh_per_second: float = 10,
438
+ style: StyleType = "bar.back",
439
+ complete_style: StyleType = "bar.complete",
440
+ finished_style: StyleType = "bar.finished",
441
+ pulse_style: StyleType = "bar.pulse",
442
+ disable: bool = False,
443
+ ) -> Union[ContextManager[BinaryIO], ContextManager[TextIO]]:
444
+ """Read bytes from a file while tracking progress.
445
+
446
+ Args:
447
+ path (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
448
+ mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt".
449
+ buffering (int): The buffering strategy to use, see :func:`io.open`.
450
+ encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`.
451
+ errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`.
452
+ newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`
453
+ total: (int, optional): Total number of bytes to read. Must be provided if reading from a file handle. Default for a path is os.stat(file).st_size.
454
+ description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
455
+ auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
456
+ transient: (bool, optional): Clear the progress on exit. Defaults to False.
457
+ console (Console, optional): Console to write to. Default creates internal Console instance.
458
+ refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
459
+ style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
460
+ complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
461
+ finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
462
+ pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
463
+ disable (bool, optional): Disable display of progress.
464
+ encoding (str, optional): The encoding to use when reading in text mode.
465
+
466
+ Returns:
467
+ ContextManager[BinaryIO]: A context manager yielding a progress reader.
468
+
469
+ """
470
+
471
+ columns: List["ProgressColumn"] = (
472
+ [TextColumn("[progress.description]{task.description}")] if description else []
473
+ )
474
+ columns.extend(
475
+ (
476
+ BarColumn(
477
+ style=style,
478
+ complete_style=complete_style,
479
+ finished_style=finished_style,
480
+ pulse_style=pulse_style,
481
+ ),
482
+ DownloadColumn(),
483
+ TimeRemainingColumn(),
484
+ )
485
+ )
486
+ progress = Progress(
487
+ *columns,
488
+ auto_refresh=auto_refresh,
489
+ console=console,
490
+ transient=transient,
491
+ get_time=get_time,
492
+ refresh_per_second=refresh_per_second or 10,
493
+ disable=disable,
494
+ )
495
+
496
+ reader = progress.open(
497
+ file,
498
+ mode=mode,
499
+ buffering=buffering,
500
+ encoding=encoding,
501
+ errors=errors,
502
+ newline=newline,
503
+ total=total,
504
+ description=description,
505
+ )
506
+ return _ReadContext(progress, reader) # type: ignore[return-value, type-var]
507
+
508
+
509
+ class ProgressColumn(ABC):
510
+ """Base class for a widget to use in progress display."""
511
+
512
+ max_refresh: Optional[float] = None
513
+
514
+ def __init__(self, table_column: Optional[Column] = None) -> None:
515
+ self._table_column = table_column
516
+ self._renderable_cache: Dict[TaskID, Tuple[float, RenderableType]] = {}
517
+ self._update_time: Optional[float] = None
518
+
519
+ def get_table_column(self) -> Column:
520
+ """Get a table column, used to build tasks table."""
521
+ return self._table_column or Column()
522
+
523
+ def __call__(self, task: "Task") -> RenderableType:
524
+ """Called by the Progress object to return a renderable for the given task.
525
+
526
+ Args:
527
+ task (Task): An object containing information regarding the task.
528
+
529
+ Returns:
530
+ RenderableType: Anything renderable (including str).
531
+ """
532
+ current_time = task.get_time()
533
+ if self.max_refresh is not None and not task.completed:
534
+ try:
535
+ timestamp, renderable = self._renderable_cache[task.id]
536
+ except KeyError:
537
+ pass
538
+ else:
539
+ if timestamp + self.max_refresh > current_time:
540
+ return renderable
541
+
542
+ renderable = self.render(task)
543
+ self._renderable_cache[task.id] = (current_time, renderable)
544
+ return renderable
545
+
546
+ @abstractmethod
547
+ def render(self, task: "Task") -> RenderableType:
548
+ """Should return a renderable object."""
549
+
550
+
551
+ class RenderableColumn(ProgressColumn):
552
+ """A column to insert an arbitrary column.
553
+
554
+ Args:
555
+ renderable (RenderableType, optional): Any renderable. Defaults to empty string.
556
+ """
557
+
558
+ def __init__(
559
+ self, renderable: RenderableType = "", *, table_column: Optional[Column] = None
560
+ ):
561
+ self.renderable = renderable
562
+ super().__init__(table_column=table_column)
563
+
564
+ def render(self, task: "Task") -> RenderableType:
565
+ return self.renderable
566
+
567
+
568
+ class SpinnerColumn(ProgressColumn):
569
+ """A column with a 'spinner' animation.
570
+
571
+ Args:
572
+ spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
573
+ style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
574
+ speed (float, optional): Speed factor of spinner. Defaults to 1.0.
575
+ finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
576
+ """
577
+
578
+ def __init__(
579
+ self,
580
+ spinner_name: str = "dots",
581
+ style: Optional[StyleType] = "progress.spinner",
582
+ speed: float = 1.0,
583
+ finished_text: TextType = " ",
584
+ table_column: Optional[Column] = None,
585
+ ):
586
+ self.spinner = Spinner(spinner_name, style=style, speed=speed)
587
+ self.finished_text = (
588
+ Text.from_markup(finished_text)
589
+ if isinstance(finished_text, str)
590
+ else finished_text
591
+ )
592
+ super().__init__(table_column=table_column)
593
+
594
+ def set_spinner(
595
+ self,
596
+ spinner_name: str,
597
+ spinner_style: Optional[StyleType] = "progress.spinner",
598
+ speed: float = 1.0,
599
+ ) -> None:
600
+ """Set a new spinner.
601
+
602
+ Args:
603
+ spinner_name (str): Spinner name, see python -m rich.spinner.
604
+ spinner_style (Optional[StyleType], optional): Spinner style. Defaults to "progress.spinner".
605
+ speed (float, optional): Speed factor of spinner. Defaults to 1.0.
606
+ """
607
+ self.spinner = Spinner(spinner_name, style=spinner_style, speed=speed)
608
+
609
+ def render(self, task: "Task") -> RenderableType:
610
+ text = (
611
+ self.finished_text
612
+ if task.finished
613
+ else self.spinner.render(task.get_time())
614
+ )
615
+ return text
616
+
617
+
618
+ class TextColumn(ProgressColumn):
619
+ """A column containing text."""
620
+
621
+ def __init__(
622
+ self,
623
+ text_format: str,
624
+ style: StyleType = "none",
625
+ justify: JustifyMethod = "left",
626
+ markup: bool = True,
627
+ highlighter: Optional[Highlighter] = None,
628
+ table_column: Optional[Column] = None,
629
+ ) -> None:
630
+ self.text_format = text_format
631
+ self.justify: JustifyMethod = justify
632
+ self.style = style
633
+ self.markup = markup
634
+ self.highlighter = highlighter
635
+ super().__init__(table_column=table_column or Column(no_wrap=True))
636
+
637
+ def render(self, task: "Task") -> Text:
638
+ _text = self.text_format.format(task=task)
639
+ if self.markup:
640
+ text = Text.from_markup(_text, style=self.style, justify=self.justify)
641
+ else:
642
+ text = Text(_text, style=self.style, justify=self.justify)
643
+ if self.highlighter:
644
+ self.highlighter.highlight(text)
645
+ return text
646
+
647
+
648
+ class BarColumn(ProgressColumn):
649
+ """Renders a visual progress bar.
650
+
651
+ Args:
652
+ bar_width (Optional[int], optional): Width of bar or None for full width. Defaults to 40.
653
+ style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
654
+ complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
655
+ finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
656
+ pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
657
+ """
658
+
659
+ def __init__(
660
+ self,
661
+ bar_width: Optional[int] = 40,
662
+ style: StyleType = "bar.back",
663
+ complete_style: StyleType = "bar.complete",
664
+ finished_style: StyleType = "bar.finished",
665
+ pulse_style: StyleType = "bar.pulse",
666
+ table_column: Optional[Column] = None,
667
+ ) -> None:
668
+ self.bar_width = bar_width
669
+ self.style = style
670
+ self.complete_style = complete_style
671
+ self.finished_style = finished_style
672
+ self.pulse_style = pulse_style
673
+ super().__init__(table_column=table_column)
674
+
675
+ def render(self, task: "Task") -> ProgressBar:
676
+ """Gets a progress bar widget for a task."""
677
+ return ProgressBar(
678
+ total=max(0, task.total) if task.total is not None else None,
679
+ completed=max(0, task.completed),
680
+ width=None if self.bar_width is None else max(1, self.bar_width),
681
+ pulse=not task.started,
682
+ animation_time=task.get_time(),
683
+ style=self.style,
684
+ complete_style=self.complete_style,
685
+ finished_style=self.finished_style,
686
+ pulse_style=self.pulse_style,
687
+ )
688
+
689
+
690
+ class TimeElapsedColumn(ProgressColumn):
691
+ """Renders time elapsed."""
692
+
693
+ def render(self, task: "Task") -> Text:
694
+ """Show time elapsed."""
695
+ elapsed = task.finished_time if task.finished else task.elapsed
696
+ if elapsed is None:
697
+ return Text("-:--:--", style="progress.elapsed")
698
+ delta = timedelta(seconds=max(0, int(elapsed)))
699
+ return Text(str(delta), style="progress.elapsed")
700
+
701
+
702
+ class TaskProgressColumn(TextColumn):
703
+ """Show task progress as a percentage.
704
+
705
+ Args:
706
+ text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%".
707
+ text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "".
708
+ style (StyleType, optional): Style of output. Defaults to "none".
709
+ justify (JustifyMethod, optional): Text justification. Defaults to "left".
710
+ markup (bool, optional): Enable markup. Defaults to True.
711
+ highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None.
712
+ table_column (Optional[Column], optional): Table Column to use. Defaults to None.
713
+ show_speed (bool, optional): Show speed if total is unknown. Defaults to False.
714
+ """
715
+
716
+ def __init__(
717
+ self,
718
+ text_format: str = "[progress.percentage]{task.percentage:>3.0f}%",
719
+ text_format_no_percentage: str = "",
720
+ style: StyleType = "none",
721
+ justify: JustifyMethod = "left",
722
+ markup: bool = True,
723
+ highlighter: Optional[Highlighter] = None,
724
+ table_column: Optional[Column] = None,
725
+ show_speed: bool = False,
726
+ ) -> None:
727
+ self.text_format_no_percentage = text_format_no_percentage
728
+ self.show_speed = show_speed
729
+ super().__init__(
730
+ text_format=text_format,
731
+ style=style,
732
+ justify=justify,
733
+ markup=markup,
734
+ highlighter=highlighter,
735
+ table_column=table_column,
736
+ )
737
+
738
+ @classmethod
739
+ def render_speed(cls, speed: Optional[float]) -> Text:
740
+ """Render the speed in iterations per second.
741
+
742
+ Args:
743
+ task (Task): A Task object.
744
+
745
+ Returns:
746
+ Text: Text object containing the task speed.
747
+ """
748
+ if speed is None:
749
+ return Text("", style="progress.percentage")
750
+ unit, suffix = filesize.pick_unit_and_suffix(
751
+ int(speed),
752
+ ["", "×10³", "×10⁶", "×10⁹", "×10¹²"],
753
+ 1000,
754
+ )
755
+ data_speed = speed / unit
756
+ return Text(f"{data_speed:.1f}{suffix} it/s", style="progress.percentage")
757
+
758
+ def render(self, task: "Task") -> Text:
759
+ if task.total is None and self.show_speed:
760
+ return self.render_speed(task.finished_speed or task.speed)
761
+ text_format = (
762
+ self.text_format_no_percentage if task.total is None else self.text_format
763
+ )
764
+ _text = text_format.format(task=task)
765
+ if self.markup:
766
+ text = Text.from_markup(_text, style=self.style, justify=self.justify)
767
+ else:
768
+ text = Text(_text, style=self.style, justify=self.justify)
769
+ if self.highlighter:
770
+ self.highlighter.highlight(text)
771
+ return text
772
+
773
+
774
+ class TimeRemainingColumn(ProgressColumn):
775
+ """Renders estimated time remaining.
776
+
777
+ Args:
778
+ compact (bool, optional): Render MM:SS when time remaining is less than an hour. Defaults to False.
779
+ elapsed_when_finished (bool, optional): Render time elapsed when the task is finished. Defaults to False.
780
+ """
781
+
782
+ # Only refresh twice a second to prevent jitter
783
+ max_refresh = 0.5
784
+
785
+ def __init__(
786
+ self,
787
+ compact: bool = False,
788
+ elapsed_when_finished: bool = False,
789
+ table_column: Optional[Column] = None,
790
+ ):
791
+ self.compact = compact
792
+ self.elapsed_when_finished = elapsed_when_finished
793
+ super().__init__(table_column=table_column)
794
+
795
+ def render(self, task: "Task") -> Text:
796
+ """Show time remaining."""
797
+ if self.elapsed_when_finished and task.finished:
798
+ task_time = task.finished_time
799
+ style = "progress.elapsed"
800
+ else:
801
+ task_time = task.time_remaining
802
+ style = "progress.remaining"
803
+
804
+ if task.total is None:
805
+ return Text("", style=style)
806
+
807
+ if task_time is None:
808
+ return Text("--:--" if self.compact else "-:--:--", style=style)
809
+
810
+ # Based on https://github.com/tqdm/tqdm/blob/master/tqdm/std.py
811
+ minutes, seconds = divmod(int(task_time), 60)
812
+ hours, minutes = divmod(minutes, 60)
813
+
814
+ if self.compact and not hours:
815
+ formatted = f"{minutes:02d}:{seconds:02d}"
816
+ else:
817
+ formatted = f"{hours:d}:{minutes:02d}:{seconds:02d}"
818
+
819
+ return Text(formatted, style=style)
820
+
821
+
822
+ class FileSizeColumn(ProgressColumn):
823
+ """Renders completed filesize."""
824
+
825
+ def render(self, task: "Task") -> Text:
826
+ """Show data completed."""
827
+ data_size = filesize.decimal(int(task.completed))
828
+ return Text(data_size, style="progress.filesize")
829
+
830
+
831
+ class TotalFileSizeColumn(ProgressColumn):
832
+ """Renders total filesize."""
833
+
834
+ def render(self, task: "Task") -> Text:
835
+ """Show data completed."""
836
+ data_size = filesize.decimal(int(task.total)) if task.total is not None else ""
837
+ return Text(data_size, style="progress.filesize.total")
838
+
839
+
840
+ class MofNCompleteColumn(ProgressColumn):
841
+ """Renders completed count/total, e.g. ' 10/1000'.
842
+
843
+ Best for bounded tasks with int quantities.
844
+
845
+ Space pads the completed count so that progress length does not change as task progresses
846
+ past powers of 10.
847
+
848
+ Args:
849
+ separator (str, optional): Text to separate completed and total values. Defaults to "/".
850
+ """
851
+
852
+ def __init__(self, separator: str = "/", table_column: Optional[Column] = None):
853
+ self.separator = separator
854
+ super().__init__(table_column=table_column)
855
+
856
+ def render(self, task: "Task") -> Text:
857
+ """Show completed/total."""
858
+ completed = int(task.completed)
859
+ total = int(task.total) if task.total is not None else "?"
860
+ total_width = len(str(total))
861
+ return Text(
862
+ f"{completed:{total_width}d}{self.separator}{total}",
863
+ style="progress.download",
864
+ )
865
+
866
+
867
+ class DownloadColumn(ProgressColumn):
868
+ """Renders file size downloaded and total, e.g. '0.5/2.3 GB'.
869
+
870
+ Args:
871
+ binary_units (bool, optional): Use binary units, KiB, MiB etc. Defaults to False.
872
+ """
873
+
874
+ def __init__(
875
+ self, binary_units: bool = False, table_column: Optional[Column] = None
876
+ ) -> None:
877
+ self.binary_units = binary_units
878
+ super().__init__(table_column=table_column)
879
+
880
+ def render(self, task: "Task") -> Text:
881
+ """Calculate common unit for completed and total."""
882
+ completed = int(task.completed)
883
+
884
+ unit_and_suffix_calculation_base = (
885
+ int(task.total) if task.total is not None else completed
886
+ )
887
+ if self.binary_units:
888
+ unit, suffix = filesize.pick_unit_and_suffix(
889
+ unit_and_suffix_calculation_base,
890
+ ["bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"],
891
+ 1024,
892
+ )
893
+ else:
894
+ unit, suffix = filesize.pick_unit_and_suffix(
895
+ unit_and_suffix_calculation_base,
896
+ ["bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
897
+ 1000,
898
+ )
899
+ precision = 0 if unit == 1 else 1
900
+
901
+ completed_ratio = completed / unit
902
+ completed_str = f"{completed_ratio:,.{precision}f}"
903
+
904
+ if task.total is not None:
905
+ total = int(task.total)
906
+ total_ratio = total / unit
907
+ total_str = f"{total_ratio:,.{precision}f}"
908
+ else:
909
+ total_str = "?"
910
+
911
+ download_status = f"{completed_str}/{total_str} {suffix}"
912
+ download_text = Text(download_status, style="progress.download")
913
+ return download_text
914
+
915
+
916
+ class TransferSpeedColumn(ProgressColumn):
917
+ """Renders human readable transfer speed."""
918
+
919
+ def render(self, task: "Task") -> Text:
920
+ """Show data transfer speed."""
921
+ speed = task.finished_speed or task.speed
922
+ if speed is None:
923
+ return Text("?", style="progress.data.speed")
924
+ data_speed = filesize.decimal(int(speed))
925
+ return Text(f"{data_speed}/s", style="progress.data.speed")
926
+
927
+
928
+ class ProgressSample(NamedTuple):
929
+ """Sample of progress for a given time."""
930
+
931
+ timestamp: float
932
+ """Timestamp of sample."""
933
+ completed: float
934
+ """Number of steps completed."""
935
+
936
+
937
+ @dataclass
938
+ class Task:
939
+ """Information regarding a progress task.
940
+
941
+ This object should be considered read-only outside of the :class:`~Progress` class.
942
+
943
+ """
944
+
945
+ id: TaskID
946
+ """Task ID associated with this task (used in Progress methods)."""
947
+
948
+ description: str
949
+ """str: Description of the task."""
950
+
951
+ total: Optional[float]
952
+ """Optional[float]: Total number of steps in this task."""
953
+
954
+ completed: float
955
+ """float: Number of steps completed"""
956
+
957
+ _get_time: GetTimeCallable
958
+ """Callable to get the current time."""
959
+
960
+ finished_time: Optional[float] = None
961
+ """float: Time task was finished."""
962
+
963
+ visible: bool = True
964
+ """bool: Indicates if this task is visible in the progress display."""
965
+
966
+ fields: Dict[str, Any] = field(default_factory=dict)
967
+ """dict: Arbitrary fields passed in via Progress.update."""
968
+
969
+ start_time: Optional[float] = field(default=None, init=False, repr=False)
970
+ """Optional[float]: Time this task was started, or None if not started."""
971
+
972
+ stop_time: Optional[float] = field(default=None, init=False, repr=False)
973
+ """Optional[float]: Time this task was stopped, or None if not stopped."""
974
+
975
+ finished_speed: Optional[float] = None
976
+ """Optional[float]: The last speed for a finished task."""
977
+
978
+ _progress: Deque[ProgressSample] = field(
979
+ default_factory=lambda: deque(maxlen=1000), init=False, repr=False
980
+ )
981
+
982
+ _lock: RLock = field(repr=False, default_factory=RLock)
983
+ """Thread lock."""
984
+
985
+ def get_time(self) -> float:
986
+ """float: Get the current time, in seconds."""
987
+ return self._get_time()
988
+
989
+ @property
990
+ def started(self) -> bool:
991
+ """bool: Check if the task as started."""
992
+ return self.start_time is not None
993
+
994
+ @property
995
+ def remaining(self) -> Optional[float]:
996
+ """Optional[float]: Get the number of steps remaining, if a non-None total was set."""
997
+ if self.total is None:
998
+ return None
999
+ return self.total - self.completed
1000
+
1001
+ @property
1002
+ def elapsed(self) -> Optional[float]:
1003
+ """Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started."""
1004
+ if self.start_time is None:
1005
+ return None
1006
+ if self.stop_time is not None:
1007
+ return self.stop_time - self.start_time
1008
+ return self.get_time() - self.start_time
1009
+
1010
+ @property
1011
+ def finished(self) -> bool:
1012
+ """Check if the task has finished."""
1013
+ return self.finished_time is not None
1014
+
1015
+ @property
1016
+ def percentage(self) -> float:
1017
+ """float: Get progress of task as a percentage. If a None total was set, returns 0"""
1018
+ if not self.total:
1019
+ return 0.0
1020
+ completed = (self.completed / self.total) * 100.0
1021
+ completed = min(100.0, max(0.0, completed))
1022
+ return completed
1023
+
1024
+ @property
1025
+ def speed(self) -> Optional[float]:
1026
+ """Optional[float]: Get the estimated speed in steps per second."""
1027
+ if self.start_time is None:
1028
+ return None
1029
+ with self._lock:
1030
+ progress = self._progress
1031
+ if not progress:
1032
+ return None
1033
+ total_time = progress[-1].timestamp - progress[0].timestamp
1034
+ if total_time == 0:
1035
+ return None
1036
+ iter_progress = iter(progress)
1037
+ next(iter_progress)
1038
+ total_completed = sum(sample.completed for sample in iter_progress)
1039
+ speed = total_completed / total_time
1040
+ return speed
1041
+
1042
+ @property
1043
+ def time_remaining(self) -> Optional[float]:
1044
+ """Optional[float]: Get estimated time to completion, or ``None`` if no data."""
1045
+ if self.finished:
1046
+ return 0.0
1047
+ speed = self.speed
1048
+ if not speed:
1049
+ return None
1050
+ remaining = self.remaining
1051
+ if remaining is None:
1052
+ return None
1053
+ estimate = ceil(remaining / speed)
1054
+ return estimate
1055
+
1056
+ def _reset(self) -> None:
1057
+ """Reset progress."""
1058
+ self._progress.clear()
1059
+ self.finished_time = None
1060
+ self.finished_speed = None
1061
+
1062
+
1063
+ class Progress(JupyterMixin):
1064
+ """Renders an auto-updating progress bar(s).
1065
+
1066
+ Args:
1067
+ console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout.
1068
+ auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`.
1069
+ refresh_per_second (Optional[float], optional): Number of times per second to refresh the progress information or None to use default (10). Defaults to None.
1070
+ speed_estimate_period: (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30.
1071
+ transient: (bool, optional): Clear the progress on exit. Defaults to False.
1072
+ redirect_stdout: (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
1073
+ redirect_stderr: (bool, optional): Enable redirection of stderr. Defaults to True.
1074
+ get_time: (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None.
1075
+ disable (bool, optional): Disable progress display. Defaults to False
1076
+ expand (bool, optional): Expand tasks table to fit width. Defaults to False.
1077
+ """
1078
+
1079
+ def __init__(
1080
+ self,
1081
+ *columns: Union[str, ProgressColumn],
1082
+ console: Optional[Console] = None,
1083
+ auto_refresh: bool = True,
1084
+ refresh_per_second: float = 10,
1085
+ speed_estimate_period: float = 30.0,
1086
+ transient: bool = False,
1087
+ redirect_stdout: bool = True,
1088
+ redirect_stderr: bool = True,
1089
+ get_time: Optional[GetTimeCallable] = None,
1090
+ disable: bool = False,
1091
+ expand: bool = False,
1092
+ ) -> None:
1093
+ assert refresh_per_second > 0, "refresh_per_second must be > 0"
1094
+ self._lock = RLock()
1095
+ self.columns = columns or self.get_default_columns()
1096
+ self.speed_estimate_period = speed_estimate_period
1097
+
1098
+ self.disable = disable
1099
+ self.expand = expand
1100
+ self._tasks: Dict[TaskID, Task] = {}
1101
+ self._task_index: TaskID = TaskID(0)
1102
+ self.live = Live(
1103
+ console=console or get_console(),
1104
+ auto_refresh=auto_refresh,
1105
+ refresh_per_second=refresh_per_second,
1106
+ transient=transient,
1107
+ redirect_stdout=redirect_stdout,
1108
+ redirect_stderr=redirect_stderr,
1109
+ get_renderable=self.get_renderable,
1110
+ )
1111
+ self.get_time = get_time or self.console.get_time
1112
+ self.print = self.console.print
1113
+ self.log = self.console.log
1114
+
1115
+ @classmethod
1116
+ def get_default_columns(cls) -> Tuple[ProgressColumn, ...]:
1117
+ """Get the default columns used for a new Progress instance:
1118
+ - a text column for the description (TextColumn)
1119
+ - the bar itself (BarColumn)
1120
+ - a text column showing completion percentage (TextColumn)
1121
+ - an estimated-time-remaining column (TimeRemainingColumn)
1122
+ If the Progress instance is created without passing a columns argument,
1123
+ the default columns defined here will be used.
1124
+
1125
+ You can also create a Progress instance using custom columns before
1126
+ and/or after the defaults, as in this example:
1127
+
1128
+ progress = Progress(
1129
+ SpinnerColumn(),
1130
+ *Progress.get_default_columns(),
1131
+ "Elapsed:",
1132
+ TimeElapsedColumn(),
1133
+ )
1134
+
1135
+ This code shows the creation of a Progress display, containing
1136
+ a spinner to the left, the default columns, and a labeled elapsed
1137
+ time column.
1138
+ """
1139
+ return (
1140
+ TextColumn("[progress.description]{task.description}"),
1141
+ BarColumn(),
1142
+ TaskProgressColumn(),
1143
+ TimeRemainingColumn(),
1144
+ )
1145
+
1146
+ @property
1147
+ def console(self) -> Console:
1148
+ return self.live.console
1149
+
1150
+ @property
1151
+ def tasks(self) -> List[Task]:
1152
+ """Get a list of Task instances."""
1153
+ with self._lock:
1154
+ return list(self._tasks.values())
1155
+
1156
+ @property
1157
+ def task_ids(self) -> List[TaskID]:
1158
+ """A list of task IDs."""
1159
+ with self._lock:
1160
+ return list(self._tasks.keys())
1161
+
1162
+ @property
1163
+ def finished(self) -> bool:
1164
+ """Check if all tasks have been completed."""
1165
+ with self._lock:
1166
+ if not self._tasks:
1167
+ return True
1168
+ return all(task.finished for task in self._tasks.values())
1169
+
1170
+ def start(self) -> None:
1171
+ """Start the progress display."""
1172
+ if not self.disable:
1173
+ self.live.start(refresh=True)
1174
+
1175
+ def stop(self) -> None:
1176
+ """Stop the progress display."""
1177
+ self.live.stop()
1178
+ if not self.console.is_interactive and not self.console.is_jupyter:
1179
+ self.console.print()
1180
+
1181
+ def __enter__(self) -> Self:
1182
+ self.start()
1183
+ return self
1184
+
1185
+ def __exit__(
1186
+ self,
1187
+ exc_type: Optional[Type[BaseException]],
1188
+ exc_val: Optional[BaseException],
1189
+ exc_tb: Optional[TracebackType],
1190
+ ) -> None:
1191
+ self.stop()
1192
+
1193
+ def track(
1194
+ self,
1195
+ sequence: Union[Iterable[ProgressType], Sequence[ProgressType]],
1196
+ total: Optional[float] = None,
1197
+ completed: int = 0,
1198
+ task_id: Optional[TaskID] = None,
1199
+ description: str = "Working...",
1200
+ update_period: float = 0.1,
1201
+ ) -> Iterable[ProgressType]:
1202
+ """Track progress by iterating over a sequence.
1203
+
1204
+ Args:
1205
+ sequence (Sequence[ProgressType]): A sequence of values you want to iterate over and track progress.
1206
+ total: (float, optional): Total number of steps. Default is len(sequence).
1207
+ completed (int, optional): Number of steps completed so far. Defaults to 0.
1208
+ task_id: (TaskID): Task to track. Default is new task.
1209
+ description: (str, optional): Description of task, if new task is created.
1210
+ update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.
1211
+
1212
+ Returns:
1213
+ Iterable[ProgressType]: An iterable of values taken from the provided sequence.
1214
+ """
1215
+ if total is None:
1216
+ total = float(length_hint(sequence)) or None
1217
+
1218
+ if task_id is None:
1219
+ task_id = self.add_task(description, total=total, completed=completed)
1220
+ else:
1221
+ self.update(task_id, total=total, completed=completed)
1222
+
1223
+ if self.live.auto_refresh:
1224
+ with _TrackThread(self, task_id, update_period) as track_thread:
1225
+ for value in sequence:
1226
+ yield value
1227
+ track_thread.completed += 1
1228
+ else:
1229
+ advance = self.advance
1230
+ refresh = self.refresh
1231
+ for value in sequence:
1232
+ yield value
1233
+ advance(task_id, 1)
1234
+ refresh()
1235
+
1236
+ def wrap_file(
1237
+ self,
1238
+ file: BinaryIO,
1239
+ total: Optional[int] = None,
1240
+ *,
1241
+ task_id: Optional[TaskID] = None,
1242
+ description: str = "Reading...",
1243
+ ) -> BinaryIO:
1244
+ """Track progress file reading from a binary file.
1245
+
1246
+ Args:
1247
+ file (BinaryIO): A file-like object opened in binary mode.
1248
+ total (int, optional): Total number of bytes to read. This must be provided unless a task with a total is also given.
1249
+ task_id (TaskID): Task to track. Default is new task.
1250
+ description (str, optional): Description of task, if new task is created.
1251
+
1252
+ Returns:
1253
+ BinaryIO: A readable file-like object in binary mode.
1254
+
1255
+ Raises:
1256
+ ValueError: When no total value can be extracted from the arguments or the task.
1257
+ """
1258
+ # attempt to recover the total from the task
1259
+ total_bytes: Optional[float] = None
1260
+ if total is not None:
1261
+ total_bytes = total
1262
+ elif task_id is not None:
1263
+ with self._lock:
1264
+ total_bytes = self._tasks[task_id].total
1265
+ if total_bytes is None:
1266
+ raise ValueError(
1267
+ f"unable to get the total number of bytes, please specify 'total'"
1268
+ )
1269
+
1270
+ # update total of task or create new task
1271
+ if task_id is None:
1272
+ task_id = self.add_task(description, total=total_bytes)
1273
+ else:
1274
+ self.update(task_id, total=total_bytes)
1275
+
1276
+ return _Reader(file, self, task_id, close_handle=False)
1277
+
1278
+ @typing.overload
1279
+ def open(
1280
+ self,
1281
+ file: Union[str, "PathLike[str]", bytes],
1282
+ mode: Literal["rb"],
1283
+ buffering: int = -1,
1284
+ encoding: Optional[str] = None,
1285
+ errors: Optional[str] = None,
1286
+ newline: Optional[str] = None,
1287
+ *,
1288
+ total: Optional[int] = None,
1289
+ task_id: Optional[TaskID] = None,
1290
+ description: str = "Reading...",
1291
+ ) -> BinaryIO:
1292
+ pass
1293
+
1294
+ @typing.overload
1295
+ def open(
1296
+ self,
1297
+ file: Union[str, "PathLike[str]", bytes],
1298
+ mode: Union[Literal["r"], Literal["rt"]],
1299
+ buffering: int = -1,
1300
+ encoding: Optional[str] = None,
1301
+ errors: Optional[str] = None,
1302
+ newline: Optional[str] = None,
1303
+ *,
1304
+ total: Optional[int] = None,
1305
+ task_id: Optional[TaskID] = None,
1306
+ description: str = "Reading...",
1307
+ ) -> TextIO:
1308
+ pass
1309
+
1310
+ def open(
1311
+ self,
1312
+ file: Union[str, "PathLike[str]", bytes],
1313
+ mode: Union[Literal["rb"], Literal["rt"], Literal["r"]] = "r",
1314
+ buffering: int = -1,
1315
+ encoding: Optional[str] = None,
1316
+ errors: Optional[str] = None,
1317
+ newline: Optional[str] = None,
1318
+ *,
1319
+ total: Optional[int] = None,
1320
+ task_id: Optional[TaskID] = None,
1321
+ description: str = "Reading...",
1322
+ ) -> Union[BinaryIO, TextIO]:
1323
+ """Track progress while reading from a binary file.
1324
+
1325
+ Args:
1326
+ path (Union[str, PathLike[str]]): The path to the file to read.
1327
+ mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt".
1328
+ buffering (int): The buffering strategy to use, see :func:`io.open`.
1329
+ encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`.
1330
+ errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`.
1331
+ newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`.
1332
+ total (int, optional): Total number of bytes to read. If none given, os.stat(path).st_size is used.
1333
+ task_id (TaskID): Task to track. Default is new task.
1334
+ description (str, optional): Description of task, if new task is created.
1335
+
1336
+ Returns:
1337
+ BinaryIO: A readable file-like object in binary mode.
1338
+
1339
+ Raises:
1340
+ ValueError: When an invalid mode is given.
1341
+ """
1342
+ # normalize the mode (always rb, rt)
1343
+ _mode = "".join(sorted(mode, reverse=False))
1344
+ if _mode not in ("br", "rt", "r"):
1345
+ raise ValueError(f"invalid mode {mode!r}")
1346
+
1347
+ # patch buffering to provide the same behaviour as the builtin `open`
1348
+ line_buffering = buffering == 1
1349
+ if _mode == "br" and buffering == 1:
1350
+ warnings.warn(
1351
+ "line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used",
1352
+ RuntimeWarning,
1353
+ )
1354
+ buffering = -1
1355
+ elif _mode in ("rt", "r"):
1356
+ if buffering == 0:
1357
+ raise ValueError("can't have unbuffered text I/O")
1358
+ elif buffering == 1:
1359
+ buffering = -1
1360
+
1361
+ # attempt to get the total with `os.stat`
1362
+ if total is None:
1363
+ total = stat(file).st_size
1364
+
1365
+ # update total of task or create new task
1366
+ if task_id is None:
1367
+ task_id = self.add_task(description, total=total)
1368
+ else:
1369
+ self.update(task_id, total=total)
1370
+
1371
+ # open the file in binary mode,
1372
+ handle = io.open(file, "rb", buffering=buffering)
1373
+ reader = _Reader(handle, self, task_id, close_handle=True)
1374
+
1375
+ # wrap the reader in a `TextIOWrapper` if text mode
1376
+ if mode in ("r", "rt"):
1377
+ return io.TextIOWrapper(
1378
+ reader,
1379
+ encoding=encoding,
1380
+ errors=errors,
1381
+ newline=newline,
1382
+ line_buffering=line_buffering,
1383
+ )
1384
+
1385
+ return reader
1386
+
1387
+ def start_task(self, task_id: TaskID) -> None:
1388
+ """Start a task.
1389
+
1390
+ Starts a task (used when calculating elapsed time). You may need to call this manually,
1391
+ if you called ``add_task`` with ``start=False``.
1392
+
1393
+ Args:
1394
+ task_id (TaskID): ID of task.
1395
+ """
1396
+ with self._lock:
1397
+ task = self._tasks[task_id]
1398
+ if task.start_time is None:
1399
+ task.start_time = self.get_time()
1400
+
1401
+ def stop_task(self, task_id: TaskID) -> None:
1402
+ """Stop a task.
1403
+
1404
+ This will freeze the elapsed time on the task.
1405
+
1406
+ Args:
1407
+ task_id (TaskID): ID of task.
1408
+ """
1409
+ with self._lock:
1410
+ task = self._tasks[task_id]
1411
+ current_time = self.get_time()
1412
+ if task.start_time is None:
1413
+ task.start_time = current_time
1414
+ task.stop_time = current_time
1415
+
1416
+ def update(
1417
+ self,
1418
+ task_id: TaskID,
1419
+ *,
1420
+ total: Optional[float] = None,
1421
+ completed: Optional[float] = None,
1422
+ advance: Optional[float] = None,
1423
+ description: Optional[str] = None,
1424
+ visible: Optional[bool] = None,
1425
+ refresh: bool = False,
1426
+ **fields: Any,
1427
+ ) -> None:
1428
+ """Update information associated with a task.
1429
+
1430
+ Args:
1431
+ task_id (TaskID): Task id (returned by add_task).
1432
+ total (float, optional): Updates task.total if not None.
1433
+ completed (float, optional): Updates task.completed if not None.
1434
+ advance (float, optional): Add a value to task.completed if not None.
1435
+ description (str, optional): Change task description if not None.
1436
+ visible (bool, optional): Set visible flag if not None.
1437
+ refresh (bool): Force a refresh of progress information. Default is False.
1438
+ **fields (Any): Additional data fields required for rendering.
1439
+ """
1440
+ with self._lock:
1441
+ task = self._tasks[task_id]
1442
+ completed_start = task.completed
1443
+
1444
+ if total is not None and total != task.total:
1445
+ task.total = total
1446
+ task._reset()
1447
+ if advance is not None:
1448
+ task.completed += advance
1449
+ if completed is not None:
1450
+ task.completed = completed
1451
+ if description is not None:
1452
+ task.description = description
1453
+ if visible is not None:
1454
+ task.visible = visible
1455
+ task.fields.update(fields)
1456
+ update_completed = task.completed - completed_start
1457
+
1458
+ current_time = self.get_time()
1459
+ old_sample_time = current_time - self.speed_estimate_period
1460
+ _progress = task._progress
1461
+
1462
+ popleft = _progress.popleft
1463
+ while _progress and _progress[0].timestamp < old_sample_time:
1464
+ popleft()
1465
+ if update_completed > 0:
1466
+ _progress.append(ProgressSample(current_time, update_completed))
1467
+ if (
1468
+ task.total is not None
1469
+ and task.completed >= task.total
1470
+ and task.finished_time is None
1471
+ ):
1472
+ task.finished_time = task.elapsed
1473
+
1474
+ if refresh:
1475
+ self.refresh()
1476
+
1477
+ def reset(
1478
+ self,
1479
+ task_id: TaskID,
1480
+ *,
1481
+ start: bool = True,
1482
+ total: Optional[float] = None,
1483
+ completed: int = 0,
1484
+ visible: Optional[bool] = None,
1485
+ description: Optional[str] = None,
1486
+ **fields: Any,
1487
+ ) -> None:
1488
+ """Reset a task so completed is 0 and the clock is reset.
1489
+
1490
+ Args:
1491
+ task_id (TaskID): ID of task.
1492
+ start (bool, optional): Start the task after reset. Defaults to True.
1493
+ total (float, optional): New total steps in task, or None to use current total. Defaults to None.
1494
+ completed (int, optional): Number of steps completed. Defaults to 0.
1495
+ visible (bool, optional): Enable display of the task. Defaults to True.
1496
+ description (str, optional): Change task description if not None. Defaults to None.
1497
+ **fields (str): Additional data fields required for rendering.
1498
+ """
1499
+ current_time = self.get_time()
1500
+ with self._lock:
1501
+ task = self._tasks[task_id]
1502
+ task._reset()
1503
+ task.start_time = current_time if start else None
1504
+ if total is not None:
1505
+ task.total = total
1506
+ task.completed = completed
1507
+ if visible is not None:
1508
+ task.visible = visible
1509
+ if fields:
1510
+ task.fields = fields
1511
+ if description is not None:
1512
+ task.description = description
1513
+ task.finished_time = None
1514
+ self.refresh()
1515
+
1516
+ def advance(self, task_id: TaskID, advance: float = 1) -> None:
1517
+ """Advance task by a number of steps.
1518
+
1519
+ Args:
1520
+ task_id (TaskID): ID of task.
1521
+ advance (float): Number of steps to advance. Default is 1.
1522
+ """
1523
+ current_time = self.get_time()
1524
+ with self._lock:
1525
+ task = self._tasks[task_id]
1526
+ completed_start = task.completed
1527
+ task.completed += advance
1528
+ update_completed = task.completed - completed_start
1529
+ old_sample_time = current_time - self.speed_estimate_period
1530
+ _progress = task._progress
1531
+
1532
+ popleft = _progress.popleft
1533
+ while _progress and _progress[0].timestamp < old_sample_time:
1534
+ popleft()
1535
+ while len(_progress) > 1000:
1536
+ popleft()
1537
+ _progress.append(ProgressSample(current_time, update_completed))
1538
+ if (
1539
+ task.total is not None
1540
+ and task.completed >= task.total
1541
+ and task.finished_time is None
1542
+ ):
1543
+ task.finished_time = task.elapsed
1544
+ task.finished_speed = task.speed
1545
+
1546
+ def refresh(self) -> None:
1547
+ """Refresh (render) the progress information."""
1548
+ if not self.disable and self.live.is_started:
1549
+ self.live.refresh()
1550
+
1551
+ def get_renderable(self) -> RenderableType:
1552
+ """Get a renderable for the progress display."""
1553
+ renderable = Group(*self.get_renderables())
1554
+ return renderable
1555
+
1556
+ def get_renderables(self) -> Iterable[RenderableType]:
1557
+ """Get a number of renderables for the progress display."""
1558
+ table = self.make_tasks_table(self.tasks)
1559
+ yield table
1560
+
1561
+ def make_tasks_table(self, tasks: Iterable[Task]) -> Table:
1562
+ """Get a table to render the Progress display.
1563
+
1564
+ Args:
1565
+ tasks (Iterable[Task]): An iterable of Task instances, one per row of the table.
1566
+
1567
+ Returns:
1568
+ Table: A table instance.
1569
+ """
1570
+ table_columns = (
1571
+ (
1572
+ Column(no_wrap=True)
1573
+ if isinstance(_column, str)
1574
+ else _column.get_table_column().copy()
1575
+ )
1576
+ for _column in self.columns
1577
+ )
1578
+ table = Table.grid(*table_columns, padding=(0, 1), expand=self.expand)
1579
+
1580
+ for task in tasks:
1581
+ if task.visible:
1582
+ table.add_row(
1583
+ *(
1584
+ (
1585
+ column.format(task=task)
1586
+ if isinstance(column, str)
1587
+ else column(task)
1588
+ )
1589
+ for column in self.columns
1590
+ )
1591
+ )
1592
+ return table
1593
+
1594
+ def __rich__(self) -> RenderableType:
1595
+ """Makes the Progress class itself renderable."""
1596
+ with self._lock:
1597
+ return self.get_renderable()
1598
+
1599
+ def add_task(
1600
+ self,
1601
+ description: str,
1602
+ start: bool = True,
1603
+ total: Optional[float] = 100.0,
1604
+ completed: int = 0,
1605
+ visible: bool = True,
1606
+ **fields: Any,
1607
+ ) -> TaskID:
1608
+ """Add a new 'task' to the Progress display.
1609
+
1610
+ Args:
1611
+ description (str): A description of the task.
1612
+ start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False,
1613
+ you will need to call `start` manually. Defaults to True.
1614
+ total (float, optional): Number of total steps in the progress if known.
1615
+ Set to None to render a pulsing animation. Defaults to 100.
1616
+ completed (int, optional): Number of steps completed so far. Defaults to 0.
1617
+ visible (bool, optional): Enable display of the task. Defaults to True.
1618
+ **fields (str): Additional data fields required for rendering.
1619
+
1620
+ Returns:
1621
+ TaskID: An ID you can use when calling `update`.
1622
+ """
1623
+ with self._lock:
1624
+ task = Task(
1625
+ self._task_index,
1626
+ description,
1627
+ total,
1628
+ completed,
1629
+ visible=visible,
1630
+ fields=fields,
1631
+ _get_time=self.get_time,
1632
+ _lock=self._lock,
1633
+ )
1634
+ self._tasks[self._task_index] = task
1635
+ if start:
1636
+ self.start_task(self._task_index)
1637
+ new_task_index = self._task_index
1638
+ self._task_index = TaskID(int(self._task_index) + 1)
1639
+ self.refresh()
1640
+ return new_task_index
1641
+
1642
+ def remove_task(self, task_id: TaskID) -> None:
1643
+ """Delete a task if it exists.
1644
+
1645
+ Args:
1646
+ task_id (TaskID): A task ID.
1647
+
1648
+ """
1649
+ with self._lock:
1650
+ del self._tasks[task_id]
1651
+
1652
+
1653
+ if __name__ == "__main__": # pragma: no coverage
1654
+ import random
1655
+ import time
1656
+
1657
+ from .panel import Panel
1658
+ from .rule import Rule
1659
+ from .syntax import Syntax
1660
+ from .table import Table
1661
+
1662
+ syntax = Syntax(
1663
+ '''def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
1664
+ """Iterate and generate a tuple with a flag for last value."""
1665
+ iter_values = iter(values)
1666
+ try:
1667
+ previous_value = next(iter_values)
1668
+ except StopIteration:
1669
+ return
1670
+ for value in iter_values:
1671
+ yield False, previous_value
1672
+ previous_value = value
1673
+ yield True, previous_value''',
1674
+ "python",
1675
+ line_numbers=True,
1676
+ )
1677
+
1678
+ table = Table("foo", "bar", "baz")
1679
+ table.add_row("1", "2", "3")
1680
+
1681
+ progress_renderables = [
1682
+ "Text may be printed while the progress bars are rendering.",
1683
+ Panel("In fact, [i]any[/i] renderable will work"),
1684
+ "Such as [magenta]tables[/]...",
1685
+ table,
1686
+ "Pretty printed structures...",
1687
+ {"type": "example", "text": "Pretty printed"},
1688
+ "Syntax...",
1689
+ syntax,
1690
+ Rule("Give it a try!"),
1691
+ ]
1692
+
1693
+ from itertools import cycle
1694
+
1695
+ examples = cycle(progress_renderables)
1696
+
1697
+ console = Console(record=True)
1698
+
1699
+ with Progress(
1700
+ SpinnerColumn(),
1701
+ *Progress.get_default_columns(),
1702
+ TimeElapsedColumn(),
1703
+ console=console,
1704
+ transient=False,
1705
+ ) as progress:
1706
+ task1 = progress.add_task("[red]Downloading", total=1000)
1707
+ task2 = progress.add_task("[green]Processing", total=1000)
1708
+ task3 = progress.add_task("[yellow]Thinking", total=None)
1709
+
1710
+ while not progress.finished:
1711
+ progress.update(task1, advance=0.5)
1712
+ progress.update(task2, advance=0.3)
1713
+ time.sleep(0.01)
1714
+ if random.randint(0, 100) < 1:
1715
+ progress.log(next(examples))
.venv/lib/python3.13/site-packages/pip/_vendor/rich/progress_bar.py ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ from functools import lru_cache
3
+ from time import monotonic
4
+ from typing import Iterable, List, Optional
5
+
6
+ from .color import Color, blend_rgb
7
+ from .color_triplet import ColorTriplet
8
+ from .console import Console, ConsoleOptions, RenderResult
9
+ from .jupyter import JupyterMixin
10
+ from .measure import Measurement
11
+ from .segment import Segment
12
+ from .style import Style, StyleType
13
+
14
+ # Number of characters before 'pulse' animation repeats
15
+ PULSE_SIZE = 20
16
+
17
+
18
+ class ProgressBar(JupyterMixin):
19
+ """Renders a (progress) bar. Used by rich.progress.
20
+
21
+ Args:
22
+ total (float, optional): Number of steps in the bar. Defaults to 100. Set to None to render a pulsing animation.
23
+ completed (float, optional): Number of steps completed. Defaults to 0.
24
+ width (int, optional): Width of the bar, or ``None`` for maximum width. Defaults to None.
25
+ pulse (bool, optional): Enable pulse effect. Defaults to False. Will pulse if a None total was passed.
26
+ style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
27
+ complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
28
+ finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
29
+ pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
30
+ animation_time (Optional[float], optional): Time in seconds to use for animation, or None to use system time.
31
+ """
32
+
33
+ def __init__(
34
+ self,
35
+ total: Optional[float] = 100.0,
36
+ completed: float = 0,
37
+ width: Optional[int] = None,
38
+ pulse: bool = False,
39
+ style: StyleType = "bar.back",
40
+ complete_style: StyleType = "bar.complete",
41
+ finished_style: StyleType = "bar.finished",
42
+ pulse_style: StyleType = "bar.pulse",
43
+ animation_time: Optional[float] = None,
44
+ ):
45
+ self.total = total
46
+ self.completed = completed
47
+ self.width = width
48
+ self.pulse = pulse
49
+ self.style = style
50
+ self.complete_style = complete_style
51
+ self.finished_style = finished_style
52
+ self.pulse_style = pulse_style
53
+ self.animation_time = animation_time
54
+
55
+ self._pulse_segments: Optional[List[Segment]] = None
56
+
57
+ def __repr__(self) -> str:
58
+ return f"<Bar {self.completed!r} of {self.total!r}>"
59
+
60
+ @property
61
+ def percentage_completed(self) -> Optional[float]:
62
+ """Calculate percentage complete."""
63
+ if self.total is None:
64
+ return None
65
+ completed = (self.completed / self.total) * 100.0
66
+ completed = min(100, max(0.0, completed))
67
+ return completed
68
+
69
+ @lru_cache(maxsize=16)
70
+ def _get_pulse_segments(
71
+ self,
72
+ fore_style: Style,
73
+ back_style: Style,
74
+ color_system: str,
75
+ no_color: bool,
76
+ ascii: bool = False,
77
+ ) -> List[Segment]:
78
+ """Get a list of segments to render a pulse animation.
79
+
80
+ Returns:
81
+ List[Segment]: A list of segments, one segment per character.
82
+ """
83
+ bar = "-" if ascii else "━"
84
+ segments: List[Segment] = []
85
+ if color_system not in ("standard", "eight_bit", "truecolor") or no_color:
86
+ segments += [Segment(bar, fore_style)] * (PULSE_SIZE // 2)
87
+ segments += [Segment(" " if no_color else bar, back_style)] * (
88
+ PULSE_SIZE - (PULSE_SIZE // 2)
89
+ )
90
+ return segments
91
+
92
+ append = segments.append
93
+ fore_color = (
94
+ fore_style.color.get_truecolor()
95
+ if fore_style.color
96
+ else ColorTriplet(255, 0, 255)
97
+ )
98
+ back_color = (
99
+ back_style.color.get_truecolor()
100
+ if back_style.color
101
+ else ColorTriplet(0, 0, 0)
102
+ )
103
+ cos = math.cos
104
+ pi = math.pi
105
+ _Segment = Segment
106
+ _Style = Style
107
+ from_triplet = Color.from_triplet
108
+
109
+ for index in range(PULSE_SIZE):
110
+ position = index / PULSE_SIZE
111
+ fade = 0.5 + cos(position * pi * 2) / 2.0
112
+ color = blend_rgb(fore_color, back_color, cross_fade=fade)
113
+ append(_Segment(bar, _Style(color=from_triplet(color))))
114
+ return segments
115
+
116
+ def update(self, completed: float, total: Optional[float] = None) -> None:
117
+ """Update progress with new values.
118
+
119
+ Args:
120
+ completed (float): Number of steps completed.
121
+ total (float, optional): Total number of steps, or ``None`` to not change. Defaults to None.
122
+ """
123
+ self.completed = completed
124
+ self.total = total if total is not None else self.total
125
+
126
+ def _render_pulse(
127
+ self, console: Console, width: int, ascii: bool = False
128
+ ) -> Iterable[Segment]:
129
+ """Renders the pulse animation.
130
+
131
+ Args:
132
+ console (Console): Console instance.
133
+ width (int): Width in characters of pulse animation.
134
+
135
+ Returns:
136
+ RenderResult: [description]
137
+
138
+ Yields:
139
+ Iterator[Segment]: Segments to render pulse
140
+ """
141
+ fore_style = console.get_style(self.pulse_style, default="white")
142
+ back_style = console.get_style(self.style, default="black")
143
+
144
+ pulse_segments = self._get_pulse_segments(
145
+ fore_style, back_style, console.color_system, console.no_color, ascii=ascii
146
+ )
147
+ segment_count = len(pulse_segments)
148
+ current_time = (
149
+ monotonic() if self.animation_time is None else self.animation_time
150
+ )
151
+ segments = pulse_segments * (int(width / segment_count) + 2)
152
+ offset = int(-current_time * 15) % segment_count
153
+ segments = segments[offset : offset + width]
154
+ yield from segments
155
+
156
+ def __rich_console__(
157
+ self, console: Console, options: ConsoleOptions
158
+ ) -> RenderResult:
159
+ width = min(self.width or options.max_width, options.max_width)
160
+ ascii = options.legacy_windows or options.ascii_only
161
+ should_pulse = self.pulse or self.total is None
162
+ if should_pulse:
163
+ yield from self._render_pulse(console, width, ascii=ascii)
164
+ return
165
+
166
+ completed: Optional[float] = (
167
+ min(self.total, max(0, self.completed)) if self.total is not None else None
168
+ )
169
+
170
+ bar = "-" if ascii else "━"
171
+ half_bar_right = " " if ascii else "╸"
172
+ half_bar_left = " " if ascii else "╺"
173
+ complete_halves = (
174
+ int(width * 2 * completed / self.total)
175
+ if self.total and completed is not None
176
+ else width * 2
177
+ )
178
+ bar_count = complete_halves // 2
179
+ half_bar_count = complete_halves % 2
180
+ style = console.get_style(self.style)
181
+ is_finished = self.total is None or self.completed >= self.total
182
+ complete_style = console.get_style(
183
+ self.finished_style if is_finished else self.complete_style
184
+ )
185
+ _Segment = Segment
186
+ if bar_count:
187
+ yield _Segment(bar * bar_count, complete_style)
188
+ if half_bar_count:
189
+ yield _Segment(half_bar_right * half_bar_count, complete_style)
190
+
191
+ if not console.no_color:
192
+ remaining_bars = width - bar_count - half_bar_count
193
+ if remaining_bars and console.color_system is not None:
194
+ if not half_bar_count and bar_count:
195
+ yield _Segment(half_bar_left, style)
196
+ remaining_bars -= 1
197
+ if remaining_bars:
198
+ yield _Segment(bar * remaining_bars, style)
199
+
200
+ def __rich_measure__(
201
+ self, console: Console, options: ConsoleOptions
202
+ ) -> Measurement:
203
+ return (
204
+ Measurement(self.width, self.width)
205
+ if self.width is not None
206
+ else Measurement(4, options.max_width)
207
+ )
208
+
209
+
210
+ if __name__ == "__main__": # pragma: no cover
211
+ console = Console()
212
+ bar = ProgressBar(width=50, total=100)
213
+
214
+ import time
215
+
216
+ console.show_cursor(False)
217
+ for n in range(0, 101, 1):
218
+ bar.update(n)
219
+ console.print(bar)
220
+ console.file.write("\r")
221
+ time.sleep(0.05)
222
+ console.show_cursor(True)
223
+ console.print()
.venv/lib/python3.13/site-packages/pip/_vendor/rich/prompt.py ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Generic, List, Optional, TextIO, TypeVar, Union, overload
2
+
3
+ from . import get_console
4
+ from .console import Console
5
+ from .text import Text, TextType
6
+
7
+ PromptType = TypeVar("PromptType")
8
+ DefaultType = TypeVar("DefaultType")
9
+
10
+
11
+ class PromptError(Exception):
12
+ """Exception base class for prompt related errors."""
13
+
14
+
15
+ class InvalidResponse(PromptError):
16
+ """Exception to indicate a response was invalid. Raise this within process_response() to indicate an error
17
+ and provide an error message.
18
+
19
+ Args:
20
+ message (Union[str, Text]): Error message.
21
+ """
22
+
23
+ def __init__(self, message: TextType) -> None:
24
+ self.message = message
25
+
26
+ def __rich__(self) -> TextType:
27
+ return self.message
28
+
29
+
30
+ class PromptBase(Generic[PromptType]):
31
+ """Ask the user for input until a valid response is received. This is the base class, see one of
32
+ the concrete classes for examples.
33
+
34
+ Args:
35
+ prompt (TextType, optional): Prompt text. Defaults to "".
36
+ console (Console, optional): A Console instance or None to use global console. Defaults to None.
37
+ password (bool, optional): Enable password input. Defaults to False.
38
+ choices (List[str], optional): A list of valid choices. Defaults to None.
39
+ case_sensitive (bool, optional): Matching of choices should be case-sensitive. Defaults to True.
40
+ show_default (bool, optional): Show default in prompt. Defaults to True.
41
+ show_choices (bool, optional): Show choices in prompt. Defaults to True.
42
+ """
43
+
44
+ response_type: type = str
45
+
46
+ validate_error_message = "[prompt.invalid]Please enter a valid value"
47
+ illegal_choice_message = (
48
+ "[prompt.invalid.choice]Please select one of the available options"
49
+ )
50
+ prompt_suffix = ": "
51
+
52
+ choices: Optional[List[str]] = None
53
+
54
+ def __init__(
55
+ self,
56
+ prompt: TextType = "",
57
+ *,
58
+ console: Optional[Console] = None,
59
+ password: bool = False,
60
+ choices: Optional[List[str]] = None,
61
+ case_sensitive: bool = True,
62
+ show_default: bool = True,
63
+ show_choices: bool = True,
64
+ ) -> None:
65
+ self.console = console or get_console()
66
+ self.prompt = (
67
+ Text.from_markup(prompt, style="prompt")
68
+ if isinstance(prompt, str)
69
+ else prompt
70
+ )
71
+ self.password = password
72
+ if choices is not None:
73
+ self.choices = choices
74
+ self.case_sensitive = case_sensitive
75
+ self.show_default = show_default
76
+ self.show_choices = show_choices
77
+
78
+ @classmethod
79
+ @overload
80
+ def ask(
81
+ cls,
82
+ prompt: TextType = "",
83
+ *,
84
+ console: Optional[Console] = None,
85
+ password: bool = False,
86
+ choices: Optional[List[str]] = None,
87
+ case_sensitive: bool = True,
88
+ show_default: bool = True,
89
+ show_choices: bool = True,
90
+ default: DefaultType,
91
+ stream: Optional[TextIO] = None,
92
+ ) -> Union[DefaultType, PromptType]:
93
+ ...
94
+
95
+ @classmethod
96
+ @overload
97
+ def ask(
98
+ cls,
99
+ prompt: TextType = "",
100
+ *,
101
+ console: Optional[Console] = None,
102
+ password: bool = False,
103
+ choices: Optional[List[str]] = None,
104
+ case_sensitive: bool = True,
105
+ show_default: bool = True,
106
+ show_choices: bool = True,
107
+ stream: Optional[TextIO] = None,
108
+ ) -> PromptType:
109
+ ...
110
+
111
+ @classmethod
112
+ def ask(
113
+ cls,
114
+ prompt: TextType = "",
115
+ *,
116
+ console: Optional[Console] = None,
117
+ password: bool = False,
118
+ choices: Optional[List[str]] = None,
119
+ case_sensitive: bool = True,
120
+ show_default: bool = True,
121
+ show_choices: bool = True,
122
+ default: Any = ...,
123
+ stream: Optional[TextIO] = None,
124
+ ) -> Any:
125
+ """Shortcut to construct and run a prompt loop and return the result.
126
+
127
+ Example:
128
+ >>> filename = Prompt.ask("Enter a filename")
129
+
130
+ Args:
131
+ prompt (TextType, optional): Prompt text. Defaults to "".
132
+ console (Console, optional): A Console instance or None to use global console. Defaults to None.
133
+ password (bool, optional): Enable password input. Defaults to False.
134
+ choices (List[str], optional): A list of valid choices. Defaults to None.
135
+ case_sensitive (bool, optional): Matching of choices should be case-sensitive. Defaults to True.
136
+ show_default (bool, optional): Show default in prompt. Defaults to True.
137
+ show_choices (bool, optional): Show choices in prompt. Defaults to True.
138
+ stream (TextIO, optional): Optional text file open for reading to get input. Defaults to None.
139
+ """
140
+ _prompt = cls(
141
+ prompt,
142
+ console=console,
143
+ password=password,
144
+ choices=choices,
145
+ case_sensitive=case_sensitive,
146
+ show_default=show_default,
147
+ show_choices=show_choices,
148
+ )
149
+ return _prompt(default=default, stream=stream)
150
+
151
+ def render_default(self, default: DefaultType) -> Text:
152
+ """Turn the supplied default in to a Text instance.
153
+
154
+ Args:
155
+ default (DefaultType): Default value.
156
+
157
+ Returns:
158
+ Text: Text containing rendering of default value.
159
+ """
160
+ return Text(f"({default})", "prompt.default")
161
+
162
+ def make_prompt(self, default: DefaultType) -> Text:
163
+ """Make prompt text.
164
+
165
+ Args:
166
+ default (DefaultType): Default value.
167
+
168
+ Returns:
169
+ Text: Text to display in prompt.
170
+ """
171
+ prompt = self.prompt.copy()
172
+ prompt.end = ""
173
+
174
+ if self.show_choices and self.choices:
175
+ _choices = "/".join(self.choices)
176
+ choices = f"[{_choices}]"
177
+ prompt.append(" ")
178
+ prompt.append(choices, "prompt.choices")
179
+
180
+ if (
181
+ default != ...
182
+ and self.show_default
183
+ and isinstance(default, (str, self.response_type))
184
+ ):
185
+ prompt.append(" ")
186
+ _default = self.render_default(default)
187
+ prompt.append(_default)
188
+
189
+ prompt.append(self.prompt_suffix)
190
+
191
+ return prompt
192
+
193
+ @classmethod
194
+ def get_input(
195
+ cls,
196
+ console: Console,
197
+ prompt: TextType,
198
+ password: bool,
199
+ stream: Optional[TextIO] = None,
200
+ ) -> str:
201
+ """Get input from user.
202
+
203
+ Args:
204
+ console (Console): Console instance.
205
+ prompt (TextType): Prompt text.
206
+ password (bool): Enable password entry.
207
+
208
+ Returns:
209
+ str: String from user.
210
+ """
211
+ return console.input(prompt, password=password, stream=stream)
212
+
213
+ def check_choice(self, value: str) -> bool:
214
+ """Check value is in the list of valid choices.
215
+
216
+ Args:
217
+ value (str): Value entered by user.
218
+
219
+ Returns:
220
+ bool: True if choice was valid, otherwise False.
221
+ """
222
+ assert self.choices is not None
223
+ if self.case_sensitive:
224
+ return value.strip() in self.choices
225
+ return value.strip().lower() in [choice.lower() for choice in self.choices]
226
+
227
+ def process_response(self, value: str) -> PromptType:
228
+ """Process response from user, convert to prompt type.
229
+
230
+ Args:
231
+ value (str): String typed by user.
232
+
233
+ Raises:
234
+ InvalidResponse: If ``value`` is invalid.
235
+
236
+ Returns:
237
+ PromptType: The value to be returned from ask method.
238
+ """
239
+ value = value.strip()
240
+ try:
241
+ return_value: PromptType = self.response_type(value)
242
+ except ValueError:
243
+ raise InvalidResponse(self.validate_error_message)
244
+
245
+ if self.choices is not None:
246
+ if not self.check_choice(value):
247
+ raise InvalidResponse(self.illegal_choice_message)
248
+
249
+ if not self.case_sensitive:
250
+ # return the original choice, not the lower case version
251
+ return_value = self.response_type(
252
+ self.choices[
253
+ [choice.lower() for choice in self.choices].index(value.lower())
254
+ ]
255
+ )
256
+ return return_value
257
+
258
+ def on_validate_error(self, value: str, error: InvalidResponse) -> None:
259
+ """Called to handle validation error.
260
+
261
+ Args:
262
+ value (str): String entered by user.
263
+ error (InvalidResponse): Exception instance the initiated the error.
264
+ """
265
+ self.console.print(error)
266
+
267
+ def pre_prompt(self) -> None:
268
+ """Hook to display something before the prompt."""
269
+
270
+ @overload
271
+ def __call__(self, *, stream: Optional[TextIO] = None) -> PromptType:
272
+ ...
273
+
274
+ @overload
275
+ def __call__(
276
+ self, *, default: DefaultType, stream: Optional[TextIO] = None
277
+ ) -> Union[PromptType, DefaultType]:
278
+ ...
279
+
280
+ def __call__(self, *, default: Any = ..., stream: Optional[TextIO] = None) -> Any:
281
+ """Run the prompt loop.
282
+
283
+ Args:
284
+ default (Any, optional): Optional default value.
285
+
286
+ Returns:
287
+ PromptType: Processed value.
288
+ """
289
+ while True:
290
+ self.pre_prompt()
291
+ prompt = self.make_prompt(default)
292
+ value = self.get_input(self.console, prompt, self.password, stream=stream)
293
+ if value == "" and default != ...:
294
+ return default
295
+ try:
296
+ return_value = self.process_response(value)
297
+ except InvalidResponse as error:
298
+ self.on_validate_error(value, error)
299
+ continue
300
+ else:
301
+ return return_value
302
+
303
+
304
+ class Prompt(PromptBase[str]):
305
+ """A prompt that returns a str.
306
+
307
+ Example:
308
+ >>> name = Prompt.ask("Enter your name")
309
+
310
+
311
+ """
312
+
313
+ response_type = str
314
+
315
+
316
+ class IntPrompt(PromptBase[int]):
317
+ """A prompt that returns an integer.
318
+
319
+ Example:
320
+ >>> burrito_count = IntPrompt.ask("How many burritos do you want to order")
321
+
322
+ """
323
+
324
+ response_type = int
325
+ validate_error_message = "[prompt.invalid]Please enter a valid integer number"
326
+
327
+
328
+ class FloatPrompt(PromptBase[float]):
329
+ """A prompt that returns a float.
330
+
331
+ Example:
332
+ >>> temperature = FloatPrompt.ask("Enter desired temperature")
333
+
334
+ """
335
+
336
+ response_type = float
337
+ validate_error_message = "[prompt.invalid]Please enter a number"
338
+
339
+
340
+ class Confirm(PromptBase[bool]):
341
+ """A yes / no confirmation prompt.
342
+
343
+ Example:
344
+ >>> if Confirm.ask("Continue"):
345
+ run_job()
346
+
347
+ """
348
+
349
+ response_type = bool
350
+ validate_error_message = "[prompt.invalid]Please enter Y or N"
351
+ choices: List[str] = ["y", "n"]
352
+
353
+ def render_default(self, default: DefaultType) -> Text:
354
+ """Render the default as (y) or (n) rather than True/False."""
355
+ yes, no = self.choices
356
+ return Text(f"({yes})" if default else f"({no})", style="prompt.default")
357
+
358
+ def process_response(self, value: str) -> bool:
359
+ """Convert choices to a bool."""
360
+ value = value.strip().lower()
361
+ if value not in self.choices:
362
+ raise InvalidResponse(self.validate_error_message)
363
+ return value == self.choices[0]
364
+
365
+
366
+ if __name__ == "__main__": # pragma: no cover
367
+ from pip._vendor.rich import print
368
+
369
+ if Confirm.ask("Run [i]prompt[/i] tests?", default=True):
370
+ while True:
371
+ result = IntPrompt.ask(
372
+ ":rocket: Enter a number between [b]1[/b] and [b]10[/b]", default=5
373
+ )
374
+ if result >= 1 and result <= 10:
375
+ break
376
+ print(":pile_of_poo: [prompt.invalid]Number must be between 1 and 10")
377
+ print(f"number={result}")
378
+
379
+ while True:
380
+ password = Prompt.ask(
381
+ "Please enter a password [cyan](must be at least 5 characters)",
382
+ password=True,
383
+ )
384
+ if len(password) >= 5:
385
+ break
386
+ print("[prompt.invalid]password too short")
387
+ print(f"password={password!r}")
388
+
389
+ fruit = Prompt.ask("Enter a fruit", choices=["apple", "orange", "pear"])
390
+ print(f"fruit={fruit!r}")
391
+
392
+ doggie = Prompt.ask(
393
+ "What's the best Dog? (Case INSENSITIVE)",
394
+ choices=["Border Terrier", "Collie", "Labradoodle"],
395
+ case_sensitive=False,
396
+ )
397
+ print(f"doggie={doggie!r}")
398
+
399
+ else:
400
+ print("[b]OK :loudly_crying_face:")
.venv/lib/python3.13/site-packages/pip/_vendor/rich/protocol.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, cast, Set, TYPE_CHECKING
2
+ from inspect import isclass
3
+
4
+ if TYPE_CHECKING:
5
+ from pip._vendor.rich.console import RenderableType
6
+
7
+ _GIBBERISH = """aihwerij235234ljsdnp34ksodfipwoe234234jlskjdf"""
8
+
9
+
10
+ def is_renderable(check_object: Any) -> bool:
11
+ """Check if an object may be rendered by Rich."""
12
+ return (
13
+ isinstance(check_object, str)
14
+ or hasattr(check_object, "__rich__")
15
+ or hasattr(check_object, "__rich_console__")
16
+ )
17
+
18
+
19
+ def rich_cast(renderable: object) -> "RenderableType":
20
+ """Cast an object to a renderable by calling __rich__ if present.
21
+
22
+ Args:
23
+ renderable (object): A potentially renderable object
24
+
25
+ Returns:
26
+ object: The result of recursively calling __rich__.
27
+ """
28
+ from pip._vendor.rich.console import RenderableType
29
+
30
+ rich_visited_set: Set[type] = set() # Prevent potential infinite loop
31
+ while hasattr(renderable, "__rich__") and not isclass(renderable):
32
+ # Detect object which claim to have all the attributes
33
+ if hasattr(renderable, _GIBBERISH):
34
+ return repr(renderable)
35
+ cast_method = getattr(renderable, "__rich__")
36
+ renderable = cast_method()
37
+ renderable_type = type(renderable)
38
+ if renderable_type in rich_visited_set:
39
+ break
40
+ rich_visited_set.add(renderable_type)
41
+
42
+ return cast(RenderableType, renderable)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/py.typed ADDED
File without changes
.venv/lib/python3.13/site-packages/pip/_vendor/rich/region.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import NamedTuple
2
+
3
+
4
+ class Region(NamedTuple):
5
+ """Defines a rectangular region of the screen."""
6
+
7
+ x: int
8
+ y: int
9
+ width: int
10
+ height: int
.venv/lib/python3.13/site-packages/pip/_vendor/rich/repr.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import inspect
2
+ from functools import partial
3
+ from typing import (
4
+ Any,
5
+ Callable,
6
+ Iterable,
7
+ List,
8
+ Optional,
9
+ Tuple,
10
+ Type,
11
+ TypeVar,
12
+ Union,
13
+ overload,
14
+ )
15
+
16
+ T = TypeVar("T")
17
+
18
+
19
+ Result = Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]
20
+ RichReprResult = Result
21
+
22
+
23
+ class ReprError(Exception):
24
+ """An error occurred when attempting to build a repr."""
25
+
26
+
27
+ @overload
28
+ def auto(cls: Optional[Type[T]]) -> Type[T]:
29
+ ...
30
+
31
+
32
+ @overload
33
+ def auto(*, angular: bool = False) -> Callable[[Type[T]], Type[T]]:
34
+ ...
35
+
36
+
37
+ def auto(
38
+ cls: Optional[Type[T]] = None, *, angular: Optional[bool] = None
39
+ ) -> Union[Type[T], Callable[[Type[T]], Type[T]]]:
40
+ """Class decorator to create __repr__ from __rich_repr__"""
41
+
42
+ def do_replace(cls: Type[T], angular: Optional[bool] = None) -> Type[T]:
43
+ def auto_repr(self: T) -> str:
44
+ """Create repr string from __rich_repr__"""
45
+ repr_str: List[str] = []
46
+ append = repr_str.append
47
+
48
+ angular: bool = getattr(self.__rich_repr__, "angular", False) # type: ignore[attr-defined]
49
+ for arg in self.__rich_repr__(): # type: ignore[attr-defined]
50
+ if isinstance(arg, tuple):
51
+ if len(arg) == 1:
52
+ append(repr(arg[0]))
53
+ else:
54
+ key, value, *default = arg
55
+ if key is None:
56
+ append(repr(value))
57
+ else:
58
+ if default and default[0] == value:
59
+ continue
60
+ append(f"{key}={value!r}")
61
+ else:
62
+ append(repr(arg))
63
+ if angular:
64
+ return f"<{self.__class__.__name__} {' '.join(repr_str)}>"
65
+ else:
66
+ return f"{self.__class__.__name__}({', '.join(repr_str)})"
67
+
68
+ def auto_rich_repr(self: Type[T]) -> Result:
69
+ """Auto generate __rich_rep__ from signature of __init__"""
70
+ try:
71
+ signature = inspect.signature(self.__init__)
72
+ for name, param in signature.parameters.items():
73
+ if param.kind == param.POSITIONAL_ONLY:
74
+ yield getattr(self, name)
75
+ elif param.kind in (
76
+ param.POSITIONAL_OR_KEYWORD,
77
+ param.KEYWORD_ONLY,
78
+ ):
79
+ if param.default is param.empty:
80
+ yield getattr(self, param.name)
81
+ else:
82
+ yield param.name, getattr(self, param.name), param.default
83
+ except Exception as error:
84
+ raise ReprError(
85
+ f"Failed to auto generate __rich_repr__; {error}"
86
+ ) from None
87
+
88
+ if not hasattr(cls, "__rich_repr__"):
89
+ auto_rich_repr.__doc__ = "Build a rich repr"
90
+ cls.__rich_repr__ = auto_rich_repr # type: ignore[attr-defined]
91
+
92
+ auto_repr.__doc__ = "Return repr(self)"
93
+ cls.__repr__ = auto_repr # type: ignore[assignment]
94
+ if angular is not None:
95
+ cls.__rich_repr__.angular = angular # type: ignore[attr-defined]
96
+ return cls
97
+
98
+ if cls is None:
99
+ return partial(do_replace, angular=angular)
100
+ else:
101
+ return do_replace(cls, angular=angular)
102
+
103
+
104
+ @overload
105
+ def rich_repr(cls: Optional[Type[T]]) -> Type[T]:
106
+ ...
107
+
108
+
109
+ @overload
110
+ def rich_repr(*, angular: bool = False) -> Callable[[Type[T]], Type[T]]:
111
+ ...
112
+
113
+
114
+ def rich_repr(
115
+ cls: Optional[Type[T]] = None, *, angular: bool = False
116
+ ) -> Union[Type[T], Callable[[Type[T]], Type[T]]]:
117
+ if cls is None:
118
+ return auto(angular=angular)
119
+ else:
120
+ return auto(cls)
121
+
122
+
123
+ if __name__ == "__main__":
124
+
125
+ @auto
126
+ class Foo:
127
+ def __rich_repr__(self) -> Result:
128
+ yield "foo"
129
+ yield "bar", {"shopping": ["eggs", "ham", "pineapple"]}
130
+ yield "buy", "hand sanitizer"
131
+
132
+ foo = Foo()
133
+ from pip._vendor.rich.console import Console
134
+
135
+ console = Console()
136
+
137
+ console.rule("Standard repr")
138
+ console.print(foo)
139
+
140
+ console.print(foo, width=60)
141
+ console.print(foo, width=30)
142
+
143
+ console.rule("Angular repr")
144
+ Foo.__rich_repr__.angular = True # type: ignore[attr-defined]
145
+
146
+ console.print(foo)
147
+
148
+ console.print(foo, width=60)
149
+ console.print(foo, width=30)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/rule.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union
2
+
3
+ from .align import AlignMethod
4
+ from .cells import cell_len, set_cell_size
5
+ from .console import Console, ConsoleOptions, RenderResult
6
+ from .jupyter import JupyterMixin
7
+ from .measure import Measurement
8
+ from .style import Style
9
+ from .text import Text
10
+
11
+
12
+ class Rule(JupyterMixin):
13
+ """A console renderable to draw a horizontal rule (line).
14
+
15
+ Args:
16
+ title (Union[str, Text], optional): Text to render in the rule. Defaults to "".
17
+ characters (str, optional): Character(s) used to draw the line. Defaults to "─".
18
+ style (StyleType, optional): Style of Rule. Defaults to "rule.line".
19
+ end (str, optional): Character at end of Rule. defaults to "\\\\n"
20
+ align (str, optional): How to align the title, one of "left", "center", or "right". Defaults to "center".
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ title: Union[str, Text] = "",
26
+ *,
27
+ characters: str = "─",
28
+ style: Union[str, Style] = "rule.line",
29
+ end: str = "\n",
30
+ align: AlignMethod = "center",
31
+ ) -> None:
32
+ if cell_len(characters) < 1:
33
+ raise ValueError(
34
+ "'characters' argument must have a cell width of at least 1"
35
+ )
36
+ if align not in ("left", "center", "right"):
37
+ raise ValueError(
38
+ f'invalid value for align, expected "left", "center", "right" (not {align!r})'
39
+ )
40
+ self.title = title
41
+ self.characters = characters
42
+ self.style = style
43
+ self.end = end
44
+ self.align = align
45
+
46
+ def __repr__(self) -> str:
47
+ return f"Rule({self.title!r}, {self.characters!r})"
48
+
49
+ def __rich_console__(
50
+ self, console: Console, options: ConsoleOptions
51
+ ) -> RenderResult:
52
+ width = options.max_width
53
+
54
+ characters = (
55
+ "-"
56
+ if (options.ascii_only and not self.characters.isascii())
57
+ else self.characters
58
+ )
59
+
60
+ chars_len = cell_len(characters)
61
+ if not self.title:
62
+ yield self._rule_line(chars_len, width)
63
+ return
64
+
65
+ if isinstance(self.title, Text):
66
+ title_text = self.title
67
+ else:
68
+ title_text = console.render_str(self.title, style="rule.text")
69
+
70
+ title_text.plain = title_text.plain.replace("\n", " ")
71
+ title_text.expand_tabs()
72
+
73
+ required_space = 4 if self.align == "center" else 2
74
+ truncate_width = max(0, width - required_space)
75
+ if not truncate_width:
76
+ yield self._rule_line(chars_len, width)
77
+ return
78
+
79
+ rule_text = Text(end=self.end)
80
+ if self.align == "center":
81
+ title_text.truncate(truncate_width, overflow="ellipsis")
82
+ side_width = (width - cell_len(title_text.plain)) // 2
83
+ left = Text(characters * (side_width // chars_len + 1))
84
+ left.truncate(side_width - 1)
85
+ right_length = width - cell_len(left.plain) - cell_len(title_text.plain)
86
+ right = Text(characters * (side_width // chars_len + 1))
87
+ right.truncate(right_length)
88
+ rule_text.append(left.plain + " ", self.style)
89
+ rule_text.append(title_text)
90
+ rule_text.append(" " + right.plain, self.style)
91
+ elif self.align == "left":
92
+ title_text.truncate(truncate_width, overflow="ellipsis")
93
+ rule_text.append(title_text)
94
+ rule_text.append(" ")
95
+ rule_text.append(characters * (width - rule_text.cell_len), self.style)
96
+ elif self.align == "right":
97
+ title_text.truncate(truncate_width, overflow="ellipsis")
98
+ rule_text.append(characters * (width - title_text.cell_len - 1), self.style)
99
+ rule_text.append(" ")
100
+ rule_text.append(title_text)
101
+
102
+ rule_text.plain = set_cell_size(rule_text.plain, width)
103
+ yield rule_text
104
+
105
+ def _rule_line(self, chars_len: int, width: int) -> Text:
106
+ rule_text = Text(self.characters * ((width // chars_len) + 1), self.style)
107
+ rule_text.truncate(width)
108
+ rule_text.plain = set_cell_size(rule_text.plain, width)
109
+ return rule_text
110
+
111
+ def __rich_measure__(
112
+ self, console: Console, options: ConsoleOptions
113
+ ) -> Measurement:
114
+ return Measurement(1, 1)
115
+
116
+
117
+ if __name__ == "__main__": # pragma: no cover
118
+ import sys
119
+
120
+ from pip._vendor.rich.console import Console
121
+
122
+ try:
123
+ text = sys.argv[1]
124
+ except IndexError:
125
+ text = "Hello, World"
126
+ console = Console()
127
+ console.print(Rule(title=text))
128
+
129
+ console = Console()
130
+ console.print(Rule("foo"), width=4)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/scope.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, Optional, Tuple
3
+
4
+ from .highlighter import ReprHighlighter
5
+ from .panel import Panel
6
+ from .pretty import Pretty
7
+ from .table import Table
8
+ from .text import Text, TextType
9
+
10
+ if TYPE_CHECKING:
11
+ from .console import ConsoleRenderable
12
+
13
+
14
+ def render_scope(
15
+ scope: "Mapping[str, Any]",
16
+ *,
17
+ title: Optional[TextType] = None,
18
+ sort_keys: bool = True,
19
+ indent_guides: bool = False,
20
+ max_length: Optional[int] = None,
21
+ max_string: Optional[int] = None,
22
+ ) -> "ConsoleRenderable":
23
+ """Render python variables in a given scope.
24
+
25
+ Args:
26
+ scope (Mapping): A mapping containing variable names and values.
27
+ title (str, optional): Optional title. Defaults to None.
28
+ sort_keys (bool, optional): Enable sorting of items. Defaults to True.
29
+ indent_guides (bool, optional): Enable indentation guides. Defaults to False.
30
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
31
+ Defaults to None.
32
+ max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
33
+
34
+ Returns:
35
+ ConsoleRenderable: A renderable object.
36
+ """
37
+ highlighter = ReprHighlighter()
38
+ items_table = Table.grid(padding=(0, 1), expand=False)
39
+ items_table.add_column(justify="right")
40
+
41
+ def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
42
+ """Sort special variables first, then alphabetically."""
43
+ key, _ = item
44
+ return (not key.startswith("__"), key.lower())
45
+
46
+ items = sorted(scope.items(), key=sort_items) if sort_keys else scope.items()
47
+ for key, value in items:
48
+ key_text = Text.assemble(
49
+ (key, "scope.key.special" if key.startswith("__") else "scope.key"),
50
+ (" =", "scope.equals"),
51
+ )
52
+ items_table.add_row(
53
+ key_text,
54
+ Pretty(
55
+ value,
56
+ highlighter=highlighter,
57
+ indent_guides=indent_guides,
58
+ max_length=max_length,
59
+ max_string=max_string,
60
+ ),
61
+ )
62
+ return Panel.fit(
63
+ items_table,
64
+ title=title,
65
+ border_style="scope.border",
66
+ padding=(0, 1),
67
+ )
68
+
69
+
70
+ if __name__ == "__main__": # pragma: no cover
71
+ from pip._vendor.rich import print
72
+
73
+ print()
74
+
75
+ def test(foo: float, bar: float) -> None:
76
+ list_of_things = [1, 2, 3, None, 4, True, False, "Hello World"]
77
+ dict_of_things = {
78
+ "version": "1.1",
79
+ "method": "confirmFruitPurchase",
80
+ "params": [["apple", "orange", "mangoes", "pomelo"], 1.123],
81
+ "id": "194521489",
82
+ }
83
+ print(render_scope(locals(), title="[i]locals", sort_keys=False))
84
+
85
+ test(20.3423, 3.1427)
86
+ print()
.venv/lib/python3.13/site-packages/pip/_vendor/rich/screen.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, TYPE_CHECKING
2
+
3
+ from .segment import Segment
4
+ from .style import StyleType
5
+ from ._loop import loop_last
6
+
7
+
8
+ if TYPE_CHECKING:
9
+ from .console import (
10
+ Console,
11
+ ConsoleOptions,
12
+ RenderResult,
13
+ RenderableType,
14
+ Group,
15
+ )
16
+
17
+
18
+ class Screen:
19
+ """A renderable that fills the terminal screen and crops excess.
20
+
21
+ Args:
22
+ renderable (RenderableType): Child renderable.
23
+ style (StyleType, optional): Optional background style. Defaults to None.
24
+ """
25
+
26
+ renderable: "RenderableType"
27
+
28
+ def __init__(
29
+ self,
30
+ *renderables: "RenderableType",
31
+ style: Optional[StyleType] = None,
32
+ application_mode: bool = False,
33
+ ) -> None:
34
+ from pip._vendor.rich.console import Group
35
+
36
+ self.renderable = Group(*renderables)
37
+ self.style = style
38
+ self.application_mode = application_mode
39
+
40
+ def __rich_console__(
41
+ self, console: "Console", options: "ConsoleOptions"
42
+ ) -> "RenderResult":
43
+ width, height = options.size
44
+ style = console.get_style(self.style) if self.style else None
45
+ render_options = options.update(width=width, height=height)
46
+ lines = console.render_lines(
47
+ self.renderable or "", render_options, style=style, pad=True
48
+ )
49
+ lines = Segment.set_shape(lines, width, height, style=style)
50
+ new_line = Segment("\n\r") if self.application_mode else Segment.line()
51
+ for last, line in loop_last(lines):
52
+ yield from line
53
+ if not last:
54
+ yield new_line
.venv/lib/python3.13/site-packages/pip/_vendor/rich/segment.py ADDED
@@ -0,0 +1,752 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from enum import IntEnum
2
+ from functools import lru_cache
3
+ from itertools import filterfalse
4
+ from logging import getLogger
5
+ from operator import attrgetter
6
+ from typing import (
7
+ TYPE_CHECKING,
8
+ Dict,
9
+ Iterable,
10
+ List,
11
+ NamedTuple,
12
+ Optional,
13
+ Sequence,
14
+ Tuple,
15
+ Type,
16
+ Union,
17
+ )
18
+
19
+ from .cells import (
20
+ _is_single_cell_widths,
21
+ cached_cell_len,
22
+ cell_len,
23
+ get_character_cell_size,
24
+ set_cell_size,
25
+ )
26
+ from .repr import Result, rich_repr
27
+ from .style import Style
28
+
29
+ if TYPE_CHECKING:
30
+ from .console import Console, ConsoleOptions, RenderResult
31
+
32
+ log = getLogger("rich")
33
+
34
+
35
+ class ControlType(IntEnum):
36
+ """Non-printable control codes which typically translate to ANSI codes."""
37
+
38
+ BELL = 1
39
+ CARRIAGE_RETURN = 2
40
+ HOME = 3
41
+ CLEAR = 4
42
+ SHOW_CURSOR = 5
43
+ HIDE_CURSOR = 6
44
+ ENABLE_ALT_SCREEN = 7
45
+ DISABLE_ALT_SCREEN = 8
46
+ CURSOR_UP = 9
47
+ CURSOR_DOWN = 10
48
+ CURSOR_FORWARD = 11
49
+ CURSOR_BACKWARD = 12
50
+ CURSOR_MOVE_TO_COLUMN = 13
51
+ CURSOR_MOVE_TO = 14
52
+ ERASE_IN_LINE = 15
53
+ SET_WINDOW_TITLE = 16
54
+
55
+
56
+ ControlCode = Union[
57
+ Tuple[ControlType],
58
+ Tuple[ControlType, Union[int, str]],
59
+ Tuple[ControlType, int, int],
60
+ ]
61
+
62
+
63
+ @rich_repr()
64
+ class Segment(NamedTuple):
65
+ """A piece of text with associated style. Segments are produced by the Console render process and
66
+ are ultimately converted in to strings to be written to the terminal.
67
+
68
+ Args:
69
+ text (str): A piece of text.
70
+ style (:class:`~rich.style.Style`, optional): An optional style to apply to the text.
71
+ control (Tuple[ControlCode], optional): Optional sequence of control codes.
72
+
73
+ Attributes:
74
+ cell_length (int): The cell length of this Segment.
75
+ """
76
+
77
+ text: str
78
+ style: Optional[Style] = None
79
+ control: Optional[Sequence[ControlCode]] = None
80
+
81
+ @property
82
+ def cell_length(self) -> int:
83
+ """The number of terminal cells required to display self.text.
84
+
85
+ Returns:
86
+ int: A number of cells.
87
+ """
88
+ text, _style, control = self
89
+ return 0 if control else cell_len(text)
90
+
91
+ def __rich_repr__(self) -> Result:
92
+ yield self.text
93
+ if self.control is None:
94
+ if self.style is not None:
95
+ yield self.style
96
+ else:
97
+ yield self.style
98
+ yield self.control
99
+
100
+ def __bool__(self) -> bool:
101
+ """Check if the segment contains text."""
102
+ return bool(self.text)
103
+
104
+ @property
105
+ def is_control(self) -> bool:
106
+ """Check if the segment contains control codes."""
107
+ return self.control is not None
108
+
109
+ @classmethod
110
+ @lru_cache(1024 * 16)
111
+ def _split_cells(cls, segment: "Segment", cut: int) -> Tuple["Segment", "Segment"]:
112
+ """Split a segment in to two at a given cell position.
113
+
114
+ Note that splitting a double-width character, may result in that character turning
115
+ into two spaces.
116
+
117
+ Args:
118
+ segment (Segment): A segment to split.
119
+ cut (int): A cell position to cut on.
120
+
121
+ Returns:
122
+ A tuple of two segments.
123
+ """
124
+ text, style, control = segment
125
+ _Segment = Segment
126
+ cell_length = segment.cell_length
127
+ if cut >= cell_length:
128
+ return segment, _Segment("", style, control)
129
+
130
+ cell_size = get_character_cell_size
131
+
132
+ pos = int((cut / cell_length) * len(text))
133
+
134
+ while True:
135
+ before = text[:pos]
136
+ cell_pos = cell_len(before)
137
+ out_by = cell_pos - cut
138
+ if not out_by:
139
+ return (
140
+ _Segment(before, style, control),
141
+ _Segment(text[pos:], style, control),
142
+ )
143
+ if out_by == -1 and cell_size(text[pos]) == 2:
144
+ return (
145
+ _Segment(text[:pos] + " ", style, control),
146
+ _Segment(" " + text[pos + 1 :], style, control),
147
+ )
148
+ if out_by == +1 and cell_size(text[pos - 1]) == 2:
149
+ return (
150
+ _Segment(text[: pos - 1] + " ", style, control),
151
+ _Segment(" " + text[pos:], style, control),
152
+ )
153
+ if cell_pos < cut:
154
+ pos += 1
155
+ else:
156
+ pos -= 1
157
+
158
+ def split_cells(self, cut: int) -> Tuple["Segment", "Segment"]:
159
+ """Split segment in to two segments at the specified column.
160
+
161
+ If the cut point falls in the middle of a 2-cell wide character then it is replaced
162
+ by two spaces, to preserve the display width of the parent segment.
163
+
164
+ Args:
165
+ cut (int): Offset within the segment to cut.
166
+
167
+ Returns:
168
+ Tuple[Segment, Segment]: Two segments.
169
+ """
170
+ text, style, control = self
171
+ assert cut >= 0
172
+
173
+ if _is_single_cell_widths(text):
174
+ # Fast path with all 1 cell characters
175
+ if cut >= len(text):
176
+ return self, Segment("", style, control)
177
+ return (
178
+ Segment(text[:cut], style, control),
179
+ Segment(text[cut:], style, control),
180
+ )
181
+
182
+ return self._split_cells(self, cut)
183
+
184
+ @classmethod
185
+ def line(cls) -> "Segment":
186
+ """Make a new line segment."""
187
+ return cls("\n")
188
+
189
+ @classmethod
190
+ def apply_style(
191
+ cls,
192
+ segments: Iterable["Segment"],
193
+ style: Optional[Style] = None,
194
+ post_style: Optional[Style] = None,
195
+ ) -> Iterable["Segment"]:
196
+ """Apply style(s) to an iterable of segments.
197
+
198
+ Returns an iterable of segments where the style is replaced by ``style + segment.style + post_style``.
199
+
200
+ Args:
201
+ segments (Iterable[Segment]): Segments to process.
202
+ style (Style, optional): Base style. Defaults to None.
203
+ post_style (Style, optional): Style to apply on top of segment style. Defaults to None.
204
+
205
+ Returns:
206
+ Iterable[Segments]: A new iterable of segments (possibly the same iterable).
207
+ """
208
+ result_segments = segments
209
+ if style:
210
+ apply = style.__add__
211
+ result_segments = (
212
+ cls(text, None if control else apply(_style), control)
213
+ for text, _style, control in result_segments
214
+ )
215
+ if post_style:
216
+ result_segments = (
217
+ cls(
218
+ text,
219
+ (
220
+ None
221
+ if control
222
+ else (_style + post_style if _style else post_style)
223
+ ),
224
+ control,
225
+ )
226
+ for text, _style, control in result_segments
227
+ )
228
+ return result_segments
229
+
230
+ @classmethod
231
+ def filter_control(
232
+ cls, segments: Iterable["Segment"], is_control: bool = False
233
+ ) -> Iterable["Segment"]:
234
+ """Filter segments by ``is_control`` attribute.
235
+
236
+ Args:
237
+ segments (Iterable[Segment]): An iterable of Segment instances.
238
+ is_control (bool, optional): is_control flag to match in search.
239
+
240
+ Returns:
241
+ Iterable[Segment]: And iterable of Segment instances.
242
+
243
+ """
244
+ if is_control:
245
+ return filter(attrgetter("control"), segments)
246
+ else:
247
+ return filterfalse(attrgetter("control"), segments)
248
+
249
+ @classmethod
250
+ def split_lines(cls, segments: Iterable["Segment"]) -> Iterable[List["Segment"]]:
251
+ """Split a sequence of segments in to a list of lines.
252
+
253
+ Args:
254
+ segments (Iterable[Segment]): Segments potentially containing line feeds.
255
+
256
+ Yields:
257
+ Iterable[List[Segment]]: Iterable of segment lists, one per line.
258
+ """
259
+ line: List[Segment] = []
260
+ append = line.append
261
+
262
+ for segment in segments:
263
+ if "\n" in segment.text and not segment.control:
264
+ text, style, _ = segment
265
+ while text:
266
+ _text, new_line, text = text.partition("\n")
267
+ if _text:
268
+ append(cls(_text, style))
269
+ if new_line:
270
+ yield line
271
+ line = []
272
+ append = line.append
273
+ else:
274
+ append(segment)
275
+ if line:
276
+ yield line
277
+
278
+ @classmethod
279
+ def split_and_crop_lines(
280
+ cls,
281
+ segments: Iterable["Segment"],
282
+ length: int,
283
+ style: Optional[Style] = None,
284
+ pad: bool = True,
285
+ include_new_lines: bool = True,
286
+ ) -> Iterable[List["Segment"]]:
287
+ """Split segments in to lines, and crop lines greater than a given length.
288
+
289
+ Args:
290
+ segments (Iterable[Segment]): An iterable of segments, probably
291
+ generated from console.render.
292
+ length (int): Desired line length.
293
+ style (Style, optional): Style to use for any padding.
294
+ pad (bool): Enable padding of lines that are less than `length`.
295
+
296
+ Returns:
297
+ Iterable[List[Segment]]: An iterable of lines of segments.
298
+ """
299
+ line: List[Segment] = []
300
+ append = line.append
301
+
302
+ adjust_line_length = cls.adjust_line_length
303
+ new_line_segment = cls("\n")
304
+
305
+ for segment in segments:
306
+ if "\n" in segment.text and not segment.control:
307
+ text, segment_style, _ = segment
308
+ while text:
309
+ _text, new_line, text = text.partition("\n")
310
+ if _text:
311
+ append(cls(_text, segment_style))
312
+ if new_line:
313
+ cropped_line = adjust_line_length(
314
+ line, length, style=style, pad=pad
315
+ )
316
+ if include_new_lines:
317
+ cropped_line.append(new_line_segment)
318
+ yield cropped_line
319
+ line.clear()
320
+ else:
321
+ append(segment)
322
+ if line:
323
+ yield adjust_line_length(line, length, style=style, pad=pad)
324
+
325
+ @classmethod
326
+ def adjust_line_length(
327
+ cls,
328
+ line: List["Segment"],
329
+ length: int,
330
+ style: Optional[Style] = None,
331
+ pad: bool = True,
332
+ ) -> List["Segment"]:
333
+ """Adjust a line to a given width (cropping or padding as required).
334
+
335
+ Args:
336
+ segments (Iterable[Segment]): A list of segments in a single line.
337
+ length (int): The desired width of the line.
338
+ style (Style, optional): The style of padding if used (space on the end). Defaults to None.
339
+ pad (bool, optional): Pad lines with spaces if they are shorter than `length`. Defaults to True.
340
+
341
+ Returns:
342
+ List[Segment]: A line of segments with the desired length.
343
+ """
344
+ line_length = sum(segment.cell_length for segment in line)
345
+ new_line: List[Segment]
346
+
347
+ if line_length < length:
348
+ if pad:
349
+ new_line = line + [cls(" " * (length - line_length), style)]
350
+ else:
351
+ new_line = line[:]
352
+ elif line_length > length:
353
+ new_line = []
354
+ append = new_line.append
355
+ line_length = 0
356
+ for segment in line:
357
+ segment_length = segment.cell_length
358
+ if line_length + segment_length < length or segment.control:
359
+ append(segment)
360
+ line_length += segment_length
361
+ else:
362
+ text, segment_style, _ = segment
363
+ text = set_cell_size(text, length - line_length)
364
+ append(cls(text, segment_style))
365
+ break
366
+ else:
367
+ new_line = line[:]
368
+ return new_line
369
+
370
+ @classmethod
371
+ def get_line_length(cls, line: List["Segment"]) -> int:
372
+ """Get the length of list of segments.
373
+
374
+ Args:
375
+ line (List[Segment]): A line encoded as a list of Segments (assumes no '\\\\n' characters),
376
+
377
+ Returns:
378
+ int: The length of the line.
379
+ """
380
+ _cell_len = cell_len
381
+ return sum(_cell_len(text) for text, style, control in line if not control)
382
+
383
+ @classmethod
384
+ def get_shape(cls, lines: List[List["Segment"]]) -> Tuple[int, int]:
385
+ """Get the shape (enclosing rectangle) of a list of lines.
386
+
387
+ Args:
388
+ lines (List[List[Segment]]): A list of lines (no '\\\\n' characters).
389
+
390
+ Returns:
391
+ Tuple[int, int]: Width and height in characters.
392
+ """
393
+ get_line_length = cls.get_line_length
394
+ max_width = max(get_line_length(line) for line in lines) if lines else 0
395
+ return (max_width, len(lines))
396
+
397
+ @classmethod
398
+ def set_shape(
399
+ cls,
400
+ lines: List[List["Segment"]],
401
+ width: int,
402
+ height: Optional[int] = None,
403
+ style: Optional[Style] = None,
404
+ new_lines: bool = False,
405
+ ) -> List[List["Segment"]]:
406
+ """Set the shape of a list of lines (enclosing rectangle).
407
+
408
+ Args:
409
+ lines (List[List[Segment]]): A list of lines.
410
+ width (int): Desired width.
411
+ height (int, optional): Desired height or None for no change.
412
+ style (Style, optional): Style of any padding added.
413
+ new_lines (bool, optional): Padded lines should include "\n". Defaults to False.
414
+
415
+ Returns:
416
+ List[List[Segment]]: New list of lines.
417
+ """
418
+ _height = height or len(lines)
419
+
420
+ blank = (
421
+ [cls(" " * width + "\n", style)] if new_lines else [cls(" " * width, style)]
422
+ )
423
+
424
+ adjust_line_length = cls.adjust_line_length
425
+ shaped_lines = lines[:_height]
426
+ shaped_lines[:] = [
427
+ adjust_line_length(line, width, style=style) for line in lines
428
+ ]
429
+ if len(shaped_lines) < _height:
430
+ shaped_lines.extend([blank] * (_height - len(shaped_lines)))
431
+ return shaped_lines
432
+
433
+ @classmethod
434
+ def align_top(
435
+ cls: Type["Segment"],
436
+ lines: List[List["Segment"]],
437
+ width: int,
438
+ height: int,
439
+ style: Style,
440
+ new_lines: bool = False,
441
+ ) -> List[List["Segment"]]:
442
+ """Aligns lines to top (adds extra lines to bottom as required).
443
+
444
+ Args:
445
+ lines (List[List[Segment]]): A list of lines.
446
+ width (int): Desired width.
447
+ height (int, optional): Desired height or None for no change.
448
+ style (Style): Style of any padding added.
449
+ new_lines (bool, optional): Padded lines should include "\n". Defaults to False.
450
+
451
+ Returns:
452
+ List[List[Segment]]: New list of lines.
453
+ """
454
+ extra_lines = height - len(lines)
455
+ if not extra_lines:
456
+ return lines[:]
457
+ lines = lines[:height]
458
+ blank = cls(" " * width + "\n", style) if new_lines else cls(" " * width, style)
459
+ lines = lines + [[blank]] * extra_lines
460
+ return lines
461
+
462
+ @classmethod
463
+ def align_bottom(
464
+ cls: Type["Segment"],
465
+ lines: List[List["Segment"]],
466
+ width: int,
467
+ height: int,
468
+ style: Style,
469
+ new_lines: bool = False,
470
+ ) -> List[List["Segment"]]:
471
+ """Aligns render to bottom (adds extra lines above as required).
472
+
473
+ Args:
474
+ lines (List[List[Segment]]): A list of lines.
475
+ width (int): Desired width.
476
+ height (int, optional): Desired height or None for no change.
477
+ style (Style): Style of any padding added. Defaults to None.
478
+ new_lines (bool, optional): Padded lines should include "\n". Defaults to False.
479
+
480
+ Returns:
481
+ List[List[Segment]]: New list of lines.
482
+ """
483
+ extra_lines = height - len(lines)
484
+ if not extra_lines:
485
+ return lines[:]
486
+ lines = lines[:height]
487
+ blank = cls(" " * width + "\n", style) if new_lines else cls(" " * width, style)
488
+ lines = [[blank]] * extra_lines + lines
489
+ return lines
490
+
491
+ @classmethod
492
+ def align_middle(
493
+ cls: Type["Segment"],
494
+ lines: List[List["Segment"]],
495
+ width: int,
496
+ height: int,
497
+ style: Style,
498
+ new_lines: bool = False,
499
+ ) -> List[List["Segment"]]:
500
+ """Aligns lines to middle (adds extra lines to above and below as required).
501
+
502
+ Args:
503
+ lines (List[List[Segment]]): A list of lines.
504
+ width (int): Desired width.
505
+ height (int, optional): Desired height or None for no change.
506
+ style (Style): Style of any padding added.
507
+ new_lines (bool, optional): Padded lines should include "\n". Defaults to False.
508
+
509
+ Returns:
510
+ List[List[Segment]]: New list of lines.
511
+ """
512
+ extra_lines = height - len(lines)
513
+ if not extra_lines:
514
+ return lines[:]
515
+ lines = lines[:height]
516
+ blank = cls(" " * width + "\n", style) if new_lines else cls(" " * width, style)
517
+ top_lines = extra_lines // 2
518
+ bottom_lines = extra_lines - top_lines
519
+ lines = [[blank]] * top_lines + lines + [[blank]] * bottom_lines
520
+ return lines
521
+
522
+ @classmethod
523
+ def simplify(cls, segments: Iterable["Segment"]) -> Iterable["Segment"]:
524
+ """Simplify an iterable of segments by combining contiguous segments with the same style.
525
+
526
+ Args:
527
+ segments (Iterable[Segment]): An iterable of segments.
528
+
529
+ Returns:
530
+ Iterable[Segment]: A possibly smaller iterable of segments that will render the same way.
531
+ """
532
+ iter_segments = iter(segments)
533
+ try:
534
+ last_segment = next(iter_segments)
535
+ except StopIteration:
536
+ return
537
+
538
+ _Segment = Segment
539
+ for segment in iter_segments:
540
+ if last_segment.style == segment.style and not segment.control:
541
+ last_segment = _Segment(
542
+ last_segment.text + segment.text, last_segment.style
543
+ )
544
+ else:
545
+ yield last_segment
546
+ last_segment = segment
547
+ yield last_segment
548
+
549
+ @classmethod
550
+ def strip_links(cls, segments: Iterable["Segment"]) -> Iterable["Segment"]:
551
+ """Remove all links from an iterable of styles.
552
+
553
+ Args:
554
+ segments (Iterable[Segment]): An iterable segments.
555
+
556
+ Yields:
557
+ Segment: Segments with link removed.
558
+ """
559
+ for segment in segments:
560
+ if segment.control or segment.style is None:
561
+ yield segment
562
+ else:
563
+ text, style, _control = segment
564
+ yield cls(text, style.update_link(None) if style else None)
565
+
566
+ @classmethod
567
+ def strip_styles(cls, segments: Iterable["Segment"]) -> Iterable["Segment"]:
568
+ """Remove all styles from an iterable of segments.
569
+
570
+ Args:
571
+ segments (Iterable[Segment]): An iterable segments.
572
+
573
+ Yields:
574
+ Segment: Segments with styles replace with None
575
+ """
576
+ for text, _style, control in segments:
577
+ yield cls(text, None, control)
578
+
579
+ @classmethod
580
+ def remove_color(cls, segments: Iterable["Segment"]) -> Iterable["Segment"]:
581
+ """Remove all color from an iterable of segments.
582
+
583
+ Args:
584
+ segments (Iterable[Segment]): An iterable segments.
585
+
586
+ Yields:
587
+ Segment: Segments with colorless style.
588
+ """
589
+
590
+ cache: Dict[Style, Style] = {}
591
+ for text, style, control in segments:
592
+ if style:
593
+ colorless_style = cache.get(style)
594
+ if colorless_style is None:
595
+ colorless_style = style.without_color
596
+ cache[style] = colorless_style
597
+ yield cls(text, colorless_style, control)
598
+ else:
599
+ yield cls(text, None, control)
600
+
601
+ @classmethod
602
+ def divide(
603
+ cls, segments: Iterable["Segment"], cuts: Iterable[int]
604
+ ) -> Iterable[List["Segment"]]:
605
+ """Divides an iterable of segments in to portions.
606
+
607
+ Args:
608
+ cuts (Iterable[int]): Cell positions where to divide.
609
+
610
+ Yields:
611
+ [Iterable[List[Segment]]]: An iterable of Segments in List.
612
+ """
613
+ split_segments: List["Segment"] = []
614
+ add_segment = split_segments.append
615
+
616
+ iter_cuts = iter(cuts)
617
+
618
+ while True:
619
+ cut = next(iter_cuts, -1)
620
+ if cut == -1:
621
+ return
622
+ if cut != 0:
623
+ break
624
+ yield []
625
+ pos = 0
626
+
627
+ segments_clear = split_segments.clear
628
+ segments_copy = split_segments.copy
629
+
630
+ _cell_len = cached_cell_len
631
+ for segment in segments:
632
+ text, _style, control = segment
633
+ while text:
634
+ end_pos = pos if control else pos + _cell_len(text)
635
+ if end_pos < cut:
636
+ add_segment(segment)
637
+ pos = end_pos
638
+ break
639
+
640
+ if end_pos == cut:
641
+ add_segment(segment)
642
+ yield segments_copy()
643
+ segments_clear()
644
+ pos = end_pos
645
+
646
+ cut = next(iter_cuts, -1)
647
+ if cut == -1:
648
+ if split_segments:
649
+ yield segments_copy()
650
+ return
651
+
652
+ break
653
+
654
+ else:
655
+ before, segment = segment.split_cells(cut - pos)
656
+ text, _style, control = segment
657
+ add_segment(before)
658
+ yield segments_copy()
659
+ segments_clear()
660
+ pos = cut
661
+
662
+ cut = next(iter_cuts, -1)
663
+ if cut == -1:
664
+ if split_segments:
665
+ yield segments_copy()
666
+ return
667
+
668
+ yield segments_copy()
669
+
670
+
671
+ class Segments:
672
+ """A simple renderable to render an iterable of segments. This class may be useful if
673
+ you want to print segments outside of a __rich_console__ method.
674
+
675
+ Args:
676
+ segments (Iterable[Segment]): An iterable of segments.
677
+ new_lines (bool, optional): Add new lines between segments. Defaults to False.
678
+ """
679
+
680
+ def __init__(self, segments: Iterable[Segment], new_lines: bool = False) -> None:
681
+ self.segments = list(segments)
682
+ self.new_lines = new_lines
683
+
684
+ def __rich_console__(
685
+ self, console: "Console", options: "ConsoleOptions"
686
+ ) -> "RenderResult":
687
+ if self.new_lines:
688
+ line = Segment.line()
689
+ for segment in self.segments:
690
+ yield segment
691
+ yield line
692
+ else:
693
+ yield from self.segments
694
+
695
+
696
+ class SegmentLines:
697
+ def __init__(self, lines: Iterable[List[Segment]], new_lines: bool = False) -> None:
698
+ """A simple renderable containing a number of lines of segments. May be used as an intermediate
699
+ in rendering process.
700
+
701
+ Args:
702
+ lines (Iterable[List[Segment]]): Lists of segments forming lines.
703
+ new_lines (bool, optional): Insert new lines after each line. Defaults to False.
704
+ """
705
+ self.lines = list(lines)
706
+ self.new_lines = new_lines
707
+
708
+ def __rich_console__(
709
+ self, console: "Console", options: "ConsoleOptions"
710
+ ) -> "RenderResult":
711
+ if self.new_lines:
712
+ new_line = Segment.line()
713
+ for line in self.lines:
714
+ yield from line
715
+ yield new_line
716
+ else:
717
+ for line in self.lines:
718
+ yield from line
719
+
720
+
721
+ if __name__ == "__main__": # pragma: no cover
722
+ from pip._vendor.rich.console import Console
723
+ from pip._vendor.rich.syntax import Syntax
724
+ from pip._vendor.rich.text import Text
725
+
726
+ code = """from rich.console import Console
727
+ console = Console()
728
+ text = Text.from_markup("Hello, [bold magenta]World[/]!")
729
+ console.print(text)"""
730
+
731
+ text = Text.from_markup("Hello, [bold magenta]World[/]!")
732
+
733
+ console = Console()
734
+
735
+ console.rule("rich.Segment")
736
+ console.print(
737
+ "A Segment is the last step in the Rich render process before generating text with ANSI codes."
738
+ )
739
+ console.print("\nConsider the following code:\n")
740
+ console.print(Syntax(code, "python", line_numbers=True))
741
+ console.print()
742
+ console.print(
743
+ "When you call [b]print()[/b], Rich [i]renders[/i] the object in to the following:\n"
744
+ )
745
+ fragments = list(console.render(text))
746
+ console.print(fragments)
747
+ console.print()
748
+ console.print("The Segments are then processed to produce the following output:\n")
749
+ console.print(text)
750
+ console.print(
751
+ "\nYou will only need to know this if you are implementing your own Rich renderables."
752
+ )
.venv/lib/python3.13/site-packages/pip/_vendor/rich/spinner.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import cast, List, Optional, TYPE_CHECKING, Union
2
+
3
+ from ._spinners import SPINNERS
4
+ from .measure import Measurement
5
+ from .table import Table
6
+ from .text import Text
7
+
8
+ if TYPE_CHECKING:
9
+ from .console import Console, ConsoleOptions, RenderResult, RenderableType
10
+ from .style import StyleType
11
+
12
+
13
+ class Spinner:
14
+ """A spinner animation.
15
+
16
+ Args:
17
+ name (str): Name of spinner (run python -m rich.spinner).
18
+ text (RenderableType, optional): A renderable to display at the right of the spinner (str or Text typically). Defaults to "".
19
+ style (StyleType, optional): Style for spinner animation. Defaults to None.
20
+ speed (float, optional): Speed factor for animation. Defaults to 1.0.
21
+
22
+ Raises:
23
+ KeyError: If name isn't one of the supported spinner animations.
24
+ """
25
+
26
+ def __init__(
27
+ self,
28
+ name: str,
29
+ text: "RenderableType" = "",
30
+ *,
31
+ style: Optional["StyleType"] = None,
32
+ speed: float = 1.0,
33
+ ) -> None:
34
+ try:
35
+ spinner = SPINNERS[name]
36
+ except KeyError:
37
+ raise KeyError(f"no spinner called {name!r}")
38
+ self.text: "Union[RenderableType, Text]" = (
39
+ Text.from_markup(text) if isinstance(text, str) else text
40
+ )
41
+ self.name = name
42
+ self.frames = cast(List[str], spinner["frames"])[:]
43
+ self.interval = cast(float, spinner["interval"])
44
+ self.start_time: Optional[float] = None
45
+ self.style = style
46
+ self.speed = speed
47
+ self.frame_no_offset: float = 0.0
48
+ self._update_speed = 0.0
49
+
50
+ def __rich_console__(
51
+ self, console: "Console", options: "ConsoleOptions"
52
+ ) -> "RenderResult":
53
+ yield self.render(console.get_time())
54
+
55
+ def __rich_measure__(
56
+ self, console: "Console", options: "ConsoleOptions"
57
+ ) -> Measurement:
58
+ text = self.render(0)
59
+ return Measurement.get(console, options, text)
60
+
61
+ def render(self, time: float) -> "RenderableType":
62
+ """Render the spinner for a given time.
63
+
64
+ Args:
65
+ time (float): Time in seconds.
66
+
67
+ Returns:
68
+ RenderableType: A renderable containing animation frame.
69
+ """
70
+ if self.start_time is None:
71
+ self.start_time = time
72
+
73
+ frame_no = ((time - self.start_time) * self.speed) / (
74
+ self.interval / 1000.0
75
+ ) + self.frame_no_offset
76
+ frame = Text(
77
+ self.frames[int(frame_no) % len(self.frames)], style=self.style or ""
78
+ )
79
+
80
+ if self._update_speed:
81
+ self.frame_no_offset = frame_no
82
+ self.start_time = time
83
+ self.speed = self._update_speed
84
+ self._update_speed = 0.0
85
+
86
+ if not self.text:
87
+ return frame
88
+ elif isinstance(self.text, (str, Text)):
89
+ return Text.assemble(frame, " ", self.text)
90
+ else:
91
+ table = Table.grid(padding=1)
92
+ table.add_row(frame, self.text)
93
+ return table
94
+
95
+ def update(
96
+ self,
97
+ *,
98
+ text: "RenderableType" = "",
99
+ style: Optional["StyleType"] = None,
100
+ speed: Optional[float] = None,
101
+ ) -> None:
102
+ """Updates attributes of a spinner after it has been started.
103
+
104
+ Args:
105
+ text (RenderableType, optional): A renderable to display at the right of the spinner (str or Text typically). Defaults to "".
106
+ style (StyleType, optional): Style for spinner animation. Defaults to None.
107
+ speed (float, optional): Speed factor for animation. Defaults to None.
108
+ """
109
+ if text:
110
+ self.text = Text.from_markup(text) if isinstance(text, str) else text
111
+ if style:
112
+ self.style = style
113
+ if speed:
114
+ self._update_speed = speed
115
+
116
+
117
+ if __name__ == "__main__": # pragma: no cover
118
+ from time import sleep
119
+
120
+ from .columns import Columns
121
+ from .panel import Panel
122
+ from .live import Live
123
+
124
+ all_spinners = Columns(
125
+ [
126
+ Spinner(spinner_name, text=Text(repr(spinner_name), style="green"))
127
+ for spinner_name in sorted(SPINNERS.keys())
128
+ ],
129
+ column_first=True,
130
+ expand=True,
131
+ )
132
+
133
+ with Live(
134
+ Panel(all_spinners, title="Spinners", border_style="blue"),
135
+ refresh_per_second=20,
136
+ ) as live:
137
+ while True:
138
+ sleep(0.1)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/status.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from types import TracebackType
2
+ from typing import Optional, Type
3
+
4
+ from .console import Console, RenderableType
5
+ from .jupyter import JupyterMixin
6
+ from .live import Live
7
+ from .spinner import Spinner
8
+ from .style import StyleType
9
+
10
+
11
+ class Status(JupyterMixin):
12
+ """Displays a status indicator with a 'spinner' animation.
13
+
14
+ Args:
15
+ status (RenderableType): A status renderable (str or Text typically).
16
+ console (Console, optional): Console instance to use, or None for global console. Defaults to None.
17
+ spinner (str, optional): Name of spinner animation (see python -m rich.spinner). Defaults to "dots".
18
+ spinner_style (StyleType, optional): Style of spinner. Defaults to "status.spinner".
19
+ speed (float, optional): Speed factor for spinner animation. Defaults to 1.0.
20
+ refresh_per_second (float, optional): Number of refreshes per second. Defaults to 12.5.
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ status: RenderableType,
26
+ *,
27
+ console: Optional[Console] = None,
28
+ spinner: str = "dots",
29
+ spinner_style: StyleType = "status.spinner",
30
+ speed: float = 1.0,
31
+ refresh_per_second: float = 12.5,
32
+ ):
33
+ self.status = status
34
+ self.spinner_style = spinner_style
35
+ self.speed = speed
36
+ self._spinner = Spinner(spinner, text=status, style=spinner_style, speed=speed)
37
+ self._live = Live(
38
+ self.renderable,
39
+ console=console,
40
+ refresh_per_second=refresh_per_second,
41
+ transient=True,
42
+ )
43
+
44
+ @property
45
+ def renderable(self) -> Spinner:
46
+ return self._spinner
47
+
48
+ @property
49
+ def console(self) -> "Console":
50
+ """Get the Console used by the Status objects."""
51
+ return self._live.console
52
+
53
+ def update(
54
+ self,
55
+ status: Optional[RenderableType] = None,
56
+ *,
57
+ spinner: Optional[str] = None,
58
+ spinner_style: Optional[StyleType] = None,
59
+ speed: Optional[float] = None,
60
+ ) -> None:
61
+ """Update status.
62
+
63
+ Args:
64
+ status (Optional[RenderableType], optional): New status renderable or None for no change. Defaults to None.
65
+ spinner (Optional[str], optional): New spinner or None for no change. Defaults to None.
66
+ spinner_style (Optional[StyleType], optional): New spinner style or None for no change. Defaults to None.
67
+ speed (Optional[float], optional): Speed factor for spinner animation or None for no change. Defaults to None.
68
+ """
69
+ if status is not None:
70
+ self.status = status
71
+ if spinner_style is not None:
72
+ self.spinner_style = spinner_style
73
+ if speed is not None:
74
+ self.speed = speed
75
+ if spinner is not None:
76
+ self._spinner = Spinner(
77
+ spinner, text=self.status, style=self.spinner_style, speed=self.speed
78
+ )
79
+ self._live.update(self.renderable, refresh=True)
80
+ else:
81
+ self._spinner.update(
82
+ text=self.status, style=self.spinner_style, speed=self.speed
83
+ )
84
+
85
+ def start(self) -> None:
86
+ """Start the status animation."""
87
+ self._live.start()
88
+
89
+ def stop(self) -> None:
90
+ """Stop the spinner animation."""
91
+ self._live.stop()
92
+
93
+ def __rich__(self) -> RenderableType:
94
+ return self.renderable
95
+
96
+ def __enter__(self) -> "Status":
97
+ self.start()
98
+ return self
99
+
100
+ def __exit__(
101
+ self,
102
+ exc_type: Optional[Type[BaseException]],
103
+ exc_val: Optional[BaseException],
104
+ exc_tb: Optional[TracebackType],
105
+ ) -> None:
106
+ self.stop()
107
+
108
+
109
+ if __name__ == "__main__": # pragma: no cover
110
+ from time import sleep
111
+
112
+ from .console import Console
113
+
114
+ console = Console()
115
+ with console.status("[magenta]Covid detector booting up") as status:
116
+ sleep(3)
117
+ console.log("Importing advanced AI")
118
+ sleep(3)
119
+ console.log("Advanced Covid AI Ready")
120
+ sleep(3)
121
+ status.update(status="[bold blue] Scanning for Covid", spinner="earth")
122
+ sleep(3)
123
+ console.log("Found 10,000,000,000 copies of Covid32.exe")
124
+ sleep(3)
125
+ status.update(
126
+ status="[bold red]Moving Covid32.exe to Trash",
127
+ spinner="bouncingBall",
128
+ spinner_style="yellow",
129
+ )
130
+ sleep(5)
131
+ console.print("[bold green]Covid deleted successfully")
.venv/lib/python3.13/site-packages/pip/_vendor/rich/style.py ADDED
@@ -0,0 +1,796 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from functools import lru_cache
3
+ from marshal import dumps, loads
4
+ from random import randint
5
+ from typing import Any, Dict, Iterable, List, Optional, Type, Union, cast
6
+
7
+ from . import errors
8
+ from .color import Color, ColorParseError, ColorSystem, blend_rgb
9
+ from .repr import Result, rich_repr
10
+ from .terminal_theme import DEFAULT_TERMINAL_THEME, TerminalTheme
11
+
12
+ # Style instances and style definitions are often interchangeable
13
+ StyleType = Union[str, "Style"]
14
+
15
+
16
+ class _Bit:
17
+ """A descriptor to get/set a style attribute bit."""
18
+
19
+ __slots__ = ["bit"]
20
+
21
+ def __init__(self, bit_no: int) -> None:
22
+ self.bit = 1 << bit_no
23
+
24
+ def __get__(self, obj: "Style", objtype: Type["Style"]) -> Optional[bool]:
25
+ if obj._set_attributes & self.bit:
26
+ return obj._attributes & self.bit != 0
27
+ return None
28
+
29
+
30
+ @rich_repr
31
+ class Style:
32
+ """A terminal style.
33
+
34
+ A terminal style consists of a color (`color`), a background color (`bgcolor`), and a number of attributes, such
35
+ as bold, italic etc. The attributes have 3 states: they can either be on
36
+ (``True``), off (``False``), or not set (``None``).
37
+
38
+ Args:
39
+ color (Union[Color, str], optional): Color of terminal text. Defaults to None.
40
+ bgcolor (Union[Color, str], optional): Color of terminal background. Defaults to None.
41
+ bold (bool, optional): Enable bold text. Defaults to None.
42
+ dim (bool, optional): Enable dim text. Defaults to None.
43
+ italic (bool, optional): Enable italic text. Defaults to None.
44
+ underline (bool, optional): Enable underlined text. Defaults to None.
45
+ blink (bool, optional): Enabled blinking text. Defaults to None.
46
+ blink2 (bool, optional): Enable fast blinking text. Defaults to None.
47
+ reverse (bool, optional): Enabled reverse text. Defaults to None.
48
+ conceal (bool, optional): Enable concealed text. Defaults to None.
49
+ strike (bool, optional): Enable strikethrough text. Defaults to None.
50
+ underline2 (bool, optional): Enable doubly underlined text. Defaults to None.
51
+ frame (bool, optional): Enable framed text. Defaults to None.
52
+ encircle (bool, optional): Enable encircled text. Defaults to None.
53
+ overline (bool, optional): Enable overlined text. Defaults to None.
54
+ link (str, link): Link URL. Defaults to None.
55
+
56
+ """
57
+
58
+ _color: Optional[Color]
59
+ _bgcolor: Optional[Color]
60
+ _attributes: int
61
+ _set_attributes: int
62
+ _hash: Optional[int]
63
+ _null: bool
64
+ _meta: Optional[bytes]
65
+
66
+ __slots__ = [
67
+ "_color",
68
+ "_bgcolor",
69
+ "_attributes",
70
+ "_set_attributes",
71
+ "_link",
72
+ "_link_id",
73
+ "_ansi",
74
+ "_style_definition",
75
+ "_hash",
76
+ "_null",
77
+ "_meta",
78
+ ]
79
+
80
+ # maps bits on to SGR parameter
81
+ _style_map = {
82
+ 0: "1",
83
+ 1: "2",
84
+ 2: "3",
85
+ 3: "4",
86
+ 4: "5",
87
+ 5: "6",
88
+ 6: "7",
89
+ 7: "8",
90
+ 8: "9",
91
+ 9: "21",
92
+ 10: "51",
93
+ 11: "52",
94
+ 12: "53",
95
+ }
96
+
97
+ STYLE_ATTRIBUTES = {
98
+ "dim": "dim",
99
+ "d": "dim",
100
+ "bold": "bold",
101
+ "b": "bold",
102
+ "italic": "italic",
103
+ "i": "italic",
104
+ "underline": "underline",
105
+ "u": "underline",
106
+ "blink": "blink",
107
+ "blink2": "blink2",
108
+ "reverse": "reverse",
109
+ "r": "reverse",
110
+ "conceal": "conceal",
111
+ "c": "conceal",
112
+ "strike": "strike",
113
+ "s": "strike",
114
+ "underline2": "underline2",
115
+ "uu": "underline2",
116
+ "frame": "frame",
117
+ "encircle": "encircle",
118
+ "overline": "overline",
119
+ "o": "overline",
120
+ }
121
+
122
+ def __init__(
123
+ self,
124
+ *,
125
+ color: Optional[Union[Color, str]] = None,
126
+ bgcolor: Optional[Union[Color, str]] = None,
127
+ bold: Optional[bool] = None,
128
+ dim: Optional[bool] = None,
129
+ italic: Optional[bool] = None,
130
+ underline: Optional[bool] = None,
131
+ blink: Optional[bool] = None,
132
+ blink2: Optional[bool] = None,
133
+ reverse: Optional[bool] = None,
134
+ conceal: Optional[bool] = None,
135
+ strike: Optional[bool] = None,
136
+ underline2: Optional[bool] = None,
137
+ frame: Optional[bool] = None,
138
+ encircle: Optional[bool] = None,
139
+ overline: Optional[bool] = None,
140
+ link: Optional[str] = None,
141
+ meta: Optional[Dict[str, Any]] = None,
142
+ ):
143
+ self._ansi: Optional[str] = None
144
+ self._style_definition: Optional[str] = None
145
+
146
+ def _make_color(color: Union[Color, str]) -> Color:
147
+ return color if isinstance(color, Color) else Color.parse(color)
148
+
149
+ self._color = None if color is None else _make_color(color)
150
+ self._bgcolor = None if bgcolor is None else _make_color(bgcolor)
151
+ self._set_attributes = sum(
152
+ (
153
+ bold is not None,
154
+ dim is not None and 2,
155
+ italic is not None and 4,
156
+ underline is not None and 8,
157
+ blink is not None and 16,
158
+ blink2 is not None and 32,
159
+ reverse is not None and 64,
160
+ conceal is not None and 128,
161
+ strike is not None and 256,
162
+ underline2 is not None and 512,
163
+ frame is not None and 1024,
164
+ encircle is not None and 2048,
165
+ overline is not None and 4096,
166
+ )
167
+ )
168
+ self._attributes = (
169
+ sum(
170
+ (
171
+ bold and 1 or 0,
172
+ dim and 2 or 0,
173
+ italic and 4 or 0,
174
+ underline and 8 or 0,
175
+ blink and 16 or 0,
176
+ blink2 and 32 or 0,
177
+ reverse and 64 or 0,
178
+ conceal and 128 or 0,
179
+ strike and 256 or 0,
180
+ underline2 and 512 or 0,
181
+ frame and 1024 or 0,
182
+ encircle and 2048 or 0,
183
+ overline and 4096 or 0,
184
+ )
185
+ )
186
+ if self._set_attributes
187
+ else 0
188
+ )
189
+
190
+ self._link = link
191
+ self._meta = None if meta is None else dumps(meta)
192
+ self._link_id = (
193
+ f"{randint(0, 999999)}{hash(self._meta)}" if (link or meta) else ""
194
+ )
195
+ self._hash: Optional[int] = None
196
+ self._null = not (self._set_attributes or color or bgcolor or link or meta)
197
+
198
+ @classmethod
199
+ def null(cls) -> "Style":
200
+ """Create an 'null' style, equivalent to Style(), but more performant."""
201
+ return NULL_STYLE
202
+
203
+ @classmethod
204
+ def from_color(
205
+ cls, color: Optional[Color] = None, bgcolor: Optional[Color] = None
206
+ ) -> "Style":
207
+ """Create a new style with colors and no attributes.
208
+
209
+ Returns:
210
+ color (Optional[Color]): A (foreground) color, or None for no color. Defaults to None.
211
+ bgcolor (Optional[Color]): A (background) color, or None for no color. Defaults to None.
212
+ """
213
+ style: Style = cls.__new__(Style)
214
+ style._ansi = None
215
+ style._style_definition = None
216
+ style._color = color
217
+ style._bgcolor = bgcolor
218
+ style._set_attributes = 0
219
+ style._attributes = 0
220
+ style._link = None
221
+ style._link_id = ""
222
+ style._meta = None
223
+ style._null = not (color or bgcolor)
224
+ style._hash = None
225
+ return style
226
+
227
+ @classmethod
228
+ def from_meta(cls, meta: Optional[Dict[str, Any]]) -> "Style":
229
+ """Create a new style with meta data.
230
+
231
+ Returns:
232
+ meta (Optional[Dict[str, Any]]): A dictionary of meta data. Defaults to None.
233
+ """
234
+ style: Style = cls.__new__(Style)
235
+ style._ansi = None
236
+ style._style_definition = None
237
+ style._color = None
238
+ style._bgcolor = None
239
+ style._set_attributes = 0
240
+ style._attributes = 0
241
+ style._link = None
242
+ style._meta = dumps(meta)
243
+ style._link_id = f"{randint(0, 999999)}{hash(style._meta)}"
244
+ style._hash = None
245
+ style._null = not (meta)
246
+ return style
247
+
248
+ @classmethod
249
+ def on(cls, meta: Optional[Dict[str, Any]] = None, **handlers: Any) -> "Style":
250
+ """Create a blank style with meta information.
251
+
252
+ Example:
253
+ style = Style.on(click=self.on_click)
254
+
255
+ Args:
256
+ meta (Optional[Dict[str, Any]], optional): An optional dict of meta information.
257
+ **handlers (Any): Keyword arguments are translated in to handlers.
258
+
259
+ Returns:
260
+ Style: A Style with meta information attached.
261
+ """
262
+ meta = {} if meta is None else meta
263
+ meta.update({f"@{key}": value for key, value in handlers.items()})
264
+ return cls.from_meta(meta)
265
+
266
+ bold = _Bit(0)
267
+ dim = _Bit(1)
268
+ italic = _Bit(2)
269
+ underline = _Bit(3)
270
+ blink = _Bit(4)
271
+ blink2 = _Bit(5)
272
+ reverse = _Bit(6)
273
+ conceal = _Bit(7)
274
+ strike = _Bit(8)
275
+ underline2 = _Bit(9)
276
+ frame = _Bit(10)
277
+ encircle = _Bit(11)
278
+ overline = _Bit(12)
279
+
280
+ @property
281
+ def link_id(self) -> str:
282
+ """Get a link id, used in ansi code for links."""
283
+ return self._link_id
284
+
285
+ def __str__(self) -> str:
286
+ """Re-generate style definition from attributes."""
287
+ if self._style_definition is None:
288
+ attributes: List[str] = []
289
+ append = attributes.append
290
+ bits = self._set_attributes
291
+ if bits & 0b0000000001111:
292
+ if bits & 1:
293
+ append("bold" if self.bold else "not bold")
294
+ if bits & (1 << 1):
295
+ append("dim" if self.dim else "not dim")
296
+ if bits & (1 << 2):
297
+ append("italic" if self.italic else "not italic")
298
+ if bits & (1 << 3):
299
+ append("underline" if self.underline else "not underline")
300
+ if bits & 0b0000111110000:
301
+ if bits & (1 << 4):
302
+ append("blink" if self.blink else "not blink")
303
+ if bits & (1 << 5):
304
+ append("blink2" if self.blink2 else "not blink2")
305
+ if bits & (1 << 6):
306
+ append("reverse" if self.reverse else "not reverse")
307
+ if bits & (1 << 7):
308
+ append("conceal" if self.conceal else "not conceal")
309
+ if bits & (1 << 8):
310
+ append("strike" if self.strike else "not strike")
311
+ if bits & 0b1111000000000:
312
+ if bits & (1 << 9):
313
+ append("underline2" if self.underline2 else "not underline2")
314
+ if bits & (1 << 10):
315
+ append("frame" if self.frame else "not frame")
316
+ if bits & (1 << 11):
317
+ append("encircle" if self.encircle else "not encircle")
318
+ if bits & (1 << 12):
319
+ append("overline" if self.overline else "not overline")
320
+ if self._color is not None:
321
+ append(self._color.name)
322
+ if self._bgcolor is not None:
323
+ append("on")
324
+ append(self._bgcolor.name)
325
+ if self._link:
326
+ append("link")
327
+ append(self._link)
328
+ self._style_definition = " ".join(attributes) or "none"
329
+ return self._style_definition
330
+
331
+ def __bool__(self) -> bool:
332
+ """A Style is false if it has no attributes, colors, or links."""
333
+ return not self._null
334
+
335
+ def _make_ansi_codes(self, color_system: ColorSystem) -> str:
336
+ """Generate ANSI codes for this style.
337
+
338
+ Args:
339
+ color_system (ColorSystem): Color system.
340
+
341
+ Returns:
342
+ str: String containing codes.
343
+ """
344
+
345
+ if self._ansi is None:
346
+ sgr: List[str] = []
347
+ append = sgr.append
348
+ _style_map = self._style_map
349
+ attributes = self._attributes & self._set_attributes
350
+ if attributes:
351
+ if attributes & 1:
352
+ append(_style_map[0])
353
+ if attributes & 2:
354
+ append(_style_map[1])
355
+ if attributes & 4:
356
+ append(_style_map[2])
357
+ if attributes & 8:
358
+ append(_style_map[3])
359
+ if attributes & 0b0000111110000:
360
+ for bit in range(4, 9):
361
+ if attributes & (1 << bit):
362
+ append(_style_map[bit])
363
+ if attributes & 0b1111000000000:
364
+ for bit in range(9, 13):
365
+ if attributes & (1 << bit):
366
+ append(_style_map[bit])
367
+ if self._color is not None:
368
+ sgr.extend(self._color.downgrade(color_system).get_ansi_codes())
369
+ if self._bgcolor is not None:
370
+ sgr.extend(
371
+ self._bgcolor.downgrade(color_system).get_ansi_codes(
372
+ foreground=False
373
+ )
374
+ )
375
+ self._ansi = ";".join(sgr)
376
+ return self._ansi
377
+
378
+ @classmethod
379
+ @lru_cache(maxsize=1024)
380
+ def normalize(cls, style: str) -> str:
381
+ """Normalize a style definition so that styles with the same effect have the same string
382
+ representation.
383
+
384
+ Args:
385
+ style (str): A style definition.
386
+
387
+ Returns:
388
+ str: Normal form of style definition.
389
+ """
390
+ try:
391
+ return str(cls.parse(style))
392
+ except errors.StyleSyntaxError:
393
+ return style.strip().lower()
394
+
395
+ @classmethod
396
+ def pick_first(cls, *values: Optional[StyleType]) -> StyleType:
397
+ """Pick first non-None style."""
398
+ for value in values:
399
+ if value is not None:
400
+ return value
401
+ raise ValueError("expected at least one non-None style")
402
+
403
+ def __rich_repr__(self) -> Result:
404
+ yield "color", self.color, None
405
+ yield "bgcolor", self.bgcolor, None
406
+ yield "bold", self.bold, None,
407
+ yield "dim", self.dim, None,
408
+ yield "italic", self.italic, None
409
+ yield "underline", self.underline, None,
410
+ yield "blink", self.blink, None
411
+ yield "blink2", self.blink2, None
412
+ yield "reverse", self.reverse, None
413
+ yield "conceal", self.conceal, None
414
+ yield "strike", self.strike, None
415
+ yield "underline2", self.underline2, None
416
+ yield "frame", self.frame, None
417
+ yield "encircle", self.encircle, None
418
+ yield "link", self.link, None
419
+ if self._meta:
420
+ yield "meta", self.meta
421
+
422
+ def __eq__(self, other: Any) -> bool:
423
+ if not isinstance(other, Style):
424
+ return NotImplemented
425
+ return self.__hash__() == other.__hash__()
426
+
427
+ def __ne__(self, other: Any) -> bool:
428
+ if not isinstance(other, Style):
429
+ return NotImplemented
430
+ return self.__hash__() != other.__hash__()
431
+
432
+ def __hash__(self) -> int:
433
+ if self._hash is not None:
434
+ return self._hash
435
+ self._hash = hash(
436
+ (
437
+ self._color,
438
+ self._bgcolor,
439
+ self._attributes,
440
+ self._set_attributes,
441
+ self._link,
442
+ self._meta,
443
+ )
444
+ )
445
+ return self._hash
446
+
447
+ @property
448
+ def color(self) -> Optional[Color]:
449
+ """The foreground color or None if it is not set."""
450
+ return self._color
451
+
452
+ @property
453
+ def bgcolor(self) -> Optional[Color]:
454
+ """The background color or None if it is not set."""
455
+ return self._bgcolor
456
+
457
+ @property
458
+ def link(self) -> Optional[str]:
459
+ """Link text, if set."""
460
+ return self._link
461
+
462
+ @property
463
+ def transparent_background(self) -> bool:
464
+ """Check if the style specified a transparent background."""
465
+ return self.bgcolor is None or self.bgcolor.is_default
466
+
467
+ @property
468
+ def background_style(self) -> "Style":
469
+ """A Style with background only."""
470
+ return Style(bgcolor=self.bgcolor)
471
+
472
+ @property
473
+ def meta(self) -> Dict[str, Any]:
474
+ """Get meta information (can not be changed after construction)."""
475
+ return {} if self._meta is None else cast(Dict[str, Any], loads(self._meta))
476
+
477
+ @property
478
+ def without_color(self) -> "Style":
479
+ """Get a copy of the style with color removed."""
480
+ if self._null:
481
+ return NULL_STYLE
482
+ style: Style = self.__new__(Style)
483
+ style._ansi = None
484
+ style._style_definition = None
485
+ style._color = None
486
+ style._bgcolor = None
487
+ style._attributes = self._attributes
488
+ style._set_attributes = self._set_attributes
489
+ style._link = self._link
490
+ style._link_id = f"{randint(0, 999999)}" if self._link else ""
491
+ style._null = False
492
+ style._meta = None
493
+ style._hash = None
494
+ return style
495
+
496
+ @classmethod
497
+ @lru_cache(maxsize=4096)
498
+ def parse(cls, style_definition: str) -> "Style":
499
+ """Parse a style definition.
500
+
501
+ Args:
502
+ style_definition (str): A string containing a style.
503
+
504
+ Raises:
505
+ errors.StyleSyntaxError: If the style definition syntax is invalid.
506
+
507
+ Returns:
508
+ `Style`: A Style instance.
509
+ """
510
+ if style_definition.strip() == "none" or not style_definition:
511
+ return cls.null()
512
+
513
+ STYLE_ATTRIBUTES = cls.STYLE_ATTRIBUTES
514
+ color: Optional[str] = None
515
+ bgcolor: Optional[str] = None
516
+ attributes: Dict[str, Optional[Any]] = {}
517
+ link: Optional[str] = None
518
+
519
+ words = iter(style_definition.split())
520
+ for original_word in words:
521
+ word = original_word.lower()
522
+ if word == "on":
523
+ word = next(words, "")
524
+ if not word:
525
+ raise errors.StyleSyntaxError("color expected after 'on'")
526
+ try:
527
+ Color.parse(word)
528
+ except ColorParseError as error:
529
+ raise errors.StyleSyntaxError(
530
+ f"unable to parse {word!r} as background color; {error}"
531
+ ) from None
532
+ bgcolor = word
533
+
534
+ elif word == "not":
535
+ word = next(words, "")
536
+ attribute = STYLE_ATTRIBUTES.get(word)
537
+ if attribute is None:
538
+ raise errors.StyleSyntaxError(
539
+ f"expected style attribute after 'not', found {word!r}"
540
+ )
541
+ attributes[attribute] = False
542
+
543
+ elif word == "link":
544
+ word = next(words, "")
545
+ if not word:
546
+ raise errors.StyleSyntaxError("URL expected after 'link'")
547
+ link = word
548
+
549
+ elif word in STYLE_ATTRIBUTES:
550
+ attributes[STYLE_ATTRIBUTES[word]] = True
551
+
552
+ else:
553
+ try:
554
+ Color.parse(word)
555
+ except ColorParseError as error:
556
+ raise errors.StyleSyntaxError(
557
+ f"unable to parse {word!r} as color; {error}"
558
+ ) from None
559
+ color = word
560
+ style = Style(color=color, bgcolor=bgcolor, link=link, **attributes)
561
+ return style
562
+
563
+ @lru_cache(maxsize=1024)
564
+ def get_html_style(self, theme: Optional[TerminalTheme] = None) -> str:
565
+ """Get a CSS style rule."""
566
+ theme = theme or DEFAULT_TERMINAL_THEME
567
+ css: List[str] = []
568
+ append = css.append
569
+
570
+ color = self.color
571
+ bgcolor = self.bgcolor
572
+ if self.reverse:
573
+ color, bgcolor = bgcolor, color
574
+ if self.dim:
575
+ foreground_color = (
576
+ theme.foreground_color if color is None else color.get_truecolor(theme)
577
+ )
578
+ color = Color.from_triplet(
579
+ blend_rgb(foreground_color, theme.background_color, 0.5)
580
+ )
581
+ if color is not None:
582
+ theme_color = color.get_truecolor(theme)
583
+ append(f"color: {theme_color.hex}")
584
+ append(f"text-decoration-color: {theme_color.hex}")
585
+ if bgcolor is not None:
586
+ theme_color = bgcolor.get_truecolor(theme, foreground=False)
587
+ append(f"background-color: {theme_color.hex}")
588
+ if self.bold:
589
+ append("font-weight: bold")
590
+ if self.italic:
591
+ append("font-style: italic")
592
+ if self.underline:
593
+ append("text-decoration: underline")
594
+ if self.strike:
595
+ append("text-decoration: line-through")
596
+ if self.overline:
597
+ append("text-decoration: overline")
598
+ return "; ".join(css)
599
+
600
+ @classmethod
601
+ def combine(cls, styles: Iterable["Style"]) -> "Style":
602
+ """Combine styles and get result.
603
+
604
+ Args:
605
+ styles (Iterable[Style]): Styles to combine.
606
+
607
+ Returns:
608
+ Style: A new style instance.
609
+ """
610
+ iter_styles = iter(styles)
611
+ return sum(iter_styles, next(iter_styles))
612
+
613
+ @classmethod
614
+ def chain(cls, *styles: "Style") -> "Style":
615
+ """Combine styles from positional argument in to a single style.
616
+
617
+ Args:
618
+ *styles (Iterable[Style]): Styles to combine.
619
+
620
+ Returns:
621
+ Style: A new style instance.
622
+ """
623
+ iter_styles = iter(styles)
624
+ return sum(iter_styles, next(iter_styles))
625
+
626
+ def copy(self) -> "Style":
627
+ """Get a copy of this style.
628
+
629
+ Returns:
630
+ Style: A new Style instance with identical attributes.
631
+ """
632
+ if self._null:
633
+ return NULL_STYLE
634
+ style: Style = self.__new__(Style)
635
+ style._ansi = self._ansi
636
+ style._style_definition = self._style_definition
637
+ style._color = self._color
638
+ style._bgcolor = self._bgcolor
639
+ style._attributes = self._attributes
640
+ style._set_attributes = self._set_attributes
641
+ style._link = self._link
642
+ style._link_id = f"{randint(0, 999999)}" if self._link else ""
643
+ style._hash = self._hash
644
+ style._null = False
645
+ style._meta = self._meta
646
+ return style
647
+
648
+ @lru_cache(maxsize=128)
649
+ def clear_meta_and_links(self) -> "Style":
650
+ """Get a copy of this style with link and meta information removed.
651
+
652
+ Returns:
653
+ Style: New style object.
654
+ """
655
+ if self._null:
656
+ return NULL_STYLE
657
+ style: Style = self.__new__(Style)
658
+ style._ansi = self._ansi
659
+ style._style_definition = self._style_definition
660
+ style._color = self._color
661
+ style._bgcolor = self._bgcolor
662
+ style._attributes = self._attributes
663
+ style._set_attributes = self._set_attributes
664
+ style._link = None
665
+ style._link_id = ""
666
+ style._hash = None
667
+ style._null = False
668
+ style._meta = None
669
+ return style
670
+
671
+ def update_link(self, link: Optional[str] = None) -> "Style":
672
+ """Get a copy with a different value for link.
673
+
674
+ Args:
675
+ link (str, optional): New value for link. Defaults to None.
676
+
677
+ Returns:
678
+ Style: A new Style instance.
679
+ """
680
+ style: Style = self.__new__(Style)
681
+ style._ansi = self._ansi
682
+ style._style_definition = self._style_definition
683
+ style._color = self._color
684
+ style._bgcolor = self._bgcolor
685
+ style._attributes = self._attributes
686
+ style._set_attributes = self._set_attributes
687
+ style._link = link
688
+ style._link_id = f"{randint(0, 999999)}" if link else ""
689
+ style._hash = None
690
+ style._null = False
691
+ style._meta = self._meta
692
+ return style
693
+
694
+ def render(
695
+ self,
696
+ text: str = "",
697
+ *,
698
+ color_system: Optional[ColorSystem] = ColorSystem.TRUECOLOR,
699
+ legacy_windows: bool = False,
700
+ ) -> str:
701
+ """Render the ANSI codes for the style.
702
+
703
+ Args:
704
+ text (str, optional): A string to style. Defaults to "".
705
+ color_system (Optional[ColorSystem], optional): Color system to render to. Defaults to ColorSystem.TRUECOLOR.
706
+
707
+ Returns:
708
+ str: A string containing ANSI style codes.
709
+ """
710
+ if not text or color_system is None:
711
+ return text
712
+ attrs = self._ansi or self._make_ansi_codes(color_system)
713
+ rendered = f"\x1b[{attrs}m{text}\x1b[0m" if attrs else text
714
+ if self._link and not legacy_windows:
715
+ rendered = (
716
+ f"\x1b]8;id={self._link_id};{self._link}\x1b\\{rendered}\x1b]8;;\x1b\\"
717
+ )
718
+ return rendered
719
+
720
+ def test(self, text: Optional[str] = None) -> None:
721
+ """Write text with style directly to terminal.
722
+
723
+ This method is for testing purposes only.
724
+
725
+ Args:
726
+ text (Optional[str], optional): Text to style or None for style name.
727
+
728
+ """
729
+ text = text or str(self)
730
+ sys.stdout.write(f"{self.render(text)}\n")
731
+
732
+ @lru_cache(maxsize=1024)
733
+ def _add(self, style: Optional["Style"]) -> "Style":
734
+ if style is None or style._null:
735
+ return self
736
+ if self._null:
737
+ return style
738
+ new_style: Style = self.__new__(Style)
739
+ new_style._ansi = None
740
+ new_style._style_definition = None
741
+ new_style._color = style._color or self._color
742
+ new_style._bgcolor = style._bgcolor or self._bgcolor
743
+ new_style._attributes = (self._attributes & ~style._set_attributes) | (
744
+ style._attributes & style._set_attributes
745
+ )
746
+ new_style._set_attributes = self._set_attributes | style._set_attributes
747
+ new_style._link = style._link or self._link
748
+ new_style._link_id = style._link_id or self._link_id
749
+ new_style._null = style._null
750
+ if self._meta and style._meta:
751
+ new_style._meta = dumps({**self.meta, **style.meta})
752
+ else:
753
+ new_style._meta = self._meta or style._meta
754
+ new_style._hash = None
755
+ return new_style
756
+
757
+ def __add__(self, style: Optional["Style"]) -> "Style":
758
+ combined_style = self._add(style)
759
+ return combined_style.copy() if combined_style.link else combined_style
760
+
761
+
762
+ NULL_STYLE = Style()
763
+
764
+
765
+ class StyleStack:
766
+ """A stack of styles."""
767
+
768
+ __slots__ = ["_stack"]
769
+
770
+ def __init__(self, default_style: "Style") -> None:
771
+ self._stack: List[Style] = [default_style]
772
+
773
+ def __repr__(self) -> str:
774
+ return f"<stylestack {self._stack!r}>"
775
+
776
+ @property
777
+ def current(self) -> Style:
778
+ """Get the Style at the top of the stack."""
779
+ return self._stack[-1]
780
+
781
+ def push(self, style: Style) -> None:
782
+ """Push a new style on to the stack.
783
+
784
+ Args:
785
+ style (Style): New style to combine with current style.
786
+ """
787
+ self._stack.append(self._stack[-1] + style)
788
+
789
+ def pop(self) -> Style:
790
+ """Pop last style and discard.
791
+
792
+ Returns:
793
+ Style: New current style (also available as stack.current)
794
+ """
795
+ self._stack.pop()
796
+ return self._stack[-1]
.venv/lib/python3.13/site-packages/pip/_vendor/rich/styled.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TYPE_CHECKING
2
+
3
+ from .measure import Measurement
4
+ from .segment import Segment
5
+ from .style import StyleType
6
+
7
+ if TYPE_CHECKING:
8
+ from .console import Console, ConsoleOptions, RenderResult, RenderableType
9
+
10
+
11
+ class Styled:
12
+ """Apply a style to a renderable.
13
+
14
+ Args:
15
+ renderable (RenderableType): Any renderable.
16
+ style (StyleType): A style to apply across the entire renderable.
17
+ """
18
+
19
+ def __init__(self, renderable: "RenderableType", style: "StyleType") -> None:
20
+ self.renderable = renderable
21
+ self.style = style
22
+
23
+ def __rich_console__(
24
+ self, console: "Console", options: "ConsoleOptions"
25
+ ) -> "RenderResult":
26
+ style = console.get_style(self.style)
27
+ rendered_segments = console.render(self.renderable, options)
28
+ segments = Segment.apply_style(rendered_segments, style)
29
+ return segments
30
+
31
+ def __rich_measure__(
32
+ self, console: "Console", options: "ConsoleOptions"
33
+ ) -> Measurement:
34
+ return Measurement.get(console, options, self.renderable)
35
+
36
+
37
+ if __name__ == "__main__": # pragma: no cover
38
+ from pip._vendor.rich import print
39
+ from pip._vendor.rich.panel import Panel
40
+
41
+ panel = Styled(Panel("hello"), "on blue")
42
+ print(panel)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/syntax.py ADDED
@@ -0,0 +1,966 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os.path
2
+ import re
3
+ import sys
4
+ import textwrap
5
+ from abc import ABC, abstractmethod
6
+ from pathlib import Path
7
+ from typing import (
8
+ Any,
9
+ Dict,
10
+ Iterable,
11
+ List,
12
+ NamedTuple,
13
+ Optional,
14
+ Sequence,
15
+ Set,
16
+ Tuple,
17
+ Type,
18
+ Union,
19
+ )
20
+
21
+ from pip._vendor.pygments.lexer import Lexer
22
+ from pip._vendor.pygments.lexers import get_lexer_by_name, guess_lexer_for_filename
23
+ from pip._vendor.pygments.style import Style as PygmentsStyle
24
+ from pip._vendor.pygments.styles import get_style_by_name
25
+ from pip._vendor.pygments.token import (
26
+ Comment,
27
+ Error,
28
+ Generic,
29
+ Keyword,
30
+ Name,
31
+ Number,
32
+ Operator,
33
+ String,
34
+ Token,
35
+ Whitespace,
36
+ )
37
+ from pip._vendor.pygments.util import ClassNotFound
38
+
39
+ from pip._vendor.rich.containers import Lines
40
+ from pip._vendor.rich.padding import Padding, PaddingDimensions
41
+
42
+ from ._loop import loop_first
43
+ from .cells import cell_len
44
+ from .color import Color, blend_rgb
45
+ from .console import Console, ConsoleOptions, JustifyMethod, RenderResult
46
+ from .jupyter import JupyterMixin
47
+ from .measure import Measurement
48
+ from .segment import Segment, Segments
49
+ from .style import Style, StyleType
50
+ from .text import Text
51
+
52
+ TokenType = Tuple[str, ...]
53
+
54
+ WINDOWS = sys.platform == "win32"
55
+ DEFAULT_THEME = "monokai"
56
+
57
+ # The following styles are based on https://github.com/pygments/pygments/blob/master/pygments/formatters/terminal.py
58
+ # A few modifications were made
59
+
60
+ ANSI_LIGHT: Dict[TokenType, Style] = {
61
+ Token: Style(),
62
+ Whitespace: Style(color="white"),
63
+ Comment: Style(dim=True),
64
+ Comment.Preproc: Style(color="cyan"),
65
+ Keyword: Style(color="blue"),
66
+ Keyword.Type: Style(color="cyan"),
67
+ Operator.Word: Style(color="magenta"),
68
+ Name.Builtin: Style(color="cyan"),
69
+ Name.Function: Style(color="green"),
70
+ Name.Namespace: Style(color="cyan", underline=True),
71
+ Name.Class: Style(color="green", underline=True),
72
+ Name.Exception: Style(color="cyan"),
73
+ Name.Decorator: Style(color="magenta", bold=True),
74
+ Name.Variable: Style(color="red"),
75
+ Name.Constant: Style(color="red"),
76
+ Name.Attribute: Style(color="cyan"),
77
+ Name.Tag: Style(color="bright_blue"),
78
+ String: Style(color="yellow"),
79
+ Number: Style(color="blue"),
80
+ Generic.Deleted: Style(color="bright_red"),
81
+ Generic.Inserted: Style(color="green"),
82
+ Generic.Heading: Style(bold=True),
83
+ Generic.Subheading: Style(color="magenta", bold=True),
84
+ Generic.Prompt: Style(bold=True),
85
+ Generic.Error: Style(color="bright_red"),
86
+ Error: Style(color="red", underline=True),
87
+ }
88
+
89
+ ANSI_DARK: Dict[TokenType, Style] = {
90
+ Token: Style(),
91
+ Whitespace: Style(color="bright_black"),
92
+ Comment: Style(dim=True),
93
+ Comment.Preproc: Style(color="bright_cyan"),
94
+ Keyword: Style(color="bright_blue"),
95
+ Keyword.Type: Style(color="bright_cyan"),
96
+ Operator.Word: Style(color="bright_magenta"),
97
+ Name.Builtin: Style(color="bright_cyan"),
98
+ Name.Function: Style(color="bright_green"),
99
+ Name.Namespace: Style(color="bright_cyan", underline=True),
100
+ Name.Class: Style(color="bright_green", underline=True),
101
+ Name.Exception: Style(color="bright_cyan"),
102
+ Name.Decorator: Style(color="bright_magenta", bold=True),
103
+ Name.Variable: Style(color="bright_red"),
104
+ Name.Constant: Style(color="bright_red"),
105
+ Name.Attribute: Style(color="bright_cyan"),
106
+ Name.Tag: Style(color="bright_blue"),
107
+ String: Style(color="yellow"),
108
+ Number: Style(color="bright_blue"),
109
+ Generic.Deleted: Style(color="bright_red"),
110
+ Generic.Inserted: Style(color="bright_green"),
111
+ Generic.Heading: Style(bold=True),
112
+ Generic.Subheading: Style(color="bright_magenta", bold=True),
113
+ Generic.Prompt: Style(bold=True),
114
+ Generic.Error: Style(color="bright_red"),
115
+ Error: Style(color="red", underline=True),
116
+ }
117
+
118
+ RICH_SYNTAX_THEMES = {"ansi_light": ANSI_LIGHT, "ansi_dark": ANSI_DARK}
119
+ NUMBERS_COLUMN_DEFAULT_PADDING = 2
120
+
121
+
122
+ class SyntaxTheme(ABC):
123
+ """Base class for a syntax theme."""
124
+
125
+ @abstractmethod
126
+ def get_style_for_token(self, token_type: TokenType) -> Style:
127
+ """Get a style for a given Pygments token."""
128
+ raise NotImplementedError # pragma: no cover
129
+
130
+ @abstractmethod
131
+ def get_background_style(self) -> Style:
132
+ """Get the background color."""
133
+ raise NotImplementedError # pragma: no cover
134
+
135
+
136
+ class PygmentsSyntaxTheme(SyntaxTheme):
137
+ """Syntax theme that delegates to Pygments theme."""
138
+
139
+ def __init__(self, theme: Union[str, Type[PygmentsStyle]]) -> None:
140
+ self._style_cache: Dict[TokenType, Style] = {}
141
+ if isinstance(theme, str):
142
+ try:
143
+ self._pygments_style_class = get_style_by_name(theme)
144
+ except ClassNotFound:
145
+ self._pygments_style_class = get_style_by_name("default")
146
+ else:
147
+ self._pygments_style_class = theme
148
+
149
+ self._background_color = self._pygments_style_class.background_color
150
+ self._background_style = Style(bgcolor=self._background_color)
151
+
152
+ def get_style_for_token(self, token_type: TokenType) -> Style:
153
+ """Get a style from a Pygments class."""
154
+ try:
155
+ return self._style_cache[token_type]
156
+ except KeyError:
157
+ try:
158
+ pygments_style = self._pygments_style_class.style_for_token(token_type)
159
+ except KeyError:
160
+ style = Style.null()
161
+ else:
162
+ color = pygments_style["color"]
163
+ bgcolor = pygments_style["bgcolor"]
164
+ style = Style(
165
+ color="#" + color if color else "#000000",
166
+ bgcolor="#" + bgcolor if bgcolor else self._background_color,
167
+ bold=pygments_style["bold"],
168
+ italic=pygments_style["italic"],
169
+ underline=pygments_style["underline"],
170
+ )
171
+ self._style_cache[token_type] = style
172
+ return style
173
+
174
+ def get_background_style(self) -> Style:
175
+ return self._background_style
176
+
177
+
178
+ class ANSISyntaxTheme(SyntaxTheme):
179
+ """Syntax theme to use standard colors."""
180
+
181
+ def __init__(self, style_map: Dict[TokenType, Style]) -> None:
182
+ self.style_map = style_map
183
+ self._missing_style = Style.null()
184
+ self._background_style = Style.null()
185
+ self._style_cache: Dict[TokenType, Style] = {}
186
+
187
+ def get_style_for_token(self, token_type: TokenType) -> Style:
188
+ """Look up style in the style map."""
189
+ try:
190
+ return self._style_cache[token_type]
191
+ except KeyError:
192
+ # Styles form a hierarchy
193
+ # We need to go from most to least specific
194
+ # e.g. ("foo", "bar", "baz") to ("foo", "bar") to ("foo",)
195
+ get_style = self.style_map.get
196
+ token = tuple(token_type)
197
+ style = self._missing_style
198
+ while token:
199
+ _style = get_style(token)
200
+ if _style is not None:
201
+ style = _style
202
+ break
203
+ token = token[:-1]
204
+ self._style_cache[token_type] = style
205
+ return style
206
+
207
+ def get_background_style(self) -> Style:
208
+ return self._background_style
209
+
210
+
211
+ SyntaxPosition = Tuple[int, int]
212
+
213
+
214
+ class _SyntaxHighlightRange(NamedTuple):
215
+ """
216
+ A range to highlight in a Syntax object.
217
+ `start` and `end` are 2-integers tuples, where the first integer is the line number
218
+ (starting from 1) and the second integer is the column index (starting from 0).
219
+ """
220
+
221
+ style: StyleType
222
+ start: SyntaxPosition
223
+ end: SyntaxPosition
224
+ style_before: bool = False
225
+
226
+
227
+ class Syntax(JupyterMixin):
228
+ """Construct a Syntax object to render syntax highlighted code.
229
+
230
+ Args:
231
+ code (str): Code to highlight.
232
+ lexer (Lexer | str): Lexer to use (see https://pygments.org/docs/lexers/)
233
+ theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "monokai".
234
+ dedent (bool, optional): Enable stripping of initial whitespace. Defaults to False.
235
+ line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
236
+ start_line (int, optional): Starting number for line numbers. Defaults to 1.
237
+ line_range (Tuple[int | None, int | None], optional): If given should be a tuple of the start and end line to render.
238
+ A value of None in the tuple indicates the range is open in that direction.
239
+ highlight_lines (Set[int]): A set of line numbers to highlight.
240
+ code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
241
+ tab_size (int, optional): Size of tabs. Defaults to 4.
242
+ word_wrap (bool, optional): Enable word wrapping.
243
+ background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
244
+ indent_guides (bool, optional): Show indent guides. Defaults to False.
245
+ padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).
246
+ """
247
+
248
+ _pygments_style_class: Type[PygmentsStyle]
249
+ _theme: SyntaxTheme
250
+
251
+ @classmethod
252
+ def get_theme(cls, name: Union[str, SyntaxTheme]) -> SyntaxTheme:
253
+ """Get a syntax theme instance."""
254
+ if isinstance(name, SyntaxTheme):
255
+ return name
256
+ theme: SyntaxTheme
257
+ if name in RICH_SYNTAX_THEMES:
258
+ theme = ANSISyntaxTheme(RICH_SYNTAX_THEMES[name])
259
+ else:
260
+ theme = PygmentsSyntaxTheme(name)
261
+ return theme
262
+
263
+ def __init__(
264
+ self,
265
+ code: str,
266
+ lexer: Union[Lexer, str],
267
+ *,
268
+ theme: Union[str, SyntaxTheme] = DEFAULT_THEME,
269
+ dedent: bool = False,
270
+ line_numbers: bool = False,
271
+ start_line: int = 1,
272
+ line_range: Optional[Tuple[Optional[int], Optional[int]]] = None,
273
+ highlight_lines: Optional[Set[int]] = None,
274
+ code_width: Optional[int] = None,
275
+ tab_size: int = 4,
276
+ word_wrap: bool = False,
277
+ background_color: Optional[str] = None,
278
+ indent_guides: bool = False,
279
+ padding: PaddingDimensions = 0,
280
+ ) -> None:
281
+ self.code = code
282
+ self._lexer = lexer
283
+ self.dedent = dedent
284
+ self.line_numbers = line_numbers
285
+ self.start_line = start_line
286
+ self.line_range = line_range
287
+ self.highlight_lines = highlight_lines or set()
288
+ self.code_width = code_width
289
+ self.tab_size = tab_size
290
+ self.word_wrap = word_wrap
291
+ self.background_color = background_color
292
+ self.background_style = (
293
+ Style(bgcolor=background_color) if background_color else Style()
294
+ )
295
+ self.indent_guides = indent_guides
296
+ self.padding = padding
297
+
298
+ self._theme = self.get_theme(theme)
299
+ self._stylized_ranges: List[_SyntaxHighlightRange] = []
300
+
301
+ @classmethod
302
+ def from_path(
303
+ cls,
304
+ path: str,
305
+ encoding: str = "utf-8",
306
+ lexer: Optional[Union[Lexer, str]] = None,
307
+ theme: Union[str, SyntaxTheme] = DEFAULT_THEME,
308
+ dedent: bool = False,
309
+ line_numbers: bool = False,
310
+ line_range: Optional[Tuple[int, int]] = None,
311
+ start_line: int = 1,
312
+ highlight_lines: Optional[Set[int]] = None,
313
+ code_width: Optional[int] = None,
314
+ tab_size: int = 4,
315
+ word_wrap: bool = False,
316
+ background_color: Optional[str] = None,
317
+ indent_guides: bool = False,
318
+ padding: PaddingDimensions = 0,
319
+ ) -> "Syntax":
320
+ """Construct a Syntax object from a file.
321
+
322
+ Args:
323
+ path (str): Path to file to highlight.
324
+ encoding (str): Encoding of file.
325
+ lexer (str | Lexer, optional): Lexer to use. If None, lexer will be auto-detected from path/file content.
326
+ theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "emacs".
327
+ dedent (bool, optional): Enable stripping of initial whitespace. Defaults to True.
328
+ line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
329
+ start_line (int, optional): Starting number for line numbers. Defaults to 1.
330
+ line_range (Tuple[int, int], optional): If given should be a tuple of the start and end line to render.
331
+ highlight_lines (Set[int]): A set of line numbers to highlight.
332
+ code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
333
+ tab_size (int, optional): Size of tabs. Defaults to 4.
334
+ word_wrap (bool, optional): Enable word wrapping of code.
335
+ background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
336
+ indent_guides (bool, optional): Show indent guides. Defaults to False.
337
+ padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).
338
+
339
+ Returns:
340
+ [Syntax]: A Syntax object that may be printed to the console
341
+ """
342
+ code = Path(path).read_text(encoding=encoding)
343
+
344
+ if not lexer:
345
+ lexer = cls.guess_lexer(path, code=code)
346
+
347
+ return cls(
348
+ code,
349
+ lexer,
350
+ theme=theme,
351
+ dedent=dedent,
352
+ line_numbers=line_numbers,
353
+ line_range=line_range,
354
+ start_line=start_line,
355
+ highlight_lines=highlight_lines,
356
+ code_width=code_width,
357
+ tab_size=tab_size,
358
+ word_wrap=word_wrap,
359
+ background_color=background_color,
360
+ indent_guides=indent_guides,
361
+ padding=padding,
362
+ )
363
+
364
+ @classmethod
365
+ def guess_lexer(cls, path: str, code: Optional[str] = None) -> str:
366
+ """Guess the alias of the Pygments lexer to use based on a path and an optional string of code.
367
+ If code is supplied, it will use a combination of the code and the filename to determine the
368
+ best lexer to use. For example, if the file is ``index.html`` and the file contains Django
369
+ templating syntax, then "html+django" will be returned. If the file is ``index.html``, and no
370
+ templating language is used, the "html" lexer will be used. If no string of code
371
+ is supplied, the lexer will be chosen based on the file extension..
372
+
373
+ Args:
374
+ path (AnyStr): The path to the file containing the code you wish to know the lexer for.
375
+ code (str, optional): Optional string of code that will be used as a fallback if no lexer
376
+ is found for the supplied path.
377
+
378
+ Returns:
379
+ str: The name of the Pygments lexer that best matches the supplied path/code.
380
+ """
381
+ lexer: Optional[Lexer] = None
382
+ lexer_name = "default"
383
+ if code:
384
+ try:
385
+ lexer = guess_lexer_for_filename(path, code)
386
+ except ClassNotFound:
387
+ pass
388
+
389
+ if not lexer:
390
+ try:
391
+ _, ext = os.path.splitext(path)
392
+ if ext:
393
+ extension = ext.lstrip(".").lower()
394
+ lexer = get_lexer_by_name(extension)
395
+ except ClassNotFound:
396
+ pass
397
+
398
+ if lexer:
399
+ if lexer.aliases:
400
+ lexer_name = lexer.aliases[0]
401
+ else:
402
+ lexer_name = lexer.name
403
+
404
+ return lexer_name
405
+
406
+ def _get_base_style(self) -> Style:
407
+ """Get the base style."""
408
+ default_style = self._theme.get_background_style() + self.background_style
409
+ return default_style
410
+
411
+ def _get_token_color(self, token_type: TokenType) -> Optional[Color]:
412
+ """Get a color (if any) for the given token.
413
+
414
+ Args:
415
+ token_type (TokenType): A token type tuple from Pygments.
416
+
417
+ Returns:
418
+ Optional[Color]: Color from theme, or None for no color.
419
+ """
420
+ style = self._theme.get_style_for_token(token_type)
421
+ return style.color
422
+
423
+ @property
424
+ def lexer(self) -> Optional[Lexer]:
425
+ """The lexer for this syntax, or None if no lexer was found.
426
+
427
+ Tries to find the lexer by name if a string was passed to the constructor.
428
+ """
429
+
430
+ if isinstance(self._lexer, Lexer):
431
+ return self._lexer
432
+ try:
433
+ return get_lexer_by_name(
434
+ self._lexer,
435
+ stripnl=False,
436
+ ensurenl=True,
437
+ tabsize=self.tab_size,
438
+ )
439
+ except ClassNotFound:
440
+ return None
441
+
442
+ @property
443
+ def default_lexer(self) -> Lexer:
444
+ """A Pygments Lexer to use if one is not specified or invalid."""
445
+ return get_lexer_by_name(
446
+ "text",
447
+ stripnl=False,
448
+ ensurenl=True,
449
+ tabsize=self.tab_size,
450
+ )
451
+
452
+ def highlight(
453
+ self,
454
+ code: str,
455
+ line_range: Optional[Tuple[Optional[int], Optional[int]]] = None,
456
+ ) -> Text:
457
+ """Highlight code and return a Text instance.
458
+
459
+ Args:
460
+ code (str): Code to highlight.
461
+ line_range(Tuple[int, int], optional): Optional line range to highlight.
462
+
463
+ Returns:
464
+ Text: A text instance containing highlighted syntax.
465
+ """
466
+
467
+ base_style = self._get_base_style()
468
+ justify: JustifyMethod = (
469
+ "default" if base_style.transparent_background else "left"
470
+ )
471
+
472
+ text = Text(
473
+ justify=justify,
474
+ style=base_style,
475
+ tab_size=self.tab_size,
476
+ no_wrap=not self.word_wrap,
477
+ )
478
+ _get_theme_style = self._theme.get_style_for_token
479
+
480
+ lexer = self.lexer or self.default_lexer
481
+
482
+ if lexer is None:
483
+ text.append(code)
484
+ else:
485
+ if line_range:
486
+ # More complicated path to only stylize a portion of the code
487
+ # This speeds up further operations as there are less spans to process
488
+ line_start, line_end = line_range
489
+
490
+ def line_tokenize() -> Iterable[Tuple[Any, str]]:
491
+ """Split tokens to one per line."""
492
+ assert lexer # required to make MyPy happy - we know lexer is not None at this point
493
+
494
+ for token_type, token in lexer.get_tokens(code):
495
+ while token:
496
+ line_token, new_line, token = token.partition("\n")
497
+ yield token_type, line_token + new_line
498
+
499
+ def tokens_to_spans() -> Iterable[Tuple[str, Optional[Style]]]:
500
+ """Convert tokens to spans."""
501
+ tokens = iter(line_tokenize())
502
+ line_no = 0
503
+ _line_start = line_start - 1 if line_start else 0
504
+
505
+ # Skip over tokens until line start
506
+ while line_no < _line_start:
507
+ try:
508
+ _token_type, token = next(tokens)
509
+ except StopIteration:
510
+ break
511
+ yield (token, None)
512
+ if token.endswith("\n"):
513
+ line_no += 1
514
+ # Generate spans until line end
515
+ for token_type, token in tokens:
516
+ yield (token, _get_theme_style(token_type))
517
+ if token.endswith("\n"):
518
+ line_no += 1
519
+ if line_end and line_no >= line_end:
520
+ break
521
+
522
+ text.append_tokens(tokens_to_spans())
523
+
524
+ else:
525
+ text.append_tokens(
526
+ (token, _get_theme_style(token_type))
527
+ for token_type, token in lexer.get_tokens(code)
528
+ )
529
+ if self.background_color is not None:
530
+ text.stylize(f"on {self.background_color}")
531
+
532
+ if self._stylized_ranges:
533
+ self._apply_stylized_ranges(text)
534
+
535
+ return text
536
+
537
+ def stylize_range(
538
+ self,
539
+ style: StyleType,
540
+ start: SyntaxPosition,
541
+ end: SyntaxPosition,
542
+ style_before: bool = False,
543
+ ) -> None:
544
+ """
545
+ Adds a custom style on a part of the code, that will be applied to the syntax display when it's rendered.
546
+ Line numbers are 1-based, while column indexes are 0-based.
547
+
548
+ Args:
549
+ style (StyleType): The style to apply.
550
+ start (Tuple[int, int]): The start of the range, in the form `[line number, column index]`.
551
+ end (Tuple[int, int]): The end of the range, in the form `[line number, column index]`.
552
+ style_before (bool): Apply the style before any existing styles.
553
+ """
554
+ self._stylized_ranges.append(
555
+ _SyntaxHighlightRange(style, start, end, style_before)
556
+ )
557
+
558
+ def _get_line_numbers_color(self, blend: float = 0.3) -> Color:
559
+ background_style = self._theme.get_background_style() + self.background_style
560
+ background_color = background_style.bgcolor
561
+ if background_color is None or background_color.is_system_defined:
562
+ return Color.default()
563
+ foreground_color = self._get_token_color(Token.Text)
564
+ if foreground_color is None or foreground_color.is_system_defined:
565
+ return foreground_color or Color.default()
566
+ new_color = blend_rgb(
567
+ background_color.get_truecolor(),
568
+ foreground_color.get_truecolor(),
569
+ cross_fade=blend,
570
+ )
571
+ return Color.from_triplet(new_color)
572
+
573
+ @property
574
+ def _numbers_column_width(self) -> int:
575
+ """Get the number of characters used to render the numbers column."""
576
+ column_width = 0
577
+ if self.line_numbers:
578
+ column_width = (
579
+ len(str(self.start_line + self.code.count("\n")))
580
+ + NUMBERS_COLUMN_DEFAULT_PADDING
581
+ )
582
+ return column_width
583
+
584
+ def _get_number_styles(self, console: Console) -> Tuple[Style, Style, Style]:
585
+ """Get background, number, and highlight styles for line numbers."""
586
+ background_style = self._get_base_style()
587
+ if background_style.transparent_background:
588
+ return Style.null(), Style(dim=True), Style.null()
589
+ if console.color_system in ("256", "truecolor"):
590
+ number_style = Style.chain(
591
+ background_style,
592
+ self._theme.get_style_for_token(Token.Text),
593
+ Style(color=self._get_line_numbers_color()),
594
+ self.background_style,
595
+ )
596
+ highlight_number_style = Style.chain(
597
+ background_style,
598
+ self._theme.get_style_for_token(Token.Text),
599
+ Style(bold=True, color=self._get_line_numbers_color(0.9)),
600
+ self.background_style,
601
+ )
602
+ else:
603
+ number_style = background_style + Style(dim=True)
604
+ highlight_number_style = background_style + Style(dim=False)
605
+ return background_style, number_style, highlight_number_style
606
+
607
+ def __rich_measure__(
608
+ self, console: "Console", options: "ConsoleOptions"
609
+ ) -> "Measurement":
610
+ _, right, _, left = Padding.unpack(self.padding)
611
+ padding = left + right
612
+ if self.code_width is not None:
613
+ width = self.code_width + self._numbers_column_width + padding + 1
614
+ return Measurement(self._numbers_column_width, width)
615
+ lines = self.code.splitlines()
616
+ width = (
617
+ self._numbers_column_width
618
+ + padding
619
+ + (max(cell_len(line) for line in lines) if lines else 0)
620
+ )
621
+ if self.line_numbers:
622
+ width += 1
623
+ return Measurement(self._numbers_column_width, width)
624
+
625
+ def __rich_console__(
626
+ self, console: Console, options: ConsoleOptions
627
+ ) -> RenderResult:
628
+ segments = Segments(self._get_syntax(console, options))
629
+ if self.padding:
630
+ yield Padding(segments, style=self._get_base_style(), pad=self.padding)
631
+ else:
632
+ yield segments
633
+
634
+ def _get_syntax(
635
+ self,
636
+ console: Console,
637
+ options: ConsoleOptions,
638
+ ) -> Iterable[Segment]:
639
+ """
640
+ Get the Segments for the Syntax object, excluding any vertical/horizontal padding
641
+ """
642
+ transparent_background = self._get_base_style().transparent_background
643
+ code_width = (
644
+ (
645
+ (options.max_width - self._numbers_column_width - 1)
646
+ if self.line_numbers
647
+ else options.max_width
648
+ )
649
+ if self.code_width is None
650
+ else self.code_width
651
+ )
652
+
653
+ ends_on_nl, processed_code = self._process_code(self.code)
654
+ text = self.highlight(processed_code, self.line_range)
655
+
656
+ if not self.line_numbers and not self.word_wrap and not self.line_range:
657
+ if not ends_on_nl:
658
+ text.remove_suffix("\n")
659
+ # Simple case of just rendering text
660
+ style = (
661
+ self._get_base_style()
662
+ + self._theme.get_style_for_token(Comment)
663
+ + Style(dim=True)
664
+ + self.background_style
665
+ )
666
+ if self.indent_guides and not options.ascii_only:
667
+ text = text.with_indent_guides(self.tab_size, style=style)
668
+ text.overflow = "crop"
669
+ if style.transparent_background:
670
+ yield from console.render(
671
+ text, options=options.update(width=code_width)
672
+ )
673
+ else:
674
+ syntax_lines = console.render_lines(
675
+ text,
676
+ options.update(width=code_width, height=None, justify="left"),
677
+ style=self.background_style,
678
+ pad=True,
679
+ new_lines=True,
680
+ )
681
+ for syntax_line in syntax_lines:
682
+ yield from syntax_line
683
+ return
684
+
685
+ start_line, end_line = self.line_range or (None, None)
686
+ line_offset = 0
687
+ if start_line:
688
+ line_offset = max(0, start_line - 1)
689
+ lines: Union[List[Text], Lines] = text.split("\n", allow_blank=ends_on_nl)
690
+ if self.line_range:
691
+ if line_offset > len(lines):
692
+ return
693
+ lines = lines[line_offset:end_line]
694
+
695
+ if self.indent_guides and not options.ascii_only:
696
+ style = (
697
+ self._get_base_style()
698
+ + self._theme.get_style_for_token(Comment)
699
+ + Style(dim=True)
700
+ + self.background_style
701
+ )
702
+ lines = (
703
+ Text("\n")
704
+ .join(lines)
705
+ .with_indent_guides(self.tab_size, style=style + Style(italic=False))
706
+ .split("\n", allow_blank=True)
707
+ )
708
+
709
+ numbers_column_width = self._numbers_column_width
710
+ render_options = options.update(width=code_width)
711
+
712
+ highlight_line = self.highlight_lines.__contains__
713
+ _Segment = Segment
714
+ new_line = _Segment("\n")
715
+
716
+ line_pointer = "> " if options.legacy_windows else "❱ "
717
+
718
+ (
719
+ background_style,
720
+ number_style,
721
+ highlight_number_style,
722
+ ) = self._get_number_styles(console)
723
+
724
+ for line_no, line in enumerate(lines, self.start_line + line_offset):
725
+ if self.word_wrap:
726
+ wrapped_lines = console.render_lines(
727
+ line,
728
+ render_options.update(height=None, justify="left"),
729
+ style=background_style,
730
+ pad=not transparent_background,
731
+ )
732
+ else:
733
+ segments = list(line.render(console, end=""))
734
+ if options.no_wrap:
735
+ wrapped_lines = [segments]
736
+ else:
737
+ wrapped_lines = [
738
+ _Segment.adjust_line_length(
739
+ segments,
740
+ render_options.max_width,
741
+ style=background_style,
742
+ pad=not transparent_background,
743
+ )
744
+ ]
745
+
746
+ if self.line_numbers:
747
+ wrapped_line_left_pad = _Segment(
748
+ " " * numbers_column_width + " ", background_style
749
+ )
750
+ for first, wrapped_line in loop_first(wrapped_lines):
751
+ if first:
752
+ line_column = str(line_no).rjust(numbers_column_width - 2) + " "
753
+ if highlight_line(line_no):
754
+ yield _Segment(line_pointer, Style(color="red"))
755
+ yield _Segment(line_column, highlight_number_style)
756
+ else:
757
+ yield _Segment(" ", highlight_number_style)
758
+ yield _Segment(line_column, number_style)
759
+ else:
760
+ yield wrapped_line_left_pad
761
+ yield from wrapped_line
762
+ yield new_line
763
+ else:
764
+ for wrapped_line in wrapped_lines:
765
+ yield from wrapped_line
766
+ yield new_line
767
+
768
+ def _apply_stylized_ranges(self, text: Text) -> None:
769
+ """
770
+ Apply stylized ranges to a text instance,
771
+ using the given code to determine the right portion to apply the style to.
772
+
773
+ Args:
774
+ text (Text): Text instance to apply the style to.
775
+ """
776
+ code = text.plain
777
+ newlines_offsets = [
778
+ # Let's add outer boundaries at each side of the list:
779
+ 0,
780
+ # N.B. using "\n" here is much faster than using metacharacters such as "^" or "\Z":
781
+ *[
782
+ match.start() + 1
783
+ for match in re.finditer("\n", code, flags=re.MULTILINE)
784
+ ],
785
+ len(code) + 1,
786
+ ]
787
+
788
+ for stylized_range in self._stylized_ranges:
789
+ start = _get_code_index_for_syntax_position(
790
+ newlines_offsets, stylized_range.start
791
+ )
792
+ end = _get_code_index_for_syntax_position(
793
+ newlines_offsets, stylized_range.end
794
+ )
795
+ if start is not None and end is not None:
796
+ if stylized_range.style_before:
797
+ text.stylize_before(stylized_range.style, start, end)
798
+ else:
799
+ text.stylize(stylized_range.style, start, end)
800
+
801
+ def _process_code(self, code: str) -> Tuple[bool, str]:
802
+ """
803
+ Applies various processing to a raw code string
804
+ (normalises it so it always ends with a line return, dedents it if necessary, etc.)
805
+
806
+ Args:
807
+ code (str): The raw code string to process
808
+
809
+ Returns:
810
+ Tuple[bool, str]: the boolean indicates whether the raw code ends with a line return,
811
+ while the string is the processed code.
812
+ """
813
+ ends_on_nl = code.endswith("\n")
814
+ processed_code = code if ends_on_nl else code + "\n"
815
+ processed_code = (
816
+ textwrap.dedent(processed_code) if self.dedent else processed_code
817
+ )
818
+ processed_code = processed_code.expandtabs(self.tab_size)
819
+ return ends_on_nl, processed_code
820
+
821
+
822
+ def _get_code_index_for_syntax_position(
823
+ newlines_offsets: Sequence[int], position: SyntaxPosition
824
+ ) -> Optional[int]:
825
+ """
826
+ Returns the index of the code string for the given positions.
827
+
828
+ Args:
829
+ newlines_offsets (Sequence[int]): The offset of each newline character found in the code snippet.
830
+ position (SyntaxPosition): The position to search for.
831
+
832
+ Returns:
833
+ Optional[int]: The index of the code string for this position, or `None`
834
+ if the given position's line number is out of range (if it's the column that is out of range
835
+ we silently clamp its value so that it reaches the end of the line)
836
+ """
837
+ lines_count = len(newlines_offsets)
838
+
839
+ line_number, column_index = position
840
+ if line_number > lines_count or len(newlines_offsets) < (line_number + 1):
841
+ return None # `line_number` is out of range
842
+ line_index = line_number - 1
843
+ line_length = newlines_offsets[line_index + 1] - newlines_offsets[line_index] - 1
844
+ # If `column_index` is out of range: let's silently clamp it:
845
+ column_index = min(line_length, column_index)
846
+ return newlines_offsets[line_index] + column_index
847
+
848
+
849
+ if __name__ == "__main__": # pragma: no cover
850
+ import argparse
851
+ import sys
852
+
853
+ parser = argparse.ArgumentParser(
854
+ description="Render syntax to the console with Rich"
855
+ )
856
+ parser.add_argument(
857
+ "path",
858
+ metavar="PATH",
859
+ help="path to file, or - for stdin",
860
+ )
861
+ parser.add_argument(
862
+ "-c",
863
+ "--force-color",
864
+ dest="force_color",
865
+ action="store_true",
866
+ default=None,
867
+ help="force color for non-terminals",
868
+ )
869
+ parser.add_argument(
870
+ "-i",
871
+ "--indent-guides",
872
+ dest="indent_guides",
873
+ action="store_true",
874
+ default=False,
875
+ help="display indent guides",
876
+ )
877
+ parser.add_argument(
878
+ "-l",
879
+ "--line-numbers",
880
+ dest="line_numbers",
881
+ action="store_true",
882
+ help="render line numbers",
883
+ )
884
+ parser.add_argument(
885
+ "-w",
886
+ "--width",
887
+ type=int,
888
+ dest="width",
889
+ default=None,
890
+ help="width of output (default will auto-detect)",
891
+ )
892
+ parser.add_argument(
893
+ "-r",
894
+ "--wrap",
895
+ dest="word_wrap",
896
+ action="store_true",
897
+ default=False,
898
+ help="word wrap long lines",
899
+ )
900
+ parser.add_argument(
901
+ "-s",
902
+ "--soft-wrap",
903
+ action="store_true",
904
+ dest="soft_wrap",
905
+ default=False,
906
+ help="enable soft wrapping mode",
907
+ )
908
+ parser.add_argument(
909
+ "-t", "--theme", dest="theme", default="monokai", help="pygments theme"
910
+ )
911
+ parser.add_argument(
912
+ "-b",
913
+ "--background-color",
914
+ dest="background_color",
915
+ default=None,
916
+ help="Override background color",
917
+ )
918
+ parser.add_argument(
919
+ "-x",
920
+ "--lexer",
921
+ default=None,
922
+ dest="lexer_name",
923
+ help="Lexer name",
924
+ )
925
+ parser.add_argument(
926
+ "-p", "--padding", type=int, default=0, dest="padding", help="Padding"
927
+ )
928
+ parser.add_argument(
929
+ "--highlight-line",
930
+ type=int,
931
+ default=None,
932
+ dest="highlight_line",
933
+ help="The line number (not index!) to highlight",
934
+ )
935
+ args = parser.parse_args()
936
+
937
+ from pip._vendor.rich.console import Console
938
+
939
+ console = Console(force_terminal=args.force_color, width=args.width)
940
+
941
+ if args.path == "-":
942
+ code = sys.stdin.read()
943
+ syntax = Syntax(
944
+ code=code,
945
+ lexer=args.lexer_name,
946
+ line_numbers=args.line_numbers,
947
+ word_wrap=args.word_wrap,
948
+ theme=args.theme,
949
+ background_color=args.background_color,
950
+ indent_guides=args.indent_guides,
951
+ padding=args.padding,
952
+ highlight_lines={args.highlight_line},
953
+ )
954
+ else:
955
+ syntax = Syntax.from_path(
956
+ args.path,
957
+ lexer=args.lexer_name,
958
+ line_numbers=args.line_numbers,
959
+ word_wrap=args.word_wrap,
960
+ theme=args.theme,
961
+ background_color=args.background_color,
962
+ indent_guides=args.indent_guides,
963
+ padding=args.padding,
964
+ highlight_lines={args.highlight_line},
965
+ )
966
+ console.print(syntax, soft_wrap=args.soft_wrap)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/table.py ADDED
@@ -0,0 +1,1006 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass, field, replace
2
+ from typing import (
3
+ TYPE_CHECKING,
4
+ Dict,
5
+ Iterable,
6
+ List,
7
+ NamedTuple,
8
+ Optional,
9
+ Sequence,
10
+ Tuple,
11
+ Union,
12
+ )
13
+
14
+ from . import box, errors
15
+ from ._loop import loop_first_last, loop_last
16
+ from ._pick import pick_bool
17
+ from ._ratio import ratio_distribute, ratio_reduce
18
+ from .align import VerticalAlignMethod
19
+ from .jupyter import JupyterMixin
20
+ from .measure import Measurement
21
+ from .padding import Padding, PaddingDimensions
22
+ from .protocol import is_renderable
23
+ from .segment import Segment
24
+ from .style import Style, StyleType
25
+ from .text import Text, TextType
26
+
27
+ if TYPE_CHECKING:
28
+ from .console import (
29
+ Console,
30
+ ConsoleOptions,
31
+ JustifyMethod,
32
+ OverflowMethod,
33
+ RenderableType,
34
+ RenderResult,
35
+ )
36
+
37
+
38
+ @dataclass
39
+ class Column:
40
+ """Defines a column within a ~Table.
41
+
42
+ Args:
43
+ title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
44
+ caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
45
+ width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
46
+ min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
47
+ box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
48
+ safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
49
+ padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
50
+ collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
51
+ pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
52
+ expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
53
+ show_header (bool, optional): Show a header row. Defaults to True.
54
+ show_footer (bool, optional): Show a footer row. Defaults to False.
55
+ show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
56
+ show_lines (bool, optional): Draw lines between every row. Defaults to False.
57
+ leading (int, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
58
+ style (Union[str, Style], optional): Default style for the table. Defaults to "none".
59
+ row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
60
+ header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
61
+ footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
62
+ border_style (Union[str, Style], optional): Style of the border. Defaults to None.
63
+ title_style (Union[str, Style], optional): Style of the title. Defaults to None.
64
+ caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
65
+ title_justify (str, optional): Justify method for title. Defaults to "center".
66
+ caption_justify (str, optional): Justify method for caption. Defaults to "center".
67
+ highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
68
+ """
69
+
70
+ header: "RenderableType" = ""
71
+ """RenderableType: Renderable for the header (typically a string)"""
72
+
73
+ footer: "RenderableType" = ""
74
+ """RenderableType: Renderable for the footer (typically a string)"""
75
+
76
+ header_style: StyleType = ""
77
+ """StyleType: The style of the header."""
78
+
79
+ footer_style: StyleType = ""
80
+ """StyleType: The style of the footer."""
81
+
82
+ style: StyleType = ""
83
+ """StyleType: The style of the column."""
84
+
85
+ justify: "JustifyMethod" = "left"
86
+ """str: How to justify text within the column ("left", "center", "right", or "full")"""
87
+
88
+ vertical: "VerticalAlignMethod" = "top"
89
+ """str: How to vertically align content ("top", "middle", or "bottom")"""
90
+
91
+ overflow: "OverflowMethod" = "ellipsis"
92
+ """str: Overflow method."""
93
+
94
+ width: Optional[int] = None
95
+ """Optional[int]: Width of the column, or ``None`` (default) to auto calculate width."""
96
+
97
+ min_width: Optional[int] = None
98
+ """Optional[int]: Minimum width of column, or ``None`` for no minimum. Defaults to None."""
99
+
100
+ max_width: Optional[int] = None
101
+ """Optional[int]: Maximum width of column, or ``None`` for no maximum. Defaults to None."""
102
+
103
+ ratio: Optional[int] = None
104
+ """Optional[int]: Ratio to use when calculating column width, or ``None`` (default) to adapt to column contents."""
105
+
106
+ no_wrap: bool = False
107
+ """bool: Prevent wrapping of text within the column. Defaults to ``False``."""
108
+
109
+ highlight: bool = False
110
+ """bool: Apply highlighter to column. Defaults to ``False``."""
111
+
112
+ _index: int = 0
113
+ """Index of column."""
114
+
115
+ _cells: List["RenderableType"] = field(default_factory=list)
116
+
117
+ def copy(self) -> "Column":
118
+ """Return a copy of this Column."""
119
+ return replace(self, _cells=[])
120
+
121
+ @property
122
+ def cells(self) -> Iterable["RenderableType"]:
123
+ """Get all cells in the column, not including header."""
124
+ yield from self._cells
125
+
126
+ @property
127
+ def flexible(self) -> bool:
128
+ """Check if this column is flexible."""
129
+ return self.ratio is not None
130
+
131
+
132
+ @dataclass
133
+ class Row:
134
+ """Information regarding a row."""
135
+
136
+ style: Optional[StyleType] = None
137
+ """Style to apply to row."""
138
+
139
+ end_section: bool = False
140
+ """Indicated end of section, which will force a line beneath the row."""
141
+
142
+
143
+ class _Cell(NamedTuple):
144
+ """A single cell in a table."""
145
+
146
+ style: StyleType
147
+ """Style to apply to cell."""
148
+ renderable: "RenderableType"
149
+ """Cell renderable."""
150
+ vertical: VerticalAlignMethod
151
+ """Cell vertical alignment."""
152
+
153
+
154
+ class Table(JupyterMixin):
155
+ """A console renderable to draw a table.
156
+
157
+ Args:
158
+ *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
159
+ title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
160
+ caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
161
+ width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
162
+ min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
163
+ box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
164
+ safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
165
+ padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
166
+ collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
167
+ pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
168
+ expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
169
+ show_header (bool, optional): Show a header row. Defaults to True.
170
+ show_footer (bool, optional): Show a footer row. Defaults to False.
171
+ show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
172
+ show_lines (bool, optional): Draw lines between every row. Defaults to False.
173
+ leading (int, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
174
+ style (Union[str, Style], optional): Default style for the table. Defaults to "none".
175
+ row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
176
+ header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
177
+ footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
178
+ border_style (Union[str, Style], optional): Style of the border. Defaults to None.
179
+ title_style (Union[str, Style], optional): Style of the title. Defaults to None.
180
+ caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
181
+ title_justify (str, optional): Justify method for title. Defaults to "center".
182
+ caption_justify (str, optional): Justify method for caption. Defaults to "center".
183
+ highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
184
+ """
185
+
186
+ columns: List[Column]
187
+ rows: List[Row]
188
+
189
+ def __init__(
190
+ self,
191
+ *headers: Union[Column, str],
192
+ title: Optional[TextType] = None,
193
+ caption: Optional[TextType] = None,
194
+ width: Optional[int] = None,
195
+ min_width: Optional[int] = None,
196
+ box: Optional[box.Box] = box.HEAVY_HEAD,
197
+ safe_box: Optional[bool] = None,
198
+ padding: PaddingDimensions = (0, 1),
199
+ collapse_padding: bool = False,
200
+ pad_edge: bool = True,
201
+ expand: bool = False,
202
+ show_header: bool = True,
203
+ show_footer: bool = False,
204
+ show_edge: bool = True,
205
+ show_lines: bool = False,
206
+ leading: int = 0,
207
+ style: StyleType = "none",
208
+ row_styles: Optional[Iterable[StyleType]] = None,
209
+ header_style: Optional[StyleType] = "table.header",
210
+ footer_style: Optional[StyleType] = "table.footer",
211
+ border_style: Optional[StyleType] = None,
212
+ title_style: Optional[StyleType] = None,
213
+ caption_style: Optional[StyleType] = None,
214
+ title_justify: "JustifyMethod" = "center",
215
+ caption_justify: "JustifyMethod" = "center",
216
+ highlight: bool = False,
217
+ ) -> None:
218
+ self.columns: List[Column] = []
219
+ self.rows: List[Row] = []
220
+ self.title = title
221
+ self.caption = caption
222
+ self.width = width
223
+ self.min_width = min_width
224
+ self.box = box
225
+ self.safe_box = safe_box
226
+ self._padding = Padding.unpack(padding)
227
+ self.pad_edge = pad_edge
228
+ self._expand = expand
229
+ self.show_header = show_header
230
+ self.show_footer = show_footer
231
+ self.show_edge = show_edge
232
+ self.show_lines = show_lines
233
+ self.leading = leading
234
+ self.collapse_padding = collapse_padding
235
+ self.style = style
236
+ self.header_style = header_style or ""
237
+ self.footer_style = footer_style or ""
238
+ self.border_style = border_style
239
+ self.title_style = title_style
240
+ self.caption_style = caption_style
241
+ self.title_justify: "JustifyMethod" = title_justify
242
+ self.caption_justify: "JustifyMethod" = caption_justify
243
+ self.highlight = highlight
244
+ self.row_styles: Sequence[StyleType] = list(row_styles or [])
245
+ append_column = self.columns.append
246
+ for header in headers:
247
+ if isinstance(header, str):
248
+ self.add_column(header=header)
249
+ else:
250
+ header._index = len(self.columns)
251
+ append_column(header)
252
+
253
+ @classmethod
254
+ def grid(
255
+ cls,
256
+ *headers: Union[Column, str],
257
+ padding: PaddingDimensions = 0,
258
+ collapse_padding: bool = True,
259
+ pad_edge: bool = False,
260
+ expand: bool = False,
261
+ ) -> "Table":
262
+ """Get a table with no lines, headers, or footer.
263
+
264
+ Args:
265
+ *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
266
+ padding (PaddingDimensions, optional): Get padding around cells. Defaults to 0.
267
+ collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to True.
268
+ pad_edge (bool, optional): Enable padding around edges of table. Defaults to False.
269
+ expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
270
+
271
+ Returns:
272
+ Table: A table instance.
273
+ """
274
+ return cls(
275
+ *headers,
276
+ box=None,
277
+ padding=padding,
278
+ collapse_padding=collapse_padding,
279
+ show_header=False,
280
+ show_footer=False,
281
+ show_edge=False,
282
+ pad_edge=pad_edge,
283
+ expand=expand,
284
+ )
285
+
286
+ @property
287
+ def expand(self) -> bool:
288
+ """Setting a non-None self.width implies expand."""
289
+ return self._expand or self.width is not None
290
+
291
+ @expand.setter
292
+ def expand(self, expand: bool) -> None:
293
+ """Set expand."""
294
+ self._expand = expand
295
+
296
+ @property
297
+ def _extra_width(self) -> int:
298
+ """Get extra width to add to cell content."""
299
+ width = 0
300
+ if self.box and self.show_edge:
301
+ width += 2
302
+ if self.box:
303
+ width += len(self.columns) - 1
304
+ return width
305
+
306
+ @property
307
+ def row_count(self) -> int:
308
+ """Get the current number of rows."""
309
+ return len(self.rows)
310
+
311
+ def get_row_style(self, console: "Console", index: int) -> StyleType:
312
+ """Get the current row style."""
313
+ style = Style.null()
314
+ if self.row_styles:
315
+ style += console.get_style(self.row_styles[index % len(self.row_styles)])
316
+ row_style = self.rows[index].style
317
+ if row_style is not None:
318
+ style += console.get_style(row_style)
319
+ return style
320
+
321
+ def __rich_measure__(
322
+ self, console: "Console", options: "ConsoleOptions"
323
+ ) -> Measurement:
324
+ max_width = options.max_width
325
+ if self.width is not None:
326
+ max_width = self.width
327
+ if max_width < 0:
328
+ return Measurement(0, 0)
329
+
330
+ extra_width = self._extra_width
331
+ max_width = sum(
332
+ self._calculate_column_widths(
333
+ console, options.update_width(max_width - extra_width)
334
+ )
335
+ )
336
+ _measure_column = self._measure_column
337
+
338
+ measurements = [
339
+ _measure_column(console, options.update_width(max_width), column)
340
+ for column in self.columns
341
+ ]
342
+ minimum_width = (
343
+ sum(measurement.minimum for measurement in measurements) + extra_width
344
+ )
345
+ maximum_width = (
346
+ sum(measurement.maximum for measurement in measurements) + extra_width
347
+ if (self.width is None)
348
+ else self.width
349
+ )
350
+ measurement = Measurement(minimum_width, maximum_width)
351
+ measurement = measurement.clamp(self.min_width)
352
+ return measurement
353
+
354
+ @property
355
+ def padding(self) -> Tuple[int, int, int, int]:
356
+ """Get cell padding."""
357
+ return self._padding
358
+
359
+ @padding.setter
360
+ def padding(self, padding: PaddingDimensions) -> "Table":
361
+ """Set cell padding."""
362
+ self._padding = Padding.unpack(padding)
363
+ return self
364
+
365
+ def add_column(
366
+ self,
367
+ header: "RenderableType" = "",
368
+ footer: "RenderableType" = "",
369
+ *,
370
+ header_style: Optional[StyleType] = None,
371
+ highlight: Optional[bool] = None,
372
+ footer_style: Optional[StyleType] = None,
373
+ style: Optional[StyleType] = None,
374
+ justify: "JustifyMethod" = "left",
375
+ vertical: "VerticalAlignMethod" = "top",
376
+ overflow: "OverflowMethod" = "ellipsis",
377
+ width: Optional[int] = None,
378
+ min_width: Optional[int] = None,
379
+ max_width: Optional[int] = None,
380
+ ratio: Optional[int] = None,
381
+ no_wrap: bool = False,
382
+ ) -> None:
383
+ """Add a column to the table.
384
+
385
+ Args:
386
+ header (RenderableType, optional): Text or renderable for the header.
387
+ Defaults to "".
388
+ footer (RenderableType, optional): Text or renderable for the footer.
389
+ Defaults to "".
390
+ header_style (Union[str, Style], optional): Style for the header, or None for default. Defaults to None.
391
+ highlight (bool, optional): Whether to highlight the text. The default of None uses the value of the table (self) object.
392
+ footer_style (Union[str, Style], optional): Style for the footer, or None for default. Defaults to None.
393
+ style (Union[str, Style], optional): Style for the column cells, or None for default. Defaults to None.
394
+ justify (JustifyMethod, optional): Alignment for cells. Defaults to "left".
395
+ vertical (VerticalAlignMethod, optional): Vertical alignment, one of "top", "middle", or "bottom". Defaults to "top".
396
+ overflow (OverflowMethod): Overflow method: "crop", "fold", "ellipsis". Defaults to "ellipsis".
397
+ width (int, optional): Desired width of column in characters, or None to fit to contents. Defaults to None.
398
+ min_width (Optional[int], optional): Minimum width of column, or ``None`` for no minimum. Defaults to None.
399
+ max_width (Optional[int], optional): Maximum width of column, or ``None`` for no maximum. Defaults to None.
400
+ ratio (int, optional): Flexible ratio for the column (requires ``Table.expand`` or ``Table.width``). Defaults to None.
401
+ no_wrap (bool, optional): Set to ``True`` to disable wrapping of this column.
402
+ """
403
+
404
+ column = Column(
405
+ _index=len(self.columns),
406
+ header=header,
407
+ footer=footer,
408
+ header_style=header_style or "",
409
+ highlight=highlight if highlight is not None else self.highlight,
410
+ footer_style=footer_style or "",
411
+ style=style or "",
412
+ justify=justify,
413
+ vertical=vertical,
414
+ overflow=overflow,
415
+ width=width,
416
+ min_width=min_width,
417
+ max_width=max_width,
418
+ ratio=ratio,
419
+ no_wrap=no_wrap,
420
+ )
421
+ self.columns.append(column)
422
+
423
+ def add_row(
424
+ self,
425
+ *renderables: Optional["RenderableType"],
426
+ style: Optional[StyleType] = None,
427
+ end_section: bool = False,
428
+ ) -> None:
429
+ """Add a row of renderables.
430
+
431
+ Args:
432
+ *renderables (None or renderable): Each cell in a row must be a renderable object (including str),
433
+ or ``None`` for a blank cell.
434
+ style (StyleType, optional): An optional style to apply to the entire row. Defaults to None.
435
+ end_section (bool, optional): End a section and draw a line. Defaults to False.
436
+
437
+ Raises:
438
+ errors.NotRenderableError: If you add something that can't be rendered.
439
+ """
440
+
441
+ def add_cell(column: Column, renderable: "RenderableType") -> None:
442
+ column._cells.append(renderable)
443
+
444
+ cell_renderables: List[Optional["RenderableType"]] = list(renderables)
445
+
446
+ columns = self.columns
447
+ if len(cell_renderables) < len(columns):
448
+ cell_renderables = [
449
+ *cell_renderables,
450
+ *[None] * (len(columns) - len(cell_renderables)),
451
+ ]
452
+ for index, renderable in enumerate(cell_renderables):
453
+ if index == len(columns):
454
+ column = Column(_index=index, highlight=self.highlight)
455
+ for _ in self.rows:
456
+ add_cell(column, Text(""))
457
+ self.columns.append(column)
458
+ else:
459
+ column = columns[index]
460
+ if renderable is None:
461
+ add_cell(column, "")
462
+ elif is_renderable(renderable):
463
+ add_cell(column, renderable)
464
+ else:
465
+ raise errors.NotRenderableError(
466
+ f"unable to render {type(renderable).__name__}; a string or other renderable object is required"
467
+ )
468
+ self.rows.append(Row(style=style, end_section=end_section))
469
+
470
+ def add_section(self) -> None:
471
+ """Add a new section (draw a line after current row)."""
472
+
473
+ if self.rows:
474
+ self.rows[-1].end_section = True
475
+
476
+ def __rich_console__(
477
+ self, console: "Console", options: "ConsoleOptions"
478
+ ) -> "RenderResult":
479
+ if not self.columns:
480
+ yield Segment("\n")
481
+ return
482
+
483
+ max_width = options.max_width
484
+ if self.width is not None:
485
+ max_width = self.width
486
+
487
+ extra_width = self._extra_width
488
+ widths = self._calculate_column_widths(
489
+ console, options.update_width(max_width - extra_width)
490
+ )
491
+ table_width = sum(widths) + extra_width
492
+
493
+ render_options = options.update(
494
+ width=table_width, highlight=self.highlight, height=None
495
+ )
496
+
497
+ def render_annotation(
498
+ text: TextType, style: StyleType, justify: "JustifyMethod" = "center"
499
+ ) -> "RenderResult":
500
+ render_text = (
501
+ console.render_str(text, style=style, highlight=False)
502
+ if isinstance(text, str)
503
+ else text
504
+ )
505
+ return console.render(
506
+ render_text, options=render_options.update(justify=justify)
507
+ )
508
+
509
+ if self.title:
510
+ yield from render_annotation(
511
+ self.title,
512
+ style=Style.pick_first(self.title_style, "table.title"),
513
+ justify=self.title_justify,
514
+ )
515
+ yield from self._render(console, render_options, widths)
516
+ if self.caption:
517
+ yield from render_annotation(
518
+ self.caption,
519
+ style=Style.pick_first(self.caption_style, "table.caption"),
520
+ justify=self.caption_justify,
521
+ )
522
+
523
+ def _calculate_column_widths(
524
+ self, console: "Console", options: "ConsoleOptions"
525
+ ) -> List[int]:
526
+ """Calculate the widths of each column, including padding, not including borders."""
527
+ max_width = options.max_width
528
+ columns = self.columns
529
+ width_ranges = [
530
+ self._measure_column(console, options, column) for column in columns
531
+ ]
532
+ widths = [_range.maximum or 1 for _range in width_ranges]
533
+ get_padding_width = self._get_padding_width
534
+ extra_width = self._extra_width
535
+ if self.expand:
536
+ ratios = [col.ratio or 0 for col in columns if col.flexible]
537
+ if any(ratios):
538
+ fixed_widths = [
539
+ 0 if column.flexible else _range.maximum
540
+ for _range, column in zip(width_ranges, columns)
541
+ ]
542
+ flex_minimum = [
543
+ (column.width or 1) + get_padding_width(column._index)
544
+ for column in columns
545
+ if column.flexible
546
+ ]
547
+ flexible_width = max_width - sum(fixed_widths)
548
+ flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
549
+ iter_flex_widths = iter(flex_widths)
550
+ for index, column in enumerate(columns):
551
+ if column.flexible:
552
+ widths[index] = fixed_widths[index] + next(iter_flex_widths)
553
+ table_width = sum(widths)
554
+
555
+ if table_width > max_width:
556
+ widths = self._collapse_widths(
557
+ widths,
558
+ [(column.width is None and not column.no_wrap) for column in columns],
559
+ max_width,
560
+ )
561
+ table_width = sum(widths)
562
+ # last resort, reduce columns evenly
563
+ if table_width > max_width:
564
+ excess_width = table_width - max_width
565
+ widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
566
+ table_width = sum(widths)
567
+
568
+ width_ranges = [
569
+ self._measure_column(console, options.update_width(width), column)
570
+ for width, column in zip(widths, columns)
571
+ ]
572
+ widths = [_range.maximum or 0 for _range in width_ranges]
573
+
574
+ if (table_width < max_width and self.expand) or (
575
+ self.min_width is not None and table_width < (self.min_width - extra_width)
576
+ ):
577
+ _max_width = (
578
+ max_width
579
+ if self.min_width is None
580
+ else min(self.min_width - extra_width, max_width)
581
+ )
582
+ pad_widths = ratio_distribute(_max_width - table_width, widths)
583
+ widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
584
+
585
+ return widths
586
+
587
+ @classmethod
588
+ def _collapse_widths(
589
+ cls, widths: List[int], wrapable: List[bool], max_width: int
590
+ ) -> List[int]:
591
+ """Reduce widths so that the total is under max_width.
592
+
593
+ Args:
594
+ widths (List[int]): List of widths.
595
+ wrapable (List[bool]): List of booleans that indicate if a column may shrink.
596
+ max_width (int): Maximum width to reduce to.
597
+
598
+ Returns:
599
+ List[int]: A new list of widths.
600
+ """
601
+ total_width = sum(widths)
602
+ excess_width = total_width - max_width
603
+ if any(wrapable):
604
+ while total_width and excess_width > 0:
605
+ max_column = max(
606
+ width for width, allow_wrap in zip(widths, wrapable) if allow_wrap
607
+ )
608
+ second_max_column = max(
609
+ width if allow_wrap and width != max_column else 0
610
+ for width, allow_wrap in zip(widths, wrapable)
611
+ )
612
+ column_difference = max_column - second_max_column
613
+ ratios = [
614
+ (1 if (width == max_column and allow_wrap) else 0)
615
+ for width, allow_wrap in zip(widths, wrapable)
616
+ ]
617
+ if not any(ratios) or not column_difference:
618
+ break
619
+ max_reduce = [min(excess_width, column_difference)] * len(widths)
620
+ widths = ratio_reduce(excess_width, ratios, max_reduce, widths)
621
+
622
+ total_width = sum(widths)
623
+ excess_width = total_width - max_width
624
+ return widths
625
+
626
+ def _get_cells(
627
+ self, console: "Console", column_index: int, column: Column
628
+ ) -> Iterable[_Cell]:
629
+ """Get all the cells with padding and optional header."""
630
+
631
+ collapse_padding = self.collapse_padding
632
+ pad_edge = self.pad_edge
633
+ padding = self.padding
634
+ any_padding = any(padding)
635
+
636
+ first_column = column_index == 0
637
+ last_column = column_index == len(self.columns) - 1
638
+
639
+ _padding_cache: Dict[Tuple[bool, bool], Tuple[int, int, int, int]] = {}
640
+
641
+ def get_padding(first_row: bool, last_row: bool) -> Tuple[int, int, int, int]:
642
+ cached = _padding_cache.get((first_row, last_row))
643
+ if cached:
644
+ return cached
645
+ top, right, bottom, left = padding
646
+
647
+ if collapse_padding:
648
+ if not first_column:
649
+ left = max(0, left - right)
650
+ if not last_row:
651
+ bottom = max(0, top - bottom)
652
+
653
+ if not pad_edge:
654
+ if first_column:
655
+ left = 0
656
+ if last_column:
657
+ right = 0
658
+ if first_row:
659
+ top = 0
660
+ if last_row:
661
+ bottom = 0
662
+ _padding = (top, right, bottom, left)
663
+ _padding_cache[(first_row, last_row)] = _padding
664
+ return _padding
665
+
666
+ raw_cells: List[Tuple[StyleType, "RenderableType"]] = []
667
+ _append = raw_cells.append
668
+ get_style = console.get_style
669
+ if self.show_header:
670
+ header_style = get_style(self.header_style or "") + get_style(
671
+ column.header_style
672
+ )
673
+ _append((header_style, column.header))
674
+ cell_style = get_style(column.style or "")
675
+ for cell in column.cells:
676
+ _append((cell_style, cell))
677
+ if self.show_footer:
678
+ footer_style = get_style(self.footer_style or "") + get_style(
679
+ column.footer_style
680
+ )
681
+ _append((footer_style, column.footer))
682
+
683
+ if any_padding:
684
+ _Padding = Padding
685
+ for first, last, (style, renderable) in loop_first_last(raw_cells):
686
+ yield _Cell(
687
+ style,
688
+ _Padding(renderable, get_padding(first, last)),
689
+ getattr(renderable, "vertical", None) or column.vertical,
690
+ )
691
+ else:
692
+ for style, renderable in raw_cells:
693
+ yield _Cell(
694
+ style,
695
+ renderable,
696
+ getattr(renderable, "vertical", None) or column.vertical,
697
+ )
698
+
699
+ def _get_padding_width(self, column_index: int) -> int:
700
+ """Get extra width from padding."""
701
+ _, pad_right, _, pad_left = self.padding
702
+ if self.collapse_padding:
703
+ if column_index > 0:
704
+ pad_left = max(0, pad_left - pad_right)
705
+ return pad_left + pad_right
706
+
707
+ def _measure_column(
708
+ self,
709
+ console: "Console",
710
+ options: "ConsoleOptions",
711
+ column: Column,
712
+ ) -> Measurement:
713
+ """Get the minimum and maximum width of the column."""
714
+
715
+ max_width = options.max_width
716
+ if max_width < 1:
717
+ return Measurement(0, 0)
718
+
719
+ padding_width = self._get_padding_width(column._index)
720
+
721
+ if column.width is not None:
722
+ # Fixed width column
723
+ return Measurement(
724
+ column.width + padding_width, column.width + padding_width
725
+ ).with_maximum(max_width)
726
+ # Flexible column, we need to measure contents
727
+ min_widths: List[int] = []
728
+ max_widths: List[int] = []
729
+ append_min = min_widths.append
730
+ append_max = max_widths.append
731
+ get_render_width = Measurement.get
732
+ for cell in self._get_cells(console, column._index, column):
733
+ _min, _max = get_render_width(console, options, cell.renderable)
734
+ append_min(_min)
735
+ append_max(_max)
736
+
737
+ measurement = Measurement(
738
+ max(min_widths) if min_widths else 1,
739
+ max(max_widths) if max_widths else max_width,
740
+ ).with_maximum(max_width)
741
+ measurement = measurement.clamp(
742
+ None if column.min_width is None else column.min_width + padding_width,
743
+ None if column.max_width is None else column.max_width + padding_width,
744
+ )
745
+ return measurement
746
+
747
+ def _render(
748
+ self, console: "Console", options: "ConsoleOptions", widths: List[int]
749
+ ) -> "RenderResult":
750
+ table_style = console.get_style(self.style or "")
751
+
752
+ border_style = table_style + console.get_style(self.border_style or "")
753
+ _column_cells = (
754
+ self._get_cells(console, column_index, column)
755
+ for column_index, column in enumerate(self.columns)
756
+ )
757
+ row_cells: List[Tuple[_Cell, ...]] = list(zip(*_column_cells))
758
+ _box = (
759
+ self.box.substitute(
760
+ options, safe=pick_bool(self.safe_box, console.safe_box)
761
+ )
762
+ if self.box
763
+ else None
764
+ )
765
+ _box = _box.get_plain_headed_box() if _box and not self.show_header else _box
766
+
767
+ new_line = Segment.line()
768
+
769
+ columns = self.columns
770
+ show_header = self.show_header
771
+ show_footer = self.show_footer
772
+ show_edge = self.show_edge
773
+ show_lines = self.show_lines
774
+ leading = self.leading
775
+
776
+ _Segment = Segment
777
+ if _box:
778
+ box_segments = [
779
+ (
780
+ _Segment(_box.head_left, border_style),
781
+ _Segment(_box.head_right, border_style),
782
+ _Segment(_box.head_vertical, border_style),
783
+ ),
784
+ (
785
+ _Segment(_box.mid_left, border_style),
786
+ _Segment(_box.mid_right, border_style),
787
+ _Segment(_box.mid_vertical, border_style),
788
+ ),
789
+ (
790
+ _Segment(_box.foot_left, border_style),
791
+ _Segment(_box.foot_right, border_style),
792
+ _Segment(_box.foot_vertical, border_style),
793
+ ),
794
+ ]
795
+ if show_edge:
796
+ yield _Segment(_box.get_top(widths), border_style)
797
+ yield new_line
798
+ else:
799
+ box_segments = []
800
+
801
+ get_row_style = self.get_row_style
802
+ get_style = console.get_style
803
+
804
+ for index, (first, last, row_cell) in enumerate(loop_first_last(row_cells)):
805
+ header_row = first and show_header
806
+ footer_row = last and show_footer
807
+ row = (
808
+ self.rows[index - show_header]
809
+ if (not header_row and not footer_row)
810
+ else None
811
+ )
812
+ max_height = 1
813
+ cells: List[List[List[Segment]]] = []
814
+ if header_row or footer_row:
815
+ row_style = Style.null()
816
+ else:
817
+ row_style = get_style(
818
+ get_row_style(console, index - 1 if show_header else index)
819
+ )
820
+ for width, cell, column in zip(widths, row_cell, columns):
821
+ render_options = options.update(
822
+ width=width,
823
+ justify=column.justify,
824
+ no_wrap=column.no_wrap,
825
+ overflow=column.overflow,
826
+ height=None,
827
+ highlight=column.highlight,
828
+ )
829
+ lines = console.render_lines(
830
+ cell.renderable,
831
+ render_options,
832
+ style=get_style(cell.style) + row_style,
833
+ )
834
+ max_height = max(max_height, len(lines))
835
+ cells.append(lines)
836
+
837
+ row_height = max(len(cell) for cell in cells)
838
+
839
+ def align_cell(
840
+ cell: List[List[Segment]],
841
+ vertical: "VerticalAlignMethod",
842
+ width: int,
843
+ style: Style,
844
+ ) -> List[List[Segment]]:
845
+ if header_row:
846
+ vertical = "bottom"
847
+ elif footer_row:
848
+ vertical = "top"
849
+
850
+ if vertical == "top":
851
+ return _Segment.align_top(cell, width, row_height, style)
852
+ elif vertical == "middle":
853
+ return _Segment.align_middle(cell, width, row_height, style)
854
+ return _Segment.align_bottom(cell, width, row_height, style)
855
+
856
+ cells[:] = [
857
+ _Segment.set_shape(
858
+ align_cell(
859
+ cell,
860
+ _cell.vertical,
861
+ width,
862
+ get_style(_cell.style) + row_style,
863
+ ),
864
+ width,
865
+ max_height,
866
+ )
867
+ for width, _cell, cell, column in zip(widths, row_cell, cells, columns)
868
+ ]
869
+
870
+ if _box:
871
+ if last and show_footer:
872
+ yield _Segment(
873
+ _box.get_row(widths, "foot", edge=show_edge), border_style
874
+ )
875
+ yield new_line
876
+ left, right, _divider = box_segments[0 if first else (2 if last else 1)]
877
+
878
+ # If the column divider is whitespace also style it with the row background
879
+ divider = (
880
+ _divider
881
+ if _divider.text.strip()
882
+ else _Segment(
883
+ _divider.text, row_style.background_style + _divider.style
884
+ )
885
+ )
886
+ for line_no in range(max_height):
887
+ if show_edge:
888
+ yield left
889
+ for last_cell, rendered_cell in loop_last(cells):
890
+ yield from rendered_cell[line_no]
891
+ if not last_cell:
892
+ yield divider
893
+ if show_edge:
894
+ yield right
895
+ yield new_line
896
+ else:
897
+ for line_no in range(max_height):
898
+ for rendered_cell in cells:
899
+ yield from rendered_cell[line_no]
900
+ yield new_line
901
+ if _box and first and show_header:
902
+ yield _Segment(
903
+ _box.get_row(widths, "head", edge=show_edge), border_style
904
+ )
905
+ yield new_line
906
+ end_section = row and row.end_section
907
+ if _box and (show_lines or leading or end_section):
908
+ if (
909
+ not last
910
+ and not (show_footer and index >= len(row_cells) - 2)
911
+ and not (show_header and header_row)
912
+ ):
913
+ if leading:
914
+ yield _Segment(
915
+ _box.get_row(widths, "mid", edge=show_edge) * leading,
916
+ border_style,
917
+ )
918
+ else:
919
+ yield _Segment(
920
+ _box.get_row(widths, "row", edge=show_edge), border_style
921
+ )
922
+ yield new_line
923
+
924
+ if _box and show_edge:
925
+ yield _Segment(_box.get_bottom(widths), border_style)
926
+ yield new_line
927
+
928
+
929
+ if __name__ == "__main__": # pragma: no cover
930
+ from pip._vendor.rich.console import Console
931
+ from pip._vendor.rich.highlighter import ReprHighlighter
932
+
933
+ from ._timer import timer
934
+
935
+ with timer("Table render"):
936
+ table = Table(
937
+ title="Star Wars Movies",
938
+ caption="Rich example table",
939
+ caption_justify="right",
940
+ )
941
+
942
+ table.add_column(
943
+ "Released", header_style="bright_cyan", style="cyan", no_wrap=True
944
+ )
945
+ table.add_column("Title", style="magenta")
946
+ table.add_column("Box Office", justify="right", style="green")
947
+
948
+ table.add_row(
949
+ "Dec 20, 2019",
950
+ "Star Wars: The Rise of Skywalker",
951
+ "$952,110,690",
952
+ )
953
+ table.add_row("May 25, 2018", "Solo: A Star Wars Story", "$393,151,347")
954
+ table.add_row(
955
+ "Dec 15, 2017",
956
+ "Star Wars Ep. V111: The Last Jedi",
957
+ "$1,332,539,889",
958
+ style="on black",
959
+ end_section=True,
960
+ )
961
+ table.add_row(
962
+ "Dec 16, 2016",
963
+ "Rogue One: A Star Wars Story",
964
+ "$1,332,439,889",
965
+ )
966
+
967
+ def header(text: str) -> None:
968
+ console.print()
969
+ console.rule(highlight(text))
970
+ console.print()
971
+
972
+ console = Console()
973
+ highlight = ReprHighlighter()
974
+ header("Example Table")
975
+ console.print(table, justify="center")
976
+
977
+ table.expand = True
978
+ header("expand=True")
979
+ console.print(table)
980
+
981
+ table.width = 50
982
+ header("width=50")
983
+
984
+ console.print(table, justify="center")
985
+
986
+ table.width = None
987
+ table.expand = False
988
+ table.row_styles = ["dim", "none"]
989
+ header("row_styles=['dim', 'none']")
990
+
991
+ console.print(table, justify="center")
992
+
993
+ table.width = None
994
+ table.expand = False
995
+ table.row_styles = ["dim", "none"]
996
+ table.leading = 1
997
+ header("leading=1, row_styles=['dim', 'none']")
998
+ console.print(table, justify="center")
999
+
1000
+ table.width = None
1001
+ table.expand = False
1002
+ table.row_styles = ["dim", "none"]
1003
+ table.show_lines = True
1004
+ table.leading = 0
1005
+ header("show_lines=True, row_styles=['dim', 'none']")
1006
+ console.print(table, justify="center")
.venv/lib/python3.13/site-packages/pip/_vendor/rich/terminal_theme.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List, Optional, Tuple
2
+
3
+ from .color_triplet import ColorTriplet
4
+ from .palette import Palette
5
+
6
+ _ColorTuple = Tuple[int, int, int]
7
+
8
+
9
+ class TerminalTheme:
10
+ """A color theme used when exporting console content.
11
+
12
+ Args:
13
+ background (Tuple[int, int, int]): The background color.
14
+ foreground (Tuple[int, int, int]): The foreground (text) color.
15
+ normal (List[Tuple[int, int, int]]): A list of 8 normal intensity colors.
16
+ bright (List[Tuple[int, int, int]], optional): A list of 8 bright colors, or None
17
+ to repeat normal intensity. Defaults to None.
18
+ """
19
+
20
+ def __init__(
21
+ self,
22
+ background: _ColorTuple,
23
+ foreground: _ColorTuple,
24
+ normal: List[_ColorTuple],
25
+ bright: Optional[List[_ColorTuple]] = None,
26
+ ) -> None:
27
+ self.background_color = ColorTriplet(*background)
28
+ self.foreground_color = ColorTriplet(*foreground)
29
+ self.ansi_colors = Palette(normal + (bright or normal))
30
+
31
+
32
+ DEFAULT_TERMINAL_THEME = TerminalTheme(
33
+ (255, 255, 255),
34
+ (0, 0, 0),
35
+ [
36
+ (0, 0, 0),
37
+ (128, 0, 0),
38
+ (0, 128, 0),
39
+ (128, 128, 0),
40
+ (0, 0, 128),
41
+ (128, 0, 128),
42
+ (0, 128, 128),
43
+ (192, 192, 192),
44
+ ],
45
+ [
46
+ (128, 128, 128),
47
+ (255, 0, 0),
48
+ (0, 255, 0),
49
+ (255, 255, 0),
50
+ (0, 0, 255),
51
+ (255, 0, 255),
52
+ (0, 255, 255),
53
+ (255, 255, 255),
54
+ ],
55
+ )
56
+
57
+ MONOKAI = TerminalTheme(
58
+ (12, 12, 12),
59
+ (217, 217, 217),
60
+ [
61
+ (26, 26, 26),
62
+ (244, 0, 95),
63
+ (152, 224, 36),
64
+ (253, 151, 31),
65
+ (157, 101, 255),
66
+ (244, 0, 95),
67
+ (88, 209, 235),
68
+ (196, 197, 181),
69
+ (98, 94, 76),
70
+ ],
71
+ [
72
+ (244, 0, 95),
73
+ (152, 224, 36),
74
+ (224, 213, 97),
75
+ (157, 101, 255),
76
+ (244, 0, 95),
77
+ (88, 209, 235),
78
+ (246, 246, 239),
79
+ ],
80
+ )
81
+ DIMMED_MONOKAI = TerminalTheme(
82
+ (25, 25, 25),
83
+ (185, 188, 186),
84
+ [
85
+ (58, 61, 67),
86
+ (190, 63, 72),
87
+ (135, 154, 59),
88
+ (197, 166, 53),
89
+ (79, 118, 161),
90
+ (133, 92, 141),
91
+ (87, 143, 164),
92
+ (185, 188, 186),
93
+ (136, 137, 135),
94
+ ],
95
+ [
96
+ (251, 0, 31),
97
+ (15, 114, 47),
98
+ (196, 112, 51),
99
+ (24, 109, 227),
100
+ (251, 0, 103),
101
+ (46, 112, 109),
102
+ (253, 255, 185),
103
+ ],
104
+ )
105
+ NIGHT_OWLISH = TerminalTheme(
106
+ (255, 255, 255),
107
+ (64, 63, 83),
108
+ [
109
+ (1, 22, 39),
110
+ (211, 66, 62),
111
+ (42, 162, 152),
112
+ (218, 170, 1),
113
+ (72, 118, 214),
114
+ (64, 63, 83),
115
+ (8, 145, 106),
116
+ (122, 129, 129),
117
+ (122, 129, 129),
118
+ ],
119
+ [
120
+ (247, 110, 110),
121
+ (73, 208, 197),
122
+ (218, 194, 107),
123
+ (92, 167, 228),
124
+ (105, 112, 152),
125
+ (0, 201, 144),
126
+ (152, 159, 177),
127
+ ],
128
+ )
129
+
130
+ SVG_EXPORT_THEME = TerminalTheme(
131
+ (41, 41, 41),
132
+ (197, 200, 198),
133
+ [
134
+ (75, 78, 85),
135
+ (204, 85, 90),
136
+ (152, 168, 75),
137
+ (208, 179, 68),
138
+ (96, 138, 177),
139
+ (152, 114, 159),
140
+ (104, 160, 179),
141
+ (197, 200, 198),
142
+ (154, 155, 153),
143
+ ],
144
+ [
145
+ (255, 38, 39),
146
+ (0, 130, 61),
147
+ (208, 132, 66),
148
+ (25, 132, 233),
149
+ (255, 44, 122),
150
+ (57, 130, 128),
151
+ (253, 253, 197),
152
+ ],
153
+ )
.venv/lib/python3.13/site-packages/pip/_vendor/rich/text.py ADDED
@@ -0,0 +1,1361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from functools import partial, reduce
3
+ from math import gcd
4
+ from operator import itemgetter
5
+ from typing import (
6
+ TYPE_CHECKING,
7
+ Any,
8
+ Callable,
9
+ Dict,
10
+ Iterable,
11
+ List,
12
+ NamedTuple,
13
+ Optional,
14
+ Pattern,
15
+ Tuple,
16
+ Union,
17
+ )
18
+
19
+ from ._loop import loop_last
20
+ from ._pick import pick_bool
21
+ from ._wrap import divide_line
22
+ from .align import AlignMethod
23
+ from .cells import cell_len, set_cell_size
24
+ from .containers import Lines
25
+ from .control import strip_control_codes
26
+ from .emoji import EmojiVariant
27
+ from .jupyter import JupyterMixin
28
+ from .measure import Measurement
29
+ from .segment import Segment
30
+ from .style import Style, StyleType
31
+
32
+ if TYPE_CHECKING: # pragma: no cover
33
+ from .console import Console, ConsoleOptions, JustifyMethod, OverflowMethod
34
+
35
+ DEFAULT_JUSTIFY: "JustifyMethod" = "default"
36
+ DEFAULT_OVERFLOW: "OverflowMethod" = "fold"
37
+
38
+
39
+ _re_whitespace = re.compile(r"\s+$")
40
+
41
+ TextType = Union[str, "Text"]
42
+ """A plain string or a :class:`Text` instance."""
43
+
44
+ GetStyleCallable = Callable[[str], Optional[StyleType]]
45
+
46
+
47
+ class Span(NamedTuple):
48
+ """A marked up region in some text."""
49
+
50
+ start: int
51
+ """Span start index."""
52
+ end: int
53
+ """Span end index."""
54
+ style: Union[str, Style]
55
+ """Style associated with the span."""
56
+
57
+ def __repr__(self) -> str:
58
+ return f"Span({self.start}, {self.end}, {self.style!r})"
59
+
60
+ def __bool__(self) -> bool:
61
+ return self.end > self.start
62
+
63
+ def split(self, offset: int) -> Tuple["Span", Optional["Span"]]:
64
+ """Split a span in to 2 from a given offset."""
65
+
66
+ if offset < self.start:
67
+ return self, None
68
+ if offset >= self.end:
69
+ return self, None
70
+
71
+ start, end, style = self
72
+ span1 = Span(start, min(end, offset), style)
73
+ span2 = Span(span1.end, end, style)
74
+ return span1, span2
75
+
76
+ def move(self, offset: int) -> "Span":
77
+ """Move start and end by a given offset.
78
+
79
+ Args:
80
+ offset (int): Number of characters to add to start and end.
81
+
82
+ Returns:
83
+ TextSpan: A new TextSpan with adjusted position.
84
+ """
85
+ start, end, style = self
86
+ return Span(start + offset, end + offset, style)
87
+
88
+ def right_crop(self, offset: int) -> "Span":
89
+ """Crop the span at the given offset.
90
+
91
+ Args:
92
+ offset (int): A value between start and end.
93
+
94
+ Returns:
95
+ Span: A new (possibly smaller) span.
96
+ """
97
+ start, end, style = self
98
+ if offset >= end:
99
+ return self
100
+ return Span(start, min(offset, end), style)
101
+
102
+ def extend(self, cells: int) -> "Span":
103
+ """Extend the span by the given number of cells.
104
+
105
+ Args:
106
+ cells (int): Additional space to add to end of span.
107
+
108
+ Returns:
109
+ Span: A span.
110
+ """
111
+ if cells:
112
+ start, end, style = self
113
+ return Span(start, end + cells, style)
114
+ else:
115
+ return self
116
+
117
+
118
+ class Text(JupyterMixin):
119
+ """Text with color / style.
120
+
121
+ Args:
122
+ text (str, optional): Default unstyled text. Defaults to "".
123
+ style (Union[str, Style], optional): Base style for text. Defaults to "".
124
+ justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None.
125
+ overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None.
126
+ no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None.
127
+ end (str, optional): Character to end text with. Defaults to "\\\\n".
128
+ tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None.
129
+ spans (List[Span], optional). A list of predefined style spans. Defaults to None.
130
+ """
131
+
132
+ __slots__ = [
133
+ "_text",
134
+ "style",
135
+ "justify",
136
+ "overflow",
137
+ "no_wrap",
138
+ "end",
139
+ "tab_size",
140
+ "_spans",
141
+ "_length",
142
+ ]
143
+
144
+ def __init__(
145
+ self,
146
+ text: str = "",
147
+ style: Union[str, Style] = "",
148
+ *,
149
+ justify: Optional["JustifyMethod"] = None,
150
+ overflow: Optional["OverflowMethod"] = None,
151
+ no_wrap: Optional[bool] = None,
152
+ end: str = "\n",
153
+ tab_size: Optional[int] = None,
154
+ spans: Optional[List[Span]] = None,
155
+ ) -> None:
156
+ sanitized_text = strip_control_codes(text)
157
+ self._text = [sanitized_text]
158
+ self.style = style
159
+ self.justify: Optional["JustifyMethod"] = justify
160
+ self.overflow: Optional["OverflowMethod"] = overflow
161
+ self.no_wrap = no_wrap
162
+ self.end = end
163
+ self.tab_size = tab_size
164
+ self._spans: List[Span] = spans or []
165
+ self._length: int = len(sanitized_text)
166
+
167
+ def __len__(self) -> int:
168
+ return self._length
169
+
170
+ def __bool__(self) -> bool:
171
+ return bool(self._length)
172
+
173
+ def __str__(self) -> str:
174
+ return self.plain
175
+
176
+ def __repr__(self) -> str:
177
+ return f"<text {self.plain!r} {self._spans!r} {self.style!r}>"
178
+
179
+ def __add__(self, other: Any) -> "Text":
180
+ if isinstance(other, (str, Text)):
181
+ result = self.copy()
182
+ result.append(other)
183
+ return result
184
+ return NotImplemented
185
+
186
+ def __eq__(self, other: object) -> bool:
187
+ if not isinstance(other, Text):
188
+ return NotImplemented
189
+ return self.plain == other.plain and self._spans == other._spans
190
+
191
+ def __contains__(self, other: object) -> bool:
192
+ if isinstance(other, str):
193
+ return other in self.plain
194
+ elif isinstance(other, Text):
195
+ return other.plain in self.plain
196
+ return False
197
+
198
+ def __getitem__(self, slice: Union[int, slice]) -> "Text":
199
+ def get_text_at(offset: int) -> "Text":
200
+ _Span = Span
201
+ text = Text(
202
+ self.plain[offset],
203
+ spans=[
204
+ _Span(0, 1, style)
205
+ for start, end, style in self._spans
206
+ if end > offset >= start
207
+ ],
208
+ end="",
209
+ )
210
+ return text
211
+
212
+ if isinstance(slice, int):
213
+ return get_text_at(slice)
214
+ else:
215
+ start, stop, step = slice.indices(len(self.plain))
216
+ if step == 1:
217
+ lines = self.divide([start, stop])
218
+ return lines[1]
219
+ else:
220
+ # This would be a bit of work to implement efficiently
221
+ # For now, its not required
222
+ raise TypeError("slices with step!=1 are not supported")
223
+
224
+ @property
225
+ def cell_len(self) -> int:
226
+ """Get the number of cells required to render this text."""
227
+ return cell_len(self.plain)
228
+
229
+ @property
230
+ def markup(self) -> str:
231
+ """Get console markup to render this Text.
232
+
233
+ Returns:
234
+ str: A string potentially creating markup tags.
235
+ """
236
+ from .markup import escape
237
+
238
+ output: List[str] = []
239
+
240
+ plain = self.plain
241
+ markup_spans = [
242
+ (0, False, self.style),
243
+ *((span.start, False, span.style) for span in self._spans),
244
+ *((span.end, True, span.style) for span in self._spans),
245
+ (len(plain), True, self.style),
246
+ ]
247
+ markup_spans.sort(key=itemgetter(0, 1))
248
+ position = 0
249
+ append = output.append
250
+ for offset, closing, style in markup_spans:
251
+ if offset > position:
252
+ append(escape(plain[position:offset]))
253
+ position = offset
254
+ if style:
255
+ append(f"[/{style}]" if closing else f"[{style}]")
256
+ markup = "".join(output)
257
+ return markup
258
+
259
+ @classmethod
260
+ def from_markup(
261
+ cls,
262
+ text: str,
263
+ *,
264
+ style: Union[str, Style] = "",
265
+ emoji: bool = True,
266
+ emoji_variant: Optional[EmojiVariant] = None,
267
+ justify: Optional["JustifyMethod"] = None,
268
+ overflow: Optional["OverflowMethod"] = None,
269
+ end: str = "\n",
270
+ ) -> "Text":
271
+ """Create Text instance from markup.
272
+
273
+ Args:
274
+ text (str): A string containing console markup.
275
+ style (Union[str, Style], optional): Base style for text. Defaults to "".
276
+ emoji (bool, optional): Also render emoji code. Defaults to True.
277
+ emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None.
278
+ justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None.
279
+ overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None.
280
+ end (str, optional): Character to end text with. Defaults to "\\\\n".
281
+
282
+ Returns:
283
+ Text: A Text instance with markup rendered.
284
+ """
285
+ from .markup import render
286
+
287
+ rendered_text = render(text, style, emoji=emoji, emoji_variant=emoji_variant)
288
+ rendered_text.justify = justify
289
+ rendered_text.overflow = overflow
290
+ rendered_text.end = end
291
+ return rendered_text
292
+
293
+ @classmethod
294
+ def from_ansi(
295
+ cls,
296
+ text: str,
297
+ *,
298
+ style: Union[str, Style] = "",
299
+ justify: Optional["JustifyMethod"] = None,
300
+ overflow: Optional["OverflowMethod"] = None,
301
+ no_wrap: Optional[bool] = None,
302
+ end: str = "\n",
303
+ tab_size: Optional[int] = 8,
304
+ ) -> "Text":
305
+ """Create a Text object from a string containing ANSI escape codes.
306
+
307
+ Args:
308
+ text (str): A string containing escape codes.
309
+ style (Union[str, Style], optional): Base style for text. Defaults to "".
310
+ justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None.
311
+ overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None.
312
+ no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None.
313
+ end (str, optional): Character to end text with. Defaults to "\\\\n".
314
+ tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None.
315
+ """
316
+ from .ansi import AnsiDecoder
317
+
318
+ joiner = Text(
319
+ "\n",
320
+ justify=justify,
321
+ overflow=overflow,
322
+ no_wrap=no_wrap,
323
+ end=end,
324
+ tab_size=tab_size,
325
+ style=style,
326
+ )
327
+ decoder = AnsiDecoder()
328
+ result = joiner.join(line for line in decoder.decode(text))
329
+ return result
330
+
331
+ @classmethod
332
+ def styled(
333
+ cls,
334
+ text: str,
335
+ style: StyleType = "",
336
+ *,
337
+ justify: Optional["JustifyMethod"] = None,
338
+ overflow: Optional["OverflowMethod"] = None,
339
+ ) -> "Text":
340
+ """Construct a Text instance with a pre-applied styled. A style applied in this way won't be used
341
+ to pad the text when it is justified.
342
+
343
+ Args:
344
+ text (str): A string containing console markup.
345
+ style (Union[str, Style]): Style to apply to the text. Defaults to "".
346
+ justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None.
347
+ overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None.
348
+
349
+ Returns:
350
+ Text: A text instance with a style applied to the entire string.
351
+ """
352
+ styled_text = cls(text, justify=justify, overflow=overflow)
353
+ styled_text.stylize(style)
354
+ return styled_text
355
+
356
+ @classmethod
357
+ def assemble(
358
+ cls,
359
+ *parts: Union[str, "Text", Tuple[str, StyleType]],
360
+ style: Union[str, Style] = "",
361
+ justify: Optional["JustifyMethod"] = None,
362
+ overflow: Optional["OverflowMethod"] = None,
363
+ no_wrap: Optional[bool] = None,
364
+ end: str = "\n",
365
+ tab_size: int = 8,
366
+ meta: Optional[Dict[str, Any]] = None,
367
+ ) -> "Text":
368
+ """Construct a text instance by combining a sequence of strings with optional styles.
369
+ The positional arguments should be either strings, or a tuple of string + style.
370
+
371
+ Args:
372
+ style (Union[str, Style], optional): Base style for text. Defaults to "".
373
+ justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None.
374
+ overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None.
375
+ no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None.
376
+ end (str, optional): Character to end text with. Defaults to "\\\\n".
377
+ tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None.
378
+ meta (Dict[str, Any], optional). Meta data to apply to text, or None for no meta data. Default to None
379
+
380
+ Returns:
381
+ Text: A new text instance.
382
+ """
383
+ text = cls(
384
+ style=style,
385
+ justify=justify,
386
+ overflow=overflow,
387
+ no_wrap=no_wrap,
388
+ end=end,
389
+ tab_size=tab_size,
390
+ )
391
+ append = text.append
392
+ _Text = Text
393
+ for part in parts:
394
+ if isinstance(part, (_Text, str)):
395
+ append(part)
396
+ else:
397
+ append(*part)
398
+ if meta:
399
+ text.apply_meta(meta)
400
+ return text
401
+
402
+ @property
403
+ def plain(self) -> str:
404
+ """Get the text as a single string."""
405
+ if len(self._text) != 1:
406
+ self._text[:] = ["".join(self._text)]
407
+ return self._text[0]
408
+
409
+ @plain.setter
410
+ def plain(self, new_text: str) -> None:
411
+ """Set the text to a new value."""
412
+ if new_text != self.plain:
413
+ sanitized_text = strip_control_codes(new_text)
414
+ self._text[:] = [sanitized_text]
415
+ old_length = self._length
416
+ self._length = len(sanitized_text)
417
+ if old_length > self._length:
418
+ self._trim_spans()
419
+
420
+ @property
421
+ def spans(self) -> List[Span]:
422
+ """Get a reference to the internal list of spans."""
423
+ return self._spans
424
+
425
+ @spans.setter
426
+ def spans(self, spans: List[Span]) -> None:
427
+ """Set spans."""
428
+ self._spans = spans[:]
429
+
430
+ def blank_copy(self, plain: str = "") -> "Text":
431
+ """Return a new Text instance with copied metadata (but not the string or spans)."""
432
+ copy_self = Text(
433
+ plain,
434
+ style=self.style,
435
+ justify=self.justify,
436
+ overflow=self.overflow,
437
+ no_wrap=self.no_wrap,
438
+ end=self.end,
439
+ tab_size=self.tab_size,
440
+ )
441
+ return copy_self
442
+
443
+ def copy(self) -> "Text":
444
+ """Return a copy of this instance."""
445
+ copy_self = Text(
446
+ self.plain,
447
+ style=self.style,
448
+ justify=self.justify,
449
+ overflow=self.overflow,
450
+ no_wrap=self.no_wrap,
451
+ end=self.end,
452
+ tab_size=self.tab_size,
453
+ )
454
+ copy_self._spans[:] = self._spans
455
+ return copy_self
456
+
457
+ def stylize(
458
+ self,
459
+ style: Union[str, Style],
460
+ start: int = 0,
461
+ end: Optional[int] = None,
462
+ ) -> None:
463
+ """Apply a style to the text, or a portion of the text.
464
+
465
+ Args:
466
+ style (Union[str, Style]): Style instance or style definition to apply.
467
+ start (int): Start offset (negative indexing is supported). Defaults to 0.
468
+ end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
469
+ """
470
+ if style:
471
+ length = len(self)
472
+ if start < 0:
473
+ start = length + start
474
+ if end is None:
475
+ end = length
476
+ if end < 0:
477
+ end = length + end
478
+ if start >= length or end <= start:
479
+ # Span not in text or not valid
480
+ return
481
+ self._spans.append(Span(start, min(length, end), style))
482
+
483
+ def stylize_before(
484
+ self,
485
+ style: Union[str, Style],
486
+ start: int = 0,
487
+ end: Optional[int] = None,
488
+ ) -> None:
489
+ """Apply a style to the text, or a portion of the text. Styles will be applied before other styles already present.
490
+
491
+ Args:
492
+ style (Union[str, Style]): Style instance or style definition to apply.
493
+ start (int): Start offset (negative indexing is supported). Defaults to 0.
494
+ end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
495
+ """
496
+ if style:
497
+ length = len(self)
498
+ if start < 0:
499
+ start = length + start
500
+ if end is None:
501
+ end = length
502
+ if end < 0:
503
+ end = length + end
504
+ if start >= length or end <= start:
505
+ # Span not in text or not valid
506
+ return
507
+ self._spans.insert(0, Span(start, min(length, end), style))
508
+
509
+ def apply_meta(
510
+ self, meta: Dict[str, Any], start: int = 0, end: Optional[int] = None
511
+ ) -> None:
512
+ """Apply metadata to the text, or a portion of the text.
513
+
514
+ Args:
515
+ meta (Dict[str, Any]): A dict of meta information.
516
+ start (int): Start offset (negative indexing is supported). Defaults to 0.
517
+ end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
518
+
519
+ """
520
+ style = Style.from_meta(meta)
521
+ self.stylize(style, start=start, end=end)
522
+
523
+ def on(self, meta: Optional[Dict[str, Any]] = None, **handlers: Any) -> "Text":
524
+ """Apply event handlers (used by Textual project).
525
+
526
+ Example:
527
+ >>> from rich.text import Text
528
+ >>> text = Text("hello world")
529
+ >>> text.on(click="view.toggle('world')")
530
+
531
+ Args:
532
+ meta (Dict[str, Any]): Mapping of meta information.
533
+ **handlers: Keyword args are prefixed with "@" to defined handlers.
534
+
535
+ Returns:
536
+ Text: Self is returned to method may be chained.
537
+ """
538
+ meta = {} if meta is None else meta
539
+ meta.update({f"@{key}": value for key, value in handlers.items()})
540
+ self.stylize(Style.from_meta(meta))
541
+ return self
542
+
543
+ def remove_suffix(self, suffix: str) -> None:
544
+ """Remove a suffix if it exists.
545
+
546
+ Args:
547
+ suffix (str): Suffix to remove.
548
+ """
549
+ if self.plain.endswith(suffix):
550
+ self.right_crop(len(suffix))
551
+
552
+ def get_style_at_offset(self, console: "Console", offset: int) -> Style:
553
+ """Get the style of a character at give offset.
554
+
555
+ Args:
556
+ console (~Console): Console where text will be rendered.
557
+ offset (int): Offset in to text (negative indexing supported)
558
+
559
+ Returns:
560
+ Style: A Style instance.
561
+ """
562
+ # TODO: This is a little inefficient, it is only used by full justify
563
+ if offset < 0:
564
+ offset = len(self) + offset
565
+ get_style = console.get_style
566
+ style = get_style(self.style).copy()
567
+ for start, end, span_style in self._spans:
568
+ if end > offset >= start:
569
+ style += get_style(span_style, default="")
570
+ return style
571
+
572
+ def extend_style(self, spaces: int) -> None:
573
+ """Extend the Text given number of spaces where the spaces have the same style as the last character.
574
+
575
+ Args:
576
+ spaces (int): Number of spaces to add to the Text.
577
+ """
578
+ if spaces <= 0:
579
+ return
580
+ spans = self.spans
581
+ new_spaces = " " * spaces
582
+ if spans:
583
+ end_offset = len(self)
584
+ self._spans[:] = [
585
+ span.extend(spaces) if span.end >= end_offset else span
586
+ for span in spans
587
+ ]
588
+ self._text.append(new_spaces)
589
+ self._length += spaces
590
+ else:
591
+ self.plain += new_spaces
592
+
593
+ def highlight_regex(
594
+ self,
595
+ re_highlight: Union[Pattern[str], str],
596
+ style: Optional[Union[GetStyleCallable, StyleType]] = None,
597
+ *,
598
+ style_prefix: str = "",
599
+ ) -> int:
600
+ """Highlight text with a regular expression, where group names are
601
+ translated to styles.
602
+
603
+ Args:
604
+ re_highlight (Union[re.Pattern, str]): A regular expression object or string.
605
+ style (Union[GetStyleCallable, StyleType]): Optional style to apply to whole match, or a callable
606
+ which accepts the matched text and returns a style. Defaults to None.
607
+ style_prefix (str, optional): Optional prefix to add to style group names.
608
+
609
+ Returns:
610
+ int: Number of regex matches
611
+ """
612
+ count = 0
613
+ append_span = self._spans.append
614
+ _Span = Span
615
+ plain = self.plain
616
+ if isinstance(re_highlight, str):
617
+ re_highlight = re.compile(re_highlight)
618
+ for match in re_highlight.finditer(plain):
619
+ get_span = match.span
620
+ if style:
621
+ start, end = get_span()
622
+ match_style = style(plain[start:end]) if callable(style) else style
623
+ if match_style is not None and end > start:
624
+ append_span(_Span(start, end, match_style))
625
+
626
+ count += 1
627
+ for name in match.groupdict().keys():
628
+ start, end = get_span(name)
629
+ if start != -1 and end > start:
630
+ append_span(_Span(start, end, f"{style_prefix}{name}"))
631
+ return count
632
+
633
+ def highlight_words(
634
+ self,
635
+ words: Iterable[str],
636
+ style: Union[str, Style],
637
+ *,
638
+ case_sensitive: bool = True,
639
+ ) -> int:
640
+ """Highlight words with a style.
641
+
642
+ Args:
643
+ words (Iterable[str]): Words to highlight.
644
+ style (Union[str, Style]): Style to apply.
645
+ case_sensitive (bool, optional): Enable case sensitive matching. Defaults to True.
646
+
647
+ Returns:
648
+ int: Number of words highlighted.
649
+ """
650
+ re_words = "|".join(re.escape(word) for word in words)
651
+ add_span = self._spans.append
652
+ count = 0
653
+ _Span = Span
654
+ for match in re.finditer(
655
+ re_words, self.plain, flags=0 if case_sensitive else re.IGNORECASE
656
+ ):
657
+ start, end = match.span(0)
658
+ add_span(_Span(start, end, style))
659
+ count += 1
660
+ return count
661
+
662
+ def rstrip(self) -> None:
663
+ """Strip whitespace from end of text."""
664
+ self.plain = self.plain.rstrip()
665
+
666
+ def rstrip_end(self, size: int) -> None:
667
+ """Remove whitespace beyond a certain width at the end of the text.
668
+
669
+ Args:
670
+ size (int): The desired size of the text.
671
+ """
672
+ text_length = len(self)
673
+ if text_length > size:
674
+ excess = text_length - size
675
+ whitespace_match = _re_whitespace.search(self.plain)
676
+ if whitespace_match is not None:
677
+ whitespace_count = len(whitespace_match.group(0))
678
+ self.right_crop(min(whitespace_count, excess))
679
+
680
+ def set_length(self, new_length: int) -> None:
681
+ """Set new length of the text, clipping or padding is required."""
682
+ length = len(self)
683
+ if length != new_length:
684
+ if length < new_length:
685
+ self.pad_right(new_length - length)
686
+ else:
687
+ self.right_crop(length - new_length)
688
+
689
+ def __rich_console__(
690
+ self, console: "Console", options: "ConsoleOptions"
691
+ ) -> Iterable[Segment]:
692
+ tab_size: int = console.tab_size if self.tab_size is None else self.tab_size
693
+ justify = self.justify or options.justify or DEFAULT_JUSTIFY
694
+
695
+ overflow = self.overflow or options.overflow or DEFAULT_OVERFLOW
696
+
697
+ lines = self.wrap(
698
+ console,
699
+ options.max_width,
700
+ justify=justify,
701
+ overflow=overflow,
702
+ tab_size=tab_size or 8,
703
+ no_wrap=pick_bool(self.no_wrap, options.no_wrap, False),
704
+ )
705
+ all_lines = Text("\n").join(lines)
706
+ yield from all_lines.render(console, end=self.end)
707
+
708
+ def __rich_measure__(
709
+ self, console: "Console", options: "ConsoleOptions"
710
+ ) -> Measurement:
711
+ text = self.plain
712
+ lines = text.splitlines()
713
+ max_text_width = max(cell_len(line) for line in lines) if lines else 0
714
+ words = text.split()
715
+ min_text_width = (
716
+ max(cell_len(word) for word in words) if words else max_text_width
717
+ )
718
+ return Measurement(min_text_width, max_text_width)
719
+
720
+ def render(self, console: "Console", end: str = "") -> Iterable["Segment"]:
721
+ """Render the text as Segments.
722
+
723
+ Args:
724
+ console (Console): Console instance.
725
+ end (Optional[str], optional): Optional end character.
726
+
727
+ Returns:
728
+ Iterable[Segment]: Result of render that may be written to the console.
729
+ """
730
+ _Segment = Segment
731
+ text = self.plain
732
+ if not self._spans:
733
+ yield Segment(text)
734
+ if end:
735
+ yield _Segment(end)
736
+ return
737
+ get_style = partial(console.get_style, default=Style.null())
738
+
739
+ enumerated_spans = list(enumerate(self._spans, 1))
740
+ style_map = {index: get_style(span.style) for index, span in enumerated_spans}
741
+ style_map[0] = get_style(self.style)
742
+
743
+ spans = [
744
+ (0, False, 0),
745
+ *((span.start, False, index) for index, span in enumerated_spans),
746
+ *((span.end, True, index) for index, span in enumerated_spans),
747
+ (len(text), True, 0),
748
+ ]
749
+ spans.sort(key=itemgetter(0, 1))
750
+
751
+ stack: List[int] = []
752
+ stack_append = stack.append
753
+ stack_pop = stack.remove
754
+
755
+ style_cache: Dict[Tuple[Style, ...], Style] = {}
756
+ style_cache_get = style_cache.get
757
+ combine = Style.combine
758
+
759
+ def get_current_style() -> Style:
760
+ """Construct current style from stack."""
761
+ styles = tuple(style_map[_style_id] for _style_id in sorted(stack))
762
+ cached_style = style_cache_get(styles)
763
+ if cached_style is not None:
764
+ return cached_style
765
+ current_style = combine(styles)
766
+ style_cache[styles] = current_style
767
+ return current_style
768
+
769
+ for (offset, leaving, style_id), (next_offset, _, _) in zip(spans, spans[1:]):
770
+ if leaving:
771
+ stack_pop(style_id)
772
+ else:
773
+ stack_append(style_id)
774
+ if next_offset > offset:
775
+ yield _Segment(text[offset:next_offset], get_current_style())
776
+ if end:
777
+ yield _Segment(end)
778
+
779
+ def join(self, lines: Iterable["Text"]) -> "Text":
780
+ """Join text together with this instance as the separator.
781
+
782
+ Args:
783
+ lines (Iterable[Text]): An iterable of Text instances to join.
784
+
785
+ Returns:
786
+ Text: A new text instance containing join text.
787
+ """
788
+
789
+ new_text = self.blank_copy()
790
+
791
+ def iter_text() -> Iterable["Text"]:
792
+ if self.plain:
793
+ for last, line in loop_last(lines):
794
+ yield line
795
+ if not last:
796
+ yield self
797
+ else:
798
+ yield from lines
799
+
800
+ extend_text = new_text._text.extend
801
+ append_span = new_text._spans.append
802
+ extend_spans = new_text._spans.extend
803
+ offset = 0
804
+ _Span = Span
805
+
806
+ for text in iter_text():
807
+ extend_text(text._text)
808
+ if text.style:
809
+ append_span(_Span(offset, offset + len(text), text.style))
810
+ extend_spans(
811
+ _Span(offset + start, offset + end, style)
812
+ for start, end, style in text._spans
813
+ )
814
+ offset += len(text)
815
+ new_text._length = offset
816
+ return new_text
817
+
818
+ def expand_tabs(self, tab_size: Optional[int] = None) -> None:
819
+ """Converts tabs to spaces.
820
+
821
+ Args:
822
+ tab_size (int, optional): Size of tabs. Defaults to 8.
823
+
824
+ """
825
+ if "\t" not in self.plain:
826
+ return
827
+ if tab_size is None:
828
+ tab_size = self.tab_size
829
+ if tab_size is None:
830
+ tab_size = 8
831
+
832
+ new_text: List[Text] = []
833
+ append = new_text.append
834
+
835
+ for line in self.split("\n", include_separator=True):
836
+ if "\t" not in line.plain:
837
+ append(line)
838
+ else:
839
+ cell_position = 0
840
+ parts = line.split("\t", include_separator=True)
841
+ for part in parts:
842
+ if part.plain.endswith("\t"):
843
+ part._text[-1] = part._text[-1][:-1] + " "
844
+ cell_position += part.cell_len
845
+ tab_remainder = cell_position % tab_size
846
+ if tab_remainder:
847
+ spaces = tab_size - tab_remainder
848
+ part.extend_style(spaces)
849
+ cell_position += spaces
850
+ else:
851
+ cell_position += part.cell_len
852
+ append(part)
853
+
854
+ result = Text("").join(new_text)
855
+
856
+ self._text = [result.plain]
857
+ self._length = len(self.plain)
858
+ self._spans[:] = result._spans
859
+
860
+ def truncate(
861
+ self,
862
+ max_width: int,
863
+ *,
864
+ overflow: Optional["OverflowMethod"] = None,
865
+ pad: bool = False,
866
+ ) -> None:
867
+ """Truncate text if it is longer that a given width.
868
+
869
+ Args:
870
+ max_width (int): Maximum number of characters in text.
871
+ overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None, to use self.overflow.
872
+ pad (bool, optional): Pad with spaces if the length is less than max_width. Defaults to False.
873
+ """
874
+ _overflow = overflow or self.overflow or DEFAULT_OVERFLOW
875
+ if _overflow != "ignore":
876
+ length = cell_len(self.plain)
877
+ if length > max_width:
878
+ if _overflow == "ellipsis":
879
+ self.plain = set_cell_size(self.plain, max_width - 1) + "…"
880
+ else:
881
+ self.plain = set_cell_size(self.plain, max_width)
882
+ if pad and length < max_width:
883
+ spaces = max_width - length
884
+ self._text = [f"{self.plain}{' ' * spaces}"]
885
+ self._length = len(self.plain)
886
+
887
+ def _trim_spans(self) -> None:
888
+ """Remove or modify any spans that are over the end of the text."""
889
+ max_offset = len(self.plain)
890
+ _Span = Span
891
+ self._spans[:] = [
892
+ (
893
+ span
894
+ if span.end < max_offset
895
+ else _Span(span.start, min(max_offset, span.end), span.style)
896
+ )
897
+ for span in self._spans
898
+ if span.start < max_offset
899
+ ]
900
+
901
+ def pad(self, count: int, character: str = " ") -> None:
902
+ """Pad left and right with a given number of characters.
903
+
904
+ Args:
905
+ count (int): Width of padding.
906
+ character (str): The character to pad with. Must be a string of length 1.
907
+ """
908
+ assert len(character) == 1, "Character must be a string of length 1"
909
+ if count:
910
+ pad_characters = character * count
911
+ self.plain = f"{pad_characters}{self.plain}{pad_characters}"
912
+ _Span = Span
913
+ self._spans[:] = [
914
+ _Span(start + count, end + count, style)
915
+ for start, end, style in self._spans
916
+ ]
917
+
918
+ def pad_left(self, count: int, character: str = " ") -> None:
919
+ """Pad the left with a given character.
920
+
921
+ Args:
922
+ count (int): Number of characters to pad.
923
+ character (str, optional): Character to pad with. Defaults to " ".
924
+ """
925
+ assert len(character) == 1, "Character must be a string of length 1"
926
+ if count:
927
+ self.plain = f"{character * count}{self.plain}"
928
+ _Span = Span
929
+ self._spans[:] = [
930
+ _Span(start + count, end + count, style)
931
+ for start, end, style in self._spans
932
+ ]
933
+
934
+ def pad_right(self, count: int, character: str = " ") -> None:
935
+ """Pad the right with a given character.
936
+
937
+ Args:
938
+ count (int): Number of characters to pad.
939
+ character (str, optional): Character to pad with. Defaults to " ".
940
+ """
941
+ assert len(character) == 1, "Character must be a string of length 1"
942
+ if count:
943
+ self.plain = f"{self.plain}{character * count}"
944
+
945
+ def align(self, align: AlignMethod, width: int, character: str = " ") -> None:
946
+ """Align text to a given width.
947
+
948
+ Args:
949
+ align (AlignMethod): One of "left", "center", or "right".
950
+ width (int): Desired width.
951
+ character (str, optional): Character to pad with. Defaults to " ".
952
+ """
953
+ self.truncate(width)
954
+ excess_space = width - cell_len(self.plain)
955
+ if excess_space:
956
+ if align == "left":
957
+ self.pad_right(excess_space, character)
958
+ elif align == "center":
959
+ left = excess_space // 2
960
+ self.pad_left(left, character)
961
+ self.pad_right(excess_space - left, character)
962
+ else:
963
+ self.pad_left(excess_space, character)
964
+
965
+ def append(
966
+ self, text: Union["Text", str], style: Optional[Union[str, "Style"]] = None
967
+ ) -> "Text":
968
+ """Add text with an optional style.
969
+
970
+ Args:
971
+ text (Union[Text, str]): A str or Text to append.
972
+ style (str, optional): A style name. Defaults to None.
973
+
974
+ Returns:
975
+ Text: Returns self for chaining.
976
+ """
977
+
978
+ if not isinstance(text, (str, Text)):
979
+ raise TypeError("Only str or Text can be appended to Text")
980
+
981
+ if len(text):
982
+ if isinstance(text, str):
983
+ sanitized_text = strip_control_codes(text)
984
+ self._text.append(sanitized_text)
985
+ offset = len(self)
986
+ text_length = len(sanitized_text)
987
+ if style:
988
+ self._spans.append(Span(offset, offset + text_length, style))
989
+ self._length += text_length
990
+ elif isinstance(text, Text):
991
+ _Span = Span
992
+ if style is not None:
993
+ raise ValueError(
994
+ "style must not be set when appending Text instance"
995
+ )
996
+ text_length = self._length
997
+ if text.style:
998
+ self._spans.append(
999
+ _Span(text_length, text_length + len(text), text.style)
1000
+ )
1001
+ self._text.append(text.plain)
1002
+ self._spans.extend(
1003
+ _Span(start + text_length, end + text_length, style)
1004
+ for start, end, style in text._spans.copy()
1005
+ )
1006
+ self._length += len(text)
1007
+ return self
1008
+
1009
+ def append_text(self, text: "Text") -> "Text":
1010
+ """Append another Text instance. This method is more performant that Text.append, but
1011
+ only works for Text.
1012
+
1013
+ Args:
1014
+ text (Text): The Text instance to append to this instance.
1015
+
1016
+ Returns:
1017
+ Text: Returns self for chaining.
1018
+ """
1019
+ _Span = Span
1020
+ text_length = self._length
1021
+ if text.style:
1022
+ self._spans.append(_Span(text_length, text_length + len(text), text.style))
1023
+ self._text.append(text.plain)
1024
+ self._spans.extend(
1025
+ _Span(start + text_length, end + text_length, style)
1026
+ for start, end, style in text._spans.copy()
1027
+ )
1028
+ self._length += len(text)
1029
+ return self
1030
+
1031
+ def append_tokens(
1032
+ self, tokens: Iterable[Tuple[str, Optional[StyleType]]]
1033
+ ) -> "Text":
1034
+ """Append iterable of str and style. Style may be a Style instance or a str style definition.
1035
+
1036
+ Args:
1037
+ tokens (Iterable[Tuple[str, Optional[StyleType]]]): An iterable of tuples containing str content and style.
1038
+
1039
+ Returns:
1040
+ Text: Returns self for chaining.
1041
+ """
1042
+ append_text = self._text.append
1043
+ append_span = self._spans.append
1044
+ _Span = Span
1045
+ offset = len(self)
1046
+ for content, style in tokens:
1047
+ content = strip_control_codes(content)
1048
+ append_text(content)
1049
+ if style:
1050
+ append_span(_Span(offset, offset + len(content), style))
1051
+ offset += len(content)
1052
+ self._length = offset
1053
+ return self
1054
+
1055
+ def copy_styles(self, text: "Text") -> None:
1056
+ """Copy styles from another Text instance.
1057
+
1058
+ Args:
1059
+ text (Text): A Text instance to copy styles from, must be the same length.
1060
+ """
1061
+ self._spans.extend(text._spans)
1062
+
1063
+ def split(
1064
+ self,
1065
+ separator: str = "\n",
1066
+ *,
1067
+ include_separator: bool = False,
1068
+ allow_blank: bool = False,
1069
+ ) -> Lines:
1070
+ """Split rich text in to lines, preserving styles.
1071
+
1072
+ Args:
1073
+ separator (str, optional): String to split on. Defaults to "\\\\n".
1074
+ include_separator (bool, optional): Include the separator in the lines. Defaults to False.
1075
+ allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.
1076
+
1077
+ Returns:
1078
+ List[RichText]: A list of rich text, one per line of the original.
1079
+ """
1080
+ assert separator, "separator must not be empty"
1081
+
1082
+ text = self.plain
1083
+ if separator not in text:
1084
+ return Lines([self.copy()])
1085
+
1086
+ if include_separator:
1087
+ lines = self.divide(
1088
+ match.end() for match in re.finditer(re.escape(separator), text)
1089
+ )
1090
+ else:
1091
+
1092
+ def flatten_spans() -> Iterable[int]:
1093
+ for match in re.finditer(re.escape(separator), text):
1094
+ start, end = match.span()
1095
+ yield start
1096
+ yield end
1097
+
1098
+ lines = Lines(
1099
+ line for line in self.divide(flatten_spans()) if line.plain != separator
1100
+ )
1101
+
1102
+ if not allow_blank and text.endswith(separator):
1103
+ lines.pop()
1104
+
1105
+ return lines
1106
+
1107
+ def divide(self, offsets: Iterable[int]) -> Lines:
1108
+ """Divide text in to a number of lines at given offsets.
1109
+
1110
+ Args:
1111
+ offsets (Iterable[int]): Offsets used to divide text.
1112
+
1113
+ Returns:
1114
+ Lines: New RichText instances between offsets.
1115
+ """
1116
+ _offsets = list(offsets)
1117
+
1118
+ if not _offsets:
1119
+ return Lines([self.copy()])
1120
+
1121
+ text = self.plain
1122
+ text_length = len(text)
1123
+ divide_offsets = [0, *_offsets, text_length]
1124
+ line_ranges = list(zip(divide_offsets, divide_offsets[1:]))
1125
+
1126
+ style = self.style
1127
+ justify = self.justify
1128
+ overflow = self.overflow
1129
+ _Text = Text
1130
+ new_lines = Lines(
1131
+ _Text(
1132
+ text[start:end],
1133
+ style=style,
1134
+ justify=justify,
1135
+ overflow=overflow,
1136
+ )
1137
+ for start, end in line_ranges
1138
+ )
1139
+ if not self._spans:
1140
+ return new_lines
1141
+
1142
+ _line_appends = [line._spans.append for line in new_lines._lines]
1143
+ line_count = len(line_ranges)
1144
+ _Span = Span
1145
+
1146
+ for span_start, span_end, style in self._spans:
1147
+ lower_bound = 0
1148
+ upper_bound = line_count
1149
+ start_line_no = (lower_bound + upper_bound) // 2
1150
+
1151
+ while True:
1152
+ line_start, line_end = line_ranges[start_line_no]
1153
+ if span_start < line_start:
1154
+ upper_bound = start_line_no - 1
1155
+ elif span_start > line_end:
1156
+ lower_bound = start_line_no + 1
1157
+ else:
1158
+ break
1159
+ start_line_no = (lower_bound + upper_bound) // 2
1160
+
1161
+ if span_end < line_end:
1162
+ end_line_no = start_line_no
1163
+ else:
1164
+ end_line_no = lower_bound = start_line_no
1165
+ upper_bound = line_count
1166
+
1167
+ while True:
1168
+ line_start, line_end = line_ranges[end_line_no]
1169
+ if span_end < line_start:
1170
+ upper_bound = end_line_no - 1
1171
+ elif span_end > line_end:
1172
+ lower_bound = end_line_no + 1
1173
+ else:
1174
+ break
1175
+ end_line_no = (lower_bound + upper_bound) // 2
1176
+
1177
+ for line_no in range(start_line_no, end_line_no + 1):
1178
+ line_start, line_end = line_ranges[line_no]
1179
+ new_start = max(0, span_start - line_start)
1180
+ new_end = min(span_end - line_start, line_end - line_start)
1181
+ if new_end > new_start:
1182
+ _line_appends[line_no](_Span(new_start, new_end, style))
1183
+
1184
+ return new_lines
1185
+
1186
+ def right_crop(self, amount: int = 1) -> None:
1187
+ """Remove a number of characters from the end of the text."""
1188
+ max_offset = len(self.plain) - amount
1189
+ _Span = Span
1190
+ self._spans[:] = [
1191
+ (
1192
+ span
1193
+ if span.end < max_offset
1194
+ else _Span(span.start, min(max_offset, span.end), span.style)
1195
+ )
1196
+ for span in self._spans
1197
+ if span.start < max_offset
1198
+ ]
1199
+ self._text = [self.plain[:-amount]]
1200
+ self._length -= amount
1201
+
1202
+ def wrap(
1203
+ self,
1204
+ console: "Console",
1205
+ width: int,
1206
+ *,
1207
+ justify: Optional["JustifyMethod"] = None,
1208
+ overflow: Optional["OverflowMethod"] = None,
1209
+ tab_size: int = 8,
1210
+ no_wrap: Optional[bool] = None,
1211
+ ) -> Lines:
1212
+ """Word wrap the text.
1213
+
1214
+ Args:
1215
+ console (Console): Console instance.
1216
+ width (int): Number of cells available per line.
1217
+ justify (str, optional): Justify method: "default", "left", "center", "full", "right". Defaults to "default".
1218
+ overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
1219
+ tab_size (int, optional): Default tab size. Defaults to 8.
1220
+ no_wrap (bool, optional): Disable wrapping, Defaults to False.
1221
+
1222
+ Returns:
1223
+ Lines: Number of lines.
1224
+ """
1225
+ wrap_justify = justify or self.justify or DEFAULT_JUSTIFY
1226
+ wrap_overflow = overflow or self.overflow or DEFAULT_OVERFLOW
1227
+
1228
+ no_wrap = pick_bool(no_wrap, self.no_wrap, False) or overflow == "ignore"
1229
+
1230
+ lines = Lines()
1231
+ for line in self.split(allow_blank=True):
1232
+ if "\t" in line:
1233
+ line.expand_tabs(tab_size)
1234
+ if no_wrap:
1235
+ new_lines = Lines([line])
1236
+ else:
1237
+ offsets = divide_line(str(line), width, fold=wrap_overflow == "fold")
1238
+ new_lines = line.divide(offsets)
1239
+ for line in new_lines:
1240
+ line.rstrip_end(width)
1241
+ if wrap_justify:
1242
+ new_lines.justify(
1243
+ console, width, justify=wrap_justify, overflow=wrap_overflow
1244
+ )
1245
+ for line in new_lines:
1246
+ line.truncate(width, overflow=wrap_overflow)
1247
+ lines.extend(new_lines)
1248
+ return lines
1249
+
1250
+ def fit(self, width: int) -> Lines:
1251
+ """Fit the text in to given width by chopping in to lines.
1252
+
1253
+ Args:
1254
+ width (int): Maximum characters in a line.
1255
+
1256
+ Returns:
1257
+ Lines: Lines container.
1258
+ """
1259
+ lines: Lines = Lines()
1260
+ append = lines.append
1261
+ for line in self.split():
1262
+ line.set_length(width)
1263
+ append(line)
1264
+ return lines
1265
+
1266
+ def detect_indentation(self) -> int:
1267
+ """Auto-detect indentation of code.
1268
+
1269
+ Returns:
1270
+ int: Number of spaces used to indent code.
1271
+ """
1272
+
1273
+ _indentations = {
1274
+ len(match.group(1))
1275
+ for match in re.finditer(r"^( *)(.*)$", self.plain, flags=re.MULTILINE)
1276
+ }
1277
+
1278
+ try:
1279
+ indentation = (
1280
+ reduce(gcd, [indent for indent in _indentations if not indent % 2]) or 1
1281
+ )
1282
+ except TypeError:
1283
+ indentation = 1
1284
+
1285
+ return indentation
1286
+
1287
+ def with_indent_guides(
1288
+ self,
1289
+ indent_size: Optional[int] = None,
1290
+ *,
1291
+ character: str = "│",
1292
+ style: StyleType = "dim green",
1293
+ ) -> "Text":
1294
+ """Adds indent guide lines to text.
1295
+
1296
+ Args:
1297
+ indent_size (Optional[int]): Size of indentation, or None to auto detect. Defaults to None.
1298
+ character (str, optional): Character to use for indentation. Defaults to "│".
1299
+ style (Union[Style, str], optional): Style of indent guides.
1300
+
1301
+ Returns:
1302
+ Text: New text with indentation guides.
1303
+ """
1304
+
1305
+ _indent_size = self.detect_indentation() if indent_size is None else indent_size
1306
+
1307
+ text = self.copy()
1308
+ text.expand_tabs()
1309
+ indent_line = f"{character}{' ' * (_indent_size - 1)}"
1310
+
1311
+ re_indent = re.compile(r"^( *)(.*)$")
1312
+ new_lines: List[Text] = []
1313
+ add_line = new_lines.append
1314
+ blank_lines = 0
1315
+ for line in text.split(allow_blank=True):
1316
+ match = re_indent.match(line.plain)
1317
+ if not match or not match.group(2):
1318
+ blank_lines += 1
1319
+ continue
1320
+ indent = match.group(1)
1321
+ full_indents, remaining_space = divmod(len(indent), _indent_size)
1322
+ new_indent = f"{indent_line * full_indents}{' ' * remaining_space}"
1323
+ line.plain = new_indent + line.plain[len(new_indent) :]
1324
+ line.stylize(style, 0, len(new_indent))
1325
+ if blank_lines:
1326
+ new_lines.extend([Text(new_indent, style=style)] * blank_lines)
1327
+ blank_lines = 0
1328
+ add_line(line)
1329
+ if blank_lines:
1330
+ new_lines.extend([Text("", style=style)] * blank_lines)
1331
+
1332
+ new_text = text.blank_copy("\n").join(new_lines)
1333
+ return new_text
1334
+
1335
+
1336
+ if __name__ == "__main__": # pragma: no cover
1337
+ from pip._vendor.rich.console import Console
1338
+
1339
+ text = Text(
1340
+ """\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n"""
1341
+ )
1342
+ text.highlight_words(["Lorem"], "bold")
1343
+ text.highlight_words(["ipsum"], "italic")
1344
+
1345
+ console = Console()
1346
+
1347
+ console.rule("justify='left'")
1348
+ console.print(text, style="red")
1349
+ console.print()
1350
+
1351
+ console.rule("justify='center'")
1352
+ console.print(text, style="green", justify="center")
1353
+ console.print()
1354
+
1355
+ console.rule("justify='right'")
1356
+ console.print(text, style="blue", justify="right")
1357
+ console.print()
1358
+
1359
+ console.rule("justify='full'")
1360
+ console.print(text, style="magenta", justify="full")
1361
+ console.print()
.venv/lib/python3.13/site-packages/pip/_vendor/rich/theme.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import configparser
2
+ from typing import IO, Dict, List, Mapping, Optional
3
+
4
+ from .default_styles import DEFAULT_STYLES
5
+ from .style import Style, StyleType
6
+
7
+
8
+ class Theme:
9
+ """A container for style information, used by :class:`~rich.console.Console`.
10
+
11
+ Args:
12
+ styles (Dict[str, Style], optional): A mapping of style names on to styles. Defaults to None for a theme with no styles.
13
+ inherit (bool, optional): Inherit default styles. Defaults to True.
14
+ """
15
+
16
+ styles: Dict[str, Style]
17
+
18
+ def __init__(
19
+ self, styles: Optional[Mapping[str, StyleType]] = None, inherit: bool = True
20
+ ):
21
+ self.styles = DEFAULT_STYLES.copy() if inherit else {}
22
+ if styles is not None:
23
+ self.styles.update(
24
+ {
25
+ name: style if isinstance(style, Style) else Style.parse(style)
26
+ for name, style in styles.items()
27
+ }
28
+ )
29
+
30
+ @property
31
+ def config(self) -> str:
32
+ """Get contents of a config file for this theme."""
33
+ config = "[styles]\n" + "\n".join(
34
+ f"{name} = {style}" for name, style in sorted(self.styles.items())
35
+ )
36
+ return config
37
+
38
+ @classmethod
39
+ def from_file(
40
+ cls, config_file: IO[str], source: Optional[str] = None, inherit: bool = True
41
+ ) -> "Theme":
42
+ """Load a theme from a text mode file.
43
+
44
+ Args:
45
+ config_file (IO[str]): An open conf file.
46
+ source (str, optional): The filename of the open file. Defaults to None.
47
+ inherit (bool, optional): Inherit default styles. Defaults to True.
48
+
49
+ Returns:
50
+ Theme: A New theme instance.
51
+ """
52
+ config = configparser.ConfigParser()
53
+ config.read_file(config_file, source=source)
54
+ styles = {name: Style.parse(value) for name, value in config.items("styles")}
55
+ theme = Theme(styles, inherit=inherit)
56
+ return theme
57
+
58
+ @classmethod
59
+ def read(
60
+ cls, path: str, inherit: bool = True, encoding: Optional[str] = None
61
+ ) -> "Theme":
62
+ """Read a theme from a path.
63
+
64
+ Args:
65
+ path (str): Path to a config file readable by Python configparser module.
66
+ inherit (bool, optional): Inherit default styles. Defaults to True.
67
+ encoding (str, optional): Encoding of the config file. Defaults to None.
68
+
69
+ Returns:
70
+ Theme: A new theme instance.
71
+ """
72
+ with open(path, encoding=encoding) as config_file:
73
+ return cls.from_file(config_file, source=path, inherit=inherit)
74
+
75
+
76
+ class ThemeStackError(Exception):
77
+ """Base exception for errors related to the theme stack."""
78
+
79
+
80
+ class ThemeStack:
81
+ """A stack of themes.
82
+
83
+ Args:
84
+ theme (Theme): A theme instance
85
+ """
86
+
87
+ def __init__(self, theme: Theme) -> None:
88
+ self._entries: List[Dict[str, Style]] = [theme.styles]
89
+ self.get = self._entries[-1].get
90
+
91
+ def push_theme(self, theme: Theme, inherit: bool = True) -> None:
92
+ """Push a theme on the top of the stack.
93
+
94
+ Args:
95
+ theme (Theme): A Theme instance.
96
+ inherit (boolean, optional): Inherit styles from current top of stack.
97
+ """
98
+ styles: Dict[str, Style]
99
+ styles = (
100
+ {**self._entries[-1], **theme.styles} if inherit else theme.styles.copy()
101
+ )
102
+ self._entries.append(styles)
103
+ self.get = self._entries[-1].get
104
+
105
+ def pop_theme(self) -> None:
106
+ """Pop (and discard) the top-most theme."""
107
+ if len(self._entries) == 1:
108
+ raise ThemeStackError("Unable to pop base theme")
109
+ self._entries.pop()
110
+ self.get = self._entries[-1].get
111
+
112
+
113
+ if __name__ == "__main__": # pragma: no cover
114
+ theme = Theme()
115
+ print(theme.config)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/themes.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from .default_styles import DEFAULT_STYLES
2
+ from .theme import Theme
3
+
4
+
5
+ DEFAULT = Theme(DEFAULT_STYLES)
.venv/lib/python3.13/site-packages/pip/_vendor/rich/traceback.py ADDED
@@ -0,0 +1,884 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import inspect
2
+ import linecache
3
+ import os
4
+ import sys
5
+ from dataclasses import dataclass, field
6
+ from itertools import islice
7
+ from traceback import walk_tb
8
+ from types import ModuleType, TracebackType
9
+ from typing import (
10
+ Any,
11
+ Callable,
12
+ Dict,
13
+ Iterable,
14
+ List,
15
+ Optional,
16
+ Sequence,
17
+ Tuple,
18
+ Type,
19
+ Union,
20
+ )
21
+
22
+ from pip._vendor.pygments.lexers import guess_lexer_for_filename
23
+ from pip._vendor.pygments.token import Comment, Keyword, Name, Number, Operator, String
24
+ from pip._vendor.pygments.token import Text as TextToken
25
+ from pip._vendor.pygments.token import Token
26
+ from pip._vendor.pygments.util import ClassNotFound
27
+
28
+ from . import pretty
29
+ from ._loop import loop_first_last, loop_last
30
+ from .columns import Columns
31
+ from .console import (
32
+ Console,
33
+ ConsoleOptions,
34
+ ConsoleRenderable,
35
+ Group,
36
+ RenderResult,
37
+ group,
38
+ )
39
+ from .constrain import Constrain
40
+ from .highlighter import RegexHighlighter, ReprHighlighter
41
+ from .panel import Panel
42
+ from .scope import render_scope
43
+ from .style import Style
44
+ from .syntax import Syntax, SyntaxPosition
45
+ from .text import Text
46
+ from .theme import Theme
47
+
48
+ WINDOWS = sys.platform == "win32"
49
+
50
+ LOCALS_MAX_LENGTH = 10
51
+ LOCALS_MAX_STRING = 80
52
+
53
+
54
+ def _iter_syntax_lines(
55
+ start: SyntaxPosition, end: SyntaxPosition
56
+ ) -> Iterable[Tuple[int, int, int]]:
57
+ """Yield start and end positions per line.
58
+
59
+ Args:
60
+ start: Start position.
61
+ end: End position.
62
+
63
+ Returns:
64
+ Iterable of (LINE, COLUMN1, COLUMN2).
65
+ """
66
+
67
+ line1, column1 = start
68
+ line2, column2 = end
69
+
70
+ if line1 == line2:
71
+ yield line1, column1, column2
72
+ else:
73
+ for first, last, line_no in loop_first_last(range(line1, line2 + 1)):
74
+ if first:
75
+ yield line_no, column1, -1
76
+ elif last:
77
+ yield line_no, 0, column2
78
+ else:
79
+ yield line_no, 0, -1
80
+
81
+
82
+ def install(
83
+ *,
84
+ console: Optional[Console] = None,
85
+ width: Optional[int] = 100,
86
+ code_width: Optional[int] = 88,
87
+ extra_lines: int = 3,
88
+ theme: Optional[str] = None,
89
+ word_wrap: bool = False,
90
+ show_locals: bool = False,
91
+ locals_max_length: int = LOCALS_MAX_LENGTH,
92
+ locals_max_string: int = LOCALS_MAX_STRING,
93
+ locals_hide_dunder: bool = True,
94
+ locals_hide_sunder: Optional[bool] = None,
95
+ indent_guides: bool = True,
96
+ suppress: Iterable[Union[str, ModuleType]] = (),
97
+ max_frames: int = 100,
98
+ ) -> Callable[[Type[BaseException], BaseException, Optional[TracebackType]], Any]:
99
+ """Install a rich traceback handler.
100
+
101
+ Once installed, any tracebacks will be printed with syntax highlighting and rich formatting.
102
+
103
+
104
+ Args:
105
+ console (Optional[Console], optional): Console to write exception to. Default uses internal Console instance.
106
+ width (Optional[int], optional): Width (in characters) of traceback. Defaults to 100.
107
+ code_width (Optional[int], optional): Code width (in characters) of traceback. Defaults to 88.
108
+ extra_lines (int, optional): Extra lines of code. Defaults to 3.
109
+ theme (Optional[str], optional): Pygments theme to use in traceback. Defaults to ``None`` which will pick
110
+ a theme appropriate for the platform.
111
+ word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
112
+ show_locals (bool, optional): Enable display of local variables. Defaults to False.
113
+ locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
114
+ Defaults to 10.
115
+ locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
116
+ locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
117
+ locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
118
+ indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
119
+ suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
120
+
121
+ Returns:
122
+ Callable: The previous exception handler that was replaced.
123
+
124
+ """
125
+ traceback_console = Console(stderr=True) if console is None else console
126
+
127
+ locals_hide_sunder = (
128
+ True
129
+ if (traceback_console.is_jupyter and locals_hide_sunder is None)
130
+ else locals_hide_sunder
131
+ )
132
+
133
+ def excepthook(
134
+ type_: Type[BaseException],
135
+ value: BaseException,
136
+ traceback: Optional[TracebackType],
137
+ ) -> None:
138
+ exception_traceback = Traceback.from_exception(
139
+ type_,
140
+ value,
141
+ traceback,
142
+ width=width,
143
+ code_width=code_width,
144
+ extra_lines=extra_lines,
145
+ theme=theme,
146
+ word_wrap=word_wrap,
147
+ show_locals=show_locals,
148
+ locals_max_length=locals_max_length,
149
+ locals_max_string=locals_max_string,
150
+ locals_hide_dunder=locals_hide_dunder,
151
+ locals_hide_sunder=bool(locals_hide_sunder),
152
+ indent_guides=indent_guides,
153
+ suppress=suppress,
154
+ max_frames=max_frames,
155
+ )
156
+ traceback_console.print(exception_traceback)
157
+
158
+ def ipy_excepthook_closure(ip: Any) -> None: # pragma: no cover
159
+ tb_data = {} # store information about showtraceback call
160
+ default_showtraceback = ip.showtraceback # keep reference of default traceback
161
+
162
+ def ipy_show_traceback(*args: Any, **kwargs: Any) -> None:
163
+ """wrap the default ip.showtraceback to store info for ip._showtraceback"""
164
+ nonlocal tb_data
165
+ tb_data = kwargs
166
+ default_showtraceback(*args, **kwargs)
167
+
168
+ def ipy_display_traceback(
169
+ *args: Any, is_syntax: bool = False, **kwargs: Any
170
+ ) -> None:
171
+ """Internally called traceback from ip._showtraceback"""
172
+ nonlocal tb_data
173
+ exc_tuple = ip._get_exc_info()
174
+
175
+ # do not display trace on syntax error
176
+ tb: Optional[TracebackType] = None if is_syntax else exc_tuple[2]
177
+
178
+ # determine correct tb_offset
179
+ compiled = tb_data.get("running_compiled_code", False)
180
+ tb_offset = tb_data.get("tb_offset", 1 if compiled else 0)
181
+ # remove ipython internal frames from trace with tb_offset
182
+ for _ in range(tb_offset):
183
+ if tb is None:
184
+ break
185
+ tb = tb.tb_next
186
+
187
+ excepthook(exc_tuple[0], exc_tuple[1], tb)
188
+ tb_data = {} # clear data upon usage
189
+
190
+ # replace _showtraceback instead of showtraceback to allow ipython features such as debugging to work
191
+ # this is also what the ipython docs recommends to modify when subclassing InteractiveShell
192
+ ip._showtraceback = ipy_display_traceback
193
+ # add wrapper to capture tb_data
194
+ ip.showtraceback = ipy_show_traceback
195
+ ip.showsyntaxerror = lambda *args, **kwargs: ipy_display_traceback(
196
+ *args, is_syntax=True, **kwargs
197
+ )
198
+
199
+ try: # pragma: no cover
200
+ # if within ipython, use customized traceback
201
+ ip = get_ipython() # type: ignore[name-defined]
202
+ ipy_excepthook_closure(ip)
203
+ return sys.excepthook
204
+ except Exception:
205
+ # otherwise use default system hook
206
+ old_excepthook = sys.excepthook
207
+ sys.excepthook = excepthook
208
+ return old_excepthook
209
+
210
+
211
+ @dataclass
212
+ class Frame:
213
+ filename: str
214
+ lineno: int
215
+ name: str
216
+ line: str = ""
217
+ locals: Optional[Dict[str, pretty.Node]] = None
218
+ last_instruction: Optional[Tuple[Tuple[int, int], Tuple[int, int]]] = None
219
+
220
+
221
+ @dataclass
222
+ class _SyntaxError:
223
+ offset: int
224
+ filename: str
225
+ line: str
226
+ lineno: int
227
+ msg: str
228
+ notes: List[str] = field(default_factory=list)
229
+
230
+
231
+ @dataclass
232
+ class Stack:
233
+ exc_type: str
234
+ exc_value: str
235
+ syntax_error: Optional[_SyntaxError] = None
236
+ is_cause: bool = False
237
+ frames: List[Frame] = field(default_factory=list)
238
+ notes: List[str] = field(default_factory=list)
239
+ is_group: bool = False
240
+ exceptions: List["Trace"] = field(default_factory=list)
241
+
242
+
243
+ @dataclass
244
+ class Trace:
245
+ stacks: List[Stack]
246
+
247
+
248
+ class PathHighlighter(RegexHighlighter):
249
+ highlights = [r"(?P<dim>.*/)(?P<bold>.+)"]
250
+
251
+
252
+ class Traceback:
253
+ """A Console renderable that renders a traceback.
254
+
255
+ Args:
256
+ trace (Trace, optional): A `Trace` object produced from `extract`. Defaults to None, which uses
257
+ the last exception.
258
+ width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
259
+ code_width (Optional[int], optional): Number of code characters used to traceback. Defaults to 88.
260
+ extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
261
+ theme (str, optional): Override pygments theme used in traceback.
262
+ word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
263
+ show_locals (bool, optional): Enable display of local variables. Defaults to False.
264
+ indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
265
+ locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
266
+ Defaults to 10.
267
+ locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
268
+ locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
269
+ locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
270
+ suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
271
+ max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
272
+
273
+ """
274
+
275
+ LEXERS = {
276
+ "": "text",
277
+ ".py": "python",
278
+ ".pxd": "cython",
279
+ ".pyx": "cython",
280
+ ".pxi": "pyrex",
281
+ }
282
+
283
+ def __init__(
284
+ self,
285
+ trace: Optional[Trace] = None,
286
+ *,
287
+ width: Optional[int] = 100,
288
+ code_width: Optional[int] = 88,
289
+ extra_lines: int = 3,
290
+ theme: Optional[str] = None,
291
+ word_wrap: bool = False,
292
+ show_locals: bool = False,
293
+ locals_max_length: int = LOCALS_MAX_LENGTH,
294
+ locals_max_string: int = LOCALS_MAX_STRING,
295
+ locals_hide_dunder: bool = True,
296
+ locals_hide_sunder: bool = False,
297
+ indent_guides: bool = True,
298
+ suppress: Iterable[Union[str, ModuleType]] = (),
299
+ max_frames: int = 100,
300
+ ):
301
+ if trace is None:
302
+ exc_type, exc_value, traceback = sys.exc_info()
303
+ if exc_type is None or exc_value is None or traceback is None:
304
+ raise ValueError(
305
+ "Value for 'trace' required if not called in except: block"
306
+ )
307
+ trace = self.extract(
308
+ exc_type, exc_value, traceback, show_locals=show_locals
309
+ )
310
+ self.trace = trace
311
+ self.width = width
312
+ self.code_width = code_width
313
+ self.extra_lines = extra_lines
314
+ self.theme = Syntax.get_theme(theme or "ansi_dark")
315
+ self.word_wrap = word_wrap
316
+ self.show_locals = show_locals
317
+ self.indent_guides = indent_guides
318
+ self.locals_max_length = locals_max_length
319
+ self.locals_max_string = locals_max_string
320
+ self.locals_hide_dunder = locals_hide_dunder
321
+ self.locals_hide_sunder = locals_hide_sunder
322
+
323
+ self.suppress: Sequence[str] = []
324
+ for suppress_entity in suppress:
325
+ if not isinstance(suppress_entity, str):
326
+ assert (
327
+ suppress_entity.__file__ is not None
328
+ ), f"{suppress_entity!r} must be a module with '__file__' attribute"
329
+ path = os.path.dirname(suppress_entity.__file__)
330
+ else:
331
+ path = suppress_entity
332
+ path = os.path.normpath(os.path.abspath(path))
333
+ self.suppress.append(path)
334
+ self.max_frames = max(4, max_frames) if max_frames > 0 else 0
335
+
336
+ @classmethod
337
+ def from_exception(
338
+ cls,
339
+ exc_type: Type[Any],
340
+ exc_value: BaseException,
341
+ traceback: Optional[TracebackType],
342
+ *,
343
+ width: Optional[int] = 100,
344
+ code_width: Optional[int] = 88,
345
+ extra_lines: int = 3,
346
+ theme: Optional[str] = None,
347
+ word_wrap: bool = False,
348
+ show_locals: bool = False,
349
+ locals_max_length: int = LOCALS_MAX_LENGTH,
350
+ locals_max_string: int = LOCALS_MAX_STRING,
351
+ locals_hide_dunder: bool = True,
352
+ locals_hide_sunder: bool = False,
353
+ indent_guides: bool = True,
354
+ suppress: Iterable[Union[str, ModuleType]] = (),
355
+ max_frames: int = 100,
356
+ ) -> "Traceback":
357
+ """Create a traceback from exception info
358
+
359
+ Args:
360
+ exc_type (Type[BaseException]): Exception type.
361
+ exc_value (BaseException): Exception value.
362
+ traceback (TracebackType): Python Traceback object.
363
+ width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
364
+ code_width (Optional[int], optional): Number of code characters used to traceback. Defaults to 88.
365
+ extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
366
+ theme (str, optional): Override pygments theme used in traceback.
367
+ word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
368
+ show_locals (bool, optional): Enable display of local variables. Defaults to False.
369
+ indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
370
+ locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
371
+ Defaults to 10.
372
+ locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
373
+ locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
374
+ locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
375
+ suppress (Iterable[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
376
+ max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
377
+
378
+ Returns:
379
+ Traceback: A Traceback instance that may be printed.
380
+ """
381
+ rich_traceback = cls.extract(
382
+ exc_type,
383
+ exc_value,
384
+ traceback,
385
+ show_locals=show_locals,
386
+ locals_max_length=locals_max_length,
387
+ locals_max_string=locals_max_string,
388
+ locals_hide_dunder=locals_hide_dunder,
389
+ locals_hide_sunder=locals_hide_sunder,
390
+ )
391
+
392
+ return cls(
393
+ rich_traceback,
394
+ width=width,
395
+ code_width=code_width,
396
+ extra_lines=extra_lines,
397
+ theme=theme,
398
+ word_wrap=word_wrap,
399
+ show_locals=show_locals,
400
+ indent_guides=indent_guides,
401
+ locals_max_length=locals_max_length,
402
+ locals_max_string=locals_max_string,
403
+ locals_hide_dunder=locals_hide_dunder,
404
+ locals_hide_sunder=locals_hide_sunder,
405
+ suppress=suppress,
406
+ max_frames=max_frames,
407
+ )
408
+
409
+ @classmethod
410
+ def extract(
411
+ cls,
412
+ exc_type: Type[BaseException],
413
+ exc_value: BaseException,
414
+ traceback: Optional[TracebackType],
415
+ *,
416
+ show_locals: bool = False,
417
+ locals_max_length: int = LOCALS_MAX_LENGTH,
418
+ locals_max_string: int = LOCALS_MAX_STRING,
419
+ locals_hide_dunder: bool = True,
420
+ locals_hide_sunder: bool = False,
421
+ ) -> Trace:
422
+ """Extract traceback information.
423
+
424
+ Args:
425
+ exc_type (Type[BaseException]): Exception type.
426
+ exc_value (BaseException): Exception value.
427
+ traceback (TracebackType): Python Traceback object.
428
+ show_locals (bool, optional): Enable display of local variables. Defaults to False.
429
+ locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
430
+ Defaults to 10.
431
+ locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
432
+ locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
433
+ locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
434
+
435
+ Returns:
436
+ Trace: A Trace instance which you can use to construct a `Traceback`.
437
+ """
438
+
439
+ stacks: List[Stack] = []
440
+ is_cause = False
441
+
442
+ from pip._vendor.rich import _IMPORT_CWD
443
+
444
+ notes: List[str] = getattr(exc_value, "__notes__", None) or []
445
+
446
+ def safe_str(_object: Any) -> str:
447
+ """Don't allow exceptions from __str__ to propagate."""
448
+ try:
449
+ return str(_object)
450
+ except Exception:
451
+ return "<exception str() failed>"
452
+
453
+ while True:
454
+ stack = Stack(
455
+ exc_type=safe_str(exc_type.__name__),
456
+ exc_value=safe_str(exc_value),
457
+ is_cause=is_cause,
458
+ notes=notes,
459
+ )
460
+
461
+ if sys.version_info >= (3, 11):
462
+ if isinstance(exc_value, (BaseExceptionGroup, ExceptionGroup)):
463
+ stack.is_group = True
464
+ for exception in exc_value.exceptions:
465
+ stack.exceptions.append(
466
+ Traceback.extract(
467
+ type(exception),
468
+ exception,
469
+ exception.__traceback__,
470
+ show_locals=show_locals,
471
+ locals_max_length=locals_max_length,
472
+ locals_hide_dunder=locals_hide_dunder,
473
+ locals_hide_sunder=locals_hide_sunder,
474
+ )
475
+ )
476
+
477
+ if isinstance(exc_value, SyntaxError):
478
+ stack.syntax_error = _SyntaxError(
479
+ offset=exc_value.offset or 0,
480
+ filename=exc_value.filename or "?",
481
+ lineno=exc_value.lineno or 0,
482
+ line=exc_value.text or "",
483
+ msg=exc_value.msg,
484
+ notes=notes,
485
+ )
486
+
487
+ stacks.append(stack)
488
+ append = stack.frames.append
489
+
490
+ def get_locals(
491
+ iter_locals: Iterable[Tuple[str, object]],
492
+ ) -> Iterable[Tuple[str, object]]:
493
+ """Extract locals from an iterator of key pairs."""
494
+ if not (locals_hide_dunder or locals_hide_sunder):
495
+ yield from iter_locals
496
+ return
497
+ for key, value in iter_locals:
498
+ if locals_hide_dunder and key.startswith("__"):
499
+ continue
500
+ if locals_hide_sunder and key.startswith("_"):
501
+ continue
502
+ yield key, value
503
+
504
+ for frame_summary, line_no in walk_tb(traceback):
505
+ filename = frame_summary.f_code.co_filename
506
+
507
+ last_instruction: Optional[Tuple[Tuple[int, int], Tuple[int, int]]]
508
+ last_instruction = None
509
+ if sys.version_info >= (3, 11):
510
+ instruction_index = frame_summary.f_lasti // 2
511
+ instruction_position = next(
512
+ islice(
513
+ frame_summary.f_code.co_positions(),
514
+ instruction_index,
515
+ instruction_index + 1,
516
+ )
517
+ )
518
+ (
519
+ start_line,
520
+ end_line,
521
+ start_column,
522
+ end_column,
523
+ ) = instruction_position
524
+ if (
525
+ start_line is not None
526
+ and end_line is not None
527
+ and start_column is not None
528
+ and end_column is not None
529
+ ):
530
+ last_instruction = (
531
+ (start_line, start_column),
532
+ (end_line, end_column),
533
+ )
534
+
535
+ if filename and not filename.startswith("<"):
536
+ if not os.path.isabs(filename):
537
+ filename = os.path.join(_IMPORT_CWD, filename)
538
+ if frame_summary.f_locals.get("_rich_traceback_omit", False):
539
+ continue
540
+
541
+ frame = Frame(
542
+ filename=filename or "?",
543
+ lineno=line_no,
544
+ name=frame_summary.f_code.co_name,
545
+ locals=(
546
+ {
547
+ key: pretty.traverse(
548
+ value,
549
+ max_length=locals_max_length,
550
+ max_string=locals_max_string,
551
+ )
552
+ for key, value in get_locals(frame_summary.f_locals.items())
553
+ if not (inspect.isfunction(value) or inspect.isclass(value))
554
+ }
555
+ if show_locals
556
+ else None
557
+ ),
558
+ last_instruction=last_instruction,
559
+ )
560
+ append(frame)
561
+ if frame_summary.f_locals.get("_rich_traceback_guard", False):
562
+ del stack.frames[:]
563
+
564
+ cause = getattr(exc_value, "__cause__", None)
565
+ if cause:
566
+ exc_type = cause.__class__
567
+ exc_value = cause
568
+ # __traceback__ can be None, e.g. for exceptions raised by the
569
+ # 'multiprocessing' module
570
+ traceback = cause.__traceback__
571
+ is_cause = True
572
+ continue
573
+
574
+ cause = exc_value.__context__
575
+ if cause and not getattr(exc_value, "__suppress_context__", False):
576
+ exc_type = cause.__class__
577
+ exc_value = cause
578
+ traceback = cause.__traceback__
579
+ is_cause = False
580
+ continue
581
+ # No cover, code is reached but coverage doesn't recognize it.
582
+ break # pragma: no cover
583
+
584
+ trace = Trace(stacks=stacks)
585
+
586
+ return trace
587
+
588
+ def __rich_console__(
589
+ self, console: Console, options: ConsoleOptions
590
+ ) -> RenderResult:
591
+ theme = self.theme
592
+ background_style = theme.get_background_style()
593
+ token_style = theme.get_style_for_token
594
+
595
+ traceback_theme = Theme(
596
+ {
597
+ "pretty": token_style(TextToken),
598
+ "pygments.text": token_style(Token),
599
+ "pygments.string": token_style(String),
600
+ "pygments.function": token_style(Name.Function),
601
+ "pygments.number": token_style(Number),
602
+ "repr.indent": token_style(Comment) + Style(dim=True),
603
+ "repr.str": token_style(String),
604
+ "repr.brace": token_style(TextToken) + Style(bold=True),
605
+ "repr.number": token_style(Number),
606
+ "repr.bool_true": token_style(Keyword.Constant),
607
+ "repr.bool_false": token_style(Keyword.Constant),
608
+ "repr.none": token_style(Keyword.Constant),
609
+ "scope.border": token_style(String.Delimiter),
610
+ "scope.equals": token_style(Operator),
611
+ "scope.key": token_style(Name),
612
+ "scope.key.special": token_style(Name.Constant) + Style(dim=True),
613
+ },
614
+ inherit=False,
615
+ )
616
+
617
+ highlighter = ReprHighlighter()
618
+
619
+ @group()
620
+ def render_stack(stack: Stack, last: bool) -> RenderResult:
621
+ if stack.frames:
622
+ stack_renderable: ConsoleRenderable = Panel(
623
+ self._render_stack(stack),
624
+ title="[traceback.title]Traceback [dim](most recent call last)",
625
+ style=background_style,
626
+ border_style="traceback.border",
627
+ expand=True,
628
+ padding=(0, 1),
629
+ )
630
+ stack_renderable = Constrain(stack_renderable, self.width)
631
+ with console.use_theme(traceback_theme):
632
+ yield stack_renderable
633
+
634
+ if stack.syntax_error is not None:
635
+ with console.use_theme(traceback_theme):
636
+ yield Constrain(
637
+ Panel(
638
+ self._render_syntax_error(stack.syntax_error),
639
+ style=background_style,
640
+ border_style="traceback.border.syntax_error",
641
+ expand=True,
642
+ padding=(0, 1),
643
+ width=self.width,
644
+ ),
645
+ self.width,
646
+ )
647
+ yield Text.assemble(
648
+ (f"{stack.exc_type}: ", "traceback.exc_type"),
649
+ highlighter(stack.syntax_error.msg),
650
+ )
651
+ elif stack.exc_value:
652
+ yield Text.assemble(
653
+ (f"{stack.exc_type}: ", "traceback.exc_type"),
654
+ highlighter(stack.exc_value),
655
+ )
656
+ else:
657
+ yield Text.assemble((f"{stack.exc_type}", "traceback.exc_type"))
658
+
659
+ for note in stack.notes:
660
+ yield Text.assemble(("[NOTE] ", "traceback.note"), highlighter(note))
661
+
662
+ if stack.is_group:
663
+ for group_no, group_exception in enumerate(stack.exceptions, 1):
664
+ grouped_exceptions: List[Group] = []
665
+ for group_last, group_stack in loop_last(group_exception.stacks):
666
+ grouped_exceptions.append(render_stack(group_stack, group_last))
667
+ yield ""
668
+ yield Constrain(
669
+ Panel(
670
+ Group(*grouped_exceptions),
671
+ title=f"Sub-exception #{group_no}",
672
+ border_style="traceback.group.border",
673
+ ),
674
+ self.width,
675
+ )
676
+
677
+ if not last:
678
+ if stack.is_cause:
679
+ yield Text.from_markup(
680
+ "\n[i]The above exception was the direct cause of the following exception:\n",
681
+ )
682
+ else:
683
+ yield Text.from_markup(
684
+ "\n[i]During handling of the above exception, another exception occurred:\n",
685
+ )
686
+
687
+ for last, stack in loop_last(reversed(self.trace.stacks)):
688
+ yield render_stack(stack, last)
689
+
690
+ @group()
691
+ def _render_syntax_error(self, syntax_error: _SyntaxError) -> RenderResult:
692
+ highlighter = ReprHighlighter()
693
+ path_highlighter = PathHighlighter()
694
+ if syntax_error.filename != "<stdin>":
695
+ if os.path.exists(syntax_error.filename):
696
+ text = Text.assemble(
697
+ (f" {syntax_error.filename}", "pygments.string"),
698
+ (":", "pygments.text"),
699
+ (str(syntax_error.lineno), "pygments.number"),
700
+ style="pygments.text",
701
+ )
702
+ yield path_highlighter(text)
703
+ syntax_error_text = highlighter(syntax_error.line.rstrip())
704
+ syntax_error_text.no_wrap = True
705
+ offset = min(syntax_error.offset - 1, len(syntax_error_text))
706
+ syntax_error_text.stylize("bold underline", offset, offset)
707
+ syntax_error_text += Text.from_markup(
708
+ "\n" + " " * offset + "[traceback.offset]▲[/]",
709
+ style="pygments.text",
710
+ )
711
+ yield syntax_error_text
712
+
713
+ @classmethod
714
+ def _guess_lexer(cls, filename: str, code: str) -> str:
715
+ ext = os.path.splitext(filename)[-1]
716
+ if not ext:
717
+ # No extension, look at first line to see if it is a hashbang
718
+ # Note, this is an educated guess and not a guarantee
719
+ # If it fails, the only downside is that the code is highlighted strangely
720
+ new_line_index = code.index("\n")
721
+ first_line = code[:new_line_index] if new_line_index != -1 else code
722
+ if first_line.startswith("#!") and "python" in first_line.lower():
723
+ return "python"
724
+ try:
725
+ return cls.LEXERS.get(ext) or guess_lexer_for_filename(filename, code).name
726
+ except ClassNotFound:
727
+ return "text"
728
+
729
+ @group()
730
+ def _render_stack(self, stack: Stack) -> RenderResult:
731
+ path_highlighter = PathHighlighter()
732
+ theme = self.theme
733
+
734
+ def render_locals(frame: Frame) -> Iterable[ConsoleRenderable]:
735
+ if frame.locals:
736
+ yield render_scope(
737
+ frame.locals,
738
+ title="locals",
739
+ indent_guides=self.indent_guides,
740
+ max_length=self.locals_max_length,
741
+ max_string=self.locals_max_string,
742
+ )
743
+
744
+ exclude_frames: Optional[range] = None
745
+ if self.max_frames != 0:
746
+ exclude_frames = range(
747
+ self.max_frames // 2,
748
+ len(stack.frames) - self.max_frames // 2,
749
+ )
750
+
751
+ excluded = False
752
+ for frame_index, frame in enumerate(stack.frames):
753
+ if exclude_frames and frame_index in exclude_frames:
754
+ excluded = True
755
+ continue
756
+
757
+ if excluded:
758
+ assert exclude_frames is not None
759
+ yield Text(
760
+ f"\n... {len(exclude_frames)} frames hidden ...",
761
+ justify="center",
762
+ style="traceback.error",
763
+ )
764
+ excluded = False
765
+
766
+ first = frame_index == 0
767
+ frame_filename = frame.filename
768
+ suppressed = any(frame_filename.startswith(path) for path in self.suppress)
769
+
770
+ if os.path.exists(frame.filename):
771
+ text = Text.assemble(
772
+ path_highlighter(Text(frame.filename, style="pygments.string")),
773
+ (":", "pygments.text"),
774
+ (str(frame.lineno), "pygments.number"),
775
+ " in ",
776
+ (frame.name, "pygments.function"),
777
+ style="pygments.text",
778
+ )
779
+ else:
780
+ text = Text.assemble(
781
+ "in ",
782
+ (frame.name, "pygments.function"),
783
+ (":", "pygments.text"),
784
+ (str(frame.lineno), "pygments.number"),
785
+ style="pygments.text",
786
+ )
787
+ if not frame.filename.startswith("<") and not first:
788
+ yield ""
789
+ yield text
790
+ if frame.filename.startswith("<"):
791
+ yield from render_locals(frame)
792
+ continue
793
+ if not suppressed:
794
+ try:
795
+ code_lines = linecache.getlines(frame.filename)
796
+ code = "".join(code_lines)
797
+ if not code:
798
+ # code may be an empty string if the file doesn't exist, OR
799
+ # if the traceback filename is generated dynamically
800
+ continue
801
+ lexer_name = self._guess_lexer(frame.filename, code)
802
+ syntax = Syntax(
803
+ code,
804
+ lexer_name,
805
+ theme=theme,
806
+ line_numbers=True,
807
+ line_range=(
808
+ frame.lineno - self.extra_lines,
809
+ frame.lineno + self.extra_lines,
810
+ ),
811
+ highlight_lines={frame.lineno},
812
+ word_wrap=self.word_wrap,
813
+ code_width=self.code_width,
814
+ indent_guides=self.indent_guides,
815
+ dedent=False,
816
+ )
817
+ yield ""
818
+ except Exception as error:
819
+ yield Text.assemble(
820
+ (f"\n{error}", "traceback.error"),
821
+ )
822
+ else:
823
+ if frame.last_instruction is not None:
824
+ start, end = frame.last_instruction
825
+
826
+ # Stylize a line at a time
827
+ # So that indentation isn't underlined (which looks bad)
828
+ for line1, column1, column2 in _iter_syntax_lines(start, end):
829
+ try:
830
+ if column1 == 0:
831
+ line = code_lines[line1 - 1]
832
+ column1 = len(line) - len(line.lstrip())
833
+ if column2 == -1:
834
+ column2 = len(code_lines[line1 - 1])
835
+ except IndexError:
836
+ # Being defensive here
837
+ # If last_instruction reports a line out-of-bounds, we don't want to crash
838
+ continue
839
+
840
+ syntax.stylize_range(
841
+ style="traceback.error_range",
842
+ start=(line1, column1),
843
+ end=(line1, column2),
844
+ )
845
+ yield (
846
+ Columns(
847
+ [
848
+ syntax,
849
+ *render_locals(frame),
850
+ ],
851
+ padding=1,
852
+ )
853
+ if frame.locals
854
+ else syntax
855
+ )
856
+
857
+
858
+ if __name__ == "__main__": # pragma: no cover
859
+ install(show_locals=True)
860
+ import sys
861
+
862
+ def bar(
863
+ a: Any,
864
+ ) -> None: # 这是对亚洲语言支持的测试。面对模棱两可的想法,拒绝猜测的诱惑
865
+ one = 1
866
+ print(one / a)
867
+
868
+ def foo(a: Any) -> None:
869
+ _rich_traceback_guard = True
870
+ zed = {
871
+ "characters": {
872
+ "Paul Atreides",
873
+ "Vladimir Harkonnen",
874
+ "Thufir Hawat",
875
+ "Duncan Idaho",
876
+ },
877
+ "atomic_types": (None, False, True),
878
+ }
879
+ bar(a)
880
+
881
+ def error() -> None:
882
+ foo(0)
883
+
884
+ error()
.venv/lib/python3.13/site-packages/pip/_vendor/rich/tree.py ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Iterator, List, Optional, Tuple
2
+
3
+ from ._loop import loop_first, loop_last
4
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
5
+ from .jupyter import JupyterMixin
6
+ from .measure import Measurement
7
+ from .segment import Segment
8
+ from .style import Style, StyleStack, StyleType
9
+ from .styled import Styled
10
+
11
+ GuideType = Tuple[str, str, str, str]
12
+
13
+
14
+ class Tree(JupyterMixin):
15
+ """A renderable for a tree structure.
16
+
17
+ Attributes:
18
+ ASCII_GUIDES (GuideType): Guide lines used when Console.ascii_only is True.
19
+ TREE_GUIDES (List[GuideType, GuideType, GuideType]): Default guide lines.
20
+
21
+ Args:
22
+ label (RenderableType): The renderable or str for the tree label.
23
+ style (StyleType, optional): Style of this tree. Defaults to "tree".
24
+ guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line".
25
+ expanded (bool, optional): Also display children. Defaults to True.
26
+ highlight (bool, optional): Highlight renderable (if str). Defaults to False.
27
+ hide_root (bool, optional): Hide the root node. Defaults to False.
28
+ """
29
+
30
+ ASCII_GUIDES = (" ", "| ", "+-- ", "`-- ")
31
+ TREE_GUIDES = [
32
+ (" ", "│ ", "├── ", "└── "),
33
+ (" ", "┃ ", "┣━━ ", "┗━━ "),
34
+ (" ", "║ ", "╠══ ", "╚══ "),
35
+ ]
36
+
37
+ def __init__(
38
+ self,
39
+ label: RenderableType,
40
+ *,
41
+ style: StyleType = "tree",
42
+ guide_style: StyleType = "tree.line",
43
+ expanded: bool = True,
44
+ highlight: bool = False,
45
+ hide_root: bool = False,
46
+ ) -> None:
47
+ self.label = label
48
+ self.style = style
49
+ self.guide_style = guide_style
50
+ self.children: List[Tree] = []
51
+ self.expanded = expanded
52
+ self.highlight = highlight
53
+ self.hide_root = hide_root
54
+
55
+ def add(
56
+ self,
57
+ label: RenderableType,
58
+ *,
59
+ style: Optional[StyleType] = None,
60
+ guide_style: Optional[StyleType] = None,
61
+ expanded: bool = True,
62
+ highlight: Optional[bool] = False,
63
+ ) -> "Tree":
64
+ """Add a child tree.
65
+
66
+ Args:
67
+ label (RenderableType): The renderable or str for the tree label.
68
+ style (StyleType, optional): Style of this tree. Defaults to "tree".
69
+ guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line".
70
+ expanded (bool, optional): Also display children. Defaults to True.
71
+ highlight (Optional[bool], optional): Highlight renderable (if str). Defaults to False.
72
+
73
+ Returns:
74
+ Tree: A new child Tree, which may be further modified.
75
+ """
76
+ node = Tree(
77
+ label,
78
+ style=self.style if style is None else style,
79
+ guide_style=self.guide_style if guide_style is None else guide_style,
80
+ expanded=expanded,
81
+ highlight=self.highlight if highlight is None else highlight,
82
+ )
83
+ self.children.append(node)
84
+ return node
85
+
86
+ def __rich_console__(
87
+ self, console: "Console", options: "ConsoleOptions"
88
+ ) -> "RenderResult":
89
+ stack: List[Iterator[Tuple[bool, Tree]]] = []
90
+ pop = stack.pop
91
+ push = stack.append
92
+ new_line = Segment.line()
93
+
94
+ get_style = console.get_style
95
+ null_style = Style.null()
96
+ guide_style = get_style(self.guide_style, default="") or null_style
97
+ SPACE, CONTINUE, FORK, END = range(4)
98
+
99
+ _Segment = Segment
100
+
101
+ def make_guide(index: int, style: Style) -> Segment:
102
+ """Make a Segment for a level of the guide lines."""
103
+ if options.ascii_only:
104
+ line = self.ASCII_GUIDES[index]
105
+ else:
106
+ guide = 1 if style.bold else (2 if style.underline2 else 0)
107
+ line = self.TREE_GUIDES[0 if options.legacy_windows else guide][index]
108
+ return _Segment(line, style)
109
+
110
+ levels: List[Segment] = [make_guide(CONTINUE, guide_style)]
111
+ push(iter(loop_last([self])))
112
+
113
+ guide_style_stack = StyleStack(get_style(self.guide_style))
114
+ style_stack = StyleStack(get_style(self.style))
115
+ remove_guide_styles = Style(bold=False, underline2=False)
116
+
117
+ depth = 0
118
+
119
+ while stack:
120
+ stack_node = pop()
121
+ try:
122
+ last, node = next(stack_node)
123
+ except StopIteration:
124
+ levels.pop()
125
+ if levels:
126
+ guide_style = levels[-1].style or null_style
127
+ levels[-1] = make_guide(FORK, guide_style)
128
+ guide_style_stack.pop()
129
+ style_stack.pop()
130
+ continue
131
+ push(stack_node)
132
+ if last:
133
+ levels[-1] = make_guide(END, levels[-1].style or null_style)
134
+
135
+ guide_style = guide_style_stack.current + get_style(node.guide_style)
136
+ style = style_stack.current + get_style(node.style)
137
+ prefix = levels[(2 if self.hide_root else 1) :]
138
+ renderable_lines = console.render_lines(
139
+ Styled(node.label, style),
140
+ options.update(
141
+ width=options.max_width
142
+ - sum(level.cell_length for level in prefix),
143
+ highlight=self.highlight,
144
+ height=None,
145
+ ),
146
+ pad=options.justify is not None,
147
+ )
148
+
149
+ if not (depth == 0 and self.hide_root):
150
+ for first, line in loop_first(renderable_lines):
151
+ if prefix:
152
+ yield from _Segment.apply_style(
153
+ prefix,
154
+ style.background_style,
155
+ post_style=remove_guide_styles,
156
+ )
157
+ yield from line
158
+ yield new_line
159
+ if first and prefix:
160
+ prefix[-1] = make_guide(
161
+ SPACE if last else CONTINUE, prefix[-1].style or null_style
162
+ )
163
+
164
+ if node.expanded and node.children:
165
+ levels[-1] = make_guide(
166
+ SPACE if last else CONTINUE, levels[-1].style or null_style
167
+ )
168
+ levels.append(
169
+ make_guide(END if len(node.children) == 1 else FORK, guide_style)
170
+ )
171
+ style_stack.push(get_style(node.style))
172
+ guide_style_stack.push(get_style(node.guide_style))
173
+ push(iter(loop_last(node.children)))
174
+ depth += 1
175
+
176
+ def __rich_measure__(
177
+ self, console: "Console", options: "ConsoleOptions"
178
+ ) -> "Measurement":
179
+ stack: List[Iterator[Tree]] = [iter([self])]
180
+ pop = stack.pop
181
+ push = stack.append
182
+ minimum = 0
183
+ maximum = 0
184
+ measure = Measurement.get
185
+ level = 0
186
+ while stack:
187
+ iter_tree = pop()
188
+ try:
189
+ tree = next(iter_tree)
190
+ except StopIteration:
191
+ level -= 1
192
+ continue
193
+ push(iter_tree)
194
+ min_measure, max_measure = measure(console, options, tree.label)
195
+ indent = level * 4
196
+ minimum = max(min_measure + indent, minimum)
197
+ maximum = max(max_measure + indent, maximum)
198
+ if tree.expanded and tree.children:
199
+ push(iter(tree.children))
200
+ level += 1
201
+ return Measurement(minimum, maximum)
202
+
203
+
204
+ if __name__ == "__main__": # pragma: no cover
205
+ from pip._vendor.rich.console import Group
206
+ from pip._vendor.rich.markdown import Markdown
207
+ from pip._vendor.rich.panel import Panel
208
+ from pip._vendor.rich.syntax import Syntax
209
+ from pip._vendor.rich.table import Table
210
+
211
+ table = Table(row_styles=["", "dim"])
212
+
213
+ table.add_column("Released", style="cyan", no_wrap=True)
214
+ table.add_column("Title", style="magenta")
215
+ table.add_column("Box Office", justify="right", style="green")
216
+
217
+ table.add_row("Dec 20, 2019", "Star Wars: The Rise of Skywalker", "$952,110,690")
218
+ table.add_row("May 25, 2018", "Solo: A Star Wars Story", "$393,151,347")
219
+ table.add_row("Dec 15, 2017", "Star Wars Ep. V111: The Last Jedi", "$1,332,539,889")
220
+ table.add_row("Dec 16, 2016", "Rogue One: A Star Wars Story", "$1,332,439,889")
221
+
222
+ code = """\
223
+ class Segment(NamedTuple):
224
+ text: str = ""
225
+ style: Optional[Style] = None
226
+ is_control: bool = False
227
+ """
228
+ syntax = Syntax(code, "python", theme="monokai", line_numbers=True)
229
+
230
+ markdown = Markdown(
231
+ """\
232
+ ### example.md
233
+ > Hello, World!
234
+ >
235
+ > Markdown _all_ the things
236
+ """
237
+ )
238
+
239
+ root = Tree("🌲 [b green]Rich Tree", highlight=True, hide_root=True)
240
+
241
+ node = root.add(":file_folder: Renderables", guide_style="red")
242
+ simple_node = node.add(":file_folder: [bold yellow]Atomic", guide_style="uu green")
243
+ simple_node.add(Group("📄 Syntax", syntax))
244
+ simple_node.add(Group("📄 Markdown", Panel(markdown, border_style="green")))
245
+
246
+ containers_node = node.add(
247
+ ":file_folder: [bold magenta]Containers", guide_style="bold magenta"
248
+ )
249
+ containers_node.expanded = True
250
+ panel = Panel.fit("Just a panel", border_style="red")
251
+ containers_node.add(Group("📄 Panels", panel))
252
+
253
+ containers_node.add(Group("📄 [b magenta]Table", table))
254
+
255
+ console = Console()
256
+
257
+ console.print(root)
.venv/lib/python3.13/site-packages/pip/_vendor/tomli/__init__.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ __all__ = ("loads", "load", "TOMLDecodeError")
6
+ __version__ = "2.2.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
7
+
8
+ from ._parser import TOMLDecodeError, load, loads
.venv/lib/python3.13/site-packages/pip/_vendor/tomli/_parser.py ADDED
@@ -0,0 +1,770 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ from __future__ import annotations
6
+
7
+ from collections.abc import Iterable
8
+ import string
9
+ import sys
10
+ from types import MappingProxyType
11
+ from typing import IO, Any, Final, NamedTuple
12
+ import warnings
13
+
14
+ from ._re import (
15
+ RE_DATETIME,
16
+ RE_LOCALTIME,
17
+ RE_NUMBER,
18
+ match_to_datetime,
19
+ match_to_localtime,
20
+ match_to_number,
21
+ )
22
+ from ._types import Key, ParseFloat, Pos
23
+
24
+ # Inline tables/arrays are implemented using recursion. Pathologically
25
+ # nested documents cause pure Python to raise RecursionError (which is OK),
26
+ # but mypyc binary wheels will crash unrecoverably (not OK). According to
27
+ # mypyc docs this will be fixed in the future:
28
+ # https://mypyc.readthedocs.io/en/latest/differences_from_python.html#stack-overflows
29
+ # Before mypyc's fix is in, recursion needs to be limited by this library.
30
+ # Choosing `sys.getrecursionlimit()` as maximum inline table/array nesting
31
+ # level, as it allows more nesting than pure Python, but still seems a far
32
+ # lower number than where mypyc binaries crash.
33
+ MAX_INLINE_NESTING: Final = sys.getrecursionlimit()
34
+
35
+ ASCII_CTRL: Final = frozenset(chr(i) for i in range(32)) | frozenset(chr(127))
36
+
37
+ # Neither of these sets include quotation mark or backslash. They are
38
+ # currently handled as separate cases in the parser functions.
39
+ ILLEGAL_BASIC_STR_CHARS: Final = ASCII_CTRL - frozenset("\t")
40
+ ILLEGAL_MULTILINE_BASIC_STR_CHARS: Final = ASCII_CTRL - frozenset("\t\n")
41
+
42
+ ILLEGAL_LITERAL_STR_CHARS: Final = ILLEGAL_BASIC_STR_CHARS
43
+ ILLEGAL_MULTILINE_LITERAL_STR_CHARS: Final = ILLEGAL_MULTILINE_BASIC_STR_CHARS
44
+
45
+ ILLEGAL_COMMENT_CHARS: Final = ILLEGAL_BASIC_STR_CHARS
46
+
47
+ TOML_WS: Final = frozenset(" \t")
48
+ TOML_WS_AND_NEWLINE: Final = TOML_WS | frozenset("\n")
49
+ BARE_KEY_CHARS: Final = frozenset(string.ascii_letters + string.digits + "-_")
50
+ KEY_INITIAL_CHARS: Final = BARE_KEY_CHARS | frozenset("\"'")
51
+ HEXDIGIT_CHARS: Final = frozenset(string.hexdigits)
52
+
53
+ BASIC_STR_ESCAPE_REPLACEMENTS: Final = MappingProxyType(
54
+ {
55
+ "\\b": "\u0008", # backspace
56
+ "\\t": "\u0009", # tab
57
+ "\\n": "\u000A", # linefeed
58
+ "\\f": "\u000C", # form feed
59
+ "\\r": "\u000D", # carriage return
60
+ '\\"': "\u0022", # quote
61
+ "\\\\": "\u005C", # backslash
62
+ }
63
+ )
64
+
65
+
66
+ class DEPRECATED_DEFAULT:
67
+ """Sentinel to be used as default arg during deprecation
68
+ period of TOMLDecodeError's free-form arguments."""
69
+
70
+
71
+ class TOMLDecodeError(ValueError):
72
+ """An error raised if a document is not valid TOML.
73
+
74
+ Adds the following attributes to ValueError:
75
+ msg: The unformatted error message
76
+ doc: The TOML document being parsed
77
+ pos: The index of doc where parsing failed
78
+ lineno: The line corresponding to pos
79
+ colno: The column corresponding to pos
80
+ """
81
+
82
+ def __init__(
83
+ self,
84
+ msg: str | type[DEPRECATED_DEFAULT] = DEPRECATED_DEFAULT,
85
+ doc: str | type[DEPRECATED_DEFAULT] = DEPRECATED_DEFAULT,
86
+ pos: Pos | type[DEPRECATED_DEFAULT] = DEPRECATED_DEFAULT,
87
+ *args: Any,
88
+ ):
89
+ if (
90
+ args
91
+ or not isinstance(msg, str)
92
+ or not isinstance(doc, str)
93
+ or not isinstance(pos, int)
94
+ ):
95
+ warnings.warn(
96
+ "Free-form arguments for TOMLDecodeError are deprecated. "
97
+ "Please set 'msg' (str), 'doc' (str) and 'pos' (int) arguments only.",
98
+ DeprecationWarning,
99
+ stacklevel=2,
100
+ )
101
+ if pos is not DEPRECATED_DEFAULT:
102
+ args = pos, *args
103
+ if doc is not DEPRECATED_DEFAULT:
104
+ args = doc, *args
105
+ if msg is not DEPRECATED_DEFAULT:
106
+ args = msg, *args
107
+ ValueError.__init__(self, *args)
108
+ return
109
+
110
+ lineno = doc.count("\n", 0, pos) + 1
111
+ if lineno == 1:
112
+ colno = pos + 1
113
+ else:
114
+ colno = pos - doc.rindex("\n", 0, pos)
115
+
116
+ if pos >= len(doc):
117
+ coord_repr = "end of document"
118
+ else:
119
+ coord_repr = f"line {lineno}, column {colno}"
120
+ errmsg = f"{msg} (at {coord_repr})"
121
+ ValueError.__init__(self, errmsg)
122
+
123
+ self.msg = msg
124
+ self.doc = doc
125
+ self.pos = pos
126
+ self.lineno = lineno
127
+ self.colno = colno
128
+
129
+
130
+ def load(__fp: IO[bytes], *, parse_float: ParseFloat = float) -> dict[str, Any]:
131
+ """Parse TOML from a binary file object."""
132
+ b = __fp.read()
133
+ try:
134
+ s = b.decode()
135
+ except AttributeError:
136
+ raise TypeError(
137
+ "File must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`"
138
+ ) from None
139
+ return loads(s, parse_float=parse_float)
140
+
141
+
142
+ def loads(__s: str, *, parse_float: ParseFloat = float) -> dict[str, Any]: # noqa: C901
143
+ """Parse TOML from a string."""
144
+
145
+ # The spec allows converting "\r\n" to "\n", even in string
146
+ # literals. Let's do so to simplify parsing.
147
+ try:
148
+ src = __s.replace("\r\n", "\n")
149
+ except (AttributeError, TypeError):
150
+ raise TypeError(
151
+ f"Expected str object, not '{type(__s).__qualname__}'"
152
+ ) from None
153
+ pos = 0
154
+ out = Output(NestedDict(), Flags())
155
+ header: Key = ()
156
+ parse_float = make_safe_parse_float(parse_float)
157
+
158
+ # Parse one statement at a time
159
+ # (typically means one line in TOML source)
160
+ while True:
161
+ # 1. Skip line leading whitespace
162
+ pos = skip_chars(src, pos, TOML_WS)
163
+
164
+ # 2. Parse rules. Expect one of the following:
165
+ # - end of file
166
+ # - end of line
167
+ # - comment
168
+ # - key/value pair
169
+ # - append dict to list (and move to its namespace)
170
+ # - create dict (and move to its namespace)
171
+ # Skip trailing whitespace when applicable.
172
+ try:
173
+ char = src[pos]
174
+ except IndexError:
175
+ break
176
+ if char == "\n":
177
+ pos += 1
178
+ continue
179
+ if char in KEY_INITIAL_CHARS:
180
+ pos = key_value_rule(src, pos, out, header, parse_float)
181
+ pos = skip_chars(src, pos, TOML_WS)
182
+ elif char == "[":
183
+ try:
184
+ second_char: str | None = src[pos + 1]
185
+ except IndexError:
186
+ second_char = None
187
+ out.flags.finalize_pending()
188
+ if second_char == "[":
189
+ pos, header = create_list_rule(src, pos, out)
190
+ else:
191
+ pos, header = create_dict_rule(src, pos, out)
192
+ pos = skip_chars(src, pos, TOML_WS)
193
+ elif char != "#":
194
+ raise TOMLDecodeError("Invalid statement", src, pos)
195
+
196
+ # 3. Skip comment
197
+ pos = skip_comment(src, pos)
198
+
199
+ # 4. Expect end of line or end of file
200
+ try:
201
+ char = src[pos]
202
+ except IndexError:
203
+ break
204
+ if char != "\n":
205
+ raise TOMLDecodeError(
206
+ "Expected newline or end of document after a statement", src, pos
207
+ )
208
+ pos += 1
209
+
210
+ return out.data.dict
211
+
212
+
213
+ class Flags:
214
+ """Flags that map to parsed keys/namespaces."""
215
+
216
+ # Marks an immutable namespace (inline array or inline table).
217
+ FROZEN: Final = 0
218
+ # Marks a nest that has been explicitly created and can no longer
219
+ # be opened using the "[table]" syntax.
220
+ EXPLICIT_NEST: Final = 1
221
+
222
+ def __init__(self) -> None:
223
+ self._flags: dict[str, dict] = {}
224
+ self._pending_flags: set[tuple[Key, int]] = set()
225
+
226
+ def add_pending(self, key: Key, flag: int) -> None:
227
+ self._pending_flags.add((key, flag))
228
+
229
+ def finalize_pending(self) -> None:
230
+ for key, flag in self._pending_flags:
231
+ self.set(key, flag, recursive=False)
232
+ self._pending_flags.clear()
233
+
234
+ def unset_all(self, key: Key) -> None:
235
+ cont = self._flags
236
+ for k in key[:-1]:
237
+ if k not in cont:
238
+ return
239
+ cont = cont[k]["nested"]
240
+ cont.pop(key[-1], None)
241
+
242
+ def set(self, key: Key, flag: int, *, recursive: bool) -> None: # noqa: A003
243
+ cont = self._flags
244
+ key_parent, key_stem = key[:-1], key[-1]
245
+ for k in key_parent:
246
+ if k not in cont:
247
+ cont[k] = {"flags": set(), "recursive_flags": set(), "nested": {}}
248
+ cont = cont[k]["nested"]
249
+ if key_stem not in cont:
250
+ cont[key_stem] = {"flags": set(), "recursive_flags": set(), "nested": {}}
251
+ cont[key_stem]["recursive_flags" if recursive else "flags"].add(flag)
252
+
253
+ def is_(self, key: Key, flag: int) -> bool:
254
+ if not key:
255
+ return False # document root has no flags
256
+ cont = self._flags
257
+ for k in key[:-1]:
258
+ if k not in cont:
259
+ return False
260
+ inner_cont = cont[k]
261
+ if flag in inner_cont["recursive_flags"]:
262
+ return True
263
+ cont = inner_cont["nested"]
264
+ key_stem = key[-1]
265
+ if key_stem in cont:
266
+ inner_cont = cont[key_stem]
267
+ return flag in inner_cont["flags"] or flag in inner_cont["recursive_flags"]
268
+ return False
269
+
270
+
271
+ class NestedDict:
272
+ def __init__(self) -> None:
273
+ # The parsed content of the TOML document
274
+ self.dict: dict[str, Any] = {}
275
+
276
+ def get_or_create_nest(
277
+ self,
278
+ key: Key,
279
+ *,
280
+ access_lists: bool = True,
281
+ ) -> dict:
282
+ cont: Any = self.dict
283
+ for k in key:
284
+ if k not in cont:
285
+ cont[k] = {}
286
+ cont = cont[k]
287
+ if access_lists and isinstance(cont, list):
288
+ cont = cont[-1]
289
+ if not isinstance(cont, dict):
290
+ raise KeyError("There is no nest behind this key")
291
+ return cont
292
+
293
+ def append_nest_to_list(self, key: Key) -> None:
294
+ cont = self.get_or_create_nest(key[:-1])
295
+ last_key = key[-1]
296
+ if last_key in cont:
297
+ list_ = cont[last_key]
298
+ if not isinstance(list_, list):
299
+ raise KeyError("An object other than list found behind this key")
300
+ list_.append({})
301
+ else:
302
+ cont[last_key] = [{}]
303
+
304
+
305
+ class Output(NamedTuple):
306
+ data: NestedDict
307
+ flags: Flags
308
+
309
+
310
+ def skip_chars(src: str, pos: Pos, chars: Iterable[str]) -> Pos:
311
+ try:
312
+ while src[pos] in chars:
313
+ pos += 1
314
+ except IndexError:
315
+ pass
316
+ return pos
317
+
318
+
319
+ def skip_until(
320
+ src: str,
321
+ pos: Pos,
322
+ expect: str,
323
+ *,
324
+ error_on: frozenset[str],
325
+ error_on_eof: bool,
326
+ ) -> Pos:
327
+ try:
328
+ new_pos = src.index(expect, pos)
329
+ except ValueError:
330
+ new_pos = len(src)
331
+ if error_on_eof:
332
+ raise TOMLDecodeError(f"Expected {expect!r}", src, new_pos) from None
333
+
334
+ if not error_on.isdisjoint(src[pos:new_pos]):
335
+ while src[pos] not in error_on:
336
+ pos += 1
337
+ raise TOMLDecodeError(f"Found invalid character {src[pos]!r}", src, pos)
338
+ return new_pos
339
+
340
+
341
+ def skip_comment(src: str, pos: Pos) -> Pos:
342
+ try:
343
+ char: str | None = src[pos]
344
+ except IndexError:
345
+ char = None
346
+ if char == "#":
347
+ return skip_until(
348
+ src, pos + 1, "\n", error_on=ILLEGAL_COMMENT_CHARS, error_on_eof=False
349
+ )
350
+ return pos
351
+
352
+
353
+ def skip_comments_and_array_ws(src: str, pos: Pos) -> Pos:
354
+ while True:
355
+ pos_before_skip = pos
356
+ pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
357
+ pos = skip_comment(src, pos)
358
+ if pos == pos_before_skip:
359
+ return pos
360
+
361
+
362
+ def create_dict_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
363
+ pos += 1 # Skip "["
364
+ pos = skip_chars(src, pos, TOML_WS)
365
+ pos, key = parse_key(src, pos)
366
+
367
+ if out.flags.is_(key, Flags.EXPLICIT_NEST) or out.flags.is_(key, Flags.FROZEN):
368
+ raise TOMLDecodeError(f"Cannot declare {key} twice", src, pos)
369
+ out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
370
+ try:
371
+ out.data.get_or_create_nest(key)
372
+ except KeyError:
373
+ raise TOMLDecodeError("Cannot overwrite a value", src, pos) from None
374
+
375
+ if not src.startswith("]", pos):
376
+ raise TOMLDecodeError(
377
+ "Expected ']' at the end of a table declaration", src, pos
378
+ )
379
+ return pos + 1, key
380
+
381
+
382
+ def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
383
+ pos += 2 # Skip "[["
384
+ pos = skip_chars(src, pos, TOML_WS)
385
+ pos, key = parse_key(src, pos)
386
+
387
+ if out.flags.is_(key, Flags.FROZEN):
388
+ raise TOMLDecodeError(f"Cannot mutate immutable namespace {key}", src, pos)
389
+ # Free the namespace now that it points to another empty list item...
390
+ out.flags.unset_all(key)
391
+ # ...but this key precisely is still prohibited from table declaration
392
+ out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
393
+ try:
394
+ out.data.append_nest_to_list(key)
395
+ except KeyError:
396
+ raise TOMLDecodeError("Cannot overwrite a value", src, pos) from None
397
+
398
+ if not src.startswith("]]", pos):
399
+ raise TOMLDecodeError(
400
+ "Expected ']]' at the end of an array declaration", src, pos
401
+ )
402
+ return pos + 2, key
403
+
404
+
405
+ def key_value_rule(
406
+ src: str, pos: Pos, out: Output, header: Key, parse_float: ParseFloat
407
+ ) -> Pos:
408
+ pos, key, value = parse_key_value_pair(src, pos, parse_float, nest_lvl=0)
409
+ key_parent, key_stem = key[:-1], key[-1]
410
+ abs_key_parent = header + key_parent
411
+
412
+ relative_path_cont_keys = (header + key[:i] for i in range(1, len(key)))
413
+ for cont_key in relative_path_cont_keys:
414
+ # Check that dotted key syntax does not redefine an existing table
415
+ if out.flags.is_(cont_key, Flags.EXPLICIT_NEST):
416
+ raise TOMLDecodeError(f"Cannot redefine namespace {cont_key}", src, pos)
417
+ # Containers in the relative path can't be opened with the table syntax or
418
+ # dotted key/value syntax in following table sections.
419
+ out.flags.add_pending(cont_key, Flags.EXPLICIT_NEST)
420
+
421
+ if out.flags.is_(abs_key_parent, Flags.FROZEN):
422
+ raise TOMLDecodeError(
423
+ f"Cannot mutate immutable namespace {abs_key_parent}", src, pos
424
+ )
425
+
426
+ try:
427
+ nest = out.data.get_or_create_nest(abs_key_parent)
428
+ except KeyError:
429
+ raise TOMLDecodeError("Cannot overwrite a value", src, pos) from None
430
+ if key_stem in nest:
431
+ raise TOMLDecodeError("Cannot overwrite a value", src, pos)
432
+ # Mark inline table and array namespaces recursively immutable
433
+ if isinstance(value, (dict, list)):
434
+ out.flags.set(header + key, Flags.FROZEN, recursive=True)
435
+ nest[key_stem] = value
436
+ return pos
437
+
438
+
439
+ def parse_key_value_pair(
440
+ src: str, pos: Pos, parse_float: ParseFloat, nest_lvl: int
441
+ ) -> tuple[Pos, Key, Any]:
442
+ pos, key = parse_key(src, pos)
443
+ try:
444
+ char: str | None = src[pos]
445
+ except IndexError:
446
+ char = None
447
+ if char != "=":
448
+ raise TOMLDecodeError("Expected '=' after a key in a key/value pair", src, pos)
449
+ pos += 1
450
+ pos = skip_chars(src, pos, TOML_WS)
451
+ pos, value = parse_value(src, pos, parse_float, nest_lvl)
452
+ return pos, key, value
453
+
454
+
455
+ def parse_key(src: str, pos: Pos) -> tuple[Pos, Key]:
456
+ pos, key_part = parse_key_part(src, pos)
457
+ key: Key = (key_part,)
458
+ pos = skip_chars(src, pos, TOML_WS)
459
+ while True:
460
+ try:
461
+ char: str | None = src[pos]
462
+ except IndexError:
463
+ char = None
464
+ if char != ".":
465
+ return pos, key
466
+ pos += 1
467
+ pos = skip_chars(src, pos, TOML_WS)
468
+ pos, key_part = parse_key_part(src, pos)
469
+ key += (key_part,)
470
+ pos = skip_chars(src, pos, TOML_WS)
471
+
472
+
473
+ def parse_key_part(src: str, pos: Pos) -> tuple[Pos, str]:
474
+ try:
475
+ char: str | None = src[pos]
476
+ except IndexError:
477
+ char = None
478
+ if char in BARE_KEY_CHARS:
479
+ start_pos = pos
480
+ pos = skip_chars(src, pos, BARE_KEY_CHARS)
481
+ return pos, src[start_pos:pos]
482
+ if char == "'":
483
+ return parse_literal_str(src, pos)
484
+ if char == '"':
485
+ return parse_one_line_basic_str(src, pos)
486
+ raise TOMLDecodeError("Invalid initial character for a key part", src, pos)
487
+
488
+
489
+ def parse_one_line_basic_str(src: str, pos: Pos) -> tuple[Pos, str]:
490
+ pos += 1
491
+ return parse_basic_str(src, pos, multiline=False)
492
+
493
+
494
+ def parse_array(
495
+ src: str, pos: Pos, parse_float: ParseFloat, nest_lvl: int
496
+ ) -> tuple[Pos, list]:
497
+ pos += 1
498
+ array: list = []
499
+
500
+ pos = skip_comments_and_array_ws(src, pos)
501
+ if src.startswith("]", pos):
502
+ return pos + 1, array
503
+ while True:
504
+ pos, val = parse_value(src, pos, parse_float, nest_lvl)
505
+ array.append(val)
506
+ pos = skip_comments_and_array_ws(src, pos)
507
+
508
+ c = src[pos : pos + 1]
509
+ if c == "]":
510
+ return pos + 1, array
511
+ if c != ",":
512
+ raise TOMLDecodeError("Unclosed array", src, pos)
513
+ pos += 1
514
+
515
+ pos = skip_comments_and_array_ws(src, pos)
516
+ if src.startswith("]", pos):
517
+ return pos + 1, array
518
+
519
+
520
+ def parse_inline_table(
521
+ src: str, pos: Pos, parse_float: ParseFloat, nest_lvl: int
522
+ ) -> tuple[Pos, dict]:
523
+ pos += 1
524
+ nested_dict = NestedDict()
525
+ flags = Flags()
526
+
527
+ pos = skip_chars(src, pos, TOML_WS)
528
+ if src.startswith("}", pos):
529
+ return pos + 1, nested_dict.dict
530
+ while True:
531
+ pos, key, value = parse_key_value_pair(src, pos, parse_float, nest_lvl)
532
+ key_parent, key_stem = key[:-1], key[-1]
533
+ if flags.is_(key, Flags.FROZEN):
534
+ raise TOMLDecodeError(f"Cannot mutate immutable namespace {key}", src, pos)
535
+ try:
536
+ nest = nested_dict.get_or_create_nest(key_parent, access_lists=False)
537
+ except KeyError:
538
+ raise TOMLDecodeError("Cannot overwrite a value", src, pos) from None
539
+ if key_stem in nest:
540
+ raise TOMLDecodeError(f"Duplicate inline table key {key_stem!r}", src, pos)
541
+ nest[key_stem] = value
542
+ pos = skip_chars(src, pos, TOML_WS)
543
+ c = src[pos : pos + 1]
544
+ if c == "}":
545
+ return pos + 1, nested_dict.dict
546
+ if c != ",":
547
+ raise TOMLDecodeError("Unclosed inline table", src, pos)
548
+ if isinstance(value, (dict, list)):
549
+ flags.set(key, Flags.FROZEN, recursive=True)
550
+ pos += 1
551
+ pos = skip_chars(src, pos, TOML_WS)
552
+
553
+
554
+ def parse_basic_str_escape(
555
+ src: str, pos: Pos, *, multiline: bool = False
556
+ ) -> tuple[Pos, str]:
557
+ escape_id = src[pos : pos + 2]
558
+ pos += 2
559
+ if multiline and escape_id in {"\\ ", "\\\t", "\\\n"}:
560
+ # Skip whitespace until next non-whitespace character or end of
561
+ # the doc. Error if non-whitespace is found before newline.
562
+ if escape_id != "\\\n":
563
+ pos = skip_chars(src, pos, TOML_WS)
564
+ try:
565
+ char = src[pos]
566
+ except IndexError:
567
+ return pos, ""
568
+ if char != "\n":
569
+ raise TOMLDecodeError("Unescaped '\\' in a string", src, pos)
570
+ pos += 1
571
+ pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
572
+ return pos, ""
573
+ if escape_id == "\\u":
574
+ return parse_hex_char(src, pos, 4)
575
+ if escape_id == "\\U":
576
+ return parse_hex_char(src, pos, 8)
577
+ try:
578
+ return pos, BASIC_STR_ESCAPE_REPLACEMENTS[escape_id]
579
+ except KeyError:
580
+ raise TOMLDecodeError("Unescaped '\\' in a string", src, pos) from None
581
+
582
+
583
+ def parse_basic_str_escape_multiline(src: str, pos: Pos) -> tuple[Pos, str]:
584
+ return parse_basic_str_escape(src, pos, multiline=True)
585
+
586
+
587
+ def parse_hex_char(src: str, pos: Pos, hex_len: int) -> tuple[Pos, str]:
588
+ hex_str = src[pos : pos + hex_len]
589
+ if len(hex_str) != hex_len or not HEXDIGIT_CHARS.issuperset(hex_str):
590
+ raise TOMLDecodeError("Invalid hex value", src, pos)
591
+ pos += hex_len
592
+ hex_int = int(hex_str, 16)
593
+ if not is_unicode_scalar_value(hex_int):
594
+ raise TOMLDecodeError(
595
+ "Escaped character is not a Unicode scalar value", src, pos
596
+ )
597
+ return pos, chr(hex_int)
598
+
599
+
600
+ def parse_literal_str(src: str, pos: Pos) -> tuple[Pos, str]:
601
+ pos += 1 # Skip starting apostrophe
602
+ start_pos = pos
603
+ pos = skip_until(
604
+ src, pos, "'", error_on=ILLEGAL_LITERAL_STR_CHARS, error_on_eof=True
605
+ )
606
+ return pos + 1, src[start_pos:pos] # Skip ending apostrophe
607
+
608
+
609
+ def parse_multiline_str(src: str, pos: Pos, *, literal: bool) -> tuple[Pos, str]:
610
+ pos += 3
611
+ if src.startswith("\n", pos):
612
+ pos += 1
613
+
614
+ if literal:
615
+ delim = "'"
616
+ end_pos = skip_until(
617
+ src,
618
+ pos,
619
+ "'''",
620
+ error_on=ILLEGAL_MULTILINE_LITERAL_STR_CHARS,
621
+ error_on_eof=True,
622
+ )
623
+ result = src[pos:end_pos]
624
+ pos = end_pos + 3
625
+ else:
626
+ delim = '"'
627
+ pos, result = parse_basic_str(src, pos, multiline=True)
628
+
629
+ # Add at maximum two extra apostrophes/quotes if the end sequence
630
+ # is 4 or 5 chars long instead of just 3.
631
+ if not src.startswith(delim, pos):
632
+ return pos, result
633
+ pos += 1
634
+ if not src.startswith(delim, pos):
635
+ return pos, result + delim
636
+ pos += 1
637
+ return pos, result + (delim * 2)
638
+
639
+
640
+ def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]:
641
+ if multiline:
642
+ error_on = ILLEGAL_MULTILINE_BASIC_STR_CHARS
643
+ parse_escapes = parse_basic_str_escape_multiline
644
+ else:
645
+ error_on = ILLEGAL_BASIC_STR_CHARS
646
+ parse_escapes = parse_basic_str_escape
647
+ result = ""
648
+ start_pos = pos
649
+ while True:
650
+ try:
651
+ char = src[pos]
652
+ except IndexError:
653
+ raise TOMLDecodeError("Unterminated string", src, pos) from None
654
+ if char == '"':
655
+ if not multiline:
656
+ return pos + 1, result + src[start_pos:pos]
657
+ if src.startswith('"""', pos):
658
+ return pos + 3, result + src[start_pos:pos]
659
+ pos += 1
660
+ continue
661
+ if char == "\\":
662
+ result += src[start_pos:pos]
663
+ pos, parsed_escape = parse_escapes(src, pos)
664
+ result += parsed_escape
665
+ start_pos = pos
666
+ continue
667
+ if char in error_on:
668
+ raise TOMLDecodeError(f"Illegal character {char!r}", src, pos)
669
+ pos += 1
670
+
671
+
672
+ def parse_value( # noqa: C901
673
+ src: str, pos: Pos, parse_float: ParseFloat, nest_lvl: int
674
+ ) -> tuple[Pos, Any]:
675
+ if nest_lvl > MAX_INLINE_NESTING:
676
+ # Pure Python should have raised RecursionError already.
677
+ # This ensures mypyc binaries eventually do the same.
678
+ raise RecursionError( # pragma: no cover
679
+ "TOML inline arrays/tables are nested more than the allowed"
680
+ f" {MAX_INLINE_NESTING} levels"
681
+ )
682
+
683
+ try:
684
+ char: str | None = src[pos]
685
+ except IndexError:
686
+ char = None
687
+
688
+ # IMPORTANT: order conditions based on speed of checking and likelihood
689
+
690
+ # Basic strings
691
+ if char == '"':
692
+ if src.startswith('"""', pos):
693
+ return parse_multiline_str(src, pos, literal=False)
694
+ return parse_one_line_basic_str(src, pos)
695
+
696
+ # Literal strings
697
+ if char == "'":
698
+ if src.startswith("'''", pos):
699
+ return parse_multiline_str(src, pos, literal=True)
700
+ return parse_literal_str(src, pos)
701
+
702
+ # Booleans
703
+ if char == "t":
704
+ if src.startswith("true", pos):
705
+ return pos + 4, True
706
+ if char == "f":
707
+ if src.startswith("false", pos):
708
+ return pos + 5, False
709
+
710
+ # Arrays
711
+ if char == "[":
712
+ return parse_array(src, pos, parse_float, nest_lvl + 1)
713
+
714
+ # Inline tables
715
+ if char == "{":
716
+ return parse_inline_table(src, pos, parse_float, nest_lvl + 1)
717
+
718
+ # Dates and times
719
+ datetime_match = RE_DATETIME.match(src, pos)
720
+ if datetime_match:
721
+ try:
722
+ datetime_obj = match_to_datetime(datetime_match)
723
+ except ValueError as e:
724
+ raise TOMLDecodeError("Invalid date or datetime", src, pos) from e
725
+ return datetime_match.end(), datetime_obj
726
+ localtime_match = RE_LOCALTIME.match(src, pos)
727
+ if localtime_match:
728
+ return localtime_match.end(), match_to_localtime(localtime_match)
729
+
730
+ # Integers and "normal" floats.
731
+ # The regex will greedily match any type starting with a decimal
732
+ # char, so needs to be located after handling of dates and times.
733
+ number_match = RE_NUMBER.match(src, pos)
734
+ if number_match:
735
+ return number_match.end(), match_to_number(number_match, parse_float)
736
+
737
+ # Special floats
738
+ first_three = src[pos : pos + 3]
739
+ if first_three in {"inf", "nan"}:
740
+ return pos + 3, parse_float(first_three)
741
+ first_four = src[pos : pos + 4]
742
+ if first_four in {"-inf", "+inf", "-nan", "+nan"}:
743
+ return pos + 4, parse_float(first_four)
744
+
745
+ raise TOMLDecodeError("Invalid value", src, pos)
746
+
747
+
748
+ def is_unicode_scalar_value(codepoint: int) -> bool:
749
+ return (0 <= codepoint <= 55295) or (57344 <= codepoint <= 1114111)
750
+
751
+
752
+ def make_safe_parse_float(parse_float: ParseFloat) -> ParseFloat:
753
+ """A decorator to make `parse_float` safe.
754
+
755
+ `parse_float` must not return dicts or lists, because these types
756
+ would be mixed with parsed TOML tables and arrays, thus confusing
757
+ the parser. The returned decorated callable raises `ValueError`
758
+ instead of returning illegal types.
759
+ """
760
+ # The default `float` callable never returns illegal types. Optimize it.
761
+ if parse_float is float:
762
+ return float
763
+
764
+ def safe_parse_float(float_str: str) -> Any:
765
+ float_value = parse_float(float_str)
766
+ if isinstance(float_value, (dict, list)):
767
+ raise ValueError("parse_float must not return dicts or lists")
768
+ return float_value
769
+
770
+ return safe_parse_float
.venv/lib/python3.13/site-packages/pip/_vendor/tomli/_re.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ from __future__ import annotations
6
+
7
+ from datetime import date, datetime, time, timedelta, timezone, tzinfo
8
+ from functools import lru_cache
9
+ import re
10
+ from typing import Any, Final
11
+
12
+ from ._types import ParseFloat
13
+
14
+ # E.g.
15
+ # - 00:32:00.999999
16
+ # - 00:32:00
17
+ _TIME_RE_STR: Final = (
18
+ r"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(?:\.([0-9]{1,6})[0-9]*)?"
19
+ )
20
+
21
+ RE_NUMBER: Final = re.compile(
22
+ r"""
23
+ 0
24
+ (?:
25
+ x[0-9A-Fa-f](?:_?[0-9A-Fa-f])* # hex
26
+ |
27
+ b[01](?:_?[01])* # bin
28
+ |
29
+ o[0-7](?:_?[0-7])* # oct
30
+ )
31
+ |
32
+ [+-]?(?:0|[1-9](?:_?[0-9])*) # dec, integer part
33
+ (?P<floatpart>
34
+ (?:\.[0-9](?:_?[0-9])*)? # optional fractional part
35
+ (?:[eE][+-]?[0-9](?:_?[0-9])*)? # optional exponent part
36
+ )
37
+ """,
38
+ flags=re.VERBOSE,
39
+ )
40
+ RE_LOCALTIME: Final = re.compile(_TIME_RE_STR)
41
+ RE_DATETIME: Final = re.compile(
42
+ rf"""
43
+ ([0-9]{{4}})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) # date, e.g. 1988-10-27
44
+ (?:
45
+ [Tt ]
46
+ {_TIME_RE_STR}
47
+ (?:([Zz])|([+-])([01][0-9]|2[0-3]):([0-5][0-9]))? # optional time offset
48
+ )?
49
+ """,
50
+ flags=re.VERBOSE,
51
+ )
52
+
53
+
54
+ def match_to_datetime(match: re.Match) -> datetime | date:
55
+ """Convert a `RE_DATETIME` match to `datetime.datetime` or `datetime.date`.
56
+
57
+ Raises ValueError if the match does not correspond to a valid date
58
+ or datetime.
59
+ """
60
+ (
61
+ year_str,
62
+ month_str,
63
+ day_str,
64
+ hour_str,
65
+ minute_str,
66
+ sec_str,
67
+ micros_str,
68
+ zulu_time,
69
+ offset_sign_str,
70
+ offset_hour_str,
71
+ offset_minute_str,
72
+ ) = match.groups()
73
+ year, month, day = int(year_str), int(month_str), int(day_str)
74
+ if hour_str is None:
75
+ return date(year, month, day)
76
+ hour, minute, sec = int(hour_str), int(minute_str), int(sec_str)
77
+ micros = int(micros_str.ljust(6, "0")) if micros_str else 0
78
+ if offset_sign_str:
79
+ tz: tzinfo | None = cached_tz(
80
+ offset_hour_str, offset_minute_str, offset_sign_str
81
+ )
82
+ elif zulu_time:
83
+ tz = timezone.utc
84
+ else: # local date-time
85
+ tz = None
86
+ return datetime(year, month, day, hour, minute, sec, micros, tzinfo=tz)
87
+
88
+
89
+ # No need to limit cache size. This is only ever called on input
90
+ # that matched RE_DATETIME, so there is an implicit bound of
91
+ # 24 (hours) * 60 (minutes) * 2 (offset direction) = 2880.
92
+ @lru_cache(maxsize=None)
93
+ def cached_tz(hour_str: str, minute_str: str, sign_str: str) -> timezone:
94
+ sign = 1 if sign_str == "+" else -1
95
+ return timezone(
96
+ timedelta(
97
+ hours=sign * int(hour_str),
98
+ minutes=sign * int(minute_str),
99
+ )
100
+ )
101
+
102
+
103
+ def match_to_localtime(match: re.Match) -> time:
104
+ hour_str, minute_str, sec_str, micros_str = match.groups()
105
+ micros = int(micros_str.ljust(6, "0")) if micros_str else 0
106
+ return time(int(hour_str), int(minute_str), int(sec_str), micros)
107
+
108
+
109
+ def match_to_number(match: re.Match, parse_float: ParseFloat) -> Any:
110
+ if match.group("floatpart"):
111
+ return parse_float(match.group())
112
+ return int(match.group(), 0)
.venv/lib/python3.13/site-packages/pip/_vendor/tomli/_types.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ from typing import Any, Callable, Tuple
6
+
7
+ # Type annotations
8
+ ParseFloat = Callable[[str], Any]
9
+ Key = Tuple[str, ...]
10
+ Pos = int
.venv/lib/python3.13/site-packages/pip/_vendor/tomli/py.typed ADDED
@@ -0,0 +1 @@
 
 
1
+ # Marker file for PEP 561