Instructions to use elichen-skymizer/GAP-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use elichen-skymizer/GAP-models with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf elichen-skymizer/GAP-models:UD-Q4_K_XL # Run inference directly in the terminal: llama cli -hf elichen-skymizer/GAP-models:UD-Q4_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf elichen-skymizer/GAP-models:UD-Q4_K_XL # Run inference directly in the terminal: llama cli -hf elichen-skymizer/GAP-models:UD-Q4_K_XL
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf elichen-skymizer/GAP-models:UD-Q4_K_XL # Run inference directly in the terminal: ./build/bin/llama cli -hf elichen-skymizer/GAP-models:UD-Q4_K_XL
Use Docker
docker model run hf.co/elichen-skymizer/GAP-models:UD-Q4_K_XL
- Llama new
- LM Studio
- Jan
- Ollama
How to use elichen-skymizer/GAP-models with Ollama:
ollama run hf.co/elichen-skymizer/GAP-models:UD-Q4_K_XL
- Unsloth Desktop
- Pi
How to use elichen-skymizer/GAP-models with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf elichen-skymizer/GAP-models:UD-Q4_K_XL
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "elichen-skymizer/GAP-models:UD-Q4_K_XL" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use elichen-skymizer/GAP-models with Docker Model Runner:
docker model run hf.co/elichen-skymizer/GAP-models:UD-Q4_K_XL
- Lemonade
How to use elichen-skymizer/GAP-models with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull elichen-skymizer/GAP-models:UD-Q4_K_XL
Run and chat with the model
lemonade run user.GAP-models-UD-Q4_K_XL
List all available models
lemonade list
- Hermes Agent
How to use elichen-skymizer/GAP-models with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf elichen-skymizer/GAP-models:UD-Q4_K_XL
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default elichen-skymizer/GAP-models:UD-Q4_K_XL
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use elichen-skymizer/GAP-models with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf elichen-skymizer/GAP-models:UD-Q4_K_XL
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "elichen-skymizer/GAP-models:UD-Q4_K_XL" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/INSTALLER +1 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/METADATA +58 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/RECORD +352 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/REQUESTED +0 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/WHEEL +4 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/entry_points.txt +2 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/__init__.py +177 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/__main__.py +245 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_emoji_codes.py +0 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_emoji_replace.py +31 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_export_format.py +76 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_extension.py +10 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_fileno.py +24 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_inspect.py +272 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_log_render.py +94 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_loop.py +43 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_null_file.py +69 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_palettes.py +309 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_pick.py +17 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_ratio.py +153 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_spinners.py +482 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_stack.py +16 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_timer.py +19 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_win32_console.py +661 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_windows.py +71 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_windows_renderer.py +56 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_wrap.py +93 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/abc.py +33 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/align.py +320 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/ansi.py +241 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/bar.py +93 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/box.py +474 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/cells.py +352 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/color.py +621 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/color_triplet.py +38 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/columns.py +187 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/console.py +0 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/constrain.py +37 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/containers.py +167 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/control.py +219 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/default_styles.py +196 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/diagnose.py +39 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/emoji.py +93 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/errors.py +34 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/file_proxy.py +60 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/filesize.py +88 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/highlighter.py +232 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/json.py +139 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/jupyter.py +101 -0
- qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/layout.py +442 -0
qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
uv
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.5
|
| 2 |
+
Name: Pygments
|
| 3 |
+
Version: 2.21.0
|
| 4 |
+
Summary: Pygments is a syntax highlighting package written in Python.
|
| 5 |
+
Project-URL: Homepage, https://pygments.org
|
| 6 |
+
Project-URL: Documentation, https://pygments.org/docs
|
| 7 |
+
Project-URL: Source, https://github.com/pygments/pygments
|
| 8 |
+
Project-URL: Bug Tracker, https://github.com/pygments/pygments/issues
|
| 9 |
+
Project-URL: Changelog, https://github.com/pygments/pygments/blob/master/CHANGES
|
| 10 |
+
Author-email: Georg Brandl <georg@python.org>
|
| 11 |
+
Maintainer: Matthäus G. Chajdas
|
| 12 |
+
Maintainer-email: Georg Brandl <georg@python.org>, Jean Abou Samra <jean@abou-samra.fr>
|
| 13 |
+
License-Expression: BSD-2-Clause
|
| 14 |
+
License-File: AUTHORS
|
| 15 |
+
License-File: LICENSE
|
| 16 |
+
Keywords: syntax highlighting
|
| 17 |
+
Classifier: Development Status :: 6 - Mature
|
| 18 |
+
Classifier: Intended Audience :: Developers
|
| 19 |
+
Classifier: Intended Audience :: End Users/Desktop
|
| 20 |
+
Classifier: Intended Audience :: System Administrators
|
| 21 |
+
Classifier: Operating System :: OS Independent
|
| 22 |
+
Classifier: Programming Language :: Python
|
| 23 |
+
Classifier: Programming Language :: Python :: 3
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 25 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 26 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 27 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 28 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 29 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 30 |
+
Classifier: Programming Language :: Python :: 3.15
|
| 31 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 32 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 33 |
+
Classifier: Topic :: Text Processing :: Filters
|
| 34 |
+
Classifier: Topic :: Utilities
|
| 35 |
+
Requires-Python: >=3.9
|
| 36 |
+
Provides-Extra: plugins
|
| 37 |
+
Provides-Extra: windows-terminal
|
| 38 |
+
Requires-Dist: colorama>=0.4.6; extra == 'windows-terminal'
|
| 39 |
+
Description-Content-Type: text/x-rst
|
| 40 |
+
|
| 41 |
+
Pygments
|
| 42 |
+
~~~~~~~~
|
| 43 |
+
|
| 44 |
+
Pygments is a syntax highlighting package written in Python.
|
| 45 |
+
|
| 46 |
+
It is a generic syntax highlighter suitable for use in code hosting, forums,
|
| 47 |
+
wikis or other applications that need to prettify source code. Highlights
|
| 48 |
+
are:
|
| 49 |
+
|
| 50 |
+
* a wide range of over 500 languages and other text formats is supported
|
| 51 |
+
* special attention is paid to details, increasing quality by a fair amount
|
| 52 |
+
* support for new languages and formats are added easily
|
| 53 |
+
* a number of output formats, presently HTML, LaTeX, RTF, SVG, all image
|
| 54 |
+
formats that PIL supports and ANSI sequences
|
| 55 |
+
* it is usable as a command-line tool and as a library
|
| 56 |
+
|
| 57 |
+
Copyright 2006-present by the Pygments team, see ``AUTHORS``.
|
| 58 |
+
Licensed under the BSD, see ``LICENSE`` for details.
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/pygmentize,sha256=yDGFg9UdVNrGysTVu3UJPLlnI4qzDOJtMMvlg4-8CCg,329
|
| 2 |
+
pygments-2.21.0.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
|
| 3 |
+
pygments-2.21.0.dist-info/METADATA,sha256=Hd4HVXATZ3THBr8ACRg6eT_g7iYuSlWQzG7_hFPu3UM,2527
|
| 4 |
+
pygments-2.21.0.dist-info/RECORD,,
|
| 5 |
+
pygments-2.21.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 6 |
+
pygments-2.21.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
| 7 |
+
pygments-2.21.0.dist-info/entry_points.txt,sha256=uUXw-XhMKBEX4pWcCtpuTTnPhL3h7OEE2jWi51VQsa8,53
|
| 8 |
+
pygments-2.21.0.dist-info/licenses/AUTHORS,sha256=cag4cq2C9Xvmks-CfgSOLNUdRRac-h6j8ocG2XqHLA8,11048
|
| 9 |
+
pygments-2.21.0.dist-info/licenses/LICENSE,sha256=qdZvHVJt8C4p3Oc0NtNOVuhjL0bCdbvf_HBWnogvnxc,1331
|
| 10 |
+
pygments/__init__.py,sha256=g_6ZaI4G7YDX1E0yX3kCfeg6Q0xg8km87_1n_aPn0rE,2962
|
| 11 |
+
pygments/__main__.py,sha256=QZWj0T6TTRsqr-w-0YvVILo1DyAvzzydGCRONwdEzqo,351
|
| 12 |
+
pygments/cmdline.py,sha256=k_r5QTPmEQFHanJqxex-k_1yrUysww2GI3VlyfisEIo,23542
|
| 13 |
+
pygments/console.py,sha256=C189JAwhC1Qh0AKgshzb1wVDzFqBnv1VZ45kTEDIO30,1721
|
| 14 |
+
pygments/filter.py,sha256=1dnbkq2AdC3AkHt3DaXwnOkTBLChl1kR6naSLwnr_tc,1913
|
| 15 |
+
pygments/filters/__init__.py,sha256=03ZYdIYmxnWCh7gNXD7lEQ869Df4kzHnOGM44iJxan8,40349
|
| 16 |
+
pygments/formatter.py,sha256=PTBnTW0EHke2vzlAKuvHJkj3-_CMj8duIx-3yVUie-o,4369
|
| 17 |
+
pygments/formatters/__init__.py,sha256=qPG4q5cuaZRGBglmEJVLP4SDv43QI3tAUskj30M-mOY,5352
|
| 18 |
+
pygments/formatters/_mapping.py,sha256=1Cw37FuQlNacnxRKmtlPX4nyLoX9_ttko5ZwscNUZZ4,4176
|
| 19 |
+
pygments/formatters/bbcode.py,sha256=lvG1REZJv0pM6VMe-QwLSuo0Yl1Ra_X51wh93fW8A2k,3299
|
| 20 |
+
pygments/formatters/groff.py,sha256=FB87OIEw5S4Z0jyVVXL2csegglHazdyqP28ay3rDiYg,5089
|
| 21 |
+
pygments/formatters/html.py,sha256=3N1fl214jgyqkCX6Lz3gS8l2EQS7v4Wj7xieYNllNig,36351
|
| 22 |
+
pygments/formatters/img.py,sha256=41uSY0pKg9VmKJYrHuavCVgg0z-mg81p28QEMktwf1o,23304
|
| 23 |
+
pygments/formatters/irc.py,sha256=hdOqAvF02bI8CY8_tutnUptBZpWEBLzVAqS4_YA0tew,4907
|
| 24 |
+
pygments/formatters/latex.py,sha256=KynzALIwJh3w4d96fGmuUqjGed-kGzB3eLvzuWE16-I,19814
|
| 25 |
+
pygments/formatters/other.py,sha256=lI66b25wazeSYlHE30yJVhj3RNvWKZqFS7tUgMMrExk,5007
|
| 26 |
+
pygments/formatters/pangomarkup.py,sha256=L4jU6oO18UqEMqXeN5FkPtkisXrXuXq9wcecgy_6dzo,2209
|
| 27 |
+
pygments/formatters/rtf.py,sha256=YQYW8NTrB4XfOjLbQzutyD4j35TimFNZ0T39dET9DOo,11924
|
| 28 |
+
pygments/formatters/svg.py,sha256=mQoph1amKkD8s-HuO7jWwHzdpSEYpQAXmCU7lOhgGBA,6852
|
| 29 |
+
pygments/formatters/terminal.py,sha256=q7jLLanle33eCZkDr4CoHAN-dHBFf1DBhi4FcBQ8_1E,4629
|
| 30 |
+
pygments/formatters/terminal256.py,sha256=lQEMwHwLRBFpWiZMPnJHbumwoKHBSoCl8HIvuF_rGBE,11718
|
| 31 |
+
pygments/lexer.py,sha256=IDdjLlw7vxjGwSoU3DiBXgWEsWsugee3ZcBK8bPhtzg,35155
|
| 32 |
+
pygments/lexers/__init__.py,sha256=G4dtqE5QMEAqoaaD1rwSZZeuqKhMyS4utlMz1szkrTg,12070
|
| 33 |
+
pygments/lexers/_ada_builtins.py,sha256=dZb-lodsSM6L5emLlgLg-rClm2HumvnHK72CetnSRdA,1546
|
| 34 |
+
pygments/lexers/_asy_builtins.py,sha256=zg54fGhgzWXQUk6-qZ6OW5GTL9d4OrnB8SJQkjrD0xs,27290
|
| 35 |
+
pygments/lexers/_cl_builtins.py,sha256=oBF00ZkJyD14LkYuR603EDFIMyitkze12aT7UzDYLYs,13997
|
| 36 |
+
pygments/lexers/_cocoa_builtins.py,sha256=ab6sq-iy5LapE1cNYyl8PJXLg6EINXx-lMRbwERdKYs,105176
|
| 37 |
+
pygments/lexers/_csound_builtins.py,sha256=wuWiQjmEMhaVvsV8b_efsebgU0YKIoMC0ECpOavTCIM,18417
|
| 38 |
+
pygments/lexers/_css_builtins.py,sha256=qhmC4tRGG53zvzMQE1qn794LvbVODRtVacxWCP3kIkA,12449
|
| 39 |
+
pygments/lexers/_googlesql_builtins.py,sha256=mGfOGuKKjZoHHAAZq6Hpc68x0qKycx-SX_wGDScSOYI,16135
|
| 40 |
+
pygments/lexers/_julia_builtins.py,sha256=u6v0yAzZjqUENjiIQ5qMfcso1r_6ERqGbj3aHwFnyqA,11886
|
| 41 |
+
pygments/lexers/_lasso_builtins.py,sha256=YO_c_f05ZoxspHxCR3oWQCpZhbAJUzBJBhVuuwTjr5c,134513
|
| 42 |
+
pygments/lexers/_lilypond_builtins.py,sha256=-_4i4gpgDgcFHvaZMJL2s1rI9dSNY2ZC6vO6ul7Hml0,115114
|
| 43 |
+
pygments/lexers/_lua_builtins.py,sha256=-OWsR1hO60uWEe-HyWFtPNoIbPOpsWzjXNfKwGcyXkQ,8110
|
| 44 |
+
pygments/lexers/_luau_builtins.py,sha256=YLUj2bcZ0Cb0SBkIlNXWHFGDUFkpddOJx-ukrZx1cMc,958
|
| 45 |
+
pygments/lexers/_mapping.py,sha256=_X4awUqJXkdZHHqRFGDrvipHyu2BFZ6ikndsCKEitPo,71218
|
| 46 |
+
pygments/lexers/_mql_builtins.py,sha256=CkcvMyHYh4U5rGgV6AgShxRnTOv0tmqEbOiVdpaFLqs,24716
|
| 47 |
+
pygments/lexers/_mysql_builtins.py,sha256=SqiVYVVirtnN4lSgtfeRPxtVpcumjUvvUq9n8JObuQ4,26876
|
| 48 |
+
pygments/lexers/_openedge_builtins.py,sha256=AzF1o6eAkMc6vnvmeVqNnUZUVijzbNYkjzrUdtCQe3M,49401
|
| 49 |
+
pygments/lexers/_php_builtins.py,sha256=9g-WLT3qbSGolQJB_4PS6FW_r7HVXBWvI5OWxKtbwok,108054
|
| 50 |
+
pygments/lexers/_postgres_builtins.py,sha256=QGg2mBTThgv4LdXjFm5wrKaKnCU9DubmJi6lXB7y2Mg,13346
|
| 51 |
+
pygments/lexers/_qlik_builtins.py,sha256=3ZkCSDjtxSxXDI9erigWTLSUct_ap_W0LqfZjFeKQYI,12598
|
| 52 |
+
pygments/lexers/_scheme_builtins.py,sha256=O3BRtt5suTESbZ_bSReQ6D0r0G_Sq_i4wCcUkdUrdS0,32567
|
| 53 |
+
pygments/lexers/_scilab_builtins.py,sha256=E33R0mknNc-5eZ9Ugu7u7Av_vUxAaQoMTtdx3MceyxU,52414
|
| 54 |
+
pygments/lexers/_sourcemod_builtins.py,sha256=8qspLxCLsfN9J7N0SWZRNs0A-qJOIGRBAJaNMeWaOBQ,26780
|
| 55 |
+
pygments/lexers/_sql_builtins.py,sha256=fLphonB6wv6Oit8zanJiExgRoLvZoFW4l9lNH-PTYvw,6770
|
| 56 |
+
pygments/lexers/_stan_builtins.py,sha256=sIoONg4TjLkGN7Ab0tZB1HM7tQ071_Z2c41n9lXZl04,16623
|
| 57 |
+
pygments/lexers/_stata_builtins.py,sha256=ymh8GxEca6eSCgHnqsLqsi9OrfRqYnt5O8yBeinJ7DE,27230
|
| 58 |
+
pygments/lexers/_tsql_builtins.py,sha256=Mw6UnMByju0U-OBgT8af3A4utfrS00Tn5lDnaxBtj9c,15463
|
| 59 |
+
pygments/lexers/_usd_builtins.py,sha256=SGp_ePf2VuktrFV59q6df4mTyxZV7AZYs0TJFSWoBAI,1661
|
| 60 |
+
pygments/lexers/_vbscript_builtins.py,sha256=TFtyc11yvpD_OlNrrFbcCOJoUYkWMq3EeHHCpw_zJNc,4228
|
| 61 |
+
pygments/lexers/_vim_builtins.py,sha256=-_wGWnH2Hu4NNtGasyzbxV6cG4_LO3-y0Lrn7seiC7E,120501
|
| 62 |
+
pygments/lexers/actionscript.py,sha256=LrMgu7597B5-C0gy0WlVLkHn22sRBbk6_gUXDhINwcA,11738
|
| 63 |
+
pygments/lexers/ada.py,sha256=BWoQ2CpWBI5TbwN-VGCd0lPsLuImYXKVtCU1tDZrAzY,5323
|
| 64 |
+
pygments/lexers/agile.py,sha256=Du-vjnGZEPHuE40XxTMO-XLt56pYcIaKIAxIwcYHFH0,899
|
| 65 |
+
pygments/lexers/algebra.py,sha256=DpVQCnuiceTGyfXRNvWdl-4s64n60S28-qo-fIMopjs,10161
|
| 66 |
+
pygments/lexers/ambient.py,sha256=8Nk8WX4qrId9zj_zgjJBuFT40yQXG2OXxFhhF3R00g8,2608
|
| 67 |
+
pygments/lexers/amdgpu.py,sha256=GkVjwo54ADtgpyWO9ELnw4YAoU7UZ9ssR3UchnQ9gqU,1725
|
| 68 |
+
pygments/lexers/ampl.py,sha256=TkqkaVyIfbNQpQBDzdTbq0gObv0gGJYZHu5IUvxC4eU,4179
|
| 69 |
+
pygments/lexers/apdlexer.py,sha256=puSpLBWevciSc8G0wg2Y_yQIoGgqPes0UBkpFImqvO4,30803
|
| 70 |
+
pygments/lexers/apl.py,sha256=-jhPYsBVT4ckL7CZmukIZNi6tfaJJbBk2vutld372rs,3407
|
| 71 |
+
pygments/lexers/archetype.py,sha256=buhH2WHtxBowy_KD5SPm5vgHpmLoKMdV9tgMs_bE4xU,11577
|
| 72 |
+
pygments/lexers/arrow.py,sha256=e6mb3Ix4jL7TMGNUpk8iRbJy_VF7VY2J0VUknlo1EvA,3567
|
| 73 |
+
pygments/lexers/arturo.py,sha256=GkklOaiEJTOz8E0zdxd_hd1zXwv7lYgp8IJl7uh13hg,11417
|
| 74 |
+
pygments/lexers/asc.py,sha256=CvFSi7FYDW6eu-5oiKGc0MN3aF1XVZDoFI5-3mHpBDk,1696
|
| 75 |
+
pygments/lexers/asm.py,sha256=cS3eEMyP6affGJ_u6TkbdFMIk8qbVHwIj0AkINziQF8,42201
|
| 76 |
+
pygments/lexers/asn1.py,sha256=MLakOeBFkdhKKr42eHFzonpGITEJxR_God8vqjWPva4,4267
|
| 77 |
+
pygments/lexers/automation.py,sha256=pHnV3yUQhW0E-icbexMyDUKI8vaK8y7RHEW1ghIU1Dw,19834
|
| 78 |
+
pygments/lexers/bare.py,sha256=AdqL9Z20nd0bhNGWielLhAHej6V8_8m1OWUkCOrSBx8,3023
|
| 79 |
+
pygments/lexers/basic.py,sha256=UoNDxIFWAOtHUb_b-bc8fKRXy--935mvO3nkbkCrYA4,27949
|
| 80 |
+
pygments/lexers/bdd.py,sha256=KeuOzXBLJRxxM2gV7aMuYsdV_aJFHyBuF8ptBpWxD5M,1644
|
| 81 |
+
pygments/lexers/berry.py,sha256=THBzW216WxxZ__5r7a36Lv7UuGIedlNGhsN9oZ70ZUU,3212
|
| 82 |
+
pygments/lexers/bibtex.py,sha256=sgfFqXyNyCxROHIe8C0gre69rzbADALnpDtTaqHfSas,4814
|
| 83 |
+
pygments/lexers/bitbake.py,sha256=zwqK9cthJnio8jxqlUJUPt5O5d_I4Byd9dwk950lfdc,6132
|
| 84 |
+
pygments/lexers/blueprint.py,sha256=dW-L5bFIiWxRPDashee2EOYmXIRHdwuCZ1y3iN-a6_0,6191
|
| 85 |
+
pygments/lexers/boa.py,sha256=VqYF1Yg_XdDA5tK_Eiuo1rr7ediBsKUTpB6xza_B5d4,3924
|
| 86 |
+
pygments/lexers/bqn.py,sha256=se4W2XPsNiT36z0Am9X5F4yNLrQvMI5X8miY6R9SEM8,3674
|
| 87 |
+
pygments/lexers/business.py,sha256=YqMwDV7SwF66W7ug0O6sjatfUk7GBjRLF9mWMArozD8,28348
|
| 88 |
+
pygments/lexers/c_cpp.py,sha256=HwYJqLkCAhedyMKnrM8xNEVZYTNa7yB-l3jbt9qpBQ0,21069
|
| 89 |
+
pygments/lexers/c_like.py,sha256=uI1J_xS7sy7bjGp_R5V7ZgLJIlW7Nm8zSJ4GpYhNhks,32374
|
| 90 |
+
pygments/lexers/capnproto.py,sha256=kc3rT95GkeQmrW1LeP5HMVb7Nk8sqXkW6OJkkWIHYbA,2177
|
| 91 |
+
pygments/lexers/carbon.py,sha256=_M-0YbofjZMrJIaiXKoT6wpkd3_6fFq-OdSZ7V961I4,3214
|
| 92 |
+
pygments/lexers/cddl.py,sha256=7Wri2q2yKexWo0CD7s2c7AoCAMbrwyEE6f_gz5B6x1Y,5079
|
| 93 |
+
pygments/lexers/cel.py,sha256=ibsHrMk7abui4WpMEIb2ApwlSugfj0AcNcoUNfra4lM,5063
|
| 94 |
+
pygments/lexers/chapel.py,sha256=hX62O91PcXe6b9d3Oi7lUWYCmiJNd0BgQoQC2pivfIA,5159
|
| 95 |
+
pygments/lexers/clean.py,sha256=_oV3Tbmrpl3S1phPMS6gyMWyGZGj6Wy0q8adpf5vunY,6421
|
| 96 |
+
pygments/lexers/codeql.py,sha256=hAX51uWeG5Zk9JhXSnOxPMaznFOpaX4ZnZHZ2krrPGk,2579
|
| 97 |
+
pygments/lexers/comal.py,sha256=0fcTyV5h36zPlxoQPWWGet2yaYi5ESXiFpx6EbsqP00,3182
|
| 98 |
+
pygments/lexers/compiled.py,sha256=PRimy7eb2weP7X6bEukz1JaSLuQAETO34K7maHLGbxA,1429
|
| 99 |
+
pygments/lexers/configs.py,sha256=9ev0yIzHwM9rVmyHPcqI5aAi5EkllP-80vSBOQT3r2Q,53776
|
| 100 |
+
pygments/lexers/console.py,sha256=UWhJ21BpDWj3913l2Ne5Ni7M_NweUrLTS8gyB9aOnbs,4752
|
| 101 |
+
pygments/lexers/cplint.py,sha256=mJI_of7ACPi_sA0K1DGzsAH2N54MW9hFregCP9ru27M,1391
|
| 102 |
+
pygments/lexers/crystal.py,sha256=k8Xy8TpfGKTPvsP1WikxILScILD8iXZ5qceLZopsLYE,15757
|
| 103 |
+
pygments/lexers/csound.py,sha256=7FVCxtcGXH8nQIoI7E5skcTo9hqEgXLeSEnL5sQZ_5Q,17006
|
| 104 |
+
pygments/lexers/css.py,sha256=6AjX9yYAx9kZ_BK6qL4ox7bqgqqiHp1gC34zR7h0eD4,26457
|
| 105 |
+
pygments/lexers/d.py,sha256=Yh8_dPSlJwFf1eFb82y-kkP1LzqYSoa8X2AFzln0x60,9917
|
| 106 |
+
pygments/lexers/dalvik.py,sha256=0f5mB5y8g0l1ID2liJ_5qM2NjyR_SBs7ckuIDeNbbj8,4609
|
| 107 |
+
pygments/lexers/data.py,sha256=cKO2LwqOeJxjD3_FaMd0jxyzjzf_tE9IKDAlEdUan3I,27068
|
| 108 |
+
pygments/lexers/dax.py,sha256=N-5fxukBfFtFCT2LJoyg1VJsfldWHxXKLY3ZPLnPrig,8101
|
| 109 |
+
pygments/lexers/devicetree.py,sha256=Tig-tTSrpmGzbGxN2ka4MMTiC344roav9A4hoc9o_kw,4826
|
| 110 |
+
pygments/lexers/diff.py,sha256=-627lmuYpJ2uUVUM_orVGgXJGXIBGSVHbmlqflCEeaM,5385
|
| 111 |
+
pygments/lexers/dns.py,sha256=ElzSN3IEoRs1g6iWMnzVIV8H0x9WSEF1wBjm2a0ByxE,3894
|
| 112 |
+
pygments/lexers/dotnet.py,sha256=b4g5nMhHtOU-5if6f-JQlttJLx36XWo-2AIN16c4y2A,40222
|
| 113 |
+
pygments/lexers/dsls.py,sha256=uI1VJaYf95U1swmpx6seFXbulDGtIaantJ5yI883iIg,36750
|
| 114 |
+
pygments/lexers/dylan.py,sha256=fi8mSyni4dnGP5x1crE6BKNqLWJs4dDWdmkur-TbbNc,10412
|
| 115 |
+
pygments/lexers/ecl.py,sha256=kT_kUz6RmeQmkMAaqayS4Qoa7yV3_e3nz_xEoa-iUKk,6374
|
| 116 |
+
pygments/lexers/eiffel.py,sha256=bZo9OWM8rIl7lJh60beL9Rvzqxo9kXIKKaJ8eWOcbfw,2656
|
| 117 |
+
pygments/lexers/elm.py,sha256=Xj3HlbUTEkEUFwhem4NCujx55tQ2TS61_Kcf6BCPHAI,3155
|
| 118 |
+
pygments/lexers/elpi.py,sha256=RZqAVzdxfA_BqBmtMHj8ATw5f9e24SKL-QeO14QuKk4,7904
|
| 119 |
+
pygments/lexers/email.py,sha256=RxPstHy9RVpCYhVX7tZmTMyXiG493WNoEZHM55h-sNI,4690
|
| 120 |
+
pygments/lexers/erlang.py,sha256=2aUlVBVFtQdR2QISsDeKTOPjGrV7r1ckyXL17KJot9c,19150
|
| 121 |
+
pygments/lexers/esoteric.py,sha256=uTYR77pBotb4Q9egWk3IOQ35-gZ7s-ioK6nV0frefJE,10502
|
| 122 |
+
pygments/lexers/ezhil.py,sha256=tbGYtGnqZAB8ffnyPdeMMJHtKYJ7OAciUFRrR_8QpXM,3275
|
| 123 |
+
pygments/lexers/factor.py,sha256=lKs1uQzTtMPEx87rMU7Bw79QRKrzxBWnBqTpJasZNu0,19403
|
| 124 |
+
pygments/lexers/fantom.py,sha256=pP_H_fxfu3Qsil87HNHtp55NeiU6Mp_N4MmSVyqu4UE,10200
|
| 125 |
+
pygments/lexers/felix.py,sha256=DvPOs_Em6fFtUBQCaZWWHWgnvAFeBrDe97Cy9XyQ8ps,9658
|
| 126 |
+
pygments/lexers/fift.py,sha256=Q9OLJivp4ngqFso7APCvX85h-ghdbp9ZqpP8GKHws1M,1647
|
| 127 |
+
pygments/lexers/floscript.py,sha256=aOBKAo64-3cnvoM6Q4XvLng2iuz4609fIReab4tMEy4,3028
|
| 128 |
+
pygments/lexers/forth.py,sha256=4e0OCfJGcElkQrHInmQMucvsI9dljuPx4FYg38dyjno,7196
|
| 129 |
+
pygments/lexers/fortran.py,sha256=ouvOHdMbj56j40Nrj21WCRf4rNKpuwphxmtlUVsnzhc,10385
|
| 130 |
+
pygments/lexers/foxpro.py,sha256=nV8yyES39QoFmTNlM8xl3MteOsvmt6yV1l6x6xnXqIU,26298
|
| 131 |
+
pygments/lexers/freefem.py,sha256=ZmZLIYLXtCK2kWqGzBmrkp7ychOy7vgfaorafUkUl1I,26916
|
| 132 |
+
pygments/lexers/func.py,sha256=ZjOerj3njJcaGnHWc_npWjxb4D5O-udxBRK7RLHEibU,3703
|
| 133 |
+
pygments/lexers/functional.py,sha256=4m9JlAnfpXxSkQQIrNOob2VTwin6hPLAqWuhv9aVkAg,697
|
| 134 |
+
pygments/lexers/futhark.py,sha256=_MAz8PIdhlK0pBSaT39OqLhsOfg36ET0booAdi70lJY,3709
|
| 135 |
+
pygments/lexers/gcodelexer.py,sha256=t8JMWaaDjWZwdGiRGwrpsYtfjKTmibwlRyOLCiJZ8qw,877
|
| 136 |
+
pygments/lexers/gdscript.py,sha256=1aIezdxqgC6zWhq6oA8G1bxntrP4YlwT7Y_5lFQWqwM,7565
|
| 137 |
+
pygments/lexers/gleam.py,sha256=Jx6LnUpWV9pmjdSYLUMt16c3UamZ-v5X6CcuEhWxf-8,2395
|
| 138 |
+
pygments/lexers/go.py,sha256=Rn7fUpj6FLjUkFYjW6qAgDFSQhk1ZrKqAAEdrrkT3Ak,3416
|
| 139 |
+
pygments/lexers/grammar_notation.py,sha256=ZGYcwhSvOolw1J7cA9Pc7hVpcIselaCgxwsvAf5yRgc,8046
|
| 140 |
+
pygments/lexers/graph.py,sha256=X_IsdjxXZn5p9Dq4cLXyqwo4C8emcYA8NP6VZ9ZTBaU,4111
|
| 141 |
+
pygments/lexers/graphics.py,sha256=KfCvhVdl6i3N7elbzehd9Gx6WrU4iYyC94jsTwVdL6A,39137
|
| 142 |
+
pygments/lexers/graphql.py,sha256=RWE_kfVUDEAnv_-SYyOi9IJUks61NvOakmUfWOlorzo,5604
|
| 143 |
+
pygments/lexers/graphviz.py,sha256=yhzFd2537OKnPlRiGF9YiEjfBzaRnMdaGF25Ib4vqLk,1937
|
| 144 |
+
pygments/lexers/gsql.py,sha256=_FJmuKNZsx5fFQUyPFp8-3cQTpnraA7fwcInPINh8b0,3993
|
| 145 |
+
pygments/lexers/hare.py,sha256=eCrRPwcswXL-ZHTWNlhE1A05G9rxzS20_IqSddv2M9Y,2652
|
| 146 |
+
pygments/lexers/haskell.py,sha256=sr5gq3U7xt0D2Bi41xdTsBaponX6otP1qPyRMCuxM7E,33323
|
| 147 |
+
pygments/lexers/haxe.py,sha256=_MzQJTWx18kD9bP_sniBshKbtOZDRm4OZnifaOgw_aY,31169
|
| 148 |
+
pygments/lexers/hdl.py,sha256=JCQKW6HFdoTdFFibL90F1m7cYJhM3IP2AWmxIYEDgdk,22742
|
| 149 |
+
pygments/lexers/hexdump.py,sha256=SAGr_YEkdL8omo1uQb_PtUCAESyE8hPlVK7FGGkOr3Q,3656
|
| 150 |
+
pygments/lexers/html.py,sha256=ROfHF8WggPj4adE6-S9sKvCh5UY0K0I868UxO5y-3fI,22007
|
| 151 |
+
pygments/lexers/idl.py,sha256=STF000ZDy03EDjWYYQzysCpXjScmNg09nzLgEnhgyWo,15451
|
| 152 |
+
pygments/lexers/igor.py,sha256=Sv5EGBJeKy0UOyl6-GF3lBeeoWArVcMDJtQtl2RXRYo,31636
|
| 153 |
+
pygments/lexers/inferno.py,sha256=J6zFrYvkPLd_PGqcH7R2nRsajW8RfRuX1xZlRzC49YA,3138
|
| 154 |
+
pygments/lexers/installers.py,sha256=ioK2JUPSJk9vcsoe3NASvMt-paXd1_Nn3e8WmaqJ7CE,14494
|
| 155 |
+
pygments/lexers/int_fiction.py,sha256=BUjvXilUiuMF-euXEQDzQZs45jn_aLs17eTKcfEptrI,56547
|
| 156 |
+
pygments/lexers/iolang.py,sha256=0YyjBAWP4xl3zd8PcsOtZMIbSh10KXnJCLc6xqclkZo,1908
|
| 157 |
+
pygments/lexers/j.py,sha256=56qUbs1C7wKdZ6-WpNnxHntNqsxWroqiO7keI2yoR1o,4856
|
| 158 |
+
pygments/lexers/javascript.py,sha256=ZuzIW7rxRSfgehj1Ek321cTG3SUkrmDiwv9BmpNfU5M,63365
|
| 159 |
+
pygments/lexers/jmespath.py,sha256=OXI1qW6ylypsmbQLRgmTr8GykaIZ3zfPHyXwqesfDZA,2087
|
| 160 |
+
pygments/lexers/jslt.py,sha256=UOVw1J3uK-hVRWomoFK2jMS_yeuo5iqga-LhXUJI660,3703
|
| 161 |
+
pygments/lexers/json5.py,sha256=GyeZ58AxKkJJiiH7JuPmakDZXropa6bDkFRguJHifqU,2505
|
| 162 |
+
pygments/lexers/jsonnet.py,sha256=rPso9d_PVMnNVJlWMqtkGSxLJb9Exb0OcAjMOtMgGME,5543
|
| 163 |
+
pygments/lexers/jsx.py,sha256=-00tc-VTkFaHkkFV5bvznuvKUeCD5xfWmS4Rqi1nq8E,2748
|
| 164 |
+
pygments/lexers/julia.py,sha256=2JR78TfsGoGI8Ky3Z-1yQSrCIgeicEvEwdCTxOhh4Bk,11688
|
| 165 |
+
pygments/lexers/jvm.py,sha256=PRMUxmztoVBtwvyNi2aN47P5qAADADlylqvzc6ifQ9Q,73264
|
| 166 |
+
pygments/lexers/kuin.py,sha256=R_WrbyuoUK2pvYlzmSjs0lXHgyN94s2NJ250WCCK1-M,11401
|
| 167 |
+
pygments/lexers/kusto.py,sha256=aP9GeFag3cin5oACFw2MXTXEdc8btMVJQm03Jkv810A,3486
|
| 168 |
+
pygments/lexers/ldap.py,sha256=_ya4_InnSIRj-RYjGagWFZJDy1NdgQUocQzVWjiRp68,6554
|
| 169 |
+
pygments/lexers/lean.py,sha256=qP_iwUQ7MJZ1C5s3KYBW8Wu6-uuVj4PAG3a2Ghjp99U,8588
|
| 170 |
+
pygments/lexers/lilypond.py,sha256=o264ovGZFrcx8ZwpKRX-gjUECK1w5T8T0n6LoTjP92U,9755
|
| 171 |
+
pygments/lexers/lisp.py,sha256=CC-VZaGEuWLWtuS66q-1xT-kIPVTuL8yqZ5YxR3HVgM,157900
|
| 172 |
+
pygments/lexers/macaulay2.py,sha256=P43kgbuo6W2jeiSggcC8IJUGkRwqhba2tJRo226alAw,35392
|
| 173 |
+
pygments/lexers/make.py,sha256=wAV0KRRXTAFMliLfAKXDihQIE2VAVUvWjFZ-yuM7a08,7834
|
| 174 |
+
pygments/lexers/maple.py,sha256=aZ4lMzm9hEtgHm0-tkBhBn3SpwR6srI1eW55tyP_3ms,7965
|
| 175 |
+
pygments/lexers/markup.py,sha256=kFcWyal07K7-jlib26R7U9yHoDfn_ubKeZjVc9MVGGU,66526
|
| 176 |
+
pygments/lexers/math.py,sha256=Nspl6IZtCyh9egiYUahboWSmy4cJCVZUBxyVnCuF1ag,698
|
| 177 |
+
pygments/lexers/matlab.py,sha256=21aZat9CTpxJLEyOdzFBePOFEpXB4hF6Hcq6zaOIg9c,132992
|
| 178 |
+
pygments/lexers/maxima.py,sha256=ha-f-JzGkjggAr5kxmVq7_uJTCcpHstQWnsLHYIhNwU,2718
|
| 179 |
+
pygments/lexers/meson.py,sha256=WXA6cdMx8OAVN_rawbAoopYsO2z9_453s3OAOutkgCA,4347
|
| 180 |
+
pygments/lexers/mime.py,sha256=l5BsFkad3agJ6KDg_IHI6nU0Ao0Y9EcwjYoYP8vQD-g,7585
|
| 181 |
+
pygments/lexers/minecraft.py,sha256=bBbMbqvsVgTfO7CBxf03oGP_qOAgrw06PSzH1QF7txs,13701
|
| 182 |
+
pygments/lexers/mips.py,sha256=QpgBoMPzsk1t90cIF0W_EV-QZ8LwgTapS-fSISxZcFc,4659
|
| 183 |
+
pygments/lexers/ml.py,sha256=jqA8SxYk8E6DlrmPID1M4ntBFqiPYa9TwsNZcnbF4Jc,35398
|
| 184 |
+
pygments/lexers/modeling.py,sha256=PplErE4xasvfL8QjY036Aiu75igMbFmyIqOd5C38KAo,14664
|
| 185 |
+
pygments/lexers/modula2.py,sha256=dXW0KNFu3ETgABsPMsIhdJI0DKF-KWtT831FKsz2VXw,53075
|
| 186 |
+
pygments/lexers/mojo.py,sha256=QrVci9-WIOgvSLczXoWhm8AD3PGAYs6VrN5FcGj4Ofo,24232
|
| 187 |
+
pygments/lexers/monte.py,sha256=JTx-jSrFKlWRwA1qzhPd647ETGSElwhP4YMlVrfXyX8,6292
|
| 188 |
+
pygments/lexers/mosel.py,sha256=qgH6LxmoSoBDb_LrL3eXswt_esaPIX96vkAy68wFH_w,9300
|
| 189 |
+
pygments/lexers/ncl.py,sha256=RZXkxOK-iHspLX_sFVT0wc5H6v-pa4kKghP79fJGQPQ,64002
|
| 190 |
+
pygments/lexers/nimrod.py,sha256=L8Ww5CUaP-ojywoQZXnjC08m5Be64fBynSf5aWGIaPw,6416
|
| 191 |
+
pygments/lexers/nit.py,sha256=ffrBJiZ4coH6THmsSBlcCEpD58lRxwkLkpAobT_v5-4,2727
|
| 192 |
+
pygments/lexers/nix.py,sha256=M2E-k--F7pneuMAOae9ag4srJsKhWJ1f1fRueO6PtKM,4424
|
| 193 |
+
pygments/lexers/numbair.py,sha256=tATiI26K4OfAyj3Sy3_8gyMMXFA4FgzIa_QuK4nV6us,1756
|
| 194 |
+
pygments/lexers/oberon.py,sha256=uH1FkPeXCfdd0IQ_--S8SHUNaf2dnjiQZjtIT-jxu4A,4216
|
| 195 |
+
pygments/lexers/objective.py,sha256=RD5nhW15pg3FUuy1IfGvb_h4be_3h5-HkFWpLVRI8eU,23663
|
| 196 |
+
pygments/lexers/ooc.py,sha256=HEjWHdQDVk7tRb_TuEb1_C5qi-peJwwyYBVAhf49MS0,3005
|
| 197 |
+
pygments/lexers/openscad.py,sha256=te2iL8VkfXul_PYXlz8UK3_QtMjdmNgt0YHCYEvdEtM,3703
|
| 198 |
+
pygments/lexers/other.py,sha256=OAlXzsrVDUx4Ma25fyG98U5LaBEHyt-LJZ2IHvMJJWY,1766
|
| 199 |
+
pygments/lexers/parasail.py,sha256=Kv6_y28WTDDusIbynUsUUj_oazx4huRbO0Dh9Hfd6jA,2987
|
| 200 |
+
pygments/lexers/parsers.py,sha256=mKalKvYx1RrCz2VpEUZaUP_asGH4bP4F_TvdKxQ8Dsc,26598
|
| 201 |
+
pygments/lexers/pascal.py,sha256=4dewXkwc12f_iiMfdNDqbxb_oqAEX2dCzb5VIZ62V54,30992
|
| 202 |
+
pygments/lexers/pawn.py,sha256=n64BStqTxTzqcqCgNECyH7gv-XYEYfl_3SFoNXmwPvo,8256
|
| 203 |
+
pygments/lexers/pddl.py,sha256=a8A2keCF9qNQvVZQirgBV5fH4u3cjrta8-eZJ8tsxmY,2992
|
| 204 |
+
pygments/lexers/perl.py,sha256=ozzAeXY4O2mTIXNOuWomFViqW6I6IPQisGD1-Hl_VoY,39195
|
| 205 |
+
pygments/lexers/phix.py,sha256=nEWWt5-OoIDapw4IJ_cNL19Th8Ztt6OIQgeuogVed10,23252
|
| 206 |
+
pygments/lexers/php.py,sha256=U6wmxPM-pS-SY1N3qdv0ebUDBxLH6-EFIFcatUvg74w,13171
|
| 207 |
+
pygments/lexers/pointless.py,sha256=gNcuhhOY9cEpIPyGFjMh2DItNB1UD8CmjceXkDRModE,1977
|
| 208 |
+
pygments/lexers/pony.py,sha256=rqrhNoTPoAGLmaYChyTM4ALgaTsnLakvmAEi1jsVUwM,3280
|
| 209 |
+
pygments/lexers/praat.py,sha256=sfVAd7zfRsI-TcCouuYMWlcU8EBxAwJ4wkh0ZuNsZ34,12679
|
| 210 |
+
pygments/lexers/procfile.py,sha256=fhRTtscyMMPcPbvzjxVtXix1mYlpO-4JuWUL7Db4ENI,1158
|
| 211 |
+
pygments/lexers/prolog.py,sha256=C5pMapUlzrV6KaPEdyD8aRdAigIlnUzjFVnFu0TvHWA,12866
|
| 212 |
+
pygments/lexers/promql.py,sha256=04fS_R6HBWhpKNe3WPp_QXgIdFvJr5p6KxStZYw7yHU,4741
|
| 213 |
+
pygments/lexers/prql.py,sha256=XJhd8dpEWPBIKmQXx_09-z1NyotLXIskpuzX36HykHo,8750
|
| 214 |
+
pygments/lexers/ptx.py,sha256=mqqaC17DGpmdc2v55u-4e_1htBxmXvuKK07Vcsbzabo,4498
|
| 215 |
+
pygments/lexers/purescript.py,sha256=cbDAly-NUN4O_SUk6v5zJSUQzoZZJbOTMHWeZRPx6lo,6086
|
| 216 |
+
pygments/lexers/python.py,sha256=56Mm_WBnPjPatEOXyZq-PxCCJNYZo05bIK9e1i62A6U,54574
|
| 217 |
+
pygments/lexers/q.py,sha256=2CbJYgRu8uz8wOSp5FMr086KCC7IjSRmIODVY0uKrCA,6939
|
| 218 |
+
pygments/lexers/qlik.py,sha256=9b6Q-6jXeeraIRcWtsKsYWCOlBhfmjNzIN49pUvMR-I,3696
|
| 219 |
+
pygments/lexers/qvt.py,sha256=Xl_lizvhmMwO-l11MUFzZuBKHb-cPNDN7F_PXhk0nBg,6106
|
| 220 |
+
pygments/lexers/r.py,sha256=-4ZaP45fsq5EiEacsZkI2PQdi1-cHV-woef-wLL355Q,6476
|
| 221 |
+
pygments/lexers/rdf.py,sha256=FM154fB1lxfOpSpeW6bWOVld5kJBgEuYyT9udt-EcK0,16063
|
| 222 |
+
pygments/lexers/rebol.py,sha256=CQ3pMaAz64UMqiQVrYoREnOgjU5QPeF_H3aaHNdVRC8,18262
|
| 223 |
+
pygments/lexers/rego.py,sha256=Yi0G4secTWOL7CUhLLCzJ9gA6SJzDJpPJNij3hXixC0,1751
|
| 224 |
+
pygments/lexers/rell.py,sha256=-oa-JHAAyRP8--ZmFrPtaifzQNuqzqydmN1jF3XclOk,2484
|
| 225 |
+
pygments/lexers/resource.py,sha256=RDEY7iSv2hgQ3V-I1DeOKVOumNKgFqbV2Me_9Y21o10,2930
|
| 226 |
+
pygments/lexers/ride.py,sha256=1zg7kGYPKRIekyuZY3f6OVqRlXyrX-sR-tHEX1M9nz4,5038
|
| 227 |
+
pygments/lexers/rita.py,sha256=fCNElPik6dDIZzGd96kKgdlY4Qqp_zVI87waTBHMBfg,1130
|
| 228 |
+
pygments/lexers/rnc.py,sha256=PNfnnTlnZjNvvG33BNMCqPzdA9LZEYvDsGoaDd_2mn8,1975
|
| 229 |
+
pygments/lexers/roboconf.py,sha256=l6BeJIS-ZAUb3zc5GEuVIb0edrRpPFmKdffEBx74Zxg,2077
|
| 230 |
+
pygments/lexers/robotframework.py,sha256=8s1U7GldhzRPGR7d8_rMSG0ZJz9ZOm-LGqBTGILwt2U,18451
|
| 231 |
+
pygments/lexers/ruby.py,sha256=5STDLcvmmBwGdRp1FNhzW25I9A4cvBv44dwLNuXy_V4,22987
|
| 232 |
+
pygments/lexers/rust.py,sha256=7qD3KGVir-tUWf_bPBt4EX8l9aIWe8TblMCFI75oorc,8263
|
| 233 |
+
pygments/lexers/sas.py,sha256=BF-HLqzjnBW64nkw3E5OplkXnIkf-OS3SX3HmWJKzyU,9457
|
| 234 |
+
pygments/lexers/savi.py,sha256=HCllgBe3rzP_7-2b1hSUEbE2dYz08Iysxc6Dcxj3f2c,4881
|
| 235 |
+
pygments/lexers/scdoc.py,sha256=9n64S-bO1dI4x-2Kzh2jrDM6gEmB5YI7ch6ndPB4-cw,2527
|
| 236 |
+
pygments/lexers/scripting.py,sha256=vsw_KNTMFb5yzWHlDwd7w5C8bKCer2ZeL_BVtUhpy0Q,83232
|
| 237 |
+
pygments/lexers/sgf.py,sha256=ya_sG4TOvDWwzEM6cIi40XSbhkTuHCqvo-uHnNYfi5Q,1988
|
| 238 |
+
pygments/lexers/shell.py,sha256=rJ1yhM-pScZ10C6SZCFZweHBbid7RRC9qmlTUG265xg,36425
|
| 239 |
+
pygments/lexers/sieve.py,sha256=CXR9S1nGeVTln2u5R600hxgkAmJFVVTTTBh_k3aw-pk,2517
|
| 240 |
+
pygments/lexers/slash.py,sha256=Vlwv2EX5_s0V-TGnlXW7VjfQIeaFpj0pE_IUamdApnQ,8491
|
| 241 |
+
pygments/lexers/smalltalk.py,sha256=q52NHegl3pjn1jMkJWA9J0nOA_A5VzUULZAPgb-6uNU,7207
|
| 242 |
+
pygments/lexers/smithy.py,sha256=PBzMxxqZslii_U3AWTMUfjY6cOFTwBPvNjdL7-iRs7Y,3233
|
| 243 |
+
pygments/lexers/smv.py,sha256=D51In9Qr2nWFicYAOX_bJpeFgmJ3BUkEXnvXPmA04D4,2808
|
| 244 |
+
pygments/lexers/snobol.py,sha256=BX_1VPUZi-ckKCYlF2sttQprF2bLUHOi8blhInFHv9s,2781
|
| 245 |
+
pygments/lexers/solidity.py,sha256=pz0DZ0xiHwufhbQ9hdCPrHMjA7NMsa6hxZ1nO-A4Y3E,3166
|
| 246 |
+
pygments/lexers/soong.py,sha256=p6FMNSSuDs86oWPTTVUseu1Jj00nth5pG4jp1kje6hg,2342
|
| 247 |
+
pygments/lexers/sophia.py,sha256=MAkWLYxhHJNcc3UUzWD3VDLzVRbf6IAd2uz4q7DY3wI,3379
|
| 248 |
+
pygments/lexers/special.py,sha256=8gpTiLICFNwIcahm282mi8Nqi_6gwYMsAfjJIM2Bq6k,3588
|
| 249 |
+
pygments/lexers/spice.py,sha256=Ss6oR3C8Vg5g6A5Lm4do-z24yeVHMbUM770zPaygD6o,2801
|
| 250 |
+
pygments/lexers/sql.py,sha256=3DLtocXfraFpaebTXaecPpDCbp6_DjzF1jt4Os9KhoQ,41901
|
| 251 |
+
pygments/lexers/srcinfo.py,sha256=MHj02VB7WP3AcoOz1WVYAqNM_3oFLjEaAda075kXVBU,1749
|
| 252 |
+
pygments/lexers/stata.py,sha256=KojmkxWHlEk-HvmxI313a52nzH_JHNqfv6r3jJoFDy8,6418
|
| 253 |
+
pygments/lexers/supercollider.py,sha256=H-qwP6sUaotemsXxuugpui6KnU3jtIdDfS3bGt3Jvh4,3700
|
| 254 |
+
pygments/lexers/tablegen.py,sha256=ryuzw-ArLdvlY55YJBn6ebOzDo3L8UnbR5xcZB8xMso,4012
|
| 255 |
+
pygments/lexers/tact.py,sha256=YbOWYNp302ZBPM5affzM4-CudJ4xRZyJb-_vSDCozCo,10812
|
| 256 |
+
pygments/lexers/tal.py,sha256=xZYmhv8mBr-A3oeoFkcSP7nDbX1r21kKOnhsLTtL3bE,2907
|
| 257 |
+
pygments/lexers/tcl.py,sha256=o0JzyYFFDzOYZK5DTS4bDnYc33SKBQzR8HZMPKxAFoc,5661
|
| 258 |
+
pygments/lexers/teal.py,sha256=pgpPi9xWPumSr-heSpGBGDcU5s3qN0aFUj2maHLE3MM,3525
|
| 259 |
+
pygments/lexers/templates.py,sha256=NGY4Dt85fHPqtSpjECAqQXaQ2agvOWySg80HdXiKz3E,75715
|
| 260 |
+
pygments/lexers/teraterm.py,sha256=YCdvILRq-FdOJ_HfiIkYVToH3c6I2QRbQoH17Q49Hx8,10045
|
| 261 |
+
pygments/lexers/testing.py,sha256=GF5SpanGwjgKKoYari32SdtdOWWXXje8xVX5-ZzTjLg,10813
|
| 262 |
+
pygments/lexers/text.py,sha256=yq6mOLz3PizKNMm4_Y8UHn9vEeBfqEY5W-3M7dk1jYs,1071
|
| 263 |
+
pygments/lexers/textedit.py,sha256=_DW3fSw25EkC_-_GRKep64DkxkmvjlbUxZNi-ajTR18,8065
|
| 264 |
+
pygments/lexers/textfmts.py,sha256=WSiJDzNKCcOsBoTU4NCYU33ti5ZHGi0Px29eGjT6pB0,15527
|
| 265 |
+
pygments/lexers/theorem.py,sha256=c-eg6tIYWUbxSYgrOtLZfFxro4g91JcAIwrIJGLPooU,17903
|
| 266 |
+
pygments/lexers/thingsdb.py,sha256=FNKjArS1vadHEN3ZXaZdDLqvcG59GbF6Ak5M8RMsTLU,6257
|
| 267 |
+
pygments/lexers/tlb.py,sha256=vWsFq_MrIrzgG2q-qdzpcoNiv9KkNow4x9ebs9_HAwA,1453
|
| 268 |
+
pygments/lexers/tls.py,sha256=GZ1lvZ8PUk1-LThq1KuiqSEnMqJVqiHo_A-16aKuJOc,1543
|
| 269 |
+
pygments/lexers/tnt.py,sha256=MNYTfkix0x5L1pDV8V8zGLS7GU8z7bt-wpiBap2W09U,10459
|
| 270 |
+
pygments/lexers/trafficscript.py,sha256=1Tawom6bKJM-u1kYey21xFaHep3D9kl62rV3RaHSvcI,1509
|
| 271 |
+
pygments/lexers/typoscript.py,sha256=dWAuOYYk0X4xE_fxKgcXz-sMYlG2wxQR4m_d7PW2PYs,8335
|
| 272 |
+
pygments/lexers/typst.py,sha256=qtbEgl8HevhvncgVUYLCmvLrgyGrzgVjZE0NlMxnaUI,7168
|
| 273 |
+
pygments/lexers/ul4.py,sha256=joM-US0-2BEWRHHK6eyZ-Y--306YgbMrevMY0hg8QTY,10502
|
| 274 |
+
pygments/lexers/unicon.py,sha256=blg8AQYmU4SujjtyATTljEY-ML39isICvIYb1FYhL5k,18562
|
| 275 |
+
pygments/lexers/urbi.py,sha256=j87k6fe60kZdbJ6AJA4g9E0no1EP0bxJY06UVP0YgnU,6085
|
| 276 |
+
pygments/lexers/usd.py,sha256=ZeIavF5ISiDyKoVFqv-HSipmUtMLzwmFHvXReevYHiY,3303
|
| 277 |
+
pygments/lexers/varnish.py,sha256=INCtYbol1yV_NXMh51CMDZDacEHgiB3SmR3H5uW-Fkc,7476
|
| 278 |
+
pygments/lexers/verification.py,sha256=BEiuUB_a_Ujt7J3jLo1xGVr3JilYE-c7sGPVASe5feQ,4256
|
| 279 |
+
pygments/lexers/verifpal.py,sha256=0iZTQWawF9f7lFZnFNPTwYRiu6L_25PtEI83tuCAmKY,2664
|
| 280 |
+
pygments/lexers/vip.py,sha256=pM5xFoeu-2GPWqAVzZJe6xPYr6WJPlozVI5084SHQ80,5714
|
| 281 |
+
pygments/lexers/vyper.py,sha256=rw2yD9c2L7yPtXqKPd0RdxJSZK-aJbW5jEa0gHfKEO0,5618
|
| 282 |
+
pygments/lexers/web.py,sha256=YMrxoHlKlQwfFJlae9_T9F1Vp03YA7IWsmgqLzh6pgI,916
|
| 283 |
+
pygments/lexers/webassembly.py,sha256=kQSeF2MyOnaAV4tRVsYHl2rcFO_FcrAjRYt0Ri2o5pU,5828
|
| 284 |
+
pygments/lexers/webidl.py,sha256=MQMaZFskluB29lMGpiGP2f6fzoja4vV8FtoCGFQH6fM,10519
|
| 285 |
+
pygments/lexers/webmisc.py,sha256=jqTLBw_Suxpi3diBtMCDPL6_Uf5gxpnGgi2uN1hWeUM,40563
|
| 286 |
+
pygments/lexers/wgsl.py,sha256=vgDtY_q42TGRvcsyS7viSadU8D3eHvatfoCNNnEP0zE,11883
|
| 287 |
+
pygments/lexers/whiley.py,sha256=MC2V7o1s7LIoLy0Fk-i8OymBoN0dpK2BPjIrdQwsnVk,4020
|
| 288 |
+
pygments/lexers/wowtoc.py,sha256=XnLSSX7p_RkwZIzlmYXO873d4byX9-A3dfvzNL5Eocw,4079
|
| 289 |
+
pygments/lexers/wren.py,sha256=2lhzwpS27xW6nERY_NeODgNN9X6mB7vl3odXSPngqY8,3232
|
| 290 |
+
pygments/lexers/x10.py,sha256=0Z0hhPboSfIVE9NTi_gTXgI_uRrS8ARj0vm7JwZagz8,1946
|
| 291 |
+
pygments/lexers/xorg.py,sha256=LUKU91t1Opc3W_F64UGzx0nB-HqKlN3Cn_6tFzt5IYw,928
|
| 292 |
+
pygments/lexers/yang.py,sha256=yIvwteHWBWL2-8zZscnCPJOnq3rMOXh5lxJujywA_Zo,4502
|
| 293 |
+
pygments/lexers/yara.py,sha256=_ISzhko7v9AhJ-1cWINZSyG3my2vJOyFSHxSjm4VdTY,2430
|
| 294 |
+
pygments/lexers/zig.py,sha256=Cf28cP0orM89xc3QpJVchIQv02pr0jsnJLRzqivSAL0,3976
|
| 295 |
+
pygments/modeline.py,sha256=me8g5rySidvPtMBOrDy2O1sMqZd02lBHMY5KDZefUws,1008
|
| 296 |
+
pygments/plugin.py,sha256=9NKTHzu9SV7hfY3-TVC4Y7wQx83C8i5Lgs3-ABTBMbQ,1933
|
| 297 |
+
pygments/regexopt.py,sha256=Ko9XtXDiLEKerWaD5492krCBWdpmZpgvkkmU_OkRmSo,3313
|
| 298 |
+
pygments/scanner.py,sha256=DtoLi1pOKpNu-6jiakJpSQLUi_ep29SQQhv7oAwYWME,3095
|
| 299 |
+
pygments/sphinxext.py,sha256=qmiWv5b7qq6bNUT2Y2wZejV2ImQmvtzGJFg6LcGENl0,7901
|
| 300 |
+
pygments/style.py,sha256=KYKfa_XPQTOPxphTuRrT9UGnbj46_GtrEyQRlGe6q1c,6479
|
| 301 |
+
pygments/styles/__init__.py,sha256=2vgGKnbyt0nf_CSDEtMhHxppPSAPr2jafzl5FiXFuGs,2009
|
| 302 |
+
pygments/styles/_mapping.py,sha256=MA3yqBy-5JIc9wawxP8y_0GYv7IWRR6OLo-t0oUGETQ,3381
|
| 303 |
+
pygments/styles/abap.py,sha256=T7Ad121Kjz8ZbuphyhulULwXyvXubSS6Czc0MDOFiJ8,752
|
| 304 |
+
pygments/styles/algol.py,sha256=6v6ZXLxPJsm_1qPqOu5ihAuWhVk644NdPXPcZqiOTTI,2265
|
| 305 |
+
pygments/styles/algol_nu.py,sha256=581Lf5db303g7zDb7z-VlvGlFNpbXMIlAnrRBxtjGts,2286
|
| 306 |
+
pygments/styles/arduino.py,sha256=oFF5gjfbQNBigKxFhC7giUIHWl0ieCshhsm9UxCIzqg,4560
|
| 307 |
+
pygments/styles/autumn.py,sha256=P9IX5utjDvdJgevM0kNGwE-wvVysRh1lgMkjO1dhDDE,2198
|
| 308 |
+
pygments/styles/borland.py,sha256=V8qTD8SrS0wLohp2udIirlijbHfPoIlWZkYpqxSdkSw,1614
|
| 309 |
+
pygments/styles/bw.py,sha256=e4Fo6Kyax2aRhqKsjsqvi2CW6lkU9QnjKoPrESZAj-I,1409
|
| 310 |
+
pygments/styles/coffee.py,sha256=0jxdctCEKbR1AqzA59fFQK4sVBdErrRkGCUn6fPF4sg,2311
|
| 311 |
+
pygments/styles/colorful.py,sha256=opkfOcjFTtDn9Fty6ogM7okFMB6bA0iR0VtTdBPE9NE,2835
|
| 312 |
+
pygments/styles/default.py,sha256=WFLDucKJS_ac5Jqutmglbz4ITc4jTTQEOnqLIMpSttA,2591
|
| 313 |
+
pygments/styles/dracula.py,sha256=H-EM1WM3Ixd2OBY9bzoObKl4IzdmhirfDVFbJ9Wsi0Q,2185
|
| 314 |
+
pygments/styles/emacs.py,sha256=iEYWPgQrDQk4RdDf8-g7j4mtoFRzo2xcKvZE1ys9mJU,2538
|
| 315 |
+
pygments/styles/friendly.py,sha256=S43XMczW53tKftmarEL4-nTroPVdN6k8fbNrINzR_QU,2607
|
| 316 |
+
pygments/styles/friendly_grayscale.py,sha256=el2E804DEkKZ6ApXt3N5FTmHAkIhqkJj-omhE1E8mdE,2831
|
| 317 |
+
pygments/styles/fruity.py,sha256=mrNDixp39QIoitRBo-yMOr8tnYLAwGd0EIMw2A6Gd8g,1327
|
| 318 |
+
pygments/styles/gh_dark.py,sha256=yb4EOBAYsQ9g5IGEOqyZ5LKI-MUbwz32l9WB5EcMLaA,3593
|
| 319 |
+
pygments/styles/gruvbox.py,sha256=_QZtRq9y1s3NYADHqek-DXELQqueOnVDXvWJ_1aTGgo,3390
|
| 320 |
+
pygments/styles/igor.py,sha256=QO_M5-Z1xIxVnusEU4LZr4VT--nTERVt-cpfbnOv4yk,740
|
| 321 |
+
pygments/styles/inkpot.py,sha256=bJvNWikqnAWLjx2AH4t_tW4jR0TsrUyVFXFVPAfOgkM,2407
|
| 322 |
+
pygments/styles/lightbulb.py,sha256=CnDv1mF1X5k1msVvRS_diR4tkp06E_jg0tK9cdHEFCQ,3175
|
| 323 |
+
pygments/styles/lilypond.py,sha256=gSCiazPPWfR_9-BV5BYHe6-2gSor4vOHnz3nyFQI2QA,2069
|
| 324 |
+
pygments/styles/lovelace.py,sha256=vZ-S9tS-QUOwfA0RHYBhSTRE3h1ZU-bZnuMW7O6ksyw,3181
|
| 325 |
+
pygments/styles/manni.py,sha256=dpsJC1Zees0e9IcWirqWuSzQxwD0jIbjhFquM23dmWM,2446
|
| 326 |
+
pygments/styles/material.py,sha256=eyyAaJgp1Fnjl4-_D39_l1wH5CW4W0VWScQ3Q0jtAgU,4204
|
| 327 |
+
pygments/styles/monokai.py,sha256=z4V7tQahiGoBXufPOXYAwM4OUsTAHUstpexEAcPAIsI,5187
|
| 328 |
+
pygments/styles/murphy.py,sha256=HsPd80nObb3Ov3-7yJQbnJr3z9mCyz30Pjn_nkWkMYo,2808
|
| 329 |
+
pygments/styles/native.py,sha256=oazEJUbuaHqqOZR5vx-jIhTPIw7dC6QZnKxW-xLr7fs,2046
|
| 330 |
+
pygments/styles/night_owl.py,sha256=bC4BDhbGrRXfYB2D2--8n9kG8xRPSRsddb289jd6T30,4565
|
| 331 |
+
pygments/styles/nord.py,sha256=t7fZj04LUgsLaHpio66FqOGMKb7a2VC3teUlmInPfRg,5394
|
| 332 |
+
pygments/styles/onedark.py,sha256=UXrMzVvA9OVP7OhCQ5gL0CaZrk5jo_I84HJm7LEN5GQ,2126
|
| 333 |
+
pygments/styles/paraiso_dark.py,sha256=rx5_j4gnZRy2j-3hAhFmWpnjnd-Vfz3Z7fcwEXRUGm0,5665
|
| 334 |
+
pygments/styles/paraiso_light.py,sha256=iERjbYRemqgsisv_9TjanBig4bJ_-80xRz5B5puhMc0,5671
|
| 335 |
+
pygments/styles/pastie.py,sha256=mnKebFiJ2do9A_wTPq4tKtgw-TQqpb0lP3kNbemQ2to,2528
|
| 336 |
+
pygments/styles/perldoc.py,sha256=-e1T4QBEQNE_l17RYW-WBowNprg2uL_hFjhSDcaMiDM,2233
|
| 337 |
+
pygments/styles/rainbow_dash.py,sha256=YP2HPVXJLmOy8Yz8p8u5GbkAyuKxLlNmu6ITZBMa1Mc,2393
|
| 338 |
+
pygments/styles/rrt.py,sha256=vs4pnWwmMIQR0eGczp06AYazsYiR0KFcRiRUzSf3rXc,1295
|
| 339 |
+
pygments/styles/sas.py,sha256=ER-JjZgU2wEJWk5K06iHAFPjVYD1iMkvjjE0rlNOt2Y,1443
|
| 340 |
+
pygments/styles/solarized.py,sha256=VdtLYhQ7xDj_iTHP_Ekr6rAdMcE3fRSrglngVSal63M,4250
|
| 341 |
+
pygments/styles/staroffice.py,sha256=peExkIBqPkRhqXFpW99n49t6pMwehI_pDYVUmQwkgdA,834
|
| 342 |
+
pygments/styles/stata_dark.py,sha256=N6imWykqHoT5drOn-sVRUzt1AZMKG3HHU-Q7LKz2d50,1260
|
| 343 |
+
pygments/styles/stata_light.py,sha256=YW7ih4teXoEuUHImOK2rGSCVxfnj43tlcKPXUsrDkRg,1292
|
| 344 |
+
pygments/styles/tango.py,sha256=Af0WVTxpH_cUdHr_ua69JDijTLI5aG1RmBTF7o2KTgk,7140
|
| 345 |
+
pygments/styles/trac.py,sha256=-h5iU-LjSmt-dQ7y5jXwJ5LQ9ABR5QD5RlPRjhnzmv8,1984
|
| 346 |
+
pygments/styles/vim.py,sha256=dWqCVC2YT45dLSpMTwLBPkKYgRsT1-cFf7ZHoc2PQpA,2022
|
| 347 |
+
pygments/styles/vs.py,sha256=7HJehhtiHE5nibjC3r3X-aYHBm5BccL33LgO_4anEiU,1133
|
| 348 |
+
pygments/styles/xcode.py,sha256=HmB6aPkxvmo4za5DijhLb5AXSyv6UbWnwOUoRUNBaZA,1507
|
| 349 |
+
pygments/styles/zenburn.py,sha256=Ax7iBbMzvVQNTpT3YdMwCEkL-nIXnpr60aVrR4Lpa6o,2206
|
| 350 |
+
pygments/token.py,sha256=DVil5T2ltHkTgQTUYy1dMtgyigjavCs1ypE4Qf2CrGo,6229
|
| 351 |
+
pygments/unistring.py,sha256=Z4w4HfOVUhueCURRkfhAqQ2b-69UzkhY4xuHevYEy5g,63211
|
| 352 |
+
pygments/util.py,sha256=N0MugoJ5puAxxVeGWqHaorJC9HcHkvRUiahTbcWS48U,10770
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/REQUESTED
ADDED
|
File without changes
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: hatchling 1.32.0
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/pygments-2.21.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
pygmentize = pygments.cmdline:main
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/__init__.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Rich text and beautiful formatting in the terminal."""
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union
|
| 5 |
+
|
| 6 |
+
from ._extension import load_ipython_extension # noqa: F401
|
| 7 |
+
|
| 8 |
+
__all__ = ["get_console", "reconfigure", "print", "inspect", "print_json"]
|
| 9 |
+
|
| 10 |
+
if TYPE_CHECKING:
|
| 11 |
+
from .console import Console
|
| 12 |
+
|
| 13 |
+
# Global console used by alternative print
|
| 14 |
+
_console: Optional["Console"] = None
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
_IMPORT_CWD = os.path.abspath(os.getcwd())
|
| 18 |
+
except FileNotFoundError:
|
| 19 |
+
# Can happen if the cwd has been deleted
|
| 20 |
+
_IMPORT_CWD = ""
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def get_console() -> "Console":
|
| 24 |
+
"""Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,
|
| 25 |
+
and hasn't been explicitly given one.
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Console: A console instance.
|
| 29 |
+
"""
|
| 30 |
+
global _console
|
| 31 |
+
if _console is None:
|
| 32 |
+
from .console import Console
|
| 33 |
+
|
| 34 |
+
_console = Console()
|
| 35 |
+
|
| 36 |
+
return _console
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def reconfigure(*args: Any, **kwargs: Any) -> None:
|
| 40 |
+
"""Reconfigures the global console by replacing it with another.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
*args (Any): Positional arguments for the replacement :class:`~rich.console.Console`.
|
| 44 |
+
**kwargs (Any): Keyword arguments for the replacement :class:`~rich.console.Console`.
|
| 45 |
+
"""
|
| 46 |
+
from rich.console import Console
|
| 47 |
+
|
| 48 |
+
new_console = Console(*args, **kwargs)
|
| 49 |
+
_console = get_console()
|
| 50 |
+
_console.__dict__ = new_console.__dict__
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def print(
|
| 54 |
+
*objects: Any,
|
| 55 |
+
sep: str = " ",
|
| 56 |
+
end: str = "\n",
|
| 57 |
+
file: Optional[IO[str]] = None,
|
| 58 |
+
flush: bool = False,
|
| 59 |
+
) -> None:
|
| 60 |
+
r"""Print object(s) supplied via positional arguments.
|
| 61 |
+
This function has an identical signature to the built-in print.
|
| 62 |
+
For more advanced features, see the :class:`~rich.console.Console` class.
|
| 63 |
+
|
| 64 |
+
Args:
|
| 65 |
+
sep (str, optional): Separator between printed objects. Defaults to " ".
|
| 66 |
+
end (str, optional): Character to write at end of output. Defaults to "\\n".
|
| 67 |
+
file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
|
| 68 |
+
flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
from .console import Console
|
| 72 |
+
|
| 73 |
+
write_console = get_console() if file is None else Console(file=file)
|
| 74 |
+
return write_console.print(*objects, sep=sep, end=end)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def print_json(
|
| 78 |
+
json: Optional[str] = None,
|
| 79 |
+
*,
|
| 80 |
+
data: Any = None,
|
| 81 |
+
indent: Union[None, int, str] = 2,
|
| 82 |
+
highlight: bool = True,
|
| 83 |
+
skip_keys: bool = False,
|
| 84 |
+
ensure_ascii: bool = False,
|
| 85 |
+
check_circular: bool = True,
|
| 86 |
+
allow_nan: bool = True,
|
| 87 |
+
default: Optional[Callable[[Any], Any]] = None,
|
| 88 |
+
sort_keys: bool = False,
|
| 89 |
+
) -> None:
|
| 90 |
+
"""Pretty prints JSON. Output will be valid JSON.
|
| 91 |
+
|
| 92 |
+
Args:
|
| 93 |
+
json (str): A string containing JSON.
|
| 94 |
+
data (Any): If json is not supplied, then encode this data.
|
| 95 |
+
indent (int, optional): Number of spaces to indent. Defaults to 2.
|
| 96 |
+
highlight (bool, optional): Enable highlighting of output: Defaults to True.
|
| 97 |
+
skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
|
| 98 |
+
ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
|
| 99 |
+
check_circular (bool, optional): Check for circular references. Defaults to True.
|
| 100 |
+
allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
|
| 101 |
+
default (Callable, optional): A callable that converts values that can not be encoded
|
| 102 |
+
in to something that can be JSON encoded. Defaults to None.
|
| 103 |
+
sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
|
| 104 |
+
"""
|
| 105 |
+
|
| 106 |
+
get_console().print_json(
|
| 107 |
+
json,
|
| 108 |
+
data=data,
|
| 109 |
+
indent=indent,
|
| 110 |
+
highlight=highlight,
|
| 111 |
+
skip_keys=skip_keys,
|
| 112 |
+
ensure_ascii=ensure_ascii,
|
| 113 |
+
check_circular=check_circular,
|
| 114 |
+
allow_nan=allow_nan,
|
| 115 |
+
default=default,
|
| 116 |
+
sort_keys=sort_keys,
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def inspect(
|
| 121 |
+
obj: Any,
|
| 122 |
+
*,
|
| 123 |
+
console: Optional["Console"] = None,
|
| 124 |
+
title: Optional[str] = None,
|
| 125 |
+
help: bool = False,
|
| 126 |
+
methods: bool = False,
|
| 127 |
+
docs: bool = True,
|
| 128 |
+
private: bool = False,
|
| 129 |
+
dunder: bool = False,
|
| 130 |
+
sort: bool = True,
|
| 131 |
+
all: bool = False,
|
| 132 |
+
value: bool = True,
|
| 133 |
+
) -> None:
|
| 134 |
+
"""Inspect any Python object.
|
| 135 |
+
|
| 136 |
+
* inspect(<OBJECT>) to see summarized info.
|
| 137 |
+
* inspect(<OBJECT>, methods=True) to see methods.
|
| 138 |
+
* inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.
|
| 139 |
+
* inspect(<OBJECT>, private=True) to see private attributes (single underscore).
|
| 140 |
+
* inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.
|
| 141 |
+
* inspect(<OBJECT>, all=True) to see all attributes.
|
| 142 |
+
|
| 143 |
+
Args:
|
| 144 |
+
obj (Any): An object to inspect.
|
| 145 |
+
title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
|
| 146 |
+
help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
|
| 147 |
+
methods (bool, optional): Enable inspection of callables. Defaults to False.
|
| 148 |
+
docs (bool, optional): Also render doc strings. Defaults to True.
|
| 149 |
+
private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
|
| 150 |
+
dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
|
| 151 |
+
sort (bool, optional): Sort attributes alphabetically, callables at the top, leading and trailing underscores ignored. Defaults to True.
|
| 152 |
+
all (bool, optional): Show all attributes. Defaults to False.
|
| 153 |
+
value (bool, optional): Pretty print value. Defaults to True.
|
| 154 |
+
"""
|
| 155 |
+
_console = console or get_console()
|
| 156 |
+
from rich._inspect import Inspect
|
| 157 |
+
|
| 158 |
+
# Special case for inspect(inspect)
|
| 159 |
+
is_inspect = obj is inspect
|
| 160 |
+
|
| 161 |
+
_inspect = Inspect(
|
| 162 |
+
obj,
|
| 163 |
+
title=title,
|
| 164 |
+
help=is_inspect or help,
|
| 165 |
+
methods=is_inspect or methods,
|
| 166 |
+
docs=is_inspect or docs,
|
| 167 |
+
private=private,
|
| 168 |
+
dunder=dunder,
|
| 169 |
+
sort=sort,
|
| 170 |
+
all=all,
|
| 171 |
+
value=value,
|
| 172 |
+
)
|
| 173 |
+
_console.print(_inspect)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if __name__ == "__main__": # pragma: no cover
|
| 177 |
+
print("Hello, **World**")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/__main__.py
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import colorsys
|
| 2 |
+
import io
|
| 3 |
+
from time import process_time
|
| 4 |
+
|
| 5 |
+
from rich import box
|
| 6 |
+
from rich.color import Color
|
| 7 |
+
from rich.console import Console, ConsoleOptions, Group, RenderableType, RenderResult
|
| 8 |
+
from rich.markdown import Markdown
|
| 9 |
+
from rich.measure import Measurement
|
| 10 |
+
from rich.pretty import Pretty
|
| 11 |
+
from rich.segment import Segment
|
| 12 |
+
from rich.style import Style
|
| 13 |
+
from rich.syntax import Syntax
|
| 14 |
+
from rich.table import Table
|
| 15 |
+
from rich.text import Text
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ColorBox:
|
| 19 |
+
def __rich_console__(
|
| 20 |
+
self, console: Console, options: ConsoleOptions
|
| 21 |
+
) -> RenderResult:
|
| 22 |
+
for y in range(0, 5):
|
| 23 |
+
for x in range(options.max_width):
|
| 24 |
+
h = x / options.max_width
|
| 25 |
+
l = 0.1 + ((y / 5) * 0.7)
|
| 26 |
+
r1, g1, b1 = colorsys.hls_to_rgb(h, l, 1.0)
|
| 27 |
+
r2, g2, b2 = colorsys.hls_to_rgb(h, l + 0.7 / 10, 1.0)
|
| 28 |
+
bgcolor = Color.from_rgb(r1 * 255, g1 * 255, b1 * 255)
|
| 29 |
+
color = Color.from_rgb(r2 * 255, g2 * 255, b2 * 255)
|
| 30 |
+
yield Segment("▄", Style(color=color, bgcolor=bgcolor))
|
| 31 |
+
yield Segment.line()
|
| 32 |
+
|
| 33 |
+
def __rich_measure__(
|
| 34 |
+
self, console: "Console", options: ConsoleOptions
|
| 35 |
+
) -> Measurement:
|
| 36 |
+
return Measurement(1, options.max_width)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def make_test_card() -> Table:
|
| 40 |
+
"""Get a renderable that demonstrates a number of features."""
|
| 41 |
+
table = Table.grid(padding=1, pad_edge=True)
|
| 42 |
+
table.title = "Rich features"
|
| 43 |
+
table.add_column("Feature", no_wrap=True, justify="center", style="bold red")
|
| 44 |
+
table.add_column("Demonstration")
|
| 45 |
+
|
| 46 |
+
color_table = Table(
|
| 47 |
+
box=None,
|
| 48 |
+
expand=False,
|
| 49 |
+
show_header=False,
|
| 50 |
+
show_edge=False,
|
| 51 |
+
pad_edge=False,
|
| 52 |
+
)
|
| 53 |
+
color_table.add_row(
|
| 54 |
+
(
|
| 55 |
+
"✓ [bold green]4-bit color[/]\n"
|
| 56 |
+
"✓ [bold blue]8-bit color[/]\n"
|
| 57 |
+
"✓ [bold magenta]Truecolor (16.7 million)[/]\n"
|
| 58 |
+
"✓ [bold yellow]Dumb terminals[/]\n"
|
| 59 |
+
"✓ [bold cyan]Automatic color conversion"
|
| 60 |
+
),
|
| 61 |
+
ColorBox(),
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
table.add_row("Colors", color_table)
|
| 65 |
+
|
| 66 |
+
table.add_row(
|
| 67 |
+
"Styles",
|
| 68 |
+
"All ansi styles: [bold]bold[/], [dim]dim[/], [italic]italic[/italic], [underline]underline[/], [strike]strikethrough[/], [reverse]reverse[/], and even [blink]blink[/].",
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus."
|
| 72 |
+
lorem_table = Table.grid(padding=1, collapse_padding=True)
|
| 73 |
+
lorem_table.pad_edge = False
|
| 74 |
+
lorem_table.add_row(
|
| 75 |
+
Text(lorem, justify="left", style="green"),
|
| 76 |
+
Text(lorem, justify="center", style="yellow"),
|
| 77 |
+
Text(lorem, justify="right", style="blue"),
|
| 78 |
+
Text(lorem, justify="full", style="red"),
|
| 79 |
+
)
|
| 80 |
+
table.add_row(
|
| 81 |
+
"Text",
|
| 82 |
+
Group(
|
| 83 |
+
Text.from_markup(
|
| 84 |
+
"""Word wrap text. Justify [green]left[/], [yellow]center[/], [blue]right[/] or [red]full[/].\n"""
|
| 85 |
+
),
|
| 86 |
+
lorem_table,
|
| 87 |
+
),
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
def comparison(renderable1: RenderableType, renderable2: RenderableType) -> Table:
|
| 91 |
+
table = Table(show_header=False, pad_edge=False, box=None, expand=True)
|
| 92 |
+
table.add_column("1", ratio=1)
|
| 93 |
+
table.add_column("2", ratio=1)
|
| 94 |
+
table.add_row(renderable1, renderable2)
|
| 95 |
+
return table
|
| 96 |
+
|
| 97 |
+
table.add_row(
|
| 98 |
+
"Asian\nlanguage\nsupport",
|
| 99 |
+
":flag_for_china: 该库支持中文,日文和韩文文本!\n:flag_for_japan: ライブラリは中国語、日本語、韓国語のテキストをサポートしています\n:flag_for_south_korea: 이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다",
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
markup_example = (
|
| 103 |
+
"[bold magenta]Rich[/] supports a simple [i]bbcode[/i]-like [b]markup[/b] for [yellow]color[/], [underline]style[/], and emoji! "
|
| 104 |
+
":+1: :apple: :ant: :bear: :baguette_bread: :bus: "
|
| 105 |
+
)
|
| 106 |
+
table.add_row("Markup", markup_example)
|
| 107 |
+
|
| 108 |
+
example_table = Table(
|
| 109 |
+
show_edge=False,
|
| 110 |
+
show_header=True,
|
| 111 |
+
expand=False,
|
| 112 |
+
row_styles=["none", "dim"],
|
| 113 |
+
box=box.SIMPLE,
|
| 114 |
+
)
|
| 115 |
+
example_table.add_column("[green]Date", style="green", no_wrap=True)
|
| 116 |
+
example_table.add_column("[blue]Title", style="blue")
|
| 117 |
+
example_table.add_column(
|
| 118 |
+
"[cyan]Production Budget",
|
| 119 |
+
style="cyan",
|
| 120 |
+
justify="right",
|
| 121 |
+
no_wrap=True,
|
| 122 |
+
)
|
| 123 |
+
example_table.add_column(
|
| 124 |
+
"[magenta]Box Office",
|
| 125 |
+
style="magenta",
|
| 126 |
+
justify="right",
|
| 127 |
+
no_wrap=True,
|
| 128 |
+
)
|
| 129 |
+
example_table.add_row(
|
| 130 |
+
"Dec 20, 2019",
|
| 131 |
+
"Star Wars: The Rise of Skywalker",
|
| 132 |
+
"$275,000,000",
|
| 133 |
+
"$375,126,118",
|
| 134 |
+
)
|
| 135 |
+
example_table.add_row(
|
| 136 |
+
"May 25, 2018",
|
| 137 |
+
"[b]Solo[/]: A Star Wars Story",
|
| 138 |
+
"$275,000,000",
|
| 139 |
+
"$393,151,347",
|
| 140 |
+
)
|
| 141 |
+
example_table.add_row(
|
| 142 |
+
"Dec 15, 2017",
|
| 143 |
+
"Star Wars Ep. VIII: The Last Jedi",
|
| 144 |
+
"$262,000,000",
|
| 145 |
+
"[bold]$1,332,539,889[/bold]",
|
| 146 |
+
)
|
| 147 |
+
example_table.add_row(
|
| 148 |
+
"May 19, 1999",
|
| 149 |
+
"Star Wars Ep. [b]I[/b]: [i]The phantom Menace",
|
| 150 |
+
"$115,000,000",
|
| 151 |
+
"$1,027,044,677",
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
table.add_row("Tables", example_table)
|
| 155 |
+
|
| 156 |
+
code = '''\
|
| 157 |
+
def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 158 |
+
"""Iterate and generate a tuple with a flag for last value."""
|
| 159 |
+
iter_values = iter(values)
|
| 160 |
+
try:
|
| 161 |
+
previous_value = next(iter_values)
|
| 162 |
+
except StopIteration:
|
| 163 |
+
return
|
| 164 |
+
for value in iter_values:
|
| 165 |
+
yield False, previous_value
|
| 166 |
+
previous_value = value
|
| 167 |
+
yield True, previous_value'''
|
| 168 |
+
|
| 169 |
+
pretty_data = {
|
| 170 |
+
"foo": [
|
| 171 |
+
3.1427,
|
| 172 |
+
(
|
| 173 |
+
"Paul Atreides",
|
| 174 |
+
"Vladimir Harkonnen",
|
| 175 |
+
"Thufir Hawat",
|
| 176 |
+
),
|
| 177 |
+
],
|
| 178 |
+
"atomic": (False, True, None),
|
| 179 |
+
}
|
| 180 |
+
table.add_row(
|
| 181 |
+
"Syntax\nhighlighting\n&\npretty\nprinting",
|
| 182 |
+
comparison(
|
| 183 |
+
Syntax(code, "python3", line_numbers=True, indent_guides=True),
|
| 184 |
+
Pretty(pretty_data, indent_guides=True),
|
| 185 |
+
),
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
markdown_example = """\
|
| 189 |
+
# Markdown
|
| 190 |
+
|
| 191 |
+
Supports much of the *markdown* __syntax__!
|
| 192 |
+
|
| 193 |
+
- Headers
|
| 194 |
+
- Basic formatting: **bold**, *italic*, `code`
|
| 195 |
+
- Block quotes
|
| 196 |
+
- Lists, and more...
|
| 197 |
+
"""
|
| 198 |
+
table.add_row(
|
| 199 |
+
"Markdown", comparison("[cyan]" + markdown_example, Markdown(markdown_example))
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
table.add_row(
|
| 203 |
+
"+more!",
|
| 204 |
+
"""Progress bars, columns, styled logging handler, tracebacks, etc...""",
|
| 205 |
+
)
|
| 206 |
+
return table
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
if __name__ == "__main__": # pragma: no cover
|
| 210 |
+
from rich.panel import Panel
|
| 211 |
+
|
| 212 |
+
console = Console(
|
| 213 |
+
file=io.StringIO(),
|
| 214 |
+
force_terminal=True,
|
| 215 |
+
)
|
| 216 |
+
test_card = make_test_card()
|
| 217 |
+
|
| 218 |
+
# Print once to warm cache
|
| 219 |
+
start = process_time()
|
| 220 |
+
console.print(test_card)
|
| 221 |
+
pre_cache_taken = round((process_time() - start) * 1000.0, 1)
|
| 222 |
+
|
| 223 |
+
console.file = io.StringIO()
|
| 224 |
+
|
| 225 |
+
start = process_time()
|
| 226 |
+
console.print(test_card)
|
| 227 |
+
taken = round((process_time() - start) * 1000.0, 1)
|
| 228 |
+
|
| 229 |
+
c = Console(record=True)
|
| 230 |
+
c.print(test_card)
|
| 231 |
+
|
| 232 |
+
console = Console()
|
| 233 |
+
console.print(f"[dim]rendered in [not dim]{pre_cache_taken}ms[/] (cold cache)")
|
| 234 |
+
console.print(f"[dim]rendered in [not dim]{taken}ms[/] (warm cache)")
|
| 235 |
+
console.print()
|
| 236 |
+
console.print(
|
| 237 |
+
Panel(
|
| 238 |
+
"[b magenta]Hope you enjoy using Rich![/]\n\n"
|
| 239 |
+
"Consider sponsoring to ensure this project is maintained.\n\n"
|
| 240 |
+
"[cyan]https://github.com/sponsors/willmcgugan[/cyan]",
|
| 241 |
+
border_style="green",
|
| 242 |
+
title="Help ensure Rich is maintained",
|
| 243 |
+
padding=(1, 2),
|
| 244 |
+
)
|
| 245 |
+
)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_emoji_codes.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_emoji_replace.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Callable, Match, Optional
|
| 3 |
+
|
| 4 |
+
_ReStringMatch = Match[str] # regex match object
|
| 5 |
+
_ReSubCallable = Callable[[_ReStringMatch], str] # Callable invoked by re.sub
|
| 6 |
+
_EmojiSubMethod = Callable[[_ReSubCallable, str], str] # Sub method of a compiled re
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _emoji_replace(
|
| 10 |
+
text: str,
|
| 11 |
+
default_variant: Optional[str] = None,
|
| 12 |
+
_emoji_sub: _EmojiSubMethod = re.compile(r"(:(\S*?)(?:(?:\-)(emoji|text))?:)").sub,
|
| 13 |
+
) -> str:
|
| 14 |
+
"""Replace emoji code in text."""
|
| 15 |
+
from ._emoji_codes import EMOJI
|
| 16 |
+
|
| 17 |
+
get_emoji = EMOJI.__getitem__
|
| 18 |
+
variants = {"text": "\ufe0e", "emoji": "\ufe0f"}
|
| 19 |
+
get_variant = variants.get
|
| 20 |
+
default_variant_code = variants.get(default_variant, "") if default_variant else ""
|
| 21 |
+
|
| 22 |
+
def do_replace(match: Match[str]) -> str:
|
| 23 |
+
emoji_code, emoji_name, variant = match.groups()
|
| 24 |
+
try:
|
| 25 |
+
return get_emoji(emoji_name.lower()) + get_variant(
|
| 26 |
+
variant, default_variant_code
|
| 27 |
+
)
|
| 28 |
+
except KeyError:
|
| 29 |
+
return emoji_code
|
| 30 |
+
|
| 31 |
+
return _emoji_sub(do_replace, text)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_export_format.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CONSOLE_HTML_FORMAT = """\
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html>
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<style>
|
| 7 |
+
{stylesheet}
|
| 8 |
+
body {{
|
| 9 |
+
color: {foreground};
|
| 10 |
+
background-color: {background};
|
| 11 |
+
}}
|
| 12 |
+
</style>
|
| 13 |
+
</head>
|
| 14 |
+
<body>
|
| 15 |
+
<pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{code}</code></pre>
|
| 16 |
+
</body>
|
| 17 |
+
</html>
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
CONSOLE_SVG_FORMAT = """\
|
| 21 |
+
<svg class="rich-terminal" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
|
| 22 |
+
<!-- Generated with Rich https://www.textualize.io -->
|
| 23 |
+
<style>
|
| 24 |
+
|
| 25 |
+
@font-face {{
|
| 26 |
+
font-family: "Fira Code";
|
| 27 |
+
src: local("FiraCode-Regular"),
|
| 28 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
|
| 29 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
|
| 30 |
+
font-style: normal;
|
| 31 |
+
font-weight: 400;
|
| 32 |
+
}}
|
| 33 |
+
@font-face {{
|
| 34 |
+
font-family: "Fira Code";
|
| 35 |
+
src: local("FiraCode-Bold"),
|
| 36 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
|
| 37 |
+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
|
| 38 |
+
font-style: bold;
|
| 39 |
+
font-weight: 700;
|
| 40 |
+
}}
|
| 41 |
+
|
| 42 |
+
.{unique_id}-matrix {{
|
| 43 |
+
font-family: Fira Code, monospace;
|
| 44 |
+
font-size: {char_height}px;
|
| 45 |
+
line-height: {line_height}px;
|
| 46 |
+
font-variant-east-asian: full-width;
|
| 47 |
+
}}
|
| 48 |
+
|
| 49 |
+
.{unique_id}-title {{
|
| 50 |
+
font-size: 18px;
|
| 51 |
+
font-weight: bold;
|
| 52 |
+
font-family: arial;
|
| 53 |
+
}}
|
| 54 |
+
|
| 55 |
+
{styles}
|
| 56 |
+
</style>
|
| 57 |
+
|
| 58 |
+
<defs>
|
| 59 |
+
<clipPath id="{unique_id}-clip-terminal">
|
| 60 |
+
<rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
|
| 61 |
+
</clipPath>
|
| 62 |
+
{lines}
|
| 63 |
+
</defs>
|
| 64 |
+
|
| 65 |
+
{chrome}
|
| 66 |
+
<g transform="translate({terminal_x}, {terminal_y})" clip-path="url(#{unique_id}-clip-terminal)">
|
| 67 |
+
{backgrounds}
|
| 68 |
+
<g class="{unique_id}-matrix">
|
| 69 |
+
{matrix}
|
| 70 |
+
</g>
|
| 71 |
+
</g>
|
| 72 |
+
</svg>
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
_SVG_FONT_FAMILY = "Rich Fira Code"
|
| 76 |
+
_SVG_CLASSES_PREFIX = "rich-svg"
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_extension.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def load_ipython_extension(ip: Any) -> None: # pragma: no cover
|
| 5 |
+
# prevent circular import
|
| 6 |
+
from rich.pretty import install
|
| 7 |
+
from rich.traceback import install as tr_install
|
| 8 |
+
|
| 9 |
+
install()
|
| 10 |
+
tr_install()
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_fileno.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import IO, Callable
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_fileno(file_like: IO[str]) -> int | None:
|
| 7 |
+
"""Get fileno() from a file, accounting for poorly implemented file-like objects.
|
| 8 |
+
|
| 9 |
+
Args:
|
| 10 |
+
file_like (IO): A file-like object.
|
| 11 |
+
|
| 12 |
+
Returns:
|
| 13 |
+
int | None: The result of fileno if available, or None if operation failed.
|
| 14 |
+
"""
|
| 15 |
+
fileno: Callable[[], int] | None = getattr(file_like, "fileno", None)
|
| 16 |
+
if fileno is not None:
|
| 17 |
+
try:
|
| 18 |
+
return fileno()
|
| 19 |
+
except Exception:
|
| 20 |
+
# `fileno` is documented as potentially raising a OSError
|
| 21 |
+
# Alas, from the issues, there are so many poorly implemented file-like objects,
|
| 22 |
+
# that `fileno()` can raise just about anything.
|
| 23 |
+
return None
|
| 24 |
+
return None
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_inspect.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
from inspect import cleandoc, getdoc, getfile, isclass, ismodule, signature
|
| 3 |
+
from typing import Any, Collection, Iterable, Optional, Tuple, Type, Union
|
| 4 |
+
|
| 5 |
+
from .console import Group, RenderableType
|
| 6 |
+
from .control import escape_control_codes
|
| 7 |
+
from .highlighter import ReprHighlighter
|
| 8 |
+
from .jupyter import JupyterMixin
|
| 9 |
+
from .panel import Panel
|
| 10 |
+
from .pretty import Pretty
|
| 11 |
+
from .table import Table
|
| 12 |
+
from .text import Text, TextType
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _first_paragraph(doc: str) -> str:
|
| 16 |
+
"""Get the first paragraph from a docstring."""
|
| 17 |
+
paragraph, _, _ = doc.partition("\n\n")
|
| 18 |
+
return paragraph
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class Inspect(JupyterMixin):
|
| 22 |
+
"""A renderable to inspect any Python Object.
|
| 23 |
+
|
| 24 |
+
Args:
|
| 25 |
+
obj (Any): An object to inspect.
|
| 26 |
+
title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
|
| 27 |
+
help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
|
| 28 |
+
methods (bool, optional): Enable inspection of callables. Defaults to False.
|
| 29 |
+
docs (bool, optional): Also render doc strings. Defaults to True.
|
| 30 |
+
private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
|
| 31 |
+
dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
|
| 32 |
+
sort (bool, optional): Sort attributes alphabetically, callables at the top, leading and trailing underscores ignored. Defaults to True.
|
| 33 |
+
all (bool, optional): Show all attributes. Defaults to False.
|
| 34 |
+
value (bool, optional): Pretty print value of object. Defaults to True.
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
def __init__(
|
| 38 |
+
self,
|
| 39 |
+
obj: Any,
|
| 40 |
+
*,
|
| 41 |
+
title: Optional[TextType] = None,
|
| 42 |
+
help: bool = False,
|
| 43 |
+
methods: bool = False,
|
| 44 |
+
docs: bool = True,
|
| 45 |
+
private: bool = False,
|
| 46 |
+
dunder: bool = False,
|
| 47 |
+
sort: bool = True,
|
| 48 |
+
all: bool = True,
|
| 49 |
+
value: bool = True,
|
| 50 |
+
) -> None:
|
| 51 |
+
self.highlighter = ReprHighlighter()
|
| 52 |
+
self.obj = obj
|
| 53 |
+
self.title = title or self._make_title(obj)
|
| 54 |
+
if all:
|
| 55 |
+
methods = private = dunder = True
|
| 56 |
+
self.help = help
|
| 57 |
+
self.methods = methods
|
| 58 |
+
self.docs = docs or help
|
| 59 |
+
self.private = private or dunder
|
| 60 |
+
self.dunder = dunder
|
| 61 |
+
self.sort = sort
|
| 62 |
+
self.value = value
|
| 63 |
+
|
| 64 |
+
def _make_title(self, obj: Any) -> Text:
|
| 65 |
+
"""Make a default title."""
|
| 66 |
+
title_str = (
|
| 67 |
+
str(obj)
|
| 68 |
+
if (isclass(obj) or callable(obj) or ismodule(obj))
|
| 69 |
+
else str(type(obj))
|
| 70 |
+
)
|
| 71 |
+
title_text = self.highlighter(title_str)
|
| 72 |
+
return title_text
|
| 73 |
+
|
| 74 |
+
def __rich__(self) -> Panel:
|
| 75 |
+
return Panel.fit(
|
| 76 |
+
Group(*self._render()),
|
| 77 |
+
title=self.title,
|
| 78 |
+
border_style="scope.border",
|
| 79 |
+
padding=(0, 1),
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
def _get_signature(self, name: str, obj: Any) -> Optional[Text]:
|
| 83 |
+
"""Get a signature for a callable."""
|
| 84 |
+
try:
|
| 85 |
+
_signature = str(signature(obj)) + ":"
|
| 86 |
+
except ValueError:
|
| 87 |
+
_signature = "(...)"
|
| 88 |
+
except TypeError:
|
| 89 |
+
return None
|
| 90 |
+
|
| 91 |
+
source_filename: Optional[str] = None
|
| 92 |
+
try:
|
| 93 |
+
source_filename = getfile(obj)
|
| 94 |
+
except (OSError, TypeError):
|
| 95 |
+
# OSError is raised if obj has no source file, e.g. when defined in REPL.
|
| 96 |
+
pass
|
| 97 |
+
|
| 98 |
+
callable_name = Text(name, style="inspect.callable")
|
| 99 |
+
if source_filename:
|
| 100 |
+
callable_name.stylize(f"link file://{source_filename}")
|
| 101 |
+
signature_text = self.highlighter(_signature)
|
| 102 |
+
|
| 103 |
+
qualname = name or getattr(obj, "__qualname__", name)
|
| 104 |
+
if not isinstance(qualname, str):
|
| 105 |
+
qualname = getattr(obj, "__name__", name)
|
| 106 |
+
if not isinstance(qualname, str):
|
| 107 |
+
qualname = name
|
| 108 |
+
|
| 109 |
+
# If obj is a module, there may be classes (which are callable) to display
|
| 110 |
+
if inspect.isclass(obj):
|
| 111 |
+
prefix = "class"
|
| 112 |
+
elif inspect.iscoroutinefunction(obj):
|
| 113 |
+
prefix = "async def"
|
| 114 |
+
else:
|
| 115 |
+
prefix = "def"
|
| 116 |
+
|
| 117 |
+
qual_signature = Text.assemble(
|
| 118 |
+
(f"{prefix} ", f"inspect.{prefix.replace(' ', '_')}"),
|
| 119 |
+
(qualname, "inspect.callable"),
|
| 120 |
+
signature_text,
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
return qual_signature
|
| 124 |
+
|
| 125 |
+
def _render(self) -> Iterable[RenderableType]:
|
| 126 |
+
"""Render object."""
|
| 127 |
+
|
| 128 |
+
def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
|
| 129 |
+
key, (_error, value) = item
|
| 130 |
+
return (callable(value), key.strip("_").lower())
|
| 131 |
+
|
| 132 |
+
def safe_getattr(attr_name: str) -> Tuple[Any, Any]:
|
| 133 |
+
"""Get attribute or any exception."""
|
| 134 |
+
try:
|
| 135 |
+
return (None, getattr(obj, attr_name))
|
| 136 |
+
except Exception as error:
|
| 137 |
+
return (error, None)
|
| 138 |
+
|
| 139 |
+
obj = self.obj
|
| 140 |
+
keys = dir(obj)
|
| 141 |
+
total_items = len(keys)
|
| 142 |
+
if not self.dunder:
|
| 143 |
+
keys = [key for key in keys if not key.startswith("__")]
|
| 144 |
+
if not self.private:
|
| 145 |
+
keys = [key for key in keys if not key.startswith("_")]
|
| 146 |
+
not_shown_count = total_items - len(keys)
|
| 147 |
+
items = [(key, safe_getattr(key)) for key in keys]
|
| 148 |
+
if self.sort:
|
| 149 |
+
items.sort(key=sort_items)
|
| 150 |
+
|
| 151 |
+
items_table = Table.grid(padding=(0, 1), expand=False)
|
| 152 |
+
items_table.add_column(justify="right")
|
| 153 |
+
add_row = items_table.add_row
|
| 154 |
+
highlighter = self.highlighter
|
| 155 |
+
|
| 156 |
+
if callable(obj):
|
| 157 |
+
signature = self._get_signature("", obj)
|
| 158 |
+
if signature is not None:
|
| 159 |
+
yield signature
|
| 160 |
+
yield ""
|
| 161 |
+
|
| 162 |
+
if self.docs:
|
| 163 |
+
_doc = self._get_formatted_doc(obj)
|
| 164 |
+
if _doc is not None:
|
| 165 |
+
doc_text = Text(_doc, style="inspect.help")
|
| 166 |
+
doc_text = highlighter(doc_text)
|
| 167 |
+
yield doc_text
|
| 168 |
+
yield ""
|
| 169 |
+
|
| 170 |
+
if self.value and not (isclass(obj) or callable(obj) or ismodule(obj)):
|
| 171 |
+
yield Panel(
|
| 172 |
+
Pretty(obj, indent_guides=True, max_length=10, max_string=60),
|
| 173 |
+
border_style="inspect.value.border",
|
| 174 |
+
)
|
| 175 |
+
yield ""
|
| 176 |
+
|
| 177 |
+
for key, (error, value) in items:
|
| 178 |
+
key_text = Text.assemble(
|
| 179 |
+
(
|
| 180 |
+
key,
|
| 181 |
+
"inspect.attr.dunder" if key.startswith("__") else "inspect.attr",
|
| 182 |
+
),
|
| 183 |
+
(" =", "inspect.equals"),
|
| 184 |
+
)
|
| 185 |
+
if error is not None:
|
| 186 |
+
warning = key_text.copy()
|
| 187 |
+
warning.stylize("inspect.error")
|
| 188 |
+
add_row(warning, highlighter(repr(error)))
|
| 189 |
+
continue
|
| 190 |
+
|
| 191 |
+
if callable(value):
|
| 192 |
+
if not self.methods:
|
| 193 |
+
continue
|
| 194 |
+
|
| 195 |
+
_signature_text = self._get_signature(key, value)
|
| 196 |
+
if _signature_text is None:
|
| 197 |
+
add_row(key_text, Pretty(value, highlighter=highlighter))
|
| 198 |
+
else:
|
| 199 |
+
if self.docs:
|
| 200 |
+
docs = self._get_formatted_doc(value)
|
| 201 |
+
if docs is not None:
|
| 202 |
+
_signature_text.append("\n" if "\n" in docs else " ")
|
| 203 |
+
doc = highlighter(docs)
|
| 204 |
+
doc.stylize("inspect.doc")
|
| 205 |
+
_signature_text.append(doc)
|
| 206 |
+
|
| 207 |
+
add_row(key_text, _signature_text)
|
| 208 |
+
else:
|
| 209 |
+
add_row(key_text, Pretty(value, highlighter=highlighter))
|
| 210 |
+
if items_table.row_count:
|
| 211 |
+
yield items_table
|
| 212 |
+
elif not_shown_count:
|
| 213 |
+
yield Text.from_markup(
|
| 214 |
+
f"[b cyan]{not_shown_count}[/][i] attribute(s) not shown.[/i] "
|
| 215 |
+
f"Run [b][magenta]inspect[/]([not b]inspect[/])[/b] for options."
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
def _get_formatted_doc(self, object_: Any) -> Optional[str]:
|
| 219 |
+
"""
|
| 220 |
+
Extract the docstring of an object, process it and returns it.
|
| 221 |
+
The processing consists in cleaning up the docstring's indentation,
|
| 222 |
+
taking only its 1st paragraph if `self.help` is not True,
|
| 223 |
+
and escape its control codes.
|
| 224 |
+
|
| 225 |
+
Args:
|
| 226 |
+
object_ (Any): the object to get the docstring from.
|
| 227 |
+
|
| 228 |
+
Returns:
|
| 229 |
+
Optional[str]: the processed docstring, or None if no docstring was found.
|
| 230 |
+
"""
|
| 231 |
+
docs = getdoc(object_)
|
| 232 |
+
if docs is None:
|
| 233 |
+
return None
|
| 234 |
+
docs = cleandoc(docs).strip()
|
| 235 |
+
if not self.help:
|
| 236 |
+
docs = _first_paragraph(docs)
|
| 237 |
+
return escape_control_codes(docs)
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def get_object_types_mro(obj: Union[object, Type[Any]]) -> Tuple[type, ...]:
|
| 241 |
+
"""Returns the MRO of an object's class, or of the object itself if it's a class."""
|
| 242 |
+
if not hasattr(obj, "__mro__"):
|
| 243 |
+
# N.B. we cannot use `if type(obj) is type` here because it doesn't work with
|
| 244 |
+
# some types of classes, such as the ones that use abc.ABCMeta.
|
| 245 |
+
obj = type(obj)
|
| 246 |
+
return getattr(obj, "__mro__", ())
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def get_object_types_mro_as_strings(obj: object) -> Collection[str]:
|
| 250 |
+
"""
|
| 251 |
+
Returns the MRO of an object's class as full qualified names, or of the object itself if it's a class.
|
| 252 |
+
|
| 253 |
+
Examples:
|
| 254 |
+
`object_types_mro_as_strings(JSONDecoder)` will return `['json.decoder.JSONDecoder', 'builtins.object']`
|
| 255 |
+
"""
|
| 256 |
+
return [
|
| 257 |
+
f'{getattr(type_, "__module__", "")}.{getattr(type_, "__qualname__", "")}'
|
| 258 |
+
for type_ in get_object_types_mro(obj)
|
| 259 |
+
]
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def is_object_one_of_types(
|
| 263 |
+
obj: object, fully_qualified_types_names: Collection[str]
|
| 264 |
+
) -> bool:
|
| 265 |
+
"""
|
| 266 |
+
Returns `True` if the given object's class (or the object itself, if it's a class) has one of the
|
| 267 |
+
fully qualified names in its MRO.
|
| 268 |
+
"""
|
| 269 |
+
for type_name in get_object_types_mro_as_strings(obj):
|
| 270 |
+
if type_name in fully_qualified_types_names:
|
| 271 |
+
return True
|
| 272 |
+
return False
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_log_render.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
from typing import Iterable, List, Optional, TYPE_CHECKING, Union, Callable
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
from .text import Text, TextType
|
| 6 |
+
|
| 7 |
+
if TYPE_CHECKING:
|
| 8 |
+
from .console import Console, ConsoleRenderable, RenderableType
|
| 9 |
+
from .table import Table
|
| 10 |
+
|
| 11 |
+
FormatTimeCallable = Callable[[datetime], Text]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class LogRender:
|
| 15 |
+
def __init__(
|
| 16 |
+
self,
|
| 17 |
+
show_time: bool = True,
|
| 18 |
+
show_level: bool = False,
|
| 19 |
+
show_path: bool = True,
|
| 20 |
+
time_format: Union[str, FormatTimeCallable] = "[%x %X]",
|
| 21 |
+
omit_repeated_times: bool = True,
|
| 22 |
+
level_width: Optional[int] = 8,
|
| 23 |
+
) -> None:
|
| 24 |
+
self.show_time = show_time
|
| 25 |
+
self.show_level = show_level
|
| 26 |
+
self.show_path = show_path
|
| 27 |
+
self.time_format = time_format
|
| 28 |
+
self.omit_repeated_times = omit_repeated_times
|
| 29 |
+
self.level_width = level_width
|
| 30 |
+
self._last_time: Optional[Text] = None
|
| 31 |
+
|
| 32 |
+
def __call__(
|
| 33 |
+
self,
|
| 34 |
+
console: "Console",
|
| 35 |
+
renderables: Iterable["ConsoleRenderable"],
|
| 36 |
+
log_time: Optional[datetime] = None,
|
| 37 |
+
time_format: Optional[Union[str, FormatTimeCallable]] = None,
|
| 38 |
+
level: TextType = "",
|
| 39 |
+
path: Optional[str] = None,
|
| 40 |
+
line_no: Optional[int] = None,
|
| 41 |
+
link_path: Optional[str] = None,
|
| 42 |
+
) -> "Table":
|
| 43 |
+
from .containers import Renderables
|
| 44 |
+
from .table import Table
|
| 45 |
+
|
| 46 |
+
output = Table.grid(padding=(0, 1))
|
| 47 |
+
output.expand = True
|
| 48 |
+
if self.show_time:
|
| 49 |
+
output.add_column(style="log.time")
|
| 50 |
+
if self.show_level:
|
| 51 |
+
output.add_column(style="log.level", width=self.level_width)
|
| 52 |
+
output.add_column(ratio=1, style="log.message", overflow="fold")
|
| 53 |
+
if self.show_path and path:
|
| 54 |
+
output.add_column(style="log.path")
|
| 55 |
+
row: List["RenderableType"] = []
|
| 56 |
+
if self.show_time:
|
| 57 |
+
log_time = log_time or console.get_datetime()
|
| 58 |
+
time_format = time_format or self.time_format
|
| 59 |
+
if callable(time_format):
|
| 60 |
+
log_time_display = time_format(log_time)
|
| 61 |
+
else:
|
| 62 |
+
log_time_display = Text(log_time.strftime(time_format))
|
| 63 |
+
if log_time_display == self._last_time and self.omit_repeated_times:
|
| 64 |
+
row.append(Text(" " * len(log_time_display)))
|
| 65 |
+
else:
|
| 66 |
+
row.append(log_time_display)
|
| 67 |
+
self._last_time = log_time_display
|
| 68 |
+
if self.show_level:
|
| 69 |
+
row.append(level)
|
| 70 |
+
|
| 71 |
+
row.append(Renderables(renderables))
|
| 72 |
+
if self.show_path and path:
|
| 73 |
+
path_text = Text()
|
| 74 |
+
path_text.append(
|
| 75 |
+
path, style=f"link file://{link_path}" if link_path else ""
|
| 76 |
+
)
|
| 77 |
+
if line_no:
|
| 78 |
+
path_text.append(":")
|
| 79 |
+
path_text.append(
|
| 80 |
+
f"{line_no}",
|
| 81 |
+
style=f"link file://{link_path}#{line_no}" if link_path else "",
|
| 82 |
+
)
|
| 83 |
+
row.append(path_text)
|
| 84 |
+
|
| 85 |
+
output.add_row(*row)
|
| 86 |
+
return output
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
if __name__ == "__main__": # pragma: no cover
|
| 90 |
+
from rich.console import Console
|
| 91 |
+
|
| 92 |
+
c = Console()
|
| 93 |
+
c.print("[on blue]Hello", justify="right")
|
| 94 |
+
c.log("[on blue]hello", justify="right")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_loop.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Iterable, Tuple, TypeVar
|
| 2 |
+
|
| 3 |
+
T = TypeVar("T")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def loop_first(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 7 |
+
"""Iterate and generate a tuple with a flag for first value."""
|
| 8 |
+
iter_values = iter(values)
|
| 9 |
+
try:
|
| 10 |
+
value = next(iter_values)
|
| 11 |
+
except StopIteration:
|
| 12 |
+
return
|
| 13 |
+
yield True, value
|
| 14 |
+
for value in iter_values:
|
| 15 |
+
yield False, value
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 19 |
+
"""Iterate and generate a tuple with a flag for last value."""
|
| 20 |
+
iter_values = iter(values)
|
| 21 |
+
try:
|
| 22 |
+
previous_value = next(iter_values)
|
| 23 |
+
except StopIteration:
|
| 24 |
+
return
|
| 25 |
+
for value in iter_values:
|
| 26 |
+
yield False, previous_value
|
| 27 |
+
previous_value = value
|
| 28 |
+
yield True, previous_value
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def loop_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]:
|
| 32 |
+
"""Iterate and generate a tuple with a flag for first and last value."""
|
| 33 |
+
iter_values = iter(values)
|
| 34 |
+
try:
|
| 35 |
+
previous_value = next(iter_values)
|
| 36 |
+
except StopIteration:
|
| 37 |
+
return
|
| 38 |
+
first = True
|
| 39 |
+
for value in iter_values:
|
| 40 |
+
yield first, False, previous_value
|
| 41 |
+
first = False
|
| 42 |
+
previous_value = value
|
| 43 |
+
yield first, True, previous_value
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_null_file.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from types import TracebackType
|
| 2 |
+
from typing import IO, Iterable, Iterator, List, Optional, Type
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class NullFile(IO[str]):
|
| 6 |
+
def close(self) -> None:
|
| 7 |
+
pass
|
| 8 |
+
|
| 9 |
+
def isatty(self) -> bool:
|
| 10 |
+
return False
|
| 11 |
+
|
| 12 |
+
def read(self, __n: int = 1) -> str:
|
| 13 |
+
return ""
|
| 14 |
+
|
| 15 |
+
def readable(self) -> bool:
|
| 16 |
+
return False
|
| 17 |
+
|
| 18 |
+
def readline(self, __limit: int = 1) -> str:
|
| 19 |
+
return ""
|
| 20 |
+
|
| 21 |
+
def readlines(self, __hint: int = 1) -> List[str]:
|
| 22 |
+
return []
|
| 23 |
+
|
| 24 |
+
def seek(self, __offset: int, __whence: int = 1) -> int:
|
| 25 |
+
return 0
|
| 26 |
+
|
| 27 |
+
def seekable(self) -> bool:
|
| 28 |
+
return False
|
| 29 |
+
|
| 30 |
+
def tell(self) -> int:
|
| 31 |
+
return 0
|
| 32 |
+
|
| 33 |
+
def truncate(self, __size: Optional[int] = 1) -> int:
|
| 34 |
+
return 0
|
| 35 |
+
|
| 36 |
+
def writable(self) -> bool:
|
| 37 |
+
return False
|
| 38 |
+
|
| 39 |
+
def writelines(self, __lines: Iterable[str]) -> None:
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
def __next__(self) -> str:
|
| 43 |
+
return ""
|
| 44 |
+
|
| 45 |
+
def __iter__(self) -> Iterator[str]:
|
| 46 |
+
return iter([""])
|
| 47 |
+
|
| 48 |
+
def __enter__(self) -> IO[str]:
|
| 49 |
+
return self
|
| 50 |
+
|
| 51 |
+
def __exit__(
|
| 52 |
+
self,
|
| 53 |
+
__t: Optional[Type[BaseException]],
|
| 54 |
+
__value: Optional[BaseException],
|
| 55 |
+
__traceback: Optional[TracebackType],
|
| 56 |
+
) -> None:
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
def write(self, text: str) -> int:
|
| 60 |
+
return 0
|
| 61 |
+
|
| 62 |
+
def flush(self) -> None:
|
| 63 |
+
pass
|
| 64 |
+
|
| 65 |
+
def fileno(self) -> int:
|
| 66 |
+
return -1
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
NULL_FILE = NullFile()
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_palettes.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .palette import Palette
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# Taken from https://en.wikipedia.org/wiki/ANSI_escape_code (Windows 10 column)
|
| 5 |
+
WINDOWS_PALETTE = Palette(
|
| 6 |
+
[
|
| 7 |
+
(12, 12, 12),
|
| 8 |
+
(197, 15, 31),
|
| 9 |
+
(19, 161, 14),
|
| 10 |
+
(193, 156, 0),
|
| 11 |
+
(0, 55, 218),
|
| 12 |
+
(136, 23, 152),
|
| 13 |
+
(58, 150, 221),
|
| 14 |
+
(204, 204, 204),
|
| 15 |
+
(118, 118, 118),
|
| 16 |
+
(231, 72, 86),
|
| 17 |
+
(22, 198, 12),
|
| 18 |
+
(249, 241, 165),
|
| 19 |
+
(59, 120, 255),
|
| 20 |
+
(180, 0, 158),
|
| 21 |
+
(97, 214, 214),
|
| 22 |
+
(242, 242, 242),
|
| 23 |
+
]
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# # The standard ansi colors (including bright variants)
|
| 27 |
+
STANDARD_PALETTE = Palette(
|
| 28 |
+
[
|
| 29 |
+
(0, 0, 0),
|
| 30 |
+
(170, 0, 0),
|
| 31 |
+
(0, 170, 0),
|
| 32 |
+
(170, 85, 0),
|
| 33 |
+
(0, 0, 170),
|
| 34 |
+
(170, 0, 170),
|
| 35 |
+
(0, 170, 170),
|
| 36 |
+
(170, 170, 170),
|
| 37 |
+
(85, 85, 85),
|
| 38 |
+
(255, 85, 85),
|
| 39 |
+
(85, 255, 85),
|
| 40 |
+
(255, 255, 85),
|
| 41 |
+
(85, 85, 255),
|
| 42 |
+
(255, 85, 255),
|
| 43 |
+
(85, 255, 255),
|
| 44 |
+
(255, 255, 255),
|
| 45 |
+
]
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# The 256 color palette
|
| 50 |
+
EIGHT_BIT_PALETTE = Palette(
|
| 51 |
+
[
|
| 52 |
+
(0, 0, 0),
|
| 53 |
+
(128, 0, 0),
|
| 54 |
+
(0, 128, 0),
|
| 55 |
+
(128, 128, 0),
|
| 56 |
+
(0, 0, 128),
|
| 57 |
+
(128, 0, 128),
|
| 58 |
+
(0, 128, 128),
|
| 59 |
+
(192, 192, 192),
|
| 60 |
+
(128, 128, 128),
|
| 61 |
+
(255, 0, 0),
|
| 62 |
+
(0, 255, 0),
|
| 63 |
+
(255, 255, 0),
|
| 64 |
+
(0, 0, 255),
|
| 65 |
+
(255, 0, 255),
|
| 66 |
+
(0, 255, 255),
|
| 67 |
+
(255, 255, 255),
|
| 68 |
+
(0, 0, 0),
|
| 69 |
+
(0, 0, 95),
|
| 70 |
+
(0, 0, 135),
|
| 71 |
+
(0, 0, 175),
|
| 72 |
+
(0, 0, 215),
|
| 73 |
+
(0, 0, 255),
|
| 74 |
+
(0, 95, 0),
|
| 75 |
+
(0, 95, 95),
|
| 76 |
+
(0, 95, 135),
|
| 77 |
+
(0, 95, 175),
|
| 78 |
+
(0, 95, 215),
|
| 79 |
+
(0, 95, 255),
|
| 80 |
+
(0, 135, 0),
|
| 81 |
+
(0, 135, 95),
|
| 82 |
+
(0, 135, 135),
|
| 83 |
+
(0, 135, 175),
|
| 84 |
+
(0, 135, 215),
|
| 85 |
+
(0, 135, 255),
|
| 86 |
+
(0, 175, 0),
|
| 87 |
+
(0, 175, 95),
|
| 88 |
+
(0, 175, 135),
|
| 89 |
+
(0, 175, 175),
|
| 90 |
+
(0, 175, 215),
|
| 91 |
+
(0, 175, 255),
|
| 92 |
+
(0, 215, 0),
|
| 93 |
+
(0, 215, 95),
|
| 94 |
+
(0, 215, 135),
|
| 95 |
+
(0, 215, 175),
|
| 96 |
+
(0, 215, 215),
|
| 97 |
+
(0, 215, 255),
|
| 98 |
+
(0, 255, 0),
|
| 99 |
+
(0, 255, 95),
|
| 100 |
+
(0, 255, 135),
|
| 101 |
+
(0, 255, 175),
|
| 102 |
+
(0, 255, 215),
|
| 103 |
+
(0, 255, 255),
|
| 104 |
+
(95, 0, 0),
|
| 105 |
+
(95, 0, 95),
|
| 106 |
+
(95, 0, 135),
|
| 107 |
+
(95, 0, 175),
|
| 108 |
+
(95, 0, 215),
|
| 109 |
+
(95, 0, 255),
|
| 110 |
+
(95, 95, 0),
|
| 111 |
+
(95, 95, 95),
|
| 112 |
+
(95, 95, 135),
|
| 113 |
+
(95, 95, 175),
|
| 114 |
+
(95, 95, 215),
|
| 115 |
+
(95, 95, 255),
|
| 116 |
+
(95, 135, 0),
|
| 117 |
+
(95, 135, 95),
|
| 118 |
+
(95, 135, 135),
|
| 119 |
+
(95, 135, 175),
|
| 120 |
+
(95, 135, 215),
|
| 121 |
+
(95, 135, 255),
|
| 122 |
+
(95, 175, 0),
|
| 123 |
+
(95, 175, 95),
|
| 124 |
+
(95, 175, 135),
|
| 125 |
+
(95, 175, 175),
|
| 126 |
+
(95, 175, 215),
|
| 127 |
+
(95, 175, 255),
|
| 128 |
+
(95, 215, 0),
|
| 129 |
+
(95, 215, 95),
|
| 130 |
+
(95, 215, 135),
|
| 131 |
+
(95, 215, 175),
|
| 132 |
+
(95, 215, 215),
|
| 133 |
+
(95, 215, 255),
|
| 134 |
+
(95, 255, 0),
|
| 135 |
+
(95, 255, 95),
|
| 136 |
+
(95, 255, 135),
|
| 137 |
+
(95, 255, 175),
|
| 138 |
+
(95, 255, 215),
|
| 139 |
+
(95, 255, 255),
|
| 140 |
+
(135, 0, 0),
|
| 141 |
+
(135, 0, 95),
|
| 142 |
+
(135, 0, 135),
|
| 143 |
+
(135, 0, 175),
|
| 144 |
+
(135, 0, 215),
|
| 145 |
+
(135, 0, 255),
|
| 146 |
+
(135, 95, 0),
|
| 147 |
+
(135, 95, 95),
|
| 148 |
+
(135, 95, 135),
|
| 149 |
+
(135, 95, 175),
|
| 150 |
+
(135, 95, 215),
|
| 151 |
+
(135, 95, 255),
|
| 152 |
+
(135, 135, 0),
|
| 153 |
+
(135, 135, 95),
|
| 154 |
+
(135, 135, 135),
|
| 155 |
+
(135, 135, 175),
|
| 156 |
+
(135, 135, 215),
|
| 157 |
+
(135, 135, 255),
|
| 158 |
+
(135, 175, 0),
|
| 159 |
+
(135, 175, 95),
|
| 160 |
+
(135, 175, 135),
|
| 161 |
+
(135, 175, 175),
|
| 162 |
+
(135, 175, 215),
|
| 163 |
+
(135, 175, 255),
|
| 164 |
+
(135, 215, 0),
|
| 165 |
+
(135, 215, 95),
|
| 166 |
+
(135, 215, 135),
|
| 167 |
+
(135, 215, 175),
|
| 168 |
+
(135, 215, 215),
|
| 169 |
+
(135, 215, 255),
|
| 170 |
+
(135, 255, 0),
|
| 171 |
+
(135, 255, 95),
|
| 172 |
+
(135, 255, 135),
|
| 173 |
+
(135, 255, 175),
|
| 174 |
+
(135, 255, 215),
|
| 175 |
+
(135, 255, 255),
|
| 176 |
+
(175, 0, 0),
|
| 177 |
+
(175, 0, 95),
|
| 178 |
+
(175, 0, 135),
|
| 179 |
+
(175, 0, 175),
|
| 180 |
+
(175, 0, 215),
|
| 181 |
+
(175, 0, 255),
|
| 182 |
+
(175, 95, 0),
|
| 183 |
+
(175, 95, 95),
|
| 184 |
+
(175, 95, 135),
|
| 185 |
+
(175, 95, 175),
|
| 186 |
+
(175, 95, 215),
|
| 187 |
+
(175, 95, 255),
|
| 188 |
+
(175, 135, 0),
|
| 189 |
+
(175, 135, 95),
|
| 190 |
+
(175, 135, 135),
|
| 191 |
+
(175, 135, 175),
|
| 192 |
+
(175, 135, 215),
|
| 193 |
+
(175, 135, 255),
|
| 194 |
+
(175, 175, 0),
|
| 195 |
+
(175, 175, 95),
|
| 196 |
+
(175, 175, 135),
|
| 197 |
+
(175, 175, 175),
|
| 198 |
+
(175, 175, 215),
|
| 199 |
+
(175, 175, 255),
|
| 200 |
+
(175, 215, 0),
|
| 201 |
+
(175, 215, 95),
|
| 202 |
+
(175, 215, 135),
|
| 203 |
+
(175, 215, 175),
|
| 204 |
+
(175, 215, 215),
|
| 205 |
+
(175, 215, 255),
|
| 206 |
+
(175, 255, 0),
|
| 207 |
+
(175, 255, 95),
|
| 208 |
+
(175, 255, 135),
|
| 209 |
+
(175, 255, 175),
|
| 210 |
+
(175, 255, 215),
|
| 211 |
+
(175, 255, 255),
|
| 212 |
+
(215, 0, 0),
|
| 213 |
+
(215, 0, 95),
|
| 214 |
+
(215, 0, 135),
|
| 215 |
+
(215, 0, 175),
|
| 216 |
+
(215, 0, 215),
|
| 217 |
+
(215, 0, 255),
|
| 218 |
+
(215, 95, 0),
|
| 219 |
+
(215, 95, 95),
|
| 220 |
+
(215, 95, 135),
|
| 221 |
+
(215, 95, 175),
|
| 222 |
+
(215, 95, 215),
|
| 223 |
+
(215, 95, 255),
|
| 224 |
+
(215, 135, 0),
|
| 225 |
+
(215, 135, 95),
|
| 226 |
+
(215, 135, 135),
|
| 227 |
+
(215, 135, 175),
|
| 228 |
+
(215, 135, 215),
|
| 229 |
+
(215, 135, 255),
|
| 230 |
+
(215, 175, 0),
|
| 231 |
+
(215, 175, 95),
|
| 232 |
+
(215, 175, 135),
|
| 233 |
+
(215, 175, 175),
|
| 234 |
+
(215, 175, 215),
|
| 235 |
+
(215, 175, 255),
|
| 236 |
+
(215, 215, 0),
|
| 237 |
+
(215, 215, 95),
|
| 238 |
+
(215, 215, 135),
|
| 239 |
+
(215, 215, 175),
|
| 240 |
+
(215, 215, 215),
|
| 241 |
+
(215, 215, 255),
|
| 242 |
+
(215, 255, 0),
|
| 243 |
+
(215, 255, 95),
|
| 244 |
+
(215, 255, 135),
|
| 245 |
+
(215, 255, 175),
|
| 246 |
+
(215, 255, 215),
|
| 247 |
+
(215, 255, 255),
|
| 248 |
+
(255, 0, 0),
|
| 249 |
+
(255, 0, 95),
|
| 250 |
+
(255, 0, 135),
|
| 251 |
+
(255, 0, 175),
|
| 252 |
+
(255, 0, 215),
|
| 253 |
+
(255, 0, 255),
|
| 254 |
+
(255, 95, 0),
|
| 255 |
+
(255, 95, 95),
|
| 256 |
+
(255, 95, 135),
|
| 257 |
+
(255, 95, 175),
|
| 258 |
+
(255, 95, 215),
|
| 259 |
+
(255, 95, 255),
|
| 260 |
+
(255, 135, 0),
|
| 261 |
+
(255, 135, 95),
|
| 262 |
+
(255, 135, 135),
|
| 263 |
+
(255, 135, 175),
|
| 264 |
+
(255, 135, 215),
|
| 265 |
+
(255, 135, 255),
|
| 266 |
+
(255, 175, 0),
|
| 267 |
+
(255, 175, 95),
|
| 268 |
+
(255, 175, 135),
|
| 269 |
+
(255, 175, 175),
|
| 270 |
+
(255, 175, 215),
|
| 271 |
+
(255, 175, 255),
|
| 272 |
+
(255, 215, 0),
|
| 273 |
+
(255, 215, 95),
|
| 274 |
+
(255, 215, 135),
|
| 275 |
+
(255, 215, 175),
|
| 276 |
+
(255, 215, 215),
|
| 277 |
+
(255, 215, 255),
|
| 278 |
+
(255, 255, 0),
|
| 279 |
+
(255, 255, 95),
|
| 280 |
+
(255, 255, 135),
|
| 281 |
+
(255, 255, 175),
|
| 282 |
+
(255, 255, 215),
|
| 283 |
+
(255, 255, 255),
|
| 284 |
+
(8, 8, 8),
|
| 285 |
+
(18, 18, 18),
|
| 286 |
+
(28, 28, 28),
|
| 287 |
+
(38, 38, 38),
|
| 288 |
+
(48, 48, 48),
|
| 289 |
+
(58, 58, 58),
|
| 290 |
+
(68, 68, 68),
|
| 291 |
+
(78, 78, 78),
|
| 292 |
+
(88, 88, 88),
|
| 293 |
+
(98, 98, 98),
|
| 294 |
+
(108, 108, 108),
|
| 295 |
+
(118, 118, 118),
|
| 296 |
+
(128, 128, 128),
|
| 297 |
+
(138, 138, 138),
|
| 298 |
+
(148, 148, 148),
|
| 299 |
+
(158, 158, 158),
|
| 300 |
+
(168, 168, 168),
|
| 301 |
+
(178, 178, 178),
|
| 302 |
+
(188, 188, 188),
|
| 303 |
+
(198, 198, 198),
|
| 304 |
+
(208, 208, 208),
|
| 305 |
+
(218, 218, 218),
|
| 306 |
+
(228, 228, 228),
|
| 307 |
+
(238, 238, 238),
|
| 308 |
+
]
|
| 309 |
+
)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_pick.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def pick_bool(*values: Optional[bool]) -> bool:
|
| 5 |
+
"""Pick the first non-none bool or return the last value.
|
| 6 |
+
|
| 7 |
+
Args:
|
| 8 |
+
*values (bool): Any number of boolean or None values.
|
| 9 |
+
|
| 10 |
+
Returns:
|
| 11 |
+
bool: First non-none boolean.
|
| 12 |
+
"""
|
| 13 |
+
assert values, "1 or more values required"
|
| 14 |
+
for value in values:
|
| 15 |
+
if value is not None:
|
| 16 |
+
return value
|
| 17 |
+
return bool(value)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_ratio.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fractions import Fraction
|
| 2 |
+
from math import ceil
|
| 3 |
+
from typing import cast, List, Optional, Sequence, Protocol
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class Edge(Protocol):
|
| 7 |
+
"""Any object that defines an edge (such as Layout)."""
|
| 8 |
+
|
| 9 |
+
size: Optional[int] = None
|
| 10 |
+
ratio: int = 1
|
| 11 |
+
minimum_size: int = 1
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def ratio_resolve(total: int, edges: Sequence[Edge]) -> List[int]:
|
| 15 |
+
"""Divide total space to satisfy size, ratio, and minimum_size, constraints.
|
| 16 |
+
|
| 17 |
+
The returned list of integers should add up to total in most cases, unless it is
|
| 18 |
+
impossible to satisfy all the constraints. For instance, if there are two edges
|
| 19 |
+
with a minimum size of 20 each and `total` is 30 then the returned list will be
|
| 20 |
+
greater than total. In practice, this would mean that a Layout object would
|
| 21 |
+
clip the rows that would overflow the screen height.
|
| 22 |
+
|
| 23 |
+
Args:
|
| 24 |
+
total (int): Total number of characters.
|
| 25 |
+
edges (List[Edge]): Edges within total space.
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
List[int]: Number of characters for each edge.
|
| 29 |
+
"""
|
| 30 |
+
# Size of edge or None for yet to be determined
|
| 31 |
+
sizes = [(edge.size or None) for edge in edges]
|
| 32 |
+
|
| 33 |
+
_Fraction = Fraction
|
| 34 |
+
|
| 35 |
+
# While any edges haven't been calculated
|
| 36 |
+
while None in sizes:
|
| 37 |
+
# Get flexible edges and index to map these back on to sizes list
|
| 38 |
+
flexible_edges = [
|
| 39 |
+
(index, edge)
|
| 40 |
+
for index, (size, edge) in enumerate(zip(sizes, edges))
|
| 41 |
+
if size is None
|
| 42 |
+
]
|
| 43 |
+
# Remaining space in total
|
| 44 |
+
remaining = total - sum(size or 0 for size in sizes)
|
| 45 |
+
if remaining <= 0:
|
| 46 |
+
# No room for flexible edges
|
| 47 |
+
return [
|
| 48 |
+
((edge.minimum_size or 1) if size is None else size)
|
| 49 |
+
for size, edge in zip(sizes, edges)
|
| 50 |
+
]
|
| 51 |
+
# Calculate number of characters in a ratio portion
|
| 52 |
+
portion = _Fraction(
|
| 53 |
+
remaining, sum((edge.ratio or 1) for _, edge in flexible_edges)
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# If any edges will be less than their minimum, replace size with the minimum
|
| 57 |
+
for index, edge in flexible_edges:
|
| 58 |
+
if portion * edge.ratio <= edge.minimum_size:
|
| 59 |
+
sizes[index] = edge.minimum_size
|
| 60 |
+
# New fixed size will invalidate calculations, so we need to repeat the process
|
| 61 |
+
break
|
| 62 |
+
else:
|
| 63 |
+
# Distribute flexible space and compensate for rounding error
|
| 64 |
+
# Since edge sizes can only be integers we need to add the remainder
|
| 65 |
+
# to the following line
|
| 66 |
+
remainder = _Fraction(0)
|
| 67 |
+
for index, edge in flexible_edges:
|
| 68 |
+
size, remainder = divmod(portion * edge.ratio + remainder, 1)
|
| 69 |
+
sizes[index] = size
|
| 70 |
+
break
|
| 71 |
+
# Sizes now contains integers only
|
| 72 |
+
return cast(List[int], sizes)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def ratio_reduce(
|
| 76 |
+
total: int, ratios: List[int], maximums: List[int], values: List[int]
|
| 77 |
+
) -> List[int]:
|
| 78 |
+
"""Divide an integer total in to parts based on ratios.
|
| 79 |
+
|
| 80 |
+
Args:
|
| 81 |
+
total (int): The total to divide.
|
| 82 |
+
ratios (List[int]): A list of integer ratios.
|
| 83 |
+
maximums (List[int]): List of maximums values for each slot.
|
| 84 |
+
values (List[int]): List of values
|
| 85 |
+
|
| 86 |
+
Returns:
|
| 87 |
+
List[int]: A list of integers guaranteed to sum to total.
|
| 88 |
+
"""
|
| 89 |
+
ratios = [ratio if _max else 0 for ratio, _max in zip(ratios, maximums)]
|
| 90 |
+
total_ratio = sum(ratios)
|
| 91 |
+
if not total_ratio:
|
| 92 |
+
return values[:]
|
| 93 |
+
total_remaining = total
|
| 94 |
+
result: List[int] = []
|
| 95 |
+
append = result.append
|
| 96 |
+
for ratio, maximum, value in zip(ratios, maximums, values):
|
| 97 |
+
if ratio and total_ratio > 0:
|
| 98 |
+
distributed = min(maximum, round(ratio * total_remaining / total_ratio))
|
| 99 |
+
append(value - distributed)
|
| 100 |
+
total_remaining -= distributed
|
| 101 |
+
total_ratio -= ratio
|
| 102 |
+
else:
|
| 103 |
+
append(value)
|
| 104 |
+
return result
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def ratio_distribute(
|
| 108 |
+
total: int, ratios: List[int], minimums: Optional[List[int]] = None
|
| 109 |
+
) -> List[int]:
|
| 110 |
+
"""Distribute an integer total in to parts based on ratios.
|
| 111 |
+
|
| 112 |
+
Args:
|
| 113 |
+
total (int): The total to divide.
|
| 114 |
+
ratios (List[int]): A list of integer ratios.
|
| 115 |
+
minimums (List[int]): List of minimum values for each slot.
|
| 116 |
+
|
| 117 |
+
Returns:
|
| 118 |
+
List[int]: A list of integers guaranteed to sum to total.
|
| 119 |
+
"""
|
| 120 |
+
if minimums:
|
| 121 |
+
ratios = [ratio if _min else 0 for ratio, _min in zip(ratios, minimums)]
|
| 122 |
+
total_ratio = sum(ratios)
|
| 123 |
+
assert total_ratio > 0, "Sum of ratios must be > 0"
|
| 124 |
+
|
| 125 |
+
total_remaining = total
|
| 126 |
+
distributed_total: List[int] = []
|
| 127 |
+
append = distributed_total.append
|
| 128 |
+
if minimums is None:
|
| 129 |
+
_minimums = [0] * len(ratios)
|
| 130 |
+
else:
|
| 131 |
+
_minimums = minimums
|
| 132 |
+
for ratio, minimum in zip(ratios, _minimums):
|
| 133 |
+
if total_ratio > 0:
|
| 134 |
+
distributed = max(minimum, ceil(ratio * total_remaining / total_ratio))
|
| 135 |
+
else:
|
| 136 |
+
distributed = total_remaining
|
| 137 |
+
append(distributed)
|
| 138 |
+
total_ratio -= ratio
|
| 139 |
+
total_remaining -= distributed
|
| 140 |
+
return distributed_total
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
if __name__ == "__main__":
|
| 144 |
+
from dataclasses import dataclass
|
| 145 |
+
|
| 146 |
+
@dataclass
|
| 147 |
+
class E:
|
| 148 |
+
size: Optional[int] = None
|
| 149 |
+
ratio: int = 1
|
| 150 |
+
minimum_size: int = 1
|
| 151 |
+
|
| 152 |
+
resolved = ratio_resolve(110, [E(None, 1, 1), E(None, 1, 1), E(None, 1, 1)])
|
| 153 |
+
print(sum(resolved))
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_spinners.py
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Spinners are from:
|
| 3 |
+
* cli-spinners:
|
| 4 |
+
MIT License
|
| 5 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
| 6 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 7 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 8 |
+
in the Software without restriction, including without limitation the rights to
|
| 9 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 10 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 11 |
+
subject to the following conditions:
|
| 12 |
+
The above copyright notice and this permission notice shall be included
|
| 13 |
+
in all copies or substantial portions of the Software.
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
| 15 |
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
| 16 |
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
| 17 |
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 18 |
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
| 19 |
+
IN THE SOFTWARE.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
SPINNERS = {
|
| 23 |
+
"dots": {
|
| 24 |
+
"interval": 80,
|
| 25 |
+
"frames": "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏",
|
| 26 |
+
},
|
| 27 |
+
"dots2": {"interval": 80, "frames": "⣾⣽⣻⢿⡿⣟⣯⣷"},
|
| 28 |
+
"dots3": {
|
| 29 |
+
"interval": 80,
|
| 30 |
+
"frames": "⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓",
|
| 31 |
+
},
|
| 32 |
+
"dots4": {
|
| 33 |
+
"interval": 80,
|
| 34 |
+
"frames": "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆",
|
| 35 |
+
},
|
| 36 |
+
"dots5": {
|
| 37 |
+
"interval": 80,
|
| 38 |
+
"frames": "⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋",
|
| 39 |
+
},
|
| 40 |
+
"dots6": {
|
| 41 |
+
"interval": 80,
|
| 42 |
+
"frames": "⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁",
|
| 43 |
+
},
|
| 44 |
+
"dots7": {
|
| 45 |
+
"interval": 80,
|
| 46 |
+
"frames": "⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈",
|
| 47 |
+
},
|
| 48 |
+
"dots8": {
|
| 49 |
+
"interval": 80,
|
| 50 |
+
"frames": "⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈",
|
| 51 |
+
},
|
| 52 |
+
"dots9": {"interval": 80, "frames": "⢹⢺⢼⣸⣇⡧⡗⡏"},
|
| 53 |
+
"dots10": {"interval": 80, "frames": "⢄⢂⢁⡁⡈⡐⡠"},
|
| 54 |
+
"dots11": {"interval": 100, "frames": "⠁⠂⠄⡀⢀⠠⠐⠈"},
|
| 55 |
+
"dots12": {
|
| 56 |
+
"interval": 80,
|
| 57 |
+
"frames": [
|
| 58 |
+
"⢀⠀",
|
| 59 |
+
"⡀⠀",
|
| 60 |
+
"⠄⠀",
|
| 61 |
+
"⢂⠀",
|
| 62 |
+
"⡂⠀",
|
| 63 |
+
"⠅⠀",
|
| 64 |
+
"⢃⠀",
|
| 65 |
+
"⡃⠀",
|
| 66 |
+
"⠍⠀",
|
| 67 |
+
"⢋⠀",
|
| 68 |
+
"⡋⠀",
|
| 69 |
+
"⠍⠁",
|
| 70 |
+
"⢋⠁",
|
| 71 |
+
"⡋⠁",
|
| 72 |
+
"⠍⠉",
|
| 73 |
+
"⠋⠉",
|
| 74 |
+
"⠋⠉",
|
| 75 |
+
"⠉⠙",
|
| 76 |
+
"⠉⠙",
|
| 77 |
+
"⠉⠩",
|
| 78 |
+
"⠈⢙",
|
| 79 |
+
"⠈⡙",
|
| 80 |
+
"⢈⠩",
|
| 81 |
+
"⡀⢙",
|
| 82 |
+
"⠄⡙",
|
| 83 |
+
"⢂⠩",
|
| 84 |
+
"⡂⢘",
|
| 85 |
+
"⠅⡘",
|
| 86 |
+
"⢃⠨",
|
| 87 |
+
"⡃⢐",
|
| 88 |
+
"⠍⡐",
|
| 89 |
+
"⢋⠠",
|
| 90 |
+
"⡋⢀",
|
| 91 |
+
"⠍⡁",
|
| 92 |
+
"⢋⠁",
|
| 93 |
+
"⡋⠁",
|
| 94 |
+
"⠍⠉",
|
| 95 |
+
"⠋⠉",
|
| 96 |
+
"⠋⠉",
|
| 97 |
+
"⠉⠙",
|
| 98 |
+
"⠉⠙",
|
| 99 |
+
"⠉⠩",
|
| 100 |
+
"⠈⢙",
|
| 101 |
+
"⠈⡙",
|
| 102 |
+
"⠈⠩",
|
| 103 |
+
"⠀⢙",
|
| 104 |
+
"⠀⡙",
|
| 105 |
+
"⠀⠩",
|
| 106 |
+
"⠀⢘",
|
| 107 |
+
"⠀⡘",
|
| 108 |
+
"⠀⠨",
|
| 109 |
+
"⠀⢐",
|
| 110 |
+
"⠀⡐",
|
| 111 |
+
"⠀⠠",
|
| 112 |
+
"⠀⢀",
|
| 113 |
+
"⠀⡀",
|
| 114 |
+
],
|
| 115 |
+
},
|
| 116 |
+
"dots8Bit": {
|
| 117 |
+
"interval": 80,
|
| 118 |
+
"frames": "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙"
|
| 119 |
+
"⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻"
|
| 120 |
+
"⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕"
|
| 121 |
+
"⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷"
|
| 122 |
+
"⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿",
|
| 123 |
+
},
|
| 124 |
+
"line": {"interval": 130, "frames": ["-", "\\", "|", "/"]},
|
| 125 |
+
"line2": {"interval": 100, "frames": "⠂-–—–-"},
|
| 126 |
+
"pipe": {"interval": 100, "frames": "┤┘┴└├┌┬┐"},
|
| 127 |
+
"simpleDots": {"interval": 400, "frames": [". ", ".. ", "...", " "]},
|
| 128 |
+
"simpleDotsScrolling": {
|
| 129 |
+
"interval": 200,
|
| 130 |
+
"frames": [". ", ".. ", "...", " ..", " .", " "],
|
| 131 |
+
},
|
| 132 |
+
"star": {"interval": 70, "frames": "✶✸✹✺✹✷"},
|
| 133 |
+
"star2": {"interval": 80, "frames": "+x*"},
|
| 134 |
+
"flip": {
|
| 135 |
+
"interval": 70,
|
| 136 |
+
"frames": "___-``'´-___",
|
| 137 |
+
},
|
| 138 |
+
"hamburger": {"interval": 100, "frames": "☱☲☴"},
|
| 139 |
+
"growVertical": {
|
| 140 |
+
"interval": 120,
|
| 141 |
+
"frames": "▁▃▄▅▆▇▆▅▄▃",
|
| 142 |
+
},
|
| 143 |
+
"growHorizontal": {
|
| 144 |
+
"interval": 120,
|
| 145 |
+
"frames": "▏▎▍▌▋▊▉▊▋▌▍▎",
|
| 146 |
+
},
|
| 147 |
+
"balloon": {"interval": 140, "frames": " .oO@* "},
|
| 148 |
+
"balloon2": {"interval": 120, "frames": ".oO°Oo."},
|
| 149 |
+
"noise": {"interval": 100, "frames": "▓▒░"},
|
| 150 |
+
"bounce": {"interval": 120, "frames": "⠁⠂⠄⠂"},
|
| 151 |
+
"boxBounce": {"interval": 120, "frames": "▖▘▝▗"},
|
| 152 |
+
"boxBounce2": {"interval": 100, "frames": "▌▀▐▄"},
|
| 153 |
+
"triangle": {"interval": 50, "frames": "◢◣◤◥"},
|
| 154 |
+
"arc": {"interval": 100, "frames": "◜◠◝◞◡◟"},
|
| 155 |
+
"circle": {"interval": 120, "frames": "◡⊙◠"},
|
| 156 |
+
"squareCorners": {"interval": 180, "frames": "◰◳◲◱"},
|
| 157 |
+
"circleQuarters": {"interval": 120, "frames": "◴◷◶◵"},
|
| 158 |
+
"circleHalves": {"interval": 50, "frames": "◐◓◑◒"},
|
| 159 |
+
"squish": {"interval": 100, "frames": "╫╪"},
|
| 160 |
+
"toggle": {"interval": 250, "frames": "⊶⊷"},
|
| 161 |
+
"toggle2": {"interval": 80, "frames": "▫▪"},
|
| 162 |
+
"toggle3": {"interval": 120, "frames": "□■"},
|
| 163 |
+
"toggle4": {"interval": 100, "frames": "■□▪▫"},
|
| 164 |
+
"toggle5": {"interval": 100, "frames": "▮▯"},
|
| 165 |
+
"toggle6": {"interval": 300, "frames": "ဝ၀"},
|
| 166 |
+
"toggle7": {"interval": 80, "frames": "⦾⦿"},
|
| 167 |
+
"toggle8": {"interval": 100, "frames": "◍◌"},
|
| 168 |
+
"toggle9": {"interval": 100, "frames": "◉◎"},
|
| 169 |
+
"toggle10": {"interval": 100, "frames": "㊂㊀㊁"},
|
| 170 |
+
"toggle11": {"interval": 50, "frames": "⧇⧆"},
|
| 171 |
+
"toggle12": {"interval": 120, "frames": "☗☖"},
|
| 172 |
+
"toggle13": {"interval": 80, "frames": "=*-"},
|
| 173 |
+
"arrow": {"interval": 100, "frames": "←↖↑↗→↘↓↙"},
|
| 174 |
+
"arrow2": {
|
| 175 |
+
"interval": 80,
|
| 176 |
+
"frames": ["⬆️ ", "↗️ ", "➡️ ", "↘️ ", "⬇️ ", "↙️ ", "⬅️ ", "↖️ "],
|
| 177 |
+
},
|
| 178 |
+
"arrow3": {
|
| 179 |
+
"interval": 120,
|
| 180 |
+
"frames": ["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"],
|
| 181 |
+
},
|
| 182 |
+
"bouncingBar": {
|
| 183 |
+
"interval": 80,
|
| 184 |
+
"frames": [
|
| 185 |
+
"[ ]",
|
| 186 |
+
"[= ]",
|
| 187 |
+
"[== ]",
|
| 188 |
+
"[=== ]",
|
| 189 |
+
"[ ===]",
|
| 190 |
+
"[ ==]",
|
| 191 |
+
"[ =]",
|
| 192 |
+
"[ ]",
|
| 193 |
+
"[ =]",
|
| 194 |
+
"[ ==]",
|
| 195 |
+
"[ ===]",
|
| 196 |
+
"[====]",
|
| 197 |
+
"[=== ]",
|
| 198 |
+
"[== ]",
|
| 199 |
+
"[= ]",
|
| 200 |
+
],
|
| 201 |
+
},
|
| 202 |
+
"bouncingBall": {
|
| 203 |
+
"interval": 80,
|
| 204 |
+
"frames": [
|
| 205 |
+
"( ● )",
|
| 206 |
+
"( ● )",
|
| 207 |
+
"( ● )",
|
| 208 |
+
"( ● )",
|
| 209 |
+
"( ●)",
|
| 210 |
+
"( ● )",
|
| 211 |
+
"( ● )",
|
| 212 |
+
"( ● )",
|
| 213 |
+
"( ● )",
|
| 214 |
+
"(● )",
|
| 215 |
+
],
|
| 216 |
+
},
|
| 217 |
+
"smiley": {"interval": 200, "frames": ["😄 ", "😝 "]},
|
| 218 |
+
"monkey": {"interval": 300, "frames": ["🙈 ", "🙈 ", "🙉 ", "🙊 "]},
|
| 219 |
+
"hearts": {"interval": 100, "frames": ["💛 ", "💙 ", "💜 ", "💚 ", "❤️ "]},
|
| 220 |
+
"clock": {
|
| 221 |
+
"interval": 100,
|
| 222 |
+
"frames": [
|
| 223 |
+
"🕛 ",
|
| 224 |
+
"🕐 ",
|
| 225 |
+
"🕑 ",
|
| 226 |
+
"🕒 ",
|
| 227 |
+
"🕓 ",
|
| 228 |
+
"🕔 ",
|
| 229 |
+
"🕕 ",
|
| 230 |
+
"🕖 ",
|
| 231 |
+
"🕗 ",
|
| 232 |
+
"🕘 ",
|
| 233 |
+
"🕙 ",
|
| 234 |
+
"🕚 ",
|
| 235 |
+
],
|
| 236 |
+
},
|
| 237 |
+
"earth": {"interval": 180, "frames": ["🌍 ", "🌎 ", "🌏 "]},
|
| 238 |
+
"material": {
|
| 239 |
+
"interval": 17,
|
| 240 |
+
"frames": [
|
| 241 |
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 242 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 243 |
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 244 |
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 245 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 246 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 247 |
+
"███████▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 248 |
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 249 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 250 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 251 |
+
"██████████▁▁▁▁▁▁▁▁▁▁",
|
| 252 |
+
"███████████▁▁▁▁▁▁▁▁▁",
|
| 253 |
+
"█████████████▁▁▁▁▁▁▁",
|
| 254 |
+
"██████████████▁▁▁▁▁▁",
|
| 255 |
+
"██████████████▁▁▁▁▁▁",
|
| 256 |
+
"▁██████████████▁▁▁▁▁",
|
| 257 |
+
"▁██████████████▁▁▁▁▁",
|
| 258 |
+
"▁██████████████▁▁▁▁▁",
|
| 259 |
+
"▁▁██████████████▁▁▁▁",
|
| 260 |
+
"▁▁▁██████████████▁▁▁",
|
| 261 |
+
"▁▁▁▁█████████████▁▁▁",
|
| 262 |
+
"▁▁▁▁██████████████▁▁",
|
| 263 |
+
"▁▁▁▁██████████████▁▁",
|
| 264 |
+
"▁▁▁▁▁██████████████▁",
|
| 265 |
+
"▁▁▁▁▁██████████████▁",
|
| 266 |
+
"▁▁▁▁▁██████████████▁",
|
| 267 |
+
"▁▁▁▁▁▁██████████████",
|
| 268 |
+
"▁▁▁▁▁▁██████████████",
|
| 269 |
+
"▁▁▁▁▁▁▁█████████████",
|
| 270 |
+
"▁▁▁▁▁▁▁█████████████",
|
| 271 |
+
"▁▁▁▁▁▁▁▁████████████",
|
| 272 |
+
"▁▁▁▁▁▁▁▁████████████",
|
| 273 |
+
"▁▁▁▁▁▁▁▁▁███████████",
|
| 274 |
+
"▁▁▁▁▁▁▁▁▁███████████",
|
| 275 |
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
| 276 |
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
| 277 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁████████",
|
| 278 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 279 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████",
|
| 280 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 281 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 282 |
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 283 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 284 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 285 |
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 286 |
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 287 |
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 288 |
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 289 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 290 |
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 291 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 292 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 293 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 294 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 295 |
+
"███████████▁▁▁▁▁▁▁▁▁",
|
| 296 |
+
"████████████▁▁▁▁▁▁▁▁",
|
| 297 |
+
"████████████▁▁▁▁▁▁▁▁",
|
| 298 |
+
"██████████████▁▁▁▁▁▁",
|
| 299 |
+
"██████████████▁▁▁▁▁▁",
|
| 300 |
+
"▁██████████████▁▁▁▁▁",
|
| 301 |
+
"▁██████████████▁▁▁▁▁",
|
| 302 |
+
"▁▁▁█████████████▁▁▁▁",
|
| 303 |
+
"▁▁▁▁▁████████████▁▁▁",
|
| 304 |
+
"▁▁▁▁▁████████████▁▁▁",
|
| 305 |
+
"▁▁▁▁▁▁███████████▁▁▁",
|
| 306 |
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
| 307 |
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
| 308 |
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
| 309 |
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
| 310 |
+
"▁▁▁▁▁▁▁▁▁▁█████████▁",
|
| 311 |
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
| 312 |
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
| 313 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
| 314 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
| 315 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 316 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 317 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 318 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 319 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 320 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 321 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 322 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 323 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 324 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 325 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 326 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 327 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 328 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 329 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 330 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 331 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 332 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 333 |
+
],
|
| 334 |
+
},
|
| 335 |
+
"moon": {
|
| 336 |
+
"interval": 80,
|
| 337 |
+
"frames": ["🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "],
|
| 338 |
+
},
|
| 339 |
+
"runner": {"interval": 140, "frames": ["🚶 ", "🏃 "]},
|
| 340 |
+
"pong": {
|
| 341 |
+
"interval": 80,
|
| 342 |
+
"frames": [
|
| 343 |
+
"▐⠂ ▌",
|
| 344 |
+
"▐⠈ ▌",
|
| 345 |
+
"▐ ⠂ ▌",
|
| 346 |
+
"▐ ⠠ ▌",
|
| 347 |
+
"▐ ⡀ ▌",
|
| 348 |
+
"▐ ⠠ ▌",
|
| 349 |
+
"▐ ⠂ ▌",
|
| 350 |
+
"▐ ⠈ ▌",
|
| 351 |
+
"▐ ⠂ ▌",
|
| 352 |
+
"▐ ⠠ ▌",
|
| 353 |
+
"▐ ⡀ ▌",
|
| 354 |
+
"▐ ⠠ ▌",
|
| 355 |
+
"▐ ⠂ ▌",
|
| 356 |
+
"▐ ⠈ ▌",
|
| 357 |
+
"▐ ⠂▌",
|
| 358 |
+
"▐ ⠠▌",
|
| 359 |
+
"▐ ⡀▌",
|
| 360 |
+
"▐ ⠠ ▌",
|
| 361 |
+
"▐ ⠂ ▌",
|
| 362 |
+
"▐ ⠈ ▌",
|
| 363 |
+
"▐ ⠂ ▌",
|
| 364 |
+
"▐ ⠠ ▌",
|
| 365 |
+
"▐ ⡀ ▌",
|
| 366 |
+
"▐ ⠠ ▌",
|
| 367 |
+
"▐ ⠂ ▌",
|
| 368 |
+
"▐ ⠈ ▌",
|
| 369 |
+
"▐ ⠂ ▌",
|
| 370 |
+
"▐ ⠠ ▌",
|
| 371 |
+
"▐ ⡀ ▌",
|
| 372 |
+
"▐⠠ ▌",
|
| 373 |
+
],
|
| 374 |
+
},
|
| 375 |
+
"shark": {
|
| 376 |
+
"interval": 120,
|
| 377 |
+
"frames": [
|
| 378 |
+
"▐|\\____________▌",
|
| 379 |
+
"▐_|\\___________▌",
|
| 380 |
+
"▐__|\\__________▌",
|
| 381 |
+
"▐___|\\_________▌",
|
| 382 |
+
"▐____|\\________▌",
|
| 383 |
+
"▐_____|\\_______▌",
|
| 384 |
+
"▐______|\\______▌",
|
| 385 |
+
"▐_______|\\_____▌",
|
| 386 |
+
"▐________|\\____▌",
|
| 387 |
+
"▐_________|\\___▌",
|
| 388 |
+
"▐__________|\\__▌",
|
| 389 |
+
"▐___________|\\_▌",
|
| 390 |
+
"▐____________|\\▌",
|
| 391 |
+
"▐____________/|▌",
|
| 392 |
+
"▐___________/|_▌",
|
| 393 |
+
"▐__________/|__▌",
|
| 394 |
+
"▐_________/|___▌",
|
| 395 |
+
"▐________/|____▌",
|
| 396 |
+
"▐_______/|_____▌",
|
| 397 |
+
"▐______/|______▌",
|
| 398 |
+
"▐_____/|_______▌",
|
| 399 |
+
"▐____/|________▌",
|
| 400 |
+
"▐___/|_________▌",
|
| 401 |
+
"▐__/|__________▌",
|
| 402 |
+
"▐_/|___________▌",
|
| 403 |
+
"▐/|____________▌",
|
| 404 |
+
],
|
| 405 |
+
},
|
| 406 |
+
"dqpb": {"interval": 100, "frames": "dqpb"},
|
| 407 |
+
"weather": {
|
| 408 |
+
"interval": 100,
|
| 409 |
+
"frames": [
|
| 410 |
+
"☀️ ",
|
| 411 |
+
"☀️ ",
|
| 412 |
+
"☀️ ",
|
| 413 |
+
"🌤 ",
|
| 414 |
+
"⛅️ ",
|
| 415 |
+
"🌥 ",
|
| 416 |
+
"☁️ ",
|
| 417 |
+
"🌧 ",
|
| 418 |
+
"🌨 ",
|
| 419 |
+
"🌧 ",
|
| 420 |
+
"🌨 ",
|
| 421 |
+
"🌧 ",
|
| 422 |
+
"🌨 ",
|
| 423 |
+
"⛈ ",
|
| 424 |
+
"🌨 ",
|
| 425 |
+
"🌧 ",
|
| 426 |
+
"🌨 ",
|
| 427 |
+
"☁️ ",
|
| 428 |
+
"🌥 ",
|
| 429 |
+
"⛅️ ",
|
| 430 |
+
"🌤 ",
|
| 431 |
+
"☀️ ",
|
| 432 |
+
"☀️ ",
|
| 433 |
+
],
|
| 434 |
+
},
|
| 435 |
+
"christmas": {"interval": 400, "frames": "🌲🎄"},
|
| 436 |
+
"grenade": {
|
| 437 |
+
"interval": 80,
|
| 438 |
+
"frames": [
|
| 439 |
+
"، ",
|
| 440 |
+
"′ ",
|
| 441 |
+
" ´ ",
|
| 442 |
+
" ‾ ",
|
| 443 |
+
" ⸌",
|
| 444 |
+
" ⸊",
|
| 445 |
+
" |",
|
| 446 |
+
" ⁎",
|
| 447 |
+
" ⁕",
|
| 448 |
+
" ෴ ",
|
| 449 |
+
" ⁓",
|
| 450 |
+
" ",
|
| 451 |
+
" ",
|
| 452 |
+
" ",
|
| 453 |
+
],
|
| 454 |
+
},
|
| 455 |
+
"point": {"interval": 125, "frames": ["∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"]},
|
| 456 |
+
"layer": {"interval": 150, "frames": "-=≡"},
|
| 457 |
+
"betaWave": {
|
| 458 |
+
"interval": 80,
|
| 459 |
+
"frames": [
|
| 460 |
+
"ρββββββ",
|
| 461 |
+
"βρβββββ",
|
| 462 |
+
"ββρββββ",
|
| 463 |
+
"βββρβββ",
|
| 464 |
+
"ββββρββ",
|
| 465 |
+
"βββββρβ",
|
| 466 |
+
"ββββββρ",
|
| 467 |
+
],
|
| 468 |
+
},
|
| 469 |
+
"aesthetic": {
|
| 470 |
+
"interval": 80,
|
| 471 |
+
"frames": [
|
| 472 |
+
"▰▱▱▱▱▱▱",
|
| 473 |
+
"▰▰▱▱▱▱▱",
|
| 474 |
+
"▰▰▰▱▱▱▱",
|
| 475 |
+
"▰▰▰▰▱▱▱",
|
| 476 |
+
"▰▰▰▰▰▱▱",
|
| 477 |
+
"▰▰▰▰▰▰▱",
|
| 478 |
+
"▰▰▰▰▰▰▰",
|
| 479 |
+
"▰▱▱▱▱▱▱",
|
| 480 |
+
],
|
| 481 |
+
},
|
| 482 |
+
}
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_stack.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, TypeVar
|
| 2 |
+
|
| 3 |
+
T = TypeVar("T")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class Stack(List[T]):
|
| 7 |
+
"""A small shim over builtin list."""
|
| 8 |
+
|
| 9 |
+
@property
|
| 10 |
+
def top(self) -> T:
|
| 11 |
+
"""Get top of stack."""
|
| 12 |
+
return self[-1]
|
| 13 |
+
|
| 14 |
+
def push(self, item: T) -> None:
|
| 15 |
+
"""Push an item on to the stack (append in stack nomenclature)."""
|
| 16 |
+
self.append(item)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_timer.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Timer context manager, only used in debug.
|
| 3 |
+
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from time import time
|
| 7 |
+
|
| 8 |
+
import contextlib
|
| 9 |
+
from typing import Generator
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@contextlib.contextmanager
|
| 13 |
+
def timer(subject: str = "time") -> Generator[None, None, None]:
|
| 14 |
+
"""print the elapsed time. (only used in debugging)"""
|
| 15 |
+
start = time()
|
| 16 |
+
yield
|
| 17 |
+
elapsed = time() - start
|
| 18 |
+
elapsed_ms = elapsed * 1000
|
| 19 |
+
print(f"{subject} elapsed {elapsed_ms:.1f}ms")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_win32_console.py
ADDED
|
@@ -0,0 +1,661 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Light wrapper around the Win32 Console API - this module should only be imported on Windows
|
| 2 |
+
|
| 3 |
+
The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import ctypes
|
| 7 |
+
import sys
|
| 8 |
+
from typing import Any
|
| 9 |
+
|
| 10 |
+
windll: Any = None
|
| 11 |
+
if sys.platform == "win32":
|
| 12 |
+
windll = ctypes.LibraryLoader(ctypes.WinDLL)
|
| 13 |
+
else:
|
| 14 |
+
raise ImportError(f"{__name__} can only be imported on Windows")
|
| 15 |
+
|
| 16 |
+
import time
|
| 17 |
+
from ctypes import Structure, byref, wintypes
|
| 18 |
+
from typing import IO, NamedTuple, Type, cast
|
| 19 |
+
|
| 20 |
+
from rich.color import ColorSystem
|
| 21 |
+
from rich.style import Style
|
| 22 |
+
|
| 23 |
+
STDOUT = -11
|
| 24 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
|
| 25 |
+
|
| 26 |
+
COORD = wintypes._COORD
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class LegacyWindowsError(Exception):
|
| 30 |
+
pass
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class WindowsCoordinates(NamedTuple):
|
| 34 |
+
"""Coordinates in the Windows Console API are (y, x), not (x, y).
|
| 35 |
+
This class is intended to prevent that confusion.
|
| 36 |
+
Rows and columns are indexed from 0.
|
| 37 |
+
This class can be used in place of wintypes._COORD in arguments and argtypes.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
row: int
|
| 41 |
+
col: int
|
| 42 |
+
|
| 43 |
+
@classmethod
|
| 44 |
+
def from_param(cls, value: "WindowsCoordinates") -> COORD:
|
| 45 |
+
"""Converts a WindowsCoordinates into a wintypes _COORD structure.
|
| 46 |
+
This classmethod is internally called by ctypes to perform the conversion.
|
| 47 |
+
|
| 48 |
+
Args:
|
| 49 |
+
value (WindowsCoordinates): The input coordinates to convert.
|
| 50 |
+
|
| 51 |
+
Returns:
|
| 52 |
+
wintypes._COORD: The converted coordinates struct.
|
| 53 |
+
"""
|
| 54 |
+
return COORD(value.col, value.row)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
| 58 |
+
_fields_ = [
|
| 59 |
+
("dwSize", COORD),
|
| 60 |
+
("dwCursorPosition", COORD),
|
| 61 |
+
("wAttributes", wintypes.WORD),
|
| 62 |
+
("srWindow", wintypes.SMALL_RECT),
|
| 63 |
+
("dwMaximumWindowSize", COORD),
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class CONSOLE_CURSOR_INFO(ctypes.Structure):
|
| 68 |
+
_fields_ = [("dwSize", wintypes.DWORD), ("bVisible", wintypes.BOOL)]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
_GetStdHandle = windll.kernel32.GetStdHandle
|
| 72 |
+
_GetStdHandle.argtypes = [
|
| 73 |
+
wintypes.DWORD,
|
| 74 |
+
]
|
| 75 |
+
_GetStdHandle.restype = wintypes.HANDLE
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def GetStdHandle(handle: int = STDOUT) -> wintypes.HANDLE:
|
| 79 |
+
"""Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
|
| 80 |
+
|
| 81 |
+
Args:
|
| 82 |
+
handle (int): Integer identifier for the handle. Defaults to -11 (stdout).
|
| 83 |
+
|
| 84 |
+
Returns:
|
| 85 |
+
wintypes.HANDLE: The handle
|
| 86 |
+
"""
|
| 87 |
+
return cast(wintypes.HANDLE, _GetStdHandle(handle))
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
_GetConsoleMode = windll.kernel32.GetConsoleMode
|
| 91 |
+
_GetConsoleMode.argtypes = [wintypes.HANDLE, wintypes.LPDWORD]
|
| 92 |
+
_GetConsoleMode.restype = wintypes.BOOL
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def GetConsoleMode(std_handle: wintypes.HANDLE) -> int:
|
| 96 |
+
"""Retrieves the current input mode of a console's input buffer
|
| 97 |
+
or the current output mode of a console screen buffer.
|
| 98 |
+
|
| 99 |
+
Args:
|
| 100 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 101 |
+
|
| 102 |
+
Raises:
|
| 103 |
+
LegacyWindowsError: If any error occurs while calling the Windows console API.
|
| 104 |
+
|
| 105 |
+
Returns:
|
| 106 |
+
int: Value representing the current console mode as documented at
|
| 107 |
+
https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
console_mode = wintypes.DWORD()
|
| 111 |
+
success = bool(_GetConsoleMode(std_handle, console_mode))
|
| 112 |
+
if not success:
|
| 113 |
+
raise LegacyWindowsError("Unable to get legacy Windows Console Mode")
|
| 114 |
+
return console_mode.value
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
_FillConsoleOutputCharacterW = windll.kernel32.FillConsoleOutputCharacterW
|
| 118 |
+
_FillConsoleOutputCharacterW.argtypes = [
|
| 119 |
+
wintypes.HANDLE,
|
| 120 |
+
ctypes.c_char,
|
| 121 |
+
wintypes.DWORD,
|
| 122 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 123 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 124 |
+
]
|
| 125 |
+
_FillConsoleOutputCharacterW.restype = wintypes.BOOL
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def FillConsoleOutputCharacter(
|
| 129 |
+
std_handle: wintypes.HANDLE,
|
| 130 |
+
char: str,
|
| 131 |
+
length: int,
|
| 132 |
+
start: WindowsCoordinates,
|
| 133 |
+
) -> int:
|
| 134 |
+
"""Writes a character to the console screen buffer a specified number of times, beginning at the specified coordinates.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 138 |
+
char (str): The character to write. Must be a string of length 1.
|
| 139 |
+
length (int): The number of times to write the character.
|
| 140 |
+
start (WindowsCoordinates): The coordinates to start writing at.
|
| 141 |
+
|
| 142 |
+
Returns:
|
| 143 |
+
int: The number of characters written.
|
| 144 |
+
"""
|
| 145 |
+
character = ctypes.c_char(char.encode())
|
| 146 |
+
num_characters = wintypes.DWORD(length)
|
| 147 |
+
num_written = wintypes.DWORD(0)
|
| 148 |
+
_FillConsoleOutputCharacterW(
|
| 149 |
+
std_handle,
|
| 150 |
+
character,
|
| 151 |
+
num_characters,
|
| 152 |
+
start,
|
| 153 |
+
byref(num_written),
|
| 154 |
+
)
|
| 155 |
+
return num_written.value
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
|
| 159 |
+
_FillConsoleOutputAttribute.argtypes = [
|
| 160 |
+
wintypes.HANDLE,
|
| 161 |
+
wintypes.WORD,
|
| 162 |
+
wintypes.DWORD,
|
| 163 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 164 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 165 |
+
]
|
| 166 |
+
_FillConsoleOutputAttribute.restype = wintypes.BOOL
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def FillConsoleOutputAttribute(
|
| 170 |
+
std_handle: wintypes.HANDLE,
|
| 171 |
+
attributes: int,
|
| 172 |
+
length: int,
|
| 173 |
+
start: WindowsCoordinates,
|
| 174 |
+
) -> int:
|
| 175 |
+
"""Sets the character attributes for a specified number of character cells,
|
| 176 |
+
beginning at the specified coordinates in a screen buffer.
|
| 177 |
+
|
| 178 |
+
Args:
|
| 179 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 180 |
+
attributes (int): Integer value representing the foreground and background colours of the cells.
|
| 181 |
+
length (int): The number of cells to set the output attribute of.
|
| 182 |
+
start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set.
|
| 183 |
+
|
| 184 |
+
Returns:
|
| 185 |
+
int: The number of cells whose attributes were actually set.
|
| 186 |
+
"""
|
| 187 |
+
num_cells = wintypes.DWORD(length)
|
| 188 |
+
style_attrs = wintypes.WORD(attributes)
|
| 189 |
+
num_written = wintypes.DWORD(0)
|
| 190 |
+
_FillConsoleOutputAttribute(
|
| 191 |
+
std_handle, style_attrs, num_cells, start, byref(num_written)
|
| 192 |
+
)
|
| 193 |
+
return num_written.value
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
|
| 197 |
+
_SetConsoleTextAttribute.argtypes = [
|
| 198 |
+
wintypes.HANDLE,
|
| 199 |
+
wintypes.WORD,
|
| 200 |
+
]
|
| 201 |
+
_SetConsoleTextAttribute.restype = wintypes.BOOL
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def SetConsoleTextAttribute(
|
| 205 |
+
std_handle: wintypes.HANDLE, attributes: wintypes.WORD
|
| 206 |
+
) -> bool:
|
| 207 |
+
"""Set the colour attributes for all text written after this function is called.
|
| 208 |
+
|
| 209 |
+
Args:
|
| 210 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 211 |
+
attributes (int): Integer value representing the foreground and background colours.
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
Returns:
|
| 215 |
+
bool: True if the attribute was set successfully, otherwise False.
|
| 216 |
+
"""
|
| 217 |
+
return bool(_SetConsoleTextAttribute(std_handle, attributes))
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
|
| 221 |
+
_GetConsoleScreenBufferInfo.argtypes = [
|
| 222 |
+
wintypes.HANDLE,
|
| 223 |
+
ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO),
|
| 224 |
+
]
|
| 225 |
+
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def GetConsoleScreenBufferInfo(
|
| 229 |
+
std_handle: wintypes.HANDLE,
|
| 230 |
+
) -> CONSOLE_SCREEN_BUFFER_INFO:
|
| 231 |
+
"""Retrieves information about the specified console screen buffer.
|
| 232 |
+
|
| 233 |
+
Args:
|
| 234 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 235 |
+
|
| 236 |
+
Returns:
|
| 237 |
+
CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about
|
| 238 |
+
screen size, cursor position, colour attributes, and more."""
|
| 239 |
+
console_screen_buffer_info = CONSOLE_SCREEN_BUFFER_INFO()
|
| 240 |
+
_GetConsoleScreenBufferInfo(std_handle, byref(console_screen_buffer_info))
|
| 241 |
+
return console_screen_buffer_info
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
|
| 245 |
+
_SetConsoleCursorPosition.argtypes = [
|
| 246 |
+
wintypes.HANDLE,
|
| 247 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 248 |
+
]
|
| 249 |
+
_SetConsoleCursorPosition.restype = wintypes.BOOL
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def SetConsoleCursorPosition(
|
| 253 |
+
std_handle: wintypes.HANDLE, coords: WindowsCoordinates
|
| 254 |
+
) -> bool:
|
| 255 |
+
"""Set the position of the cursor in the console screen
|
| 256 |
+
|
| 257 |
+
Args:
|
| 258 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 259 |
+
coords (WindowsCoordinates): The coordinates to move the cursor to.
|
| 260 |
+
|
| 261 |
+
Returns:
|
| 262 |
+
bool: True if the function succeeds, otherwise False.
|
| 263 |
+
"""
|
| 264 |
+
return bool(_SetConsoleCursorPosition(std_handle, coords))
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
_GetConsoleCursorInfo = windll.kernel32.GetConsoleCursorInfo
|
| 268 |
+
_GetConsoleCursorInfo.argtypes = [
|
| 269 |
+
wintypes.HANDLE,
|
| 270 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 271 |
+
]
|
| 272 |
+
_GetConsoleCursorInfo.restype = wintypes.BOOL
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def GetConsoleCursorInfo(
|
| 276 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 277 |
+
) -> bool:
|
| 278 |
+
"""Get the cursor info - used to get cursor visibility and width
|
| 279 |
+
|
| 280 |
+
Args:
|
| 281 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 282 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information
|
| 283 |
+
about the console's cursor.
|
| 284 |
+
|
| 285 |
+
Returns:
|
| 286 |
+
bool: True if the function succeeds, otherwise False.
|
| 287 |
+
"""
|
| 288 |
+
return bool(_GetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
_SetConsoleCursorInfo = windll.kernel32.SetConsoleCursorInfo
|
| 292 |
+
_SetConsoleCursorInfo.argtypes = [
|
| 293 |
+
wintypes.HANDLE,
|
| 294 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 295 |
+
]
|
| 296 |
+
_SetConsoleCursorInfo.restype = wintypes.BOOL
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def SetConsoleCursorInfo(
|
| 300 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 301 |
+
) -> bool:
|
| 302 |
+
"""Set the cursor info - used for adjusting cursor visibility and width
|
| 303 |
+
|
| 304 |
+
Args:
|
| 305 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 306 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info.
|
| 307 |
+
|
| 308 |
+
Returns:
|
| 309 |
+
bool: True if the function succeeds, otherwise False.
|
| 310 |
+
"""
|
| 311 |
+
return bool(_SetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
_SetConsoleTitle = windll.kernel32.SetConsoleTitleW
|
| 315 |
+
_SetConsoleTitle.argtypes = [wintypes.LPCWSTR]
|
| 316 |
+
_SetConsoleTitle.restype = wintypes.BOOL
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
def SetConsoleTitle(title: str) -> bool:
|
| 320 |
+
"""Sets the title of the current console window
|
| 321 |
+
|
| 322 |
+
Args:
|
| 323 |
+
title (str): The new title of the console window.
|
| 324 |
+
|
| 325 |
+
Returns:
|
| 326 |
+
bool: True if the function succeeds, otherwise False.
|
| 327 |
+
"""
|
| 328 |
+
return bool(_SetConsoleTitle(title))
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
class LegacyWindowsTerm:
|
| 332 |
+
"""This class allows interaction with the legacy Windows Console API. It should only be used in the context
|
| 333 |
+
of environments where virtual terminal processing is not available. However, if it is used in a Windows environment,
|
| 334 |
+
the entire API should work.
|
| 335 |
+
|
| 336 |
+
Args:
|
| 337 |
+
file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout.
|
| 338 |
+
"""
|
| 339 |
+
|
| 340 |
+
BRIGHT_BIT = 8
|
| 341 |
+
|
| 342 |
+
# Indices are ANSI color numbers, values are the corresponding Windows Console API color numbers
|
| 343 |
+
ANSI_TO_WINDOWS = [
|
| 344 |
+
0, # black The Windows colours are defined in wincon.h as follows:
|
| 345 |
+
4, # red define FOREGROUND_BLUE 0x0001 -- 0000 0001
|
| 346 |
+
2, # green define FOREGROUND_GREEN 0x0002 -- 0000 0010
|
| 347 |
+
6, # yellow define FOREGROUND_RED 0x0004 -- 0000 0100
|
| 348 |
+
1, # blue define FOREGROUND_INTENSITY 0x0008 -- 0000 1000
|
| 349 |
+
5, # magenta define BACKGROUND_BLUE 0x0010 -- 0001 0000
|
| 350 |
+
3, # cyan define BACKGROUND_GREEN 0x0020 -- 0010 0000
|
| 351 |
+
7, # white define BACKGROUND_RED 0x0040 -- 0100 0000
|
| 352 |
+
8, # bright black (grey) define BACKGROUND_INTENSITY 0x0080 -- 1000 0000
|
| 353 |
+
12, # bright red
|
| 354 |
+
10, # bright green
|
| 355 |
+
14, # bright yellow
|
| 356 |
+
9, # bright blue
|
| 357 |
+
13, # bright magenta
|
| 358 |
+
11, # bright cyan
|
| 359 |
+
15, # bright white
|
| 360 |
+
]
|
| 361 |
+
|
| 362 |
+
def __init__(self, file: "IO[str]") -> None:
|
| 363 |
+
handle = GetStdHandle(STDOUT)
|
| 364 |
+
self._handle = handle
|
| 365 |
+
default_text = GetConsoleScreenBufferInfo(handle).wAttributes
|
| 366 |
+
self._default_text = default_text
|
| 367 |
+
|
| 368 |
+
self._default_fore = default_text & 7
|
| 369 |
+
self._default_back = (default_text >> 4) & 7
|
| 370 |
+
self._default_attrs = self._default_fore | (self._default_back << 4)
|
| 371 |
+
|
| 372 |
+
self._file = file
|
| 373 |
+
self.write = file.write
|
| 374 |
+
self.flush = file.flush
|
| 375 |
+
|
| 376 |
+
@property
|
| 377 |
+
def cursor_position(self) -> WindowsCoordinates:
|
| 378 |
+
"""Returns the current position of the cursor (0-based)
|
| 379 |
+
|
| 380 |
+
Returns:
|
| 381 |
+
WindowsCoordinates: The current cursor position.
|
| 382 |
+
"""
|
| 383 |
+
coord: COORD = GetConsoleScreenBufferInfo(self._handle).dwCursorPosition
|
| 384 |
+
return WindowsCoordinates(row=coord.Y, col=coord.X)
|
| 385 |
+
|
| 386 |
+
@property
|
| 387 |
+
def screen_size(self) -> WindowsCoordinates:
|
| 388 |
+
"""Returns the current size of the console screen buffer, in character columns and rows
|
| 389 |
+
|
| 390 |
+
Returns:
|
| 391 |
+
WindowsCoordinates: The width and height of the screen as WindowsCoordinates.
|
| 392 |
+
"""
|
| 393 |
+
screen_size: COORD = GetConsoleScreenBufferInfo(self._handle).dwSize
|
| 394 |
+
return WindowsCoordinates(row=screen_size.Y, col=screen_size.X)
|
| 395 |
+
|
| 396 |
+
def write_text(self, text: str) -> None:
|
| 397 |
+
"""Write text directly to the terminal without any modification of styles
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
text (str): The text to write to the console
|
| 401 |
+
"""
|
| 402 |
+
self.write(text)
|
| 403 |
+
self.flush()
|
| 404 |
+
|
| 405 |
+
def write_styled(self, text: str, style: Style) -> None:
|
| 406 |
+
"""Write styled text to the terminal.
|
| 407 |
+
|
| 408 |
+
Args:
|
| 409 |
+
text (str): The text to write
|
| 410 |
+
style (Style): The style of the text
|
| 411 |
+
"""
|
| 412 |
+
color = style.color
|
| 413 |
+
bgcolor = style.bgcolor
|
| 414 |
+
if style.reverse:
|
| 415 |
+
color, bgcolor = bgcolor, color
|
| 416 |
+
|
| 417 |
+
if color:
|
| 418 |
+
fore = color.downgrade(ColorSystem.WINDOWS).number
|
| 419 |
+
fore = fore if fore is not None else 7 # Default to ANSI 7: White
|
| 420 |
+
if style.bold:
|
| 421 |
+
fore = fore | self.BRIGHT_BIT
|
| 422 |
+
if style.dim:
|
| 423 |
+
fore = fore & ~self.BRIGHT_BIT
|
| 424 |
+
fore = self.ANSI_TO_WINDOWS[fore]
|
| 425 |
+
else:
|
| 426 |
+
fore = self._default_fore
|
| 427 |
+
|
| 428 |
+
if bgcolor:
|
| 429 |
+
back = bgcolor.downgrade(ColorSystem.WINDOWS).number
|
| 430 |
+
back = back if back is not None else 0 # Default to ANSI 0: Black
|
| 431 |
+
back = self.ANSI_TO_WINDOWS[back]
|
| 432 |
+
else:
|
| 433 |
+
back = self._default_back
|
| 434 |
+
|
| 435 |
+
assert fore is not None
|
| 436 |
+
assert back is not None
|
| 437 |
+
|
| 438 |
+
SetConsoleTextAttribute(
|
| 439 |
+
self._handle, attributes=ctypes.c_ushort(fore | (back << 4))
|
| 440 |
+
)
|
| 441 |
+
self.write_text(text)
|
| 442 |
+
SetConsoleTextAttribute(self._handle, attributes=self._default_text)
|
| 443 |
+
|
| 444 |
+
def move_cursor_to(self, new_position: WindowsCoordinates) -> None:
|
| 445 |
+
"""Set the position of the cursor
|
| 446 |
+
|
| 447 |
+
Args:
|
| 448 |
+
new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor.
|
| 449 |
+
"""
|
| 450 |
+
if new_position.col < 0 or new_position.row < 0:
|
| 451 |
+
return
|
| 452 |
+
SetConsoleCursorPosition(self._handle, coords=new_position)
|
| 453 |
+
|
| 454 |
+
def erase_line(self) -> None:
|
| 455 |
+
"""Erase all content on the line the cursor is currently located at"""
|
| 456 |
+
screen_size = self.screen_size
|
| 457 |
+
cursor_position = self.cursor_position
|
| 458 |
+
cells_to_erase = screen_size.col
|
| 459 |
+
start_coordinates = WindowsCoordinates(row=cursor_position.row, col=0)
|
| 460 |
+
FillConsoleOutputCharacter(
|
| 461 |
+
self._handle, " ", length=cells_to_erase, start=start_coordinates
|
| 462 |
+
)
|
| 463 |
+
FillConsoleOutputAttribute(
|
| 464 |
+
self._handle,
|
| 465 |
+
self._default_attrs,
|
| 466 |
+
length=cells_to_erase,
|
| 467 |
+
start=start_coordinates,
|
| 468 |
+
)
|
| 469 |
+
|
| 470 |
+
def erase_end_of_line(self) -> None:
|
| 471 |
+
"""Erase all content from the cursor position to the end of that line"""
|
| 472 |
+
cursor_position = self.cursor_position
|
| 473 |
+
cells_to_erase = self.screen_size.col - cursor_position.col
|
| 474 |
+
FillConsoleOutputCharacter(
|
| 475 |
+
self._handle, " ", length=cells_to_erase, start=cursor_position
|
| 476 |
+
)
|
| 477 |
+
FillConsoleOutputAttribute(
|
| 478 |
+
self._handle,
|
| 479 |
+
self._default_attrs,
|
| 480 |
+
length=cells_to_erase,
|
| 481 |
+
start=cursor_position,
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
def erase_start_of_line(self) -> None:
|
| 485 |
+
"""Erase all content from the cursor position to the start of that line"""
|
| 486 |
+
row, col = self.cursor_position
|
| 487 |
+
start = WindowsCoordinates(row, 0)
|
| 488 |
+
FillConsoleOutputCharacter(self._handle, " ", length=col, start=start)
|
| 489 |
+
FillConsoleOutputAttribute(
|
| 490 |
+
self._handle, self._default_attrs, length=col, start=start
|
| 491 |
+
)
|
| 492 |
+
|
| 493 |
+
def move_cursor_up(self) -> None:
|
| 494 |
+
"""Move the cursor up a single cell"""
|
| 495 |
+
cursor_position = self.cursor_position
|
| 496 |
+
SetConsoleCursorPosition(
|
| 497 |
+
self._handle,
|
| 498 |
+
coords=WindowsCoordinates(
|
| 499 |
+
row=cursor_position.row - 1, col=cursor_position.col
|
| 500 |
+
),
|
| 501 |
+
)
|
| 502 |
+
|
| 503 |
+
def move_cursor_down(self) -> None:
|
| 504 |
+
"""Move the cursor down a single cell"""
|
| 505 |
+
cursor_position = self.cursor_position
|
| 506 |
+
SetConsoleCursorPosition(
|
| 507 |
+
self._handle,
|
| 508 |
+
coords=WindowsCoordinates(
|
| 509 |
+
row=cursor_position.row + 1,
|
| 510 |
+
col=cursor_position.col,
|
| 511 |
+
),
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
def move_cursor_forward(self) -> None:
|
| 515 |
+
"""Move the cursor forward a single cell. Wrap to the next line if required."""
|
| 516 |
+
row, col = self.cursor_position
|
| 517 |
+
if col == self.screen_size.col - 1:
|
| 518 |
+
row += 1
|
| 519 |
+
col = 0
|
| 520 |
+
else:
|
| 521 |
+
col += 1
|
| 522 |
+
SetConsoleCursorPosition(
|
| 523 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 524 |
+
)
|
| 525 |
+
|
| 526 |
+
def move_cursor_to_column(self, column: int) -> None:
|
| 527 |
+
"""Move cursor to the column specified by the zero-based column index, staying on the same row
|
| 528 |
+
|
| 529 |
+
Args:
|
| 530 |
+
column (int): The zero-based column index to move the cursor to.
|
| 531 |
+
"""
|
| 532 |
+
row, _ = self.cursor_position
|
| 533 |
+
SetConsoleCursorPosition(self._handle, coords=WindowsCoordinates(row, column))
|
| 534 |
+
|
| 535 |
+
def move_cursor_backward(self) -> None:
|
| 536 |
+
"""Move the cursor backward a single cell. Wrap to the previous line if required."""
|
| 537 |
+
row, col = self.cursor_position
|
| 538 |
+
if col == 0:
|
| 539 |
+
row -= 1
|
| 540 |
+
col = self.screen_size.col - 1
|
| 541 |
+
else:
|
| 542 |
+
col -= 1
|
| 543 |
+
SetConsoleCursorPosition(
|
| 544 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
def hide_cursor(self) -> None:
|
| 548 |
+
"""Hide the cursor"""
|
| 549 |
+
current_cursor_size = self._get_cursor_size()
|
| 550 |
+
invisible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=0)
|
| 551 |
+
SetConsoleCursorInfo(self._handle, cursor_info=invisible_cursor)
|
| 552 |
+
|
| 553 |
+
def show_cursor(self) -> None:
|
| 554 |
+
"""Show the cursor"""
|
| 555 |
+
current_cursor_size = self._get_cursor_size()
|
| 556 |
+
visible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=1)
|
| 557 |
+
SetConsoleCursorInfo(self._handle, cursor_info=visible_cursor)
|
| 558 |
+
|
| 559 |
+
def set_title(self, title: str) -> None:
|
| 560 |
+
"""Set the title of the terminal window
|
| 561 |
+
|
| 562 |
+
Args:
|
| 563 |
+
title (str): The new title of the console window
|
| 564 |
+
"""
|
| 565 |
+
assert len(title) < 255, "Console title must be less than 255 characters"
|
| 566 |
+
SetConsoleTitle(title)
|
| 567 |
+
|
| 568 |
+
def _get_cursor_size(self) -> int:
|
| 569 |
+
"""Get the percentage of the character cell that is filled by the cursor"""
|
| 570 |
+
cursor_info = CONSOLE_CURSOR_INFO()
|
| 571 |
+
GetConsoleCursorInfo(self._handle, cursor_info=cursor_info)
|
| 572 |
+
return int(cursor_info.dwSize)
|
| 573 |
+
|
| 574 |
+
|
| 575 |
+
if __name__ == "__main__":
|
| 576 |
+
handle = GetStdHandle()
|
| 577 |
+
|
| 578 |
+
from rich.console import Console
|
| 579 |
+
|
| 580 |
+
console = Console()
|
| 581 |
+
|
| 582 |
+
term = LegacyWindowsTerm(sys.stdout)
|
| 583 |
+
term.set_title("Win32 Console Examples")
|
| 584 |
+
|
| 585 |
+
style = Style(color="black", bgcolor="red")
|
| 586 |
+
|
| 587 |
+
heading = Style.parse("black on green")
|
| 588 |
+
|
| 589 |
+
# Check colour output
|
| 590 |
+
console.rule("Checking colour output")
|
| 591 |
+
console.print("[on red]on red!")
|
| 592 |
+
console.print("[blue]blue!")
|
| 593 |
+
console.print("[yellow]yellow!")
|
| 594 |
+
console.print("[bold yellow]bold yellow!")
|
| 595 |
+
console.print("[bright_yellow]bright_yellow!")
|
| 596 |
+
console.print("[dim bright_yellow]dim bright_yellow!")
|
| 597 |
+
console.print("[italic cyan]italic cyan!")
|
| 598 |
+
console.print("[bold white on blue]bold white on blue!")
|
| 599 |
+
console.print("[reverse bold white on blue]reverse bold white on blue!")
|
| 600 |
+
console.print("[bold black on cyan]bold black on cyan!")
|
| 601 |
+
console.print("[black on green]black on green!")
|
| 602 |
+
console.print("[blue on green]blue on green!")
|
| 603 |
+
console.print("[white on black]white on black!")
|
| 604 |
+
console.print("[black on white]black on white!")
|
| 605 |
+
console.print("[#1BB152 on #DA812D]#1BB152 on #DA812D!")
|
| 606 |
+
|
| 607 |
+
# Check cursor movement
|
| 608 |
+
console.rule("Checking cursor movement")
|
| 609 |
+
console.print()
|
| 610 |
+
term.move_cursor_backward()
|
| 611 |
+
term.move_cursor_backward()
|
| 612 |
+
term.write_text("went back and wrapped to prev line")
|
| 613 |
+
time.sleep(1)
|
| 614 |
+
term.move_cursor_up()
|
| 615 |
+
term.write_text("we go up")
|
| 616 |
+
time.sleep(1)
|
| 617 |
+
term.move_cursor_down()
|
| 618 |
+
term.write_text("and down")
|
| 619 |
+
time.sleep(1)
|
| 620 |
+
term.move_cursor_up()
|
| 621 |
+
term.move_cursor_backward()
|
| 622 |
+
term.move_cursor_backward()
|
| 623 |
+
term.write_text("we went up and back 2")
|
| 624 |
+
time.sleep(1)
|
| 625 |
+
term.move_cursor_down()
|
| 626 |
+
term.move_cursor_backward()
|
| 627 |
+
term.move_cursor_backward()
|
| 628 |
+
term.write_text("we went down and back 2")
|
| 629 |
+
time.sleep(1)
|
| 630 |
+
|
| 631 |
+
# Check erasing of lines
|
| 632 |
+
term.hide_cursor()
|
| 633 |
+
console.print()
|
| 634 |
+
console.rule("Checking line erasing")
|
| 635 |
+
console.print("\n...Deleting to the start of the line...")
|
| 636 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 637 |
+
time.sleep(1)
|
| 638 |
+
term.move_cursor_to_column(16)
|
| 639 |
+
term.write_styled("<", Style.parse("black on red"))
|
| 640 |
+
term.move_cursor_backward()
|
| 641 |
+
time.sleep(1)
|
| 642 |
+
term.erase_start_of_line()
|
| 643 |
+
time.sleep(1)
|
| 644 |
+
|
| 645 |
+
console.print("\n\n...And to the end of the line...")
|
| 646 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 647 |
+
time.sleep(1)
|
| 648 |
+
|
| 649 |
+
term.move_cursor_to_column(16)
|
| 650 |
+
term.write_styled(">", Style.parse("black on red"))
|
| 651 |
+
time.sleep(1)
|
| 652 |
+
term.erase_end_of_line()
|
| 653 |
+
time.sleep(1)
|
| 654 |
+
|
| 655 |
+
console.print("\n\n...Now the whole line will be erased...")
|
| 656 |
+
term.write_styled("I'm going to disappear!", style=Style.parse("black on cyan"))
|
| 657 |
+
time.sleep(1)
|
| 658 |
+
term.erase_line()
|
| 659 |
+
|
| 660 |
+
term.show_cursor()
|
| 661 |
+
print("\n")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_windows.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from dataclasses import dataclass
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@dataclass
|
| 6 |
+
class WindowsConsoleFeatures:
|
| 7 |
+
"""Windows features available."""
|
| 8 |
+
|
| 9 |
+
vt: bool = False
|
| 10 |
+
"""The console supports VT codes."""
|
| 11 |
+
truecolor: bool = False
|
| 12 |
+
"""The console supports truecolor."""
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
import ctypes
|
| 17 |
+
from ctypes import LibraryLoader
|
| 18 |
+
|
| 19 |
+
if sys.platform == "win32":
|
| 20 |
+
windll = LibraryLoader(ctypes.WinDLL)
|
| 21 |
+
else:
|
| 22 |
+
windll = None
|
| 23 |
+
raise ImportError("Not windows")
|
| 24 |
+
|
| 25 |
+
from rich._win32_console import (
|
| 26 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING,
|
| 27 |
+
GetConsoleMode,
|
| 28 |
+
GetStdHandle,
|
| 29 |
+
LegacyWindowsError,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
except (AttributeError, ImportError, ValueError):
|
| 33 |
+
# Fallback if we can't load the Windows DLL
|
| 34 |
+
def get_windows_console_features() -> WindowsConsoleFeatures:
|
| 35 |
+
features = WindowsConsoleFeatures()
|
| 36 |
+
return features
|
| 37 |
+
|
| 38 |
+
else:
|
| 39 |
+
|
| 40 |
+
def get_windows_console_features() -> WindowsConsoleFeatures:
|
| 41 |
+
"""Get windows console features.
|
| 42 |
+
|
| 43 |
+
Returns:
|
| 44 |
+
WindowsConsoleFeatures: An instance of WindowsConsoleFeatures.
|
| 45 |
+
"""
|
| 46 |
+
handle = GetStdHandle()
|
| 47 |
+
try:
|
| 48 |
+
console_mode = GetConsoleMode(handle)
|
| 49 |
+
success = True
|
| 50 |
+
except LegacyWindowsError:
|
| 51 |
+
console_mode = 0
|
| 52 |
+
success = False
|
| 53 |
+
vt = bool(success and console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
| 54 |
+
truecolor = False
|
| 55 |
+
if vt:
|
| 56 |
+
win_version = sys.getwindowsversion()
|
| 57 |
+
truecolor = win_version.major > 10 or (
|
| 58 |
+
win_version.major == 10 and win_version.build >= 15063
|
| 59 |
+
)
|
| 60 |
+
features = WindowsConsoleFeatures(vt=vt, truecolor=truecolor)
|
| 61 |
+
return features
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
if __name__ == "__main__":
|
| 65 |
+
import platform
|
| 66 |
+
|
| 67 |
+
features = get_windows_console_features()
|
| 68 |
+
from rich import print
|
| 69 |
+
|
| 70 |
+
print(f'platform="{platform.system()}"')
|
| 71 |
+
print(repr(features))
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_windows_renderer.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Iterable, Sequence, Tuple, cast
|
| 2 |
+
|
| 3 |
+
from rich._win32_console import LegacyWindowsTerm, WindowsCoordinates
|
| 4 |
+
from rich.segment import ControlCode, ControlType, Segment
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def legacy_windows_render(buffer: Iterable[Segment], term: LegacyWindowsTerm) -> None:
|
| 8 |
+
"""Makes appropriate Windows Console API calls based on the segments in the buffer.
|
| 9 |
+
|
| 10 |
+
Args:
|
| 11 |
+
buffer (Iterable[Segment]): Iterable of Segments to convert to Win32 API calls.
|
| 12 |
+
term (LegacyWindowsTerm): Used to call the Windows Console API.
|
| 13 |
+
"""
|
| 14 |
+
for text, style, control in buffer:
|
| 15 |
+
if not control:
|
| 16 |
+
if style:
|
| 17 |
+
term.write_styled(text, style)
|
| 18 |
+
else:
|
| 19 |
+
term.write_text(text)
|
| 20 |
+
else:
|
| 21 |
+
control_codes: Sequence[ControlCode] = control
|
| 22 |
+
for control_code in control_codes:
|
| 23 |
+
control_type = control_code[0]
|
| 24 |
+
if control_type == ControlType.CURSOR_MOVE_TO:
|
| 25 |
+
_, x, y = cast(Tuple[ControlType, int, int], control_code)
|
| 26 |
+
term.move_cursor_to(WindowsCoordinates(row=y - 1, col=x - 1))
|
| 27 |
+
elif control_type == ControlType.CARRIAGE_RETURN:
|
| 28 |
+
term.write_text("\r")
|
| 29 |
+
elif control_type == ControlType.HOME:
|
| 30 |
+
term.move_cursor_to(WindowsCoordinates(0, 0))
|
| 31 |
+
elif control_type == ControlType.CURSOR_UP:
|
| 32 |
+
term.move_cursor_up()
|
| 33 |
+
elif control_type == ControlType.CURSOR_DOWN:
|
| 34 |
+
term.move_cursor_down()
|
| 35 |
+
elif control_type == ControlType.CURSOR_FORWARD:
|
| 36 |
+
term.move_cursor_forward()
|
| 37 |
+
elif control_type == ControlType.CURSOR_BACKWARD:
|
| 38 |
+
term.move_cursor_backward()
|
| 39 |
+
elif control_type == ControlType.CURSOR_MOVE_TO_COLUMN:
|
| 40 |
+
_, column = cast(Tuple[ControlType, int], control_code)
|
| 41 |
+
term.move_cursor_to_column(column - 1)
|
| 42 |
+
elif control_type == ControlType.HIDE_CURSOR:
|
| 43 |
+
term.hide_cursor()
|
| 44 |
+
elif control_type == ControlType.SHOW_CURSOR:
|
| 45 |
+
term.show_cursor()
|
| 46 |
+
elif control_type == ControlType.ERASE_IN_LINE:
|
| 47 |
+
_, mode = cast(Tuple[ControlType, int], control_code)
|
| 48 |
+
if mode == 0:
|
| 49 |
+
term.erase_end_of_line()
|
| 50 |
+
elif mode == 1:
|
| 51 |
+
term.erase_start_of_line()
|
| 52 |
+
elif mode == 2:
|
| 53 |
+
term.erase_line()
|
| 54 |
+
elif control_type == ControlType.SET_WINDOW_TITLE:
|
| 55 |
+
_, title = cast(Tuple[ControlType, str], control_code)
|
| 56 |
+
term.set_title(title)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/_wrap.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import re
|
| 4 |
+
from typing import Iterable
|
| 5 |
+
|
| 6 |
+
from ._loop import loop_last
|
| 7 |
+
from .cells import cell_len, chop_cells
|
| 8 |
+
|
| 9 |
+
re_word = re.compile(r"\s*\S+\s*")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def words(text: str) -> Iterable[tuple[int, int, str]]:
|
| 13 |
+
"""Yields each word from the text as a tuple
|
| 14 |
+
containing (start_index, end_index, word). A "word" in this context may
|
| 15 |
+
include the actual word and any whitespace to the right.
|
| 16 |
+
"""
|
| 17 |
+
position = 0
|
| 18 |
+
word_match = re_word.match(text, position)
|
| 19 |
+
while word_match is not None:
|
| 20 |
+
start, end = word_match.span()
|
| 21 |
+
word = word_match.group(0)
|
| 22 |
+
yield start, end, word
|
| 23 |
+
word_match = re_word.match(text, end)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def divide_line(text: str, width: int, fold: bool = True) -> list[int]:
|
| 27 |
+
"""Given a string of text, and a width (measured in cells), return a list
|
| 28 |
+
of cell offsets which the string should be split at in order for it to fit
|
| 29 |
+
within the given width.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
text: The text to examine.
|
| 33 |
+
width: The available cell width.
|
| 34 |
+
fold: If True, words longer than `width` will be folded onto a new line.
|
| 35 |
+
|
| 36 |
+
Returns:
|
| 37 |
+
A list of indices to break the line at.
|
| 38 |
+
"""
|
| 39 |
+
break_positions: list[int] = [] # offsets to insert the breaks at
|
| 40 |
+
append = break_positions.append
|
| 41 |
+
cell_offset = 0
|
| 42 |
+
_cell_len = cell_len
|
| 43 |
+
|
| 44 |
+
for start, _end, word in words(text):
|
| 45 |
+
word_length = _cell_len(word.rstrip())
|
| 46 |
+
remaining_space = width - cell_offset
|
| 47 |
+
word_fits_remaining_space = remaining_space >= word_length
|
| 48 |
+
|
| 49 |
+
if word_fits_remaining_space:
|
| 50 |
+
# Simplest case - the word fits within the remaining width for this line.
|
| 51 |
+
cell_offset += _cell_len(word)
|
| 52 |
+
else:
|
| 53 |
+
# Not enough space remaining for this word on the current line.
|
| 54 |
+
if word_length > width:
|
| 55 |
+
# The word doesn't fit on any line, so we can't simply
|
| 56 |
+
# place it on the next line...
|
| 57 |
+
if fold:
|
| 58 |
+
# Fold the word across multiple lines.
|
| 59 |
+
folded_word = chop_cells(word, width=width)
|
| 60 |
+
for last, line in loop_last(folded_word):
|
| 61 |
+
if start:
|
| 62 |
+
append(start)
|
| 63 |
+
if last:
|
| 64 |
+
cell_offset = _cell_len(line)
|
| 65 |
+
else:
|
| 66 |
+
start += len(line)
|
| 67 |
+
else:
|
| 68 |
+
# Folding isn't allowed, so crop the word.
|
| 69 |
+
if start:
|
| 70 |
+
append(start)
|
| 71 |
+
cell_offset = _cell_len(word)
|
| 72 |
+
elif cell_offset and start:
|
| 73 |
+
# The word doesn't fit within the remaining space on the current
|
| 74 |
+
# line, but it *can* fit on to the next (empty) line.
|
| 75 |
+
append(start)
|
| 76 |
+
cell_offset = _cell_len(word)
|
| 77 |
+
|
| 78 |
+
return break_positions
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__ == "__main__": # pragma: no cover
|
| 82 |
+
from .console import Console
|
| 83 |
+
|
| 84 |
+
console = Console(width=10)
|
| 85 |
+
console.print("12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345")
|
| 86 |
+
print(chop_cells("abcdefghijklmnopqrstuvwxyz", 10))
|
| 87 |
+
|
| 88 |
+
console = Console(width=20)
|
| 89 |
+
console.rule()
|
| 90 |
+
console.print("TextualはPythonの高速アプリケーション開発フレームワークです")
|
| 91 |
+
|
| 92 |
+
console.rule()
|
| 93 |
+
console.print("アプリケーションは1670万色を使用でき")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/abc.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class RichRenderable(ABC):
|
| 5 |
+
"""An abstract base class for Rich renderables.
|
| 6 |
+
|
| 7 |
+
Note that there is no need to extend this class, the intended use is to check if an
|
| 8 |
+
object supports the Rich renderable protocol. For example::
|
| 9 |
+
|
| 10 |
+
if isinstance(my_object, RichRenderable):
|
| 11 |
+
console.print(my_object)
|
| 12 |
+
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
@classmethod
|
| 16 |
+
def __subclasshook__(cls, other: type) -> bool:
|
| 17 |
+
"""Check if this class supports the rich render protocol."""
|
| 18 |
+
return hasattr(other, "__rich_console__") or hasattr(other, "__rich__")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__": # pragma: no cover
|
| 22 |
+
from rich.text import Text
|
| 23 |
+
|
| 24 |
+
t = Text()
|
| 25 |
+
print(isinstance(Text, RichRenderable))
|
| 26 |
+
print(isinstance(t, RichRenderable))
|
| 27 |
+
|
| 28 |
+
class Foo:
|
| 29 |
+
pass
|
| 30 |
+
|
| 31 |
+
f = Foo()
|
| 32 |
+
print(isinstance(f, RichRenderable))
|
| 33 |
+
print(isinstance("", RichRenderable))
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/align.py
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from itertools import chain
|
| 2 |
+
from typing import TYPE_CHECKING, Iterable, Optional, Literal
|
| 3 |
+
|
| 4 |
+
from .constrain import Constrain
|
| 5 |
+
from .jupyter import JupyterMixin
|
| 6 |
+
from .measure import Measurement
|
| 7 |
+
from .segment import Segment
|
| 8 |
+
from .style import StyleType
|
| 9 |
+
|
| 10 |
+
if TYPE_CHECKING:
|
| 11 |
+
from .console import Console, ConsoleOptions, RenderableType, RenderResult
|
| 12 |
+
|
| 13 |
+
AlignMethod = Literal["left", "center", "right"]
|
| 14 |
+
VerticalAlignMethod = Literal["top", "middle", "bottom"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Align(JupyterMixin):
|
| 18 |
+
"""Align a renderable by adding spaces if necessary.
|
| 19 |
+
|
| 20 |
+
Args:
|
| 21 |
+
renderable (RenderableType): A console renderable.
|
| 22 |
+
align (AlignMethod): One of "left", "center", or "right""
|
| 23 |
+
style (StyleType, optional): An optional style to apply to the background.
|
| 24 |
+
vertical (Optional[VerticalAlignMethod], optional): Optional vertical align, one of "top", "middle", or "bottom". Defaults to None.
|
| 25 |
+
pad (bool, optional): Pad the right with spaces. Defaults to True.
|
| 26 |
+
width (int, optional): Restrict contents to given width, or None to use default width. Defaults to None.
|
| 27 |
+
height (int, optional): Set height of align renderable, or None to fit to contents. Defaults to None.
|
| 28 |
+
|
| 29 |
+
Raises:
|
| 30 |
+
ValueError: if ``align`` is not one of the expected values.
|
| 31 |
+
|
| 32 |
+
Example:
|
| 33 |
+
.. code-block:: python
|
| 34 |
+
|
| 35 |
+
from rich.console import Console
|
| 36 |
+
from rich.align import Align
|
| 37 |
+
from rich.panel import Panel
|
| 38 |
+
|
| 39 |
+
console = Console()
|
| 40 |
+
# Create a panel 20 characters wide
|
| 41 |
+
p = Panel("Hello, [b]World[/b]!", style="on green", width=20)
|
| 42 |
+
|
| 43 |
+
# Renders the panel centered in the terminal
|
| 44 |
+
console.print(Align(p, align="center"))
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
def __init__(
|
| 48 |
+
self,
|
| 49 |
+
renderable: "RenderableType",
|
| 50 |
+
align: AlignMethod = "left",
|
| 51 |
+
style: Optional[StyleType] = None,
|
| 52 |
+
*,
|
| 53 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 54 |
+
pad: bool = True,
|
| 55 |
+
width: Optional[int] = None,
|
| 56 |
+
height: Optional[int] = None,
|
| 57 |
+
) -> None:
|
| 58 |
+
if align not in ("left", "center", "right"):
|
| 59 |
+
raise ValueError(
|
| 60 |
+
f'invalid value for align, expected "left", "center", or "right" (not {align!r})'
|
| 61 |
+
)
|
| 62 |
+
if vertical is not None and vertical not in ("top", "middle", "bottom"):
|
| 63 |
+
raise ValueError(
|
| 64 |
+
f'invalid value for vertical, expected "top", "middle", or "bottom" (not {vertical!r})'
|
| 65 |
+
)
|
| 66 |
+
self.renderable = renderable
|
| 67 |
+
self.align = align
|
| 68 |
+
self.style = style
|
| 69 |
+
self.vertical = vertical
|
| 70 |
+
self.pad = pad
|
| 71 |
+
self.width = width
|
| 72 |
+
self.height = height
|
| 73 |
+
|
| 74 |
+
def __repr__(self) -> str:
|
| 75 |
+
return f"Align({self.renderable!r}, {self.align!r})"
|
| 76 |
+
|
| 77 |
+
@classmethod
|
| 78 |
+
def left(
|
| 79 |
+
cls,
|
| 80 |
+
renderable: "RenderableType",
|
| 81 |
+
style: Optional[StyleType] = None,
|
| 82 |
+
*,
|
| 83 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 84 |
+
pad: bool = True,
|
| 85 |
+
width: Optional[int] = None,
|
| 86 |
+
height: Optional[int] = None,
|
| 87 |
+
) -> "Align":
|
| 88 |
+
"""Align a renderable to the left."""
|
| 89 |
+
return cls(
|
| 90 |
+
renderable,
|
| 91 |
+
"left",
|
| 92 |
+
style=style,
|
| 93 |
+
vertical=vertical,
|
| 94 |
+
pad=pad,
|
| 95 |
+
width=width,
|
| 96 |
+
height=height,
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
@classmethod
|
| 100 |
+
def center(
|
| 101 |
+
cls,
|
| 102 |
+
renderable: "RenderableType",
|
| 103 |
+
style: Optional[StyleType] = None,
|
| 104 |
+
*,
|
| 105 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 106 |
+
pad: bool = True,
|
| 107 |
+
width: Optional[int] = None,
|
| 108 |
+
height: Optional[int] = None,
|
| 109 |
+
) -> "Align":
|
| 110 |
+
"""Align a renderable to the center."""
|
| 111 |
+
return cls(
|
| 112 |
+
renderable,
|
| 113 |
+
"center",
|
| 114 |
+
style=style,
|
| 115 |
+
vertical=vertical,
|
| 116 |
+
pad=pad,
|
| 117 |
+
width=width,
|
| 118 |
+
height=height,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
@classmethod
|
| 122 |
+
def right(
|
| 123 |
+
cls,
|
| 124 |
+
renderable: "RenderableType",
|
| 125 |
+
style: Optional[StyleType] = None,
|
| 126 |
+
*,
|
| 127 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 128 |
+
pad: bool = True,
|
| 129 |
+
width: Optional[int] = None,
|
| 130 |
+
height: Optional[int] = None,
|
| 131 |
+
) -> "Align":
|
| 132 |
+
"""Align a renderable to the right."""
|
| 133 |
+
return cls(
|
| 134 |
+
renderable,
|
| 135 |
+
"right",
|
| 136 |
+
style=style,
|
| 137 |
+
vertical=vertical,
|
| 138 |
+
pad=pad,
|
| 139 |
+
width=width,
|
| 140 |
+
height=height,
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
def __rich_console__(
|
| 144 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 145 |
+
) -> "RenderResult":
|
| 146 |
+
align = self.align
|
| 147 |
+
width = console.measure(self.renderable, options=options).maximum
|
| 148 |
+
rendered = console.render(
|
| 149 |
+
Constrain(
|
| 150 |
+
self.renderable, width if self.width is None else min(width, self.width)
|
| 151 |
+
),
|
| 152 |
+
options.update(height=None),
|
| 153 |
+
)
|
| 154 |
+
lines = list(Segment.split_lines(rendered))
|
| 155 |
+
width, height = Segment.get_shape(lines)
|
| 156 |
+
lines = Segment.set_shape(lines, width, height)
|
| 157 |
+
new_line = Segment.line()
|
| 158 |
+
excess_space = options.max_width - width
|
| 159 |
+
style = console.get_style(self.style) if self.style is not None else None
|
| 160 |
+
|
| 161 |
+
def generate_segments() -> Iterable[Segment]:
|
| 162 |
+
if excess_space <= 0:
|
| 163 |
+
# Exact fit
|
| 164 |
+
for line in lines:
|
| 165 |
+
yield from line
|
| 166 |
+
yield new_line
|
| 167 |
+
|
| 168 |
+
elif align == "left":
|
| 169 |
+
# Pad on the right
|
| 170 |
+
pad = Segment(" " * excess_space, style) if self.pad else None
|
| 171 |
+
for line in lines:
|
| 172 |
+
yield from line
|
| 173 |
+
if pad:
|
| 174 |
+
yield pad
|
| 175 |
+
yield new_line
|
| 176 |
+
|
| 177 |
+
elif align == "center":
|
| 178 |
+
# Pad left and right
|
| 179 |
+
left = excess_space // 2
|
| 180 |
+
pad = Segment(" " * left, style)
|
| 181 |
+
pad_right = (
|
| 182 |
+
Segment(" " * (excess_space - left), style) if self.pad else None
|
| 183 |
+
)
|
| 184 |
+
for line in lines:
|
| 185 |
+
if left:
|
| 186 |
+
yield pad
|
| 187 |
+
yield from line
|
| 188 |
+
if pad_right:
|
| 189 |
+
yield pad_right
|
| 190 |
+
yield new_line
|
| 191 |
+
|
| 192 |
+
elif align == "right":
|
| 193 |
+
# Padding on left
|
| 194 |
+
pad = Segment(" " * excess_space, style)
|
| 195 |
+
for line in lines:
|
| 196 |
+
yield pad
|
| 197 |
+
yield from line
|
| 198 |
+
yield new_line
|
| 199 |
+
|
| 200 |
+
blank_line = (
|
| 201 |
+
Segment(f"{' ' * (self.width or options.max_width)}\n", style)
|
| 202 |
+
if self.pad
|
| 203 |
+
else Segment("\n")
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
def blank_lines(count: int) -> Iterable[Segment]:
|
| 207 |
+
if count > 0:
|
| 208 |
+
for _ in range(count):
|
| 209 |
+
yield blank_line
|
| 210 |
+
|
| 211 |
+
vertical_height = self.height or options.height
|
| 212 |
+
iter_segments: Iterable[Segment]
|
| 213 |
+
if self.vertical and vertical_height is not None:
|
| 214 |
+
if self.vertical == "top":
|
| 215 |
+
bottom_space = vertical_height - height
|
| 216 |
+
iter_segments = chain(generate_segments(), blank_lines(bottom_space))
|
| 217 |
+
elif self.vertical == "middle":
|
| 218 |
+
top_space = (vertical_height - height) // 2
|
| 219 |
+
bottom_space = vertical_height - top_space - height
|
| 220 |
+
iter_segments = chain(
|
| 221 |
+
blank_lines(top_space),
|
| 222 |
+
generate_segments(),
|
| 223 |
+
blank_lines(bottom_space),
|
| 224 |
+
)
|
| 225 |
+
else: # self.vertical == "bottom":
|
| 226 |
+
top_space = vertical_height - height
|
| 227 |
+
iter_segments = chain(blank_lines(top_space), generate_segments())
|
| 228 |
+
else:
|
| 229 |
+
iter_segments = generate_segments()
|
| 230 |
+
if self.style:
|
| 231 |
+
style = console.get_style(self.style)
|
| 232 |
+
iter_segments = Segment.apply_style(iter_segments, style)
|
| 233 |
+
yield from iter_segments
|
| 234 |
+
|
| 235 |
+
def __rich_measure__(
|
| 236 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 237 |
+
) -> Measurement:
|
| 238 |
+
measurement = Measurement.get(console, options, self.renderable)
|
| 239 |
+
return measurement
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
class VerticalCenter(JupyterMixin):
|
| 243 |
+
"""Vertically aligns a renderable.
|
| 244 |
+
|
| 245 |
+
Warn:
|
| 246 |
+
This class is deprecated and may be removed in a future version. Use Align class with
|
| 247 |
+
`vertical="middle"`.
|
| 248 |
+
|
| 249 |
+
Args:
|
| 250 |
+
renderable (RenderableType): A renderable object.
|
| 251 |
+
style (StyleType, optional): An optional style to apply to the background. Defaults to None.
|
| 252 |
+
"""
|
| 253 |
+
|
| 254 |
+
def __init__(
|
| 255 |
+
self,
|
| 256 |
+
renderable: "RenderableType",
|
| 257 |
+
style: Optional[StyleType] = None,
|
| 258 |
+
) -> None:
|
| 259 |
+
self.renderable = renderable
|
| 260 |
+
self.style = style
|
| 261 |
+
|
| 262 |
+
def __repr__(self) -> str:
|
| 263 |
+
return f"VerticalCenter({self.renderable!r})"
|
| 264 |
+
|
| 265 |
+
def __rich_console__(
|
| 266 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 267 |
+
) -> "RenderResult":
|
| 268 |
+
style = console.get_style(self.style) if self.style is not None else None
|
| 269 |
+
lines = console.render_lines(
|
| 270 |
+
self.renderable, options.update(height=None), pad=False
|
| 271 |
+
)
|
| 272 |
+
width, _height = Segment.get_shape(lines)
|
| 273 |
+
new_line = Segment.line()
|
| 274 |
+
height = options.height or options.size.height
|
| 275 |
+
top_space = (height - len(lines)) // 2
|
| 276 |
+
bottom_space = height - top_space - len(lines)
|
| 277 |
+
blank_line = Segment(f"{' ' * width}", style)
|
| 278 |
+
|
| 279 |
+
def blank_lines(count: int) -> Iterable[Segment]:
|
| 280 |
+
for _ in range(count):
|
| 281 |
+
yield blank_line
|
| 282 |
+
yield new_line
|
| 283 |
+
|
| 284 |
+
if top_space > 0:
|
| 285 |
+
yield from blank_lines(top_space)
|
| 286 |
+
for line in lines:
|
| 287 |
+
yield from line
|
| 288 |
+
yield new_line
|
| 289 |
+
if bottom_space > 0:
|
| 290 |
+
yield from blank_lines(bottom_space)
|
| 291 |
+
|
| 292 |
+
def __rich_measure__(
|
| 293 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 294 |
+
) -> Measurement:
|
| 295 |
+
measurement = Measurement.get(console, options, self.renderable)
|
| 296 |
+
return measurement
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
if __name__ == "__main__": # pragma: no cover
|
| 300 |
+
from rich.console import Console, Group
|
| 301 |
+
from rich.highlighter import ReprHighlighter
|
| 302 |
+
from rich.panel import Panel
|
| 303 |
+
|
| 304 |
+
highlighter = ReprHighlighter()
|
| 305 |
+
console = Console()
|
| 306 |
+
|
| 307 |
+
panel = Panel(
|
| 308 |
+
Group(
|
| 309 |
+
Align.left(highlighter("align='left'")),
|
| 310 |
+
Align.center(highlighter("align='center'")),
|
| 311 |
+
Align.right(highlighter("align='right'")),
|
| 312 |
+
),
|
| 313 |
+
width=60,
|
| 314 |
+
style="on dark_blue",
|
| 315 |
+
title="Align",
|
| 316 |
+
)
|
| 317 |
+
|
| 318 |
+
console.print(
|
| 319 |
+
Align.center(panel, vertical="middle", style="on red", height=console.height)
|
| 320 |
+
)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/ansi.py
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
import sys
|
| 3 |
+
from contextlib import suppress
|
| 4 |
+
from typing import Iterable, NamedTuple, Optional
|
| 5 |
+
|
| 6 |
+
from .color import Color
|
| 7 |
+
from .style import Style
|
| 8 |
+
from .text import Text
|
| 9 |
+
|
| 10 |
+
re_ansi = re.compile(
|
| 11 |
+
r"""
|
| 12 |
+
(?:\x1b[0-?])|
|
| 13 |
+
(?:\x1b\](.*?)\x1b\\)|
|
| 14 |
+
(?:\x1b([(@-Z\\-_]|\[[0-?]*[ -/]*[@-~]))
|
| 15 |
+
""",
|
| 16 |
+
re.VERBOSE,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class _AnsiToken(NamedTuple):
|
| 21 |
+
"""Result of ansi tokenized string."""
|
| 22 |
+
|
| 23 |
+
plain: str = ""
|
| 24 |
+
sgr: Optional[str] = ""
|
| 25 |
+
osc: Optional[str] = ""
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _ansi_tokenize(ansi_text: str) -> Iterable[_AnsiToken]:
|
| 29 |
+
"""Tokenize a string in to plain text and ANSI codes.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
ansi_text (str): A String containing ANSI codes.
|
| 33 |
+
|
| 34 |
+
Yields:
|
| 35 |
+
AnsiToken: A named tuple of (plain, sgr, osc)
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
position = 0
|
| 39 |
+
sgr: Optional[str]
|
| 40 |
+
osc: Optional[str]
|
| 41 |
+
for match in re_ansi.finditer(ansi_text):
|
| 42 |
+
start, end = match.span(0)
|
| 43 |
+
osc, sgr = match.groups()
|
| 44 |
+
if start > position:
|
| 45 |
+
yield _AnsiToken(ansi_text[position:start])
|
| 46 |
+
if sgr:
|
| 47 |
+
if sgr == "(":
|
| 48 |
+
position = end + 1
|
| 49 |
+
continue
|
| 50 |
+
if sgr.endswith("m"):
|
| 51 |
+
yield _AnsiToken("", sgr[1:-1], osc)
|
| 52 |
+
else:
|
| 53 |
+
yield _AnsiToken("", sgr, osc)
|
| 54 |
+
position = end
|
| 55 |
+
if position < len(ansi_text):
|
| 56 |
+
yield _AnsiToken(ansi_text[position:])
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
SGR_STYLE_MAP = {
|
| 60 |
+
1: "bold",
|
| 61 |
+
2: "dim",
|
| 62 |
+
3: "italic",
|
| 63 |
+
4: "underline",
|
| 64 |
+
5: "blink",
|
| 65 |
+
6: "blink2",
|
| 66 |
+
7: "reverse",
|
| 67 |
+
8: "conceal",
|
| 68 |
+
9: "strike",
|
| 69 |
+
21: "underline2",
|
| 70 |
+
22: "not dim not bold",
|
| 71 |
+
23: "not italic",
|
| 72 |
+
24: "not underline",
|
| 73 |
+
25: "not blink",
|
| 74 |
+
26: "not blink2",
|
| 75 |
+
27: "not reverse",
|
| 76 |
+
28: "not conceal",
|
| 77 |
+
29: "not strike",
|
| 78 |
+
30: "color(0)",
|
| 79 |
+
31: "color(1)",
|
| 80 |
+
32: "color(2)",
|
| 81 |
+
33: "color(3)",
|
| 82 |
+
34: "color(4)",
|
| 83 |
+
35: "color(5)",
|
| 84 |
+
36: "color(6)",
|
| 85 |
+
37: "color(7)",
|
| 86 |
+
39: "default",
|
| 87 |
+
40: "on color(0)",
|
| 88 |
+
41: "on color(1)",
|
| 89 |
+
42: "on color(2)",
|
| 90 |
+
43: "on color(3)",
|
| 91 |
+
44: "on color(4)",
|
| 92 |
+
45: "on color(5)",
|
| 93 |
+
46: "on color(6)",
|
| 94 |
+
47: "on color(7)",
|
| 95 |
+
49: "on default",
|
| 96 |
+
51: "frame",
|
| 97 |
+
52: "encircle",
|
| 98 |
+
53: "overline",
|
| 99 |
+
54: "not frame not encircle",
|
| 100 |
+
55: "not overline",
|
| 101 |
+
90: "color(8)",
|
| 102 |
+
91: "color(9)",
|
| 103 |
+
92: "color(10)",
|
| 104 |
+
93: "color(11)",
|
| 105 |
+
94: "color(12)",
|
| 106 |
+
95: "color(13)",
|
| 107 |
+
96: "color(14)",
|
| 108 |
+
97: "color(15)",
|
| 109 |
+
100: "on color(8)",
|
| 110 |
+
101: "on color(9)",
|
| 111 |
+
102: "on color(10)",
|
| 112 |
+
103: "on color(11)",
|
| 113 |
+
104: "on color(12)",
|
| 114 |
+
105: "on color(13)",
|
| 115 |
+
106: "on color(14)",
|
| 116 |
+
107: "on color(15)",
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class AnsiDecoder:
|
| 121 |
+
"""Translate ANSI code in to styled Text."""
|
| 122 |
+
|
| 123 |
+
def __init__(self) -> None:
|
| 124 |
+
self.style = Style.null()
|
| 125 |
+
|
| 126 |
+
def decode(self, terminal_text: str) -> Iterable[Text]:
|
| 127 |
+
"""Decode ANSI codes in an iterable of lines.
|
| 128 |
+
|
| 129 |
+
Args:
|
| 130 |
+
terminal_text: Output potentially containing ANSI escape sequences.
|
| 131 |
+
|
| 132 |
+
Yields:
|
| 133 |
+
Text: Marked up Text.
|
| 134 |
+
"""
|
| 135 |
+
for line in re.split(r"(?<=\n)", terminal_text):
|
| 136 |
+
yield self.decode_line(line.rstrip("\n"))
|
| 137 |
+
|
| 138 |
+
def decode_line(self, line: str) -> Text:
|
| 139 |
+
"""Decode a line containing ansi codes.
|
| 140 |
+
|
| 141 |
+
Args:
|
| 142 |
+
line (str): A line of terminal output.
|
| 143 |
+
|
| 144 |
+
Returns:
|
| 145 |
+
Text: A Text instance marked up according to ansi codes.
|
| 146 |
+
"""
|
| 147 |
+
from_ansi = Color.from_ansi
|
| 148 |
+
from_rgb = Color.from_rgb
|
| 149 |
+
_Style = Style
|
| 150 |
+
text = Text()
|
| 151 |
+
append = text.append
|
| 152 |
+
line = line.rsplit("\r", 1)[-1]
|
| 153 |
+
for plain_text, sgr, osc in _ansi_tokenize(line):
|
| 154 |
+
if plain_text:
|
| 155 |
+
append(plain_text, self.style or None)
|
| 156 |
+
elif osc is not None:
|
| 157 |
+
if osc.startswith("8;"):
|
| 158 |
+
_params, semicolon, link = osc[2:].partition(";")
|
| 159 |
+
if semicolon:
|
| 160 |
+
self.style = self.style.update_link(link or None)
|
| 161 |
+
elif sgr is not None:
|
| 162 |
+
# Translate in to semi-colon separated codes
|
| 163 |
+
# Ignore invalid codes, because we want to be lenient
|
| 164 |
+
codes = [
|
| 165 |
+
min(255, int(_code) if _code else 0)
|
| 166 |
+
for _code in sgr.split(";")
|
| 167 |
+
if _code.isdigit() or _code == ""
|
| 168 |
+
]
|
| 169 |
+
iter_codes = iter(codes)
|
| 170 |
+
for code in iter_codes:
|
| 171 |
+
if code == 0:
|
| 172 |
+
# reset
|
| 173 |
+
self.style = _Style.null()
|
| 174 |
+
elif code in SGR_STYLE_MAP:
|
| 175 |
+
# styles
|
| 176 |
+
self.style += _Style.parse(SGR_STYLE_MAP[code])
|
| 177 |
+
elif code == 38:
|
| 178 |
+
# Foreground
|
| 179 |
+
with suppress(StopIteration):
|
| 180 |
+
color_type = next(iter_codes)
|
| 181 |
+
if color_type == 5:
|
| 182 |
+
self.style += _Style.from_color(
|
| 183 |
+
from_ansi(next(iter_codes))
|
| 184 |
+
)
|
| 185 |
+
elif color_type == 2:
|
| 186 |
+
self.style += _Style.from_color(
|
| 187 |
+
from_rgb(
|
| 188 |
+
next(iter_codes),
|
| 189 |
+
next(iter_codes),
|
| 190 |
+
next(iter_codes),
|
| 191 |
+
)
|
| 192 |
+
)
|
| 193 |
+
elif code == 48:
|
| 194 |
+
# Background
|
| 195 |
+
with suppress(StopIteration):
|
| 196 |
+
color_type = next(iter_codes)
|
| 197 |
+
if color_type == 5:
|
| 198 |
+
self.style += _Style.from_color(
|
| 199 |
+
None, from_ansi(next(iter_codes))
|
| 200 |
+
)
|
| 201 |
+
elif color_type == 2:
|
| 202 |
+
self.style += _Style.from_color(
|
| 203 |
+
None,
|
| 204 |
+
from_rgb(
|
| 205 |
+
next(iter_codes),
|
| 206 |
+
next(iter_codes),
|
| 207 |
+
next(iter_codes),
|
| 208 |
+
),
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
return text
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
if sys.platform != "win32" and __name__ == "__main__": # pragma: no cover
|
| 215 |
+
import io
|
| 216 |
+
import os
|
| 217 |
+
import pty
|
| 218 |
+
import sys
|
| 219 |
+
|
| 220 |
+
decoder = AnsiDecoder()
|
| 221 |
+
|
| 222 |
+
stdout = io.BytesIO()
|
| 223 |
+
|
| 224 |
+
def read(fd: int) -> bytes:
|
| 225 |
+
data = os.read(fd, 1024)
|
| 226 |
+
stdout.write(data)
|
| 227 |
+
return data
|
| 228 |
+
|
| 229 |
+
pty.spawn(sys.argv[1:], read)
|
| 230 |
+
|
| 231 |
+
from .console import Console
|
| 232 |
+
|
| 233 |
+
console = Console(record=True)
|
| 234 |
+
|
| 235 |
+
stdout_result = stdout.getvalue().decode("utf-8")
|
| 236 |
+
print(stdout_result)
|
| 237 |
+
|
| 238 |
+
for line in decoder.decode(stdout_result):
|
| 239 |
+
console.print(line)
|
| 240 |
+
|
| 241 |
+
console.save_html("stdout.html")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/bar.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Union
|
| 2 |
+
|
| 3 |
+
from .color import Color
|
| 4 |
+
from .console import Console, ConsoleOptions, RenderResult
|
| 5 |
+
from .jupyter import JupyterMixin
|
| 6 |
+
from .measure import Measurement
|
| 7 |
+
from .segment import Segment
|
| 8 |
+
from .style import Style
|
| 9 |
+
|
| 10 |
+
# There are left-aligned characters for 1/8 to 7/8, but
|
| 11 |
+
# the right-aligned characters exist only for 1/8 and 4/8.
|
| 12 |
+
BEGIN_BLOCK_ELEMENTS = ["█", "█", "█", "▐", "▐", "▐", "▕", "▕"]
|
| 13 |
+
END_BLOCK_ELEMENTS = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉"]
|
| 14 |
+
FULL_BLOCK = "█"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Bar(JupyterMixin):
|
| 18 |
+
"""Renders a solid block bar.
|
| 19 |
+
|
| 20 |
+
Args:
|
| 21 |
+
size (float): Value for the end of the bar.
|
| 22 |
+
begin (float): Begin point (between 0 and size, inclusive).
|
| 23 |
+
end (float): End point (between 0 and size, inclusive).
|
| 24 |
+
width (int, optional): Width of the bar, or ``None`` for maximum width. Defaults to None.
|
| 25 |
+
color (Union[Color, str], optional): Color of the bar. Defaults to "default".
|
| 26 |
+
bgcolor (Union[Color, str], optional): Color of bar background. Defaults to "default".
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
def __init__(
|
| 30 |
+
self,
|
| 31 |
+
size: float,
|
| 32 |
+
begin: float,
|
| 33 |
+
end: float,
|
| 34 |
+
*,
|
| 35 |
+
width: Optional[int] = None,
|
| 36 |
+
color: Union[Color, str] = "default",
|
| 37 |
+
bgcolor: Union[Color, str] = "default",
|
| 38 |
+
):
|
| 39 |
+
self.size = size
|
| 40 |
+
self.begin = max(begin, 0)
|
| 41 |
+
self.end = min(end, size)
|
| 42 |
+
self.width = width
|
| 43 |
+
self.style = Style(color=color, bgcolor=bgcolor)
|
| 44 |
+
|
| 45 |
+
def __repr__(self) -> str:
|
| 46 |
+
return f"Bar({self.size}, {self.begin}, {self.end})"
|
| 47 |
+
|
| 48 |
+
def __rich_console__(
|
| 49 |
+
self, console: Console, options: ConsoleOptions
|
| 50 |
+
) -> RenderResult:
|
| 51 |
+
width = min(
|
| 52 |
+
self.width if self.width is not None else options.max_width,
|
| 53 |
+
options.max_width,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
if self.begin >= self.end:
|
| 57 |
+
yield Segment(" " * width, self.style)
|
| 58 |
+
yield Segment.line()
|
| 59 |
+
return
|
| 60 |
+
|
| 61 |
+
prefix_complete_eights = int(width * 8 * self.begin / self.size)
|
| 62 |
+
prefix_bar_count = prefix_complete_eights // 8
|
| 63 |
+
prefix_eights_count = prefix_complete_eights % 8
|
| 64 |
+
|
| 65 |
+
body_complete_eights = int(width * 8 * self.end / self.size)
|
| 66 |
+
body_bar_count = body_complete_eights // 8
|
| 67 |
+
body_eights_count = body_complete_eights % 8
|
| 68 |
+
|
| 69 |
+
# When start and end fall into the same cell, we ideally should render
|
| 70 |
+
# a symbol that's "center-aligned", but there is no good symbol in Unicode.
|
| 71 |
+
# In this case, we fall back to right-aligned block symbol for simplicity.
|
| 72 |
+
|
| 73 |
+
prefix = " " * prefix_bar_count
|
| 74 |
+
if prefix_eights_count:
|
| 75 |
+
prefix += BEGIN_BLOCK_ELEMENTS[prefix_eights_count]
|
| 76 |
+
|
| 77 |
+
body = FULL_BLOCK * body_bar_count
|
| 78 |
+
if body_eights_count:
|
| 79 |
+
body += END_BLOCK_ELEMENTS[body_eights_count]
|
| 80 |
+
|
| 81 |
+
suffix = " " * (width - len(body))
|
| 82 |
+
|
| 83 |
+
yield Segment(prefix + body[len(prefix) :] + suffix, self.style)
|
| 84 |
+
yield Segment.line()
|
| 85 |
+
|
| 86 |
+
def __rich_measure__(
|
| 87 |
+
self, console: Console, options: ConsoleOptions
|
| 88 |
+
) -> Measurement:
|
| 89 |
+
return (
|
| 90 |
+
Measurement(self.width, self.width)
|
| 91 |
+
if self.width is not None
|
| 92 |
+
else Measurement(4, options.max_width)
|
| 93 |
+
)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/box.py
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING, Iterable, List, Literal
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
from ._loop import loop_last
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from rich.console import ConsoleOptions
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class Box:
|
| 11 |
+
"""Defines characters to render boxes.
|
| 12 |
+
|
| 13 |
+
┌─┬┐ top
|
| 14 |
+
│ ││ head
|
| 15 |
+
├─┼┤ head_row
|
| 16 |
+
│ ││ mid
|
| 17 |
+
├─┼┤ row
|
| 18 |
+
├─┼┤ foot_row
|
| 19 |
+
│ ││ foot
|
| 20 |
+
└─┴┘ bottom
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
box (str): Characters making up box.
|
| 24 |
+
ascii (bool, optional): True if this box uses ascii characters only. Default is False.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
def __init__(self, box: str, *, ascii: bool = False) -> None:
|
| 28 |
+
self._box = box
|
| 29 |
+
self.ascii = ascii
|
| 30 |
+
line1, line2, line3, line4, line5, line6, line7, line8 = box.splitlines()
|
| 31 |
+
# top
|
| 32 |
+
self.top_left, self.top, self.top_divider, self.top_right = iter(line1)
|
| 33 |
+
# head
|
| 34 |
+
self.head_left, _, self.head_vertical, self.head_right = iter(line2)
|
| 35 |
+
# head_row
|
| 36 |
+
(
|
| 37 |
+
self.head_row_left,
|
| 38 |
+
self.head_row_horizontal,
|
| 39 |
+
self.head_row_cross,
|
| 40 |
+
self.head_row_right,
|
| 41 |
+
) = iter(line3)
|
| 42 |
+
|
| 43 |
+
# mid
|
| 44 |
+
self.mid_left, _, self.mid_vertical, self.mid_right = iter(line4)
|
| 45 |
+
# row
|
| 46 |
+
self.row_left, self.row_horizontal, self.row_cross, self.row_right = iter(line5)
|
| 47 |
+
# foot_row
|
| 48 |
+
(
|
| 49 |
+
self.foot_row_left,
|
| 50 |
+
self.foot_row_horizontal,
|
| 51 |
+
self.foot_row_cross,
|
| 52 |
+
self.foot_row_right,
|
| 53 |
+
) = iter(line6)
|
| 54 |
+
# foot
|
| 55 |
+
self.foot_left, _, self.foot_vertical, self.foot_right = iter(line7)
|
| 56 |
+
# bottom
|
| 57 |
+
self.bottom_left, self.bottom, self.bottom_divider, self.bottom_right = iter(
|
| 58 |
+
line8
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
def __repr__(self) -> str:
|
| 62 |
+
return "Box(...)"
|
| 63 |
+
|
| 64 |
+
def __str__(self) -> str:
|
| 65 |
+
return self._box
|
| 66 |
+
|
| 67 |
+
def substitute(self, options: "ConsoleOptions", safe: bool = True) -> "Box":
|
| 68 |
+
"""Substitute this box for another if it won't render due to platform issues.
|
| 69 |
+
|
| 70 |
+
Args:
|
| 71 |
+
options (ConsoleOptions): Console options used in rendering.
|
| 72 |
+
safe (bool, optional): Substitute this for another Box if there are known problems
|
| 73 |
+
displaying on the platform (currently only relevant on Windows). Default is True.
|
| 74 |
+
|
| 75 |
+
Returns:
|
| 76 |
+
Box: A different Box or the same Box.
|
| 77 |
+
"""
|
| 78 |
+
box = self
|
| 79 |
+
if options.legacy_windows and safe:
|
| 80 |
+
box = LEGACY_WINDOWS_SUBSTITUTIONS.get(box, box)
|
| 81 |
+
if options.ascii_only and not box.ascii:
|
| 82 |
+
box = ASCII
|
| 83 |
+
return box
|
| 84 |
+
|
| 85 |
+
def get_plain_headed_box(self) -> "Box":
|
| 86 |
+
"""If this box uses special characters for the borders of the header, then
|
| 87 |
+
return the equivalent box that does not.
|
| 88 |
+
|
| 89 |
+
Returns:
|
| 90 |
+
Box: The most similar Box that doesn't use header-specific box characters.
|
| 91 |
+
If the current Box already satisfies this criterion, then it's returned.
|
| 92 |
+
"""
|
| 93 |
+
return PLAIN_HEADED_SUBSTITUTIONS.get(self, self)
|
| 94 |
+
|
| 95 |
+
def get_top(self, widths: Iterable[int]) -> str:
|
| 96 |
+
"""Get the top of a simple box.
|
| 97 |
+
|
| 98 |
+
Args:
|
| 99 |
+
widths (List[int]): Widths of columns.
|
| 100 |
+
|
| 101 |
+
Returns:
|
| 102 |
+
str: A string of box characters.
|
| 103 |
+
"""
|
| 104 |
+
|
| 105 |
+
parts: List[str] = []
|
| 106 |
+
append = parts.append
|
| 107 |
+
append(self.top_left)
|
| 108 |
+
for last, width in loop_last(widths):
|
| 109 |
+
append(self.top * width)
|
| 110 |
+
if not last:
|
| 111 |
+
append(self.top_divider)
|
| 112 |
+
append(self.top_right)
|
| 113 |
+
return "".join(parts)
|
| 114 |
+
|
| 115 |
+
def get_row(
|
| 116 |
+
self,
|
| 117 |
+
widths: Iterable[int],
|
| 118 |
+
level: Literal["head", "row", "foot", "mid"] = "row",
|
| 119 |
+
edge: bool = True,
|
| 120 |
+
) -> str:
|
| 121 |
+
"""Get the top of a simple box.
|
| 122 |
+
|
| 123 |
+
Args:
|
| 124 |
+
width (List[int]): Widths of columns.
|
| 125 |
+
|
| 126 |
+
Returns:
|
| 127 |
+
str: A string of box characters.
|
| 128 |
+
"""
|
| 129 |
+
if level == "head":
|
| 130 |
+
left = self.head_row_left
|
| 131 |
+
horizontal = self.head_row_horizontal
|
| 132 |
+
cross = self.head_row_cross
|
| 133 |
+
right = self.head_row_right
|
| 134 |
+
elif level == "row":
|
| 135 |
+
left = self.row_left
|
| 136 |
+
horizontal = self.row_horizontal
|
| 137 |
+
cross = self.row_cross
|
| 138 |
+
right = self.row_right
|
| 139 |
+
elif level == "mid":
|
| 140 |
+
left = self.mid_left
|
| 141 |
+
horizontal = " "
|
| 142 |
+
cross = self.mid_vertical
|
| 143 |
+
right = self.mid_right
|
| 144 |
+
elif level == "foot":
|
| 145 |
+
left = self.foot_row_left
|
| 146 |
+
horizontal = self.foot_row_horizontal
|
| 147 |
+
cross = self.foot_row_cross
|
| 148 |
+
right = self.foot_row_right
|
| 149 |
+
else:
|
| 150 |
+
raise ValueError("level must be 'head', 'row' or 'foot'")
|
| 151 |
+
|
| 152 |
+
parts: List[str] = []
|
| 153 |
+
append = parts.append
|
| 154 |
+
if edge:
|
| 155 |
+
append(left)
|
| 156 |
+
for last, width in loop_last(widths):
|
| 157 |
+
append(horizontal * width)
|
| 158 |
+
if not last:
|
| 159 |
+
append(cross)
|
| 160 |
+
if edge:
|
| 161 |
+
append(right)
|
| 162 |
+
return "".join(parts)
|
| 163 |
+
|
| 164 |
+
def get_bottom(self, widths: Iterable[int]) -> str:
|
| 165 |
+
"""Get the bottom of a simple box.
|
| 166 |
+
|
| 167 |
+
Args:
|
| 168 |
+
widths (List[int]): Widths of columns.
|
| 169 |
+
|
| 170 |
+
Returns:
|
| 171 |
+
str: A string of box characters.
|
| 172 |
+
"""
|
| 173 |
+
|
| 174 |
+
parts: List[str] = []
|
| 175 |
+
append = parts.append
|
| 176 |
+
append(self.bottom_left)
|
| 177 |
+
for last, width in loop_last(widths):
|
| 178 |
+
append(self.bottom * width)
|
| 179 |
+
if not last:
|
| 180 |
+
append(self.bottom_divider)
|
| 181 |
+
append(self.bottom_right)
|
| 182 |
+
return "".join(parts)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
# fmt: off
|
| 186 |
+
ASCII: Box = Box(
|
| 187 |
+
"+--+\n"
|
| 188 |
+
"| ||\n"
|
| 189 |
+
"|-+|\n"
|
| 190 |
+
"| ||\n"
|
| 191 |
+
"|-+|\n"
|
| 192 |
+
"|-+|\n"
|
| 193 |
+
"| ||\n"
|
| 194 |
+
"+--+\n",
|
| 195 |
+
ascii=True,
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
ASCII2: Box = Box(
|
| 199 |
+
"+-++\n"
|
| 200 |
+
"| ||\n"
|
| 201 |
+
"+-++\n"
|
| 202 |
+
"| ||\n"
|
| 203 |
+
"+-++\n"
|
| 204 |
+
"+-++\n"
|
| 205 |
+
"| ||\n"
|
| 206 |
+
"+-++\n",
|
| 207 |
+
ascii=True,
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
ASCII_DOUBLE_HEAD: Box = Box(
|
| 211 |
+
"+-++\n"
|
| 212 |
+
"| ||\n"
|
| 213 |
+
"+=++\n"
|
| 214 |
+
"| ||\n"
|
| 215 |
+
"+-++\n"
|
| 216 |
+
"+-++\n"
|
| 217 |
+
"| ||\n"
|
| 218 |
+
"+-++\n",
|
| 219 |
+
ascii=True,
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
SQUARE: Box = Box(
|
| 223 |
+
"┌─┬┐\n"
|
| 224 |
+
"│ ││\n"
|
| 225 |
+
"├─┼┤\n"
|
| 226 |
+
"│ ││\n"
|
| 227 |
+
"├─┼┤\n"
|
| 228 |
+
"├─┼┤\n"
|
| 229 |
+
"│ ││\n"
|
| 230 |
+
"└─┴┘\n"
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
SQUARE_DOUBLE_HEAD: Box = Box(
|
| 234 |
+
"┌─┬┐\n"
|
| 235 |
+
"│ ││\n"
|
| 236 |
+
"╞═╪╡\n"
|
| 237 |
+
"│ ││\n"
|
| 238 |
+
"├─┼┤\n"
|
| 239 |
+
"├─┼┤\n"
|
| 240 |
+
"│ ││\n"
|
| 241 |
+
"└─┴┘\n"
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
MINIMAL: Box = Box(
|
| 245 |
+
" ╷ \n"
|
| 246 |
+
" │ \n"
|
| 247 |
+
"╶─┼╴\n"
|
| 248 |
+
" │ \n"
|
| 249 |
+
"╶─┼╴\n"
|
| 250 |
+
"╶─┼╴\n"
|
| 251 |
+
" │ \n"
|
| 252 |
+
" ╵ \n"
|
| 253 |
+
)
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
MINIMAL_HEAVY_HEAD: Box = Box(
|
| 257 |
+
" ╷ \n"
|
| 258 |
+
" │ \n"
|
| 259 |
+
"╺━┿╸\n"
|
| 260 |
+
" │ \n"
|
| 261 |
+
"╶─┼╴\n"
|
| 262 |
+
"╶─┼╴\n"
|
| 263 |
+
" │ \n"
|
| 264 |
+
" ╵ \n"
|
| 265 |
+
)
|
| 266 |
+
|
| 267 |
+
MINIMAL_DOUBLE_HEAD: Box = Box(
|
| 268 |
+
" ╷ \n"
|
| 269 |
+
" │ \n"
|
| 270 |
+
" ═╪ \n"
|
| 271 |
+
" │ \n"
|
| 272 |
+
" ─┼ \n"
|
| 273 |
+
" ─┼ \n"
|
| 274 |
+
" │ \n"
|
| 275 |
+
" ╵ \n"
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
SIMPLE: Box = Box(
|
| 280 |
+
" \n"
|
| 281 |
+
" \n"
|
| 282 |
+
" ── \n"
|
| 283 |
+
" \n"
|
| 284 |
+
" \n"
|
| 285 |
+
" ── \n"
|
| 286 |
+
" \n"
|
| 287 |
+
" \n"
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
SIMPLE_HEAD: Box = Box(
|
| 291 |
+
" \n"
|
| 292 |
+
" \n"
|
| 293 |
+
" ── \n"
|
| 294 |
+
" \n"
|
| 295 |
+
" \n"
|
| 296 |
+
" \n"
|
| 297 |
+
" \n"
|
| 298 |
+
" \n"
|
| 299 |
+
)
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
SIMPLE_HEAVY: Box = Box(
|
| 303 |
+
" \n"
|
| 304 |
+
" \n"
|
| 305 |
+
" ━━ \n"
|
| 306 |
+
" \n"
|
| 307 |
+
" \n"
|
| 308 |
+
" ━━ \n"
|
| 309 |
+
" \n"
|
| 310 |
+
" \n"
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
HORIZONTALS: Box = Box(
|
| 315 |
+
" ── \n"
|
| 316 |
+
" \n"
|
| 317 |
+
" ── \n"
|
| 318 |
+
" \n"
|
| 319 |
+
" ── \n"
|
| 320 |
+
" ── \n"
|
| 321 |
+
" \n"
|
| 322 |
+
" ── \n"
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
ROUNDED: Box = Box(
|
| 326 |
+
"╭─┬╮\n"
|
| 327 |
+
"│ ││\n"
|
| 328 |
+
"├─┼┤\n"
|
| 329 |
+
"│ ││\n"
|
| 330 |
+
"├─┼┤\n"
|
| 331 |
+
"├─┼┤\n"
|
| 332 |
+
"│ ││\n"
|
| 333 |
+
"╰─┴╯\n"
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
HEAVY: Box = Box(
|
| 337 |
+
"┏━┳┓\n"
|
| 338 |
+
"┃ ┃┃\n"
|
| 339 |
+
"┣━╋┫\n"
|
| 340 |
+
"┃ ┃┃\n"
|
| 341 |
+
"┣━╋┫\n"
|
| 342 |
+
"┣━╋┫\n"
|
| 343 |
+
"┃ ┃┃\n"
|
| 344 |
+
"┗━┻┛\n"
|
| 345 |
+
)
|
| 346 |
+
|
| 347 |
+
HEAVY_EDGE: Box = Box(
|
| 348 |
+
"┏━┯┓\n"
|
| 349 |
+
"┃ │┃\n"
|
| 350 |
+
"┠─┼┨\n"
|
| 351 |
+
"┃ │┃\n"
|
| 352 |
+
"┠─┼┨\n"
|
| 353 |
+
"┠─┼┨\n"
|
| 354 |
+
"┃ │┃\n"
|
| 355 |
+
"┗━┷┛\n"
|
| 356 |
+
)
|
| 357 |
+
|
| 358 |
+
HEAVY_HEAD: Box = Box(
|
| 359 |
+
"┏━┳┓\n"
|
| 360 |
+
"┃ ┃┃\n"
|
| 361 |
+
"┡━╇┩\n"
|
| 362 |
+
"│ ││\n"
|
| 363 |
+
"├─┼┤\n"
|
| 364 |
+
"├─┼┤\n"
|
| 365 |
+
"│ ││\n"
|
| 366 |
+
"└─┴┘\n"
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
DOUBLE: Box = Box(
|
| 370 |
+
"╔═╦╗\n"
|
| 371 |
+
"║ ║║\n"
|
| 372 |
+
"╠═╬╣\n"
|
| 373 |
+
"║ ║║\n"
|
| 374 |
+
"╠═╬╣\n"
|
| 375 |
+
"╠═╬╣\n"
|
| 376 |
+
"║ ║║\n"
|
| 377 |
+
"╚═╩╝\n"
|
| 378 |
+
)
|
| 379 |
+
|
| 380 |
+
DOUBLE_EDGE: Box = Box(
|
| 381 |
+
"╔═╤╗\n"
|
| 382 |
+
"║ │║\n"
|
| 383 |
+
"╟─┼╢\n"
|
| 384 |
+
"║ │║\n"
|
| 385 |
+
"╟─┼╢\n"
|
| 386 |
+
"╟─┼╢\n"
|
| 387 |
+
"║ │║\n"
|
| 388 |
+
"╚═╧╝\n"
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
MARKDOWN: Box = Box(
|
| 392 |
+
" \n"
|
| 393 |
+
"| ||\n"
|
| 394 |
+
"|-||\n"
|
| 395 |
+
"| ||\n"
|
| 396 |
+
"|-||\n"
|
| 397 |
+
"|-||\n"
|
| 398 |
+
"| ||\n"
|
| 399 |
+
" \n",
|
| 400 |
+
ascii=True,
|
| 401 |
+
)
|
| 402 |
+
# fmt: on
|
| 403 |
+
|
| 404 |
+
# Map Boxes that don't render with raster fonts on to equivalent that do
|
| 405 |
+
LEGACY_WINDOWS_SUBSTITUTIONS = {
|
| 406 |
+
ROUNDED: SQUARE,
|
| 407 |
+
MINIMAL_HEAVY_HEAD: MINIMAL,
|
| 408 |
+
SIMPLE_HEAVY: SIMPLE,
|
| 409 |
+
HEAVY: SQUARE,
|
| 410 |
+
HEAVY_EDGE: SQUARE,
|
| 411 |
+
HEAVY_HEAD: SQUARE,
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
# Map headed boxes to their headerless equivalents
|
| 415 |
+
PLAIN_HEADED_SUBSTITUTIONS = {
|
| 416 |
+
HEAVY_HEAD: SQUARE,
|
| 417 |
+
SQUARE_DOUBLE_HEAD: SQUARE,
|
| 418 |
+
MINIMAL_DOUBLE_HEAD: MINIMAL,
|
| 419 |
+
MINIMAL_HEAVY_HEAD: MINIMAL,
|
| 420 |
+
ASCII_DOUBLE_HEAD: ASCII2,
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
if __name__ == "__main__": # pragma: no cover
|
| 425 |
+
from rich.columns import Columns
|
| 426 |
+
from rich.panel import Panel
|
| 427 |
+
|
| 428 |
+
from . import box as box
|
| 429 |
+
from .console import Console
|
| 430 |
+
from .table import Table
|
| 431 |
+
from .text import Text
|
| 432 |
+
|
| 433 |
+
console = Console(record=True)
|
| 434 |
+
|
| 435 |
+
BOXES = [
|
| 436 |
+
"ASCII",
|
| 437 |
+
"ASCII2",
|
| 438 |
+
"ASCII_DOUBLE_HEAD",
|
| 439 |
+
"SQUARE",
|
| 440 |
+
"SQUARE_DOUBLE_HEAD",
|
| 441 |
+
"MINIMAL",
|
| 442 |
+
"MINIMAL_HEAVY_HEAD",
|
| 443 |
+
"MINIMAL_DOUBLE_HEAD",
|
| 444 |
+
"SIMPLE",
|
| 445 |
+
"SIMPLE_HEAD",
|
| 446 |
+
"SIMPLE_HEAVY",
|
| 447 |
+
"HORIZONTALS",
|
| 448 |
+
"ROUNDED",
|
| 449 |
+
"HEAVY",
|
| 450 |
+
"HEAVY_EDGE",
|
| 451 |
+
"HEAVY_HEAD",
|
| 452 |
+
"DOUBLE",
|
| 453 |
+
"DOUBLE_EDGE",
|
| 454 |
+
"MARKDOWN",
|
| 455 |
+
]
|
| 456 |
+
|
| 457 |
+
console.print(Panel("[bold green]Box Constants", style="green"), justify="center")
|
| 458 |
+
console.print()
|
| 459 |
+
|
| 460 |
+
columns = Columns(expand=True, padding=2)
|
| 461 |
+
for box_name in sorted(BOXES):
|
| 462 |
+
table = Table(
|
| 463 |
+
show_footer=True, style="dim", border_style="not dim", expand=True
|
| 464 |
+
)
|
| 465 |
+
table.add_column("Header 1", "Footer 1")
|
| 466 |
+
table.add_column("Header 2", "Footer 2")
|
| 467 |
+
table.add_row("Cell", "Cell")
|
| 468 |
+
table.add_row("Cell", "Cell")
|
| 469 |
+
table.box = getattr(box, box_name)
|
| 470 |
+
table.title = Text(f"box.{box_name}", style="magenta")
|
| 471 |
+
columns.add_renderable(table)
|
| 472 |
+
console.print(columns)
|
| 473 |
+
|
| 474 |
+
# console.save_svg("box.svg")
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/cells.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from functools import lru_cache
|
| 4 |
+
from operator import itemgetter
|
| 5 |
+
from typing import Callable, NamedTuple, Sequence, Tuple
|
| 6 |
+
|
| 7 |
+
from rich._unicode_data import load as load_cell_table
|
| 8 |
+
|
| 9 |
+
CellSpan = Tuple[int, int, int]
|
| 10 |
+
|
| 11 |
+
_span_get_cell_len = itemgetter(2)
|
| 12 |
+
|
| 13 |
+
# Ranges of unicode ordinals that produce a 1-cell wide character
|
| 14 |
+
# This is non-exhaustive, but covers most common Western characters
|
| 15 |
+
_SINGLE_CELL_UNICODE_RANGES: list[tuple[int, int]] = [
|
| 16 |
+
(0x20, 0x7E), # Latin (excluding non-printable)
|
| 17 |
+
(0xA0, 0xAC),
|
| 18 |
+
(0xAE, 0x002FF),
|
| 19 |
+
(0x00370, 0x00482), # Greek / Cyrillic
|
| 20 |
+
(0x02500, 0x025FC), # Box drawing, box elements, geometric shapes
|
| 21 |
+
(0x02800, 0x028FF), # Braille
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
# A frozen set of characters that are a single cell wide
|
| 25 |
+
_SINGLE_CELLS = frozenset(
|
| 26 |
+
[
|
| 27 |
+
character
|
| 28 |
+
for _start, _end in _SINGLE_CELL_UNICODE_RANGES
|
| 29 |
+
for character in map(chr, range(_start, _end + 1))
|
| 30 |
+
]
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# When called with a string this will return True if all
|
| 34 |
+
# characters are single-cell, otherwise False
|
| 35 |
+
_is_single_cell_widths: Callable[[str], bool] = _SINGLE_CELLS.issuperset
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class CellTable(NamedTuple):
|
| 39 |
+
"""Contains unicode data required to measure the cell widths of glyphs."""
|
| 40 |
+
|
| 41 |
+
unicode_version: str
|
| 42 |
+
widths: Sequence[tuple[int, int, int]]
|
| 43 |
+
narrow_to_wide: frozenset[str]
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
@lru_cache(maxsize=4096)
|
| 47 |
+
def get_character_cell_size(character: str, unicode_version: str = "auto") -> int:
|
| 48 |
+
"""Get the cell size of a character.
|
| 49 |
+
|
| 50 |
+
Args:
|
| 51 |
+
character (str): A single character.
|
| 52 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 53 |
+
|
| 54 |
+
Returns:
|
| 55 |
+
int: Number of cells (0, 1 or 2) occupied by that character.
|
| 56 |
+
"""
|
| 57 |
+
codepoint = ord(character)
|
| 58 |
+
if codepoint and codepoint < 32 or 0x07F <= codepoint < 0x0A0:
|
| 59 |
+
return 0
|
| 60 |
+
table = load_cell_table(unicode_version).widths
|
| 61 |
+
|
| 62 |
+
last_entry = table[-1]
|
| 63 |
+
if codepoint > last_entry[1]:
|
| 64 |
+
return 1
|
| 65 |
+
|
| 66 |
+
lower_bound = 0
|
| 67 |
+
upper_bound = len(table) - 1
|
| 68 |
+
|
| 69 |
+
while lower_bound <= upper_bound:
|
| 70 |
+
index = (lower_bound + upper_bound) >> 1
|
| 71 |
+
start, end, width = table[index]
|
| 72 |
+
if codepoint < start:
|
| 73 |
+
upper_bound = index - 1
|
| 74 |
+
elif codepoint > end:
|
| 75 |
+
lower_bound = index + 1
|
| 76 |
+
else:
|
| 77 |
+
return width
|
| 78 |
+
return 1
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
@lru_cache(4096)
|
| 82 |
+
def cached_cell_len(text: str, unicode_version: str = "auto") -> int:
|
| 83 |
+
"""Get the number of cells required to display text.
|
| 84 |
+
|
| 85 |
+
This method always caches, which may use up a lot of memory. It is recommended to use
|
| 86 |
+
`cell_len` over this method.
|
| 87 |
+
|
| 88 |
+
Args:
|
| 89 |
+
text (str): Text to display.
|
| 90 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 91 |
+
|
| 92 |
+
Returns:
|
| 93 |
+
int: Get the number of cells required to display text.
|
| 94 |
+
"""
|
| 95 |
+
return _cell_len(text, unicode_version)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def cell_len(text: str, unicode_version: str = "auto") -> int:
|
| 99 |
+
"""Get the cell length of a string (length as it appears in the terminal).
|
| 100 |
+
|
| 101 |
+
Args:
|
| 102 |
+
text: String to measure.
|
| 103 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 104 |
+
|
| 105 |
+
Returns:
|
| 106 |
+
Length of string in terminal cells.
|
| 107 |
+
"""
|
| 108 |
+
if len(text) < 512:
|
| 109 |
+
return cached_cell_len(text, unicode_version)
|
| 110 |
+
return _cell_len(text, unicode_version)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def _cell_len(text: str, unicode_version: str) -> int:
|
| 114 |
+
"""Get the cell length of a string (length as it appears in the terminal).
|
| 115 |
+
|
| 116 |
+
Args:
|
| 117 |
+
text: String to measure.
|
| 118 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 119 |
+
|
| 120 |
+
Returns:
|
| 121 |
+
Length of string in terminal cells.
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
if _is_single_cell_widths(text):
|
| 125 |
+
return len(text)
|
| 126 |
+
|
| 127 |
+
# "\u200d" is zero width joiner
|
| 128 |
+
# "\ufe0f" is variation selector 16
|
| 129 |
+
if "\u200d" not in text and "\ufe0f" not in text:
|
| 130 |
+
# Simplest case with no unicode stuff that changes the size
|
| 131 |
+
return sum(
|
| 132 |
+
get_character_cell_size(character, unicode_version) for character in text
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
cell_table = load_cell_table(unicode_version)
|
| 136 |
+
total_width = 0
|
| 137 |
+
last_measured_character: str | None = None
|
| 138 |
+
|
| 139 |
+
SPECIAL = {"\u200d", "\ufe0f"}
|
| 140 |
+
|
| 141 |
+
index = 0
|
| 142 |
+
character_count = len(text)
|
| 143 |
+
|
| 144 |
+
while index < character_count:
|
| 145 |
+
character = text[index]
|
| 146 |
+
if character in SPECIAL:
|
| 147 |
+
if character == "\u200d":
|
| 148 |
+
index += 1
|
| 149 |
+
elif last_measured_character:
|
| 150 |
+
total_width += last_measured_character in cell_table.narrow_to_wide
|
| 151 |
+
last_measured_character = None
|
| 152 |
+
else:
|
| 153 |
+
if character_width := get_character_cell_size(character, unicode_version):
|
| 154 |
+
last_measured_character = character
|
| 155 |
+
total_width += character_width
|
| 156 |
+
index += 1
|
| 157 |
+
|
| 158 |
+
return total_width
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def split_graphemes(
|
| 162 |
+
text: str, unicode_version: str = "auto"
|
| 163 |
+
) -> "tuple[list[CellSpan], int]":
|
| 164 |
+
"""Divide text into spans that define a single grapheme, and additionally return the cell length of the whole string.
|
| 165 |
+
|
| 166 |
+
The returned spans will cover every index in the string, with no gaps. It is possible for some graphemes to have a cell length of zero.
|
| 167 |
+
This can occur for nonsense strings like two zero width joiners, or for control codes that don't contribute to the grapheme size.
|
| 168 |
+
|
| 169 |
+
Args:
|
| 170 |
+
text: String to split.
|
| 171 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 172 |
+
|
| 173 |
+
Returns:
|
| 174 |
+
A tuple of a list of *spans* and the cell length of the entire string. A span is a list of tuples
|
| 175 |
+
of three values consisting of (<START>, <END>, <CELL LENGTH>), where START and END are string indices,
|
| 176 |
+
and CELL LENGTH is the cell length of the single grapheme.
|
| 177 |
+
"""
|
| 178 |
+
|
| 179 |
+
cell_table = load_cell_table(unicode_version)
|
| 180 |
+
codepoint_count = len(text)
|
| 181 |
+
index = 0
|
| 182 |
+
last_measured_character: str | None = None
|
| 183 |
+
|
| 184 |
+
total_width = 0
|
| 185 |
+
spans: list[tuple[int, int, int]] = []
|
| 186 |
+
SPECIAL = {"\u200d", "\ufe0f"}
|
| 187 |
+
while index < codepoint_count:
|
| 188 |
+
if (character := text[index]) in SPECIAL:
|
| 189 |
+
if not spans:
|
| 190 |
+
# ZWJ or variation selector at the beginning of the string doesn't really make sense.
|
| 191 |
+
# But handle it, we must.
|
| 192 |
+
spans.append((index, index := index + 1, 0))
|
| 193 |
+
continue
|
| 194 |
+
if character == "\u200d":
|
| 195 |
+
# zero width joiner
|
| 196 |
+
# The condition handles the case where a ZWJ is at the end of the string, and has nothing to join
|
| 197 |
+
index += 2 if index < (codepoint_count - 1) else 1
|
| 198 |
+
start, _end, cell_length = spans[-1]
|
| 199 |
+
spans[-1] = (start, index, cell_length)
|
| 200 |
+
else:
|
| 201 |
+
# variation selector 16
|
| 202 |
+
index += 1
|
| 203 |
+
if last_measured_character:
|
| 204 |
+
start, _end, cell_length = spans[-1]
|
| 205 |
+
if last_measured_character in cell_table.narrow_to_wide:
|
| 206 |
+
last_measured_character = None
|
| 207 |
+
cell_length += 1
|
| 208 |
+
total_width += 1
|
| 209 |
+
spans[-1] = (start, index, cell_length)
|
| 210 |
+
else:
|
| 211 |
+
# No previous character to change the size of.
|
| 212 |
+
# Shouldn't occur in practice.
|
| 213 |
+
# But handle it, we must.
|
| 214 |
+
start, _end, cell_length = spans[-1]
|
| 215 |
+
spans[-1] = (start, index, cell_length)
|
| 216 |
+
continue
|
| 217 |
+
|
| 218 |
+
if character_width := get_character_cell_size(character, unicode_version):
|
| 219 |
+
last_measured_character = character
|
| 220 |
+
spans.append((index, index := index + 1, character_width))
|
| 221 |
+
total_width += character_width
|
| 222 |
+
else:
|
| 223 |
+
# Character has zero width
|
| 224 |
+
if spans:
|
| 225 |
+
# zero width characters are associated with the previous character
|
| 226 |
+
start, _end, cell_length = spans[-1]
|
| 227 |
+
spans[-1] = (start, index := index + 1, cell_length)
|
| 228 |
+
else:
|
| 229 |
+
# A zero width character with no prior spans
|
| 230 |
+
spans.append((index, index := index + 1, 0))
|
| 231 |
+
|
| 232 |
+
return (spans, total_width)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def _split_text(
|
| 236 |
+
text: str, cell_position: int, unicode_version: str = "auto"
|
| 237 |
+
) -> tuple[str, str]:
|
| 238 |
+
"""Split text by cell position.
|
| 239 |
+
|
| 240 |
+
If the cell position falls within a double width character, it is converted to two spaces.
|
| 241 |
+
|
| 242 |
+
Args:
|
| 243 |
+
text: Text to split.
|
| 244 |
+
cell_position Offset in cells.
|
| 245 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 246 |
+
|
| 247 |
+
Returns:
|
| 248 |
+
Tuple to two split strings.
|
| 249 |
+
"""
|
| 250 |
+
if cell_position <= 0:
|
| 251 |
+
return "", text
|
| 252 |
+
|
| 253 |
+
spans, cell_length = split_graphemes(text, unicode_version)
|
| 254 |
+
|
| 255 |
+
# Guess initial offset
|
| 256 |
+
offset = int((cell_position / cell_length) * len(spans))
|
| 257 |
+
left_size = sum(map(_span_get_cell_len, spans[:offset]))
|
| 258 |
+
|
| 259 |
+
while True:
|
| 260 |
+
if left_size == cell_position:
|
| 261 |
+
if offset >= len(spans):
|
| 262 |
+
return text, ""
|
| 263 |
+
split_index = spans[offset][0]
|
| 264 |
+
return text[:split_index], text[split_index:]
|
| 265 |
+
if left_size < cell_position:
|
| 266 |
+
start, end, cell_size = spans[offset]
|
| 267 |
+
if left_size + cell_size > cell_position:
|
| 268 |
+
return text[:start] + " ", " " + text[end:]
|
| 269 |
+
offset += 1
|
| 270 |
+
left_size += cell_size
|
| 271 |
+
else: # left_size > cell_position
|
| 272 |
+
start, end, cell_size = spans[offset - 1]
|
| 273 |
+
if left_size - cell_size < cell_position:
|
| 274 |
+
return text[:start] + " ", " " + text[end:]
|
| 275 |
+
offset -= 1
|
| 276 |
+
left_size -= cell_size
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def split_text(
|
| 280 |
+
text: str, cell_position: int, unicode_version: str = "auto"
|
| 281 |
+
) -> tuple[str, str]:
|
| 282 |
+
"""Split text by cell position.
|
| 283 |
+
|
| 284 |
+
If the cell position falls within a double width character, it is converted to two spaces.
|
| 285 |
+
|
| 286 |
+
Args:
|
| 287 |
+
text: Text to split.
|
| 288 |
+
cell_position Offset in cells.
|
| 289 |
+
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
|
| 290 |
+
|
| 291 |
+
Returns:
|
| 292 |
+
Tuple to two split strings.
|
| 293 |
+
"""
|
| 294 |
+
if _is_single_cell_widths(text):
|
| 295 |
+
return text[:cell_position], text[cell_position:]
|
| 296 |
+
return _split_text(text, cell_position, unicode_version)
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def set_cell_size(text: str, total: int, unicode_version: str = "auto") -> str:
|
| 300 |
+
"""Adjust a string by cropping or padding with spaces such that it fits within the given number of cells.
|
| 301 |
+
|
| 302 |
+
Args:
|
| 303 |
+
text: String to adjust.
|
| 304 |
+
total: Desired size in cells.
|
| 305 |
+
unicode_version: Unicode version.
|
| 306 |
+
|
| 307 |
+
Returns:
|
| 308 |
+
A string with cell size equal to total.
|
| 309 |
+
"""
|
| 310 |
+
if _is_single_cell_widths(text):
|
| 311 |
+
size = len(text)
|
| 312 |
+
if size < total:
|
| 313 |
+
return text + " " * (total - size)
|
| 314 |
+
return text[:total]
|
| 315 |
+
if total <= 0:
|
| 316 |
+
return ""
|
| 317 |
+
cell_size = cell_len(text)
|
| 318 |
+
if cell_size == total:
|
| 319 |
+
return text
|
| 320 |
+
if cell_size < total:
|
| 321 |
+
return text + " " * (total - cell_size)
|
| 322 |
+
text, _ = _split_text(text, total, unicode_version)
|
| 323 |
+
return text
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def chop_cells(text: str, width: int, unicode_version: str = "auto") -> list[str]:
|
| 327 |
+
"""Split text into lines such that each line fits within the available (cell) width.
|
| 328 |
+
|
| 329 |
+
Args:
|
| 330 |
+
text: The text to fold such that it fits in the given width.
|
| 331 |
+
width: The width available (number of cells).
|
| 332 |
+
|
| 333 |
+
Returns:
|
| 334 |
+
A list of strings such that each string in the list has cell width
|
| 335 |
+
less than or equal to the available width.
|
| 336 |
+
"""
|
| 337 |
+
if _is_single_cell_widths(text):
|
| 338 |
+
return [text[index : index + width] for index in range(0, len(text), width)]
|
| 339 |
+
spans, _ = split_graphemes(text, unicode_version)
|
| 340 |
+
line_size = 0 # Size of line in cells
|
| 341 |
+
lines: list[str] = []
|
| 342 |
+
line_offset = 0 # Offset (in codepoints) of start of line
|
| 343 |
+
for start, end, cell_size in spans:
|
| 344 |
+
if line_size + cell_size > width:
|
| 345 |
+
lines.append(text[line_offset:start])
|
| 346 |
+
line_offset = start
|
| 347 |
+
line_size = 0
|
| 348 |
+
line_size += cell_size
|
| 349 |
+
if line_size:
|
| 350 |
+
lines.append(text[line_offset:])
|
| 351 |
+
|
| 352 |
+
return lines
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/color.py
ADDED
|
@@ -0,0 +1,621 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
import sys
|
| 3 |
+
from colorsys import rgb_to_hls
|
| 4 |
+
from enum import IntEnum
|
| 5 |
+
from functools import lru_cache
|
| 6 |
+
from typing import TYPE_CHECKING, NamedTuple, Optional, Tuple
|
| 7 |
+
|
| 8 |
+
from ._palettes import EIGHT_BIT_PALETTE, STANDARD_PALETTE, WINDOWS_PALETTE
|
| 9 |
+
from .color_triplet import ColorTriplet
|
| 10 |
+
from .repr import Result, rich_repr
|
| 11 |
+
from .terminal_theme import DEFAULT_TERMINAL_THEME
|
| 12 |
+
|
| 13 |
+
if TYPE_CHECKING: # pragma: no cover
|
| 14 |
+
from .terminal_theme import TerminalTheme
|
| 15 |
+
from .text import Text
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
WINDOWS = sys.platform == "win32"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class ColorSystem(IntEnum):
|
| 22 |
+
"""One of the 3 color system supported by terminals."""
|
| 23 |
+
|
| 24 |
+
STANDARD = 1
|
| 25 |
+
EIGHT_BIT = 2
|
| 26 |
+
TRUECOLOR = 3
|
| 27 |
+
WINDOWS = 4
|
| 28 |
+
|
| 29 |
+
def __repr__(self) -> str:
|
| 30 |
+
return f"ColorSystem.{self.name}"
|
| 31 |
+
|
| 32 |
+
def __str__(self) -> str:
|
| 33 |
+
return repr(self)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class ColorType(IntEnum):
|
| 37 |
+
"""Type of color stored in Color class."""
|
| 38 |
+
|
| 39 |
+
DEFAULT = 0
|
| 40 |
+
STANDARD = 1
|
| 41 |
+
EIGHT_BIT = 2
|
| 42 |
+
TRUECOLOR = 3
|
| 43 |
+
WINDOWS = 4
|
| 44 |
+
|
| 45 |
+
def __repr__(self) -> str:
|
| 46 |
+
return f"ColorType.{self.name}"
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
ANSI_COLOR_NAMES = {
|
| 50 |
+
"black": 0,
|
| 51 |
+
"red": 1,
|
| 52 |
+
"green": 2,
|
| 53 |
+
"yellow": 3,
|
| 54 |
+
"blue": 4,
|
| 55 |
+
"magenta": 5,
|
| 56 |
+
"cyan": 6,
|
| 57 |
+
"white": 7,
|
| 58 |
+
"bright_black": 8,
|
| 59 |
+
"bright_red": 9,
|
| 60 |
+
"bright_green": 10,
|
| 61 |
+
"bright_yellow": 11,
|
| 62 |
+
"bright_blue": 12,
|
| 63 |
+
"bright_magenta": 13,
|
| 64 |
+
"bright_cyan": 14,
|
| 65 |
+
"bright_white": 15,
|
| 66 |
+
"grey0": 16,
|
| 67 |
+
"gray0": 16,
|
| 68 |
+
"navy_blue": 17,
|
| 69 |
+
"dark_blue": 18,
|
| 70 |
+
"blue3": 20,
|
| 71 |
+
"blue1": 21,
|
| 72 |
+
"dark_green": 22,
|
| 73 |
+
"deep_sky_blue4": 25,
|
| 74 |
+
"dodger_blue3": 26,
|
| 75 |
+
"dodger_blue2": 27,
|
| 76 |
+
"green4": 28,
|
| 77 |
+
"spring_green4": 29,
|
| 78 |
+
"turquoise4": 30,
|
| 79 |
+
"deep_sky_blue3": 32,
|
| 80 |
+
"dodger_blue1": 33,
|
| 81 |
+
"green3": 40,
|
| 82 |
+
"spring_green3": 41,
|
| 83 |
+
"dark_cyan": 36,
|
| 84 |
+
"light_sea_green": 37,
|
| 85 |
+
"deep_sky_blue2": 38,
|
| 86 |
+
"deep_sky_blue1": 39,
|
| 87 |
+
"spring_green2": 47,
|
| 88 |
+
"cyan3": 43,
|
| 89 |
+
"dark_turquoise": 44,
|
| 90 |
+
"turquoise2": 45,
|
| 91 |
+
"green1": 46,
|
| 92 |
+
"spring_green1": 48,
|
| 93 |
+
"medium_spring_green": 49,
|
| 94 |
+
"cyan2": 50,
|
| 95 |
+
"cyan1": 51,
|
| 96 |
+
"dark_red": 88,
|
| 97 |
+
"deep_pink4": 125,
|
| 98 |
+
"purple4": 55,
|
| 99 |
+
"purple3": 56,
|
| 100 |
+
"blue_violet": 57,
|
| 101 |
+
"orange4": 94,
|
| 102 |
+
"grey37": 59,
|
| 103 |
+
"gray37": 59,
|
| 104 |
+
"medium_purple4": 60,
|
| 105 |
+
"slate_blue3": 62,
|
| 106 |
+
"royal_blue1": 63,
|
| 107 |
+
"chartreuse4": 64,
|
| 108 |
+
"dark_sea_green4": 71,
|
| 109 |
+
"pale_turquoise4": 66,
|
| 110 |
+
"steel_blue": 67,
|
| 111 |
+
"steel_blue3": 68,
|
| 112 |
+
"cornflower_blue": 69,
|
| 113 |
+
"chartreuse3": 76,
|
| 114 |
+
"cadet_blue": 73,
|
| 115 |
+
"sky_blue3": 74,
|
| 116 |
+
"steel_blue1": 81,
|
| 117 |
+
"pale_green3": 114,
|
| 118 |
+
"sea_green3": 78,
|
| 119 |
+
"aquamarine3": 79,
|
| 120 |
+
"medium_turquoise": 80,
|
| 121 |
+
"chartreuse2": 112,
|
| 122 |
+
"sea_green2": 83,
|
| 123 |
+
"sea_green1": 85,
|
| 124 |
+
"aquamarine1": 122,
|
| 125 |
+
"dark_slate_gray2": 87,
|
| 126 |
+
"dark_magenta": 91,
|
| 127 |
+
"dark_violet": 128,
|
| 128 |
+
"purple": 129,
|
| 129 |
+
"light_pink4": 95,
|
| 130 |
+
"plum4": 96,
|
| 131 |
+
"medium_purple3": 98,
|
| 132 |
+
"slate_blue1": 99,
|
| 133 |
+
"yellow4": 106,
|
| 134 |
+
"wheat4": 101,
|
| 135 |
+
"grey53": 102,
|
| 136 |
+
"gray53": 102,
|
| 137 |
+
"light_slate_grey": 103,
|
| 138 |
+
"light_slate_gray": 103,
|
| 139 |
+
"medium_purple": 104,
|
| 140 |
+
"light_slate_blue": 105,
|
| 141 |
+
"dark_olive_green3": 149,
|
| 142 |
+
"dark_sea_green": 108,
|
| 143 |
+
"light_sky_blue3": 110,
|
| 144 |
+
"sky_blue2": 111,
|
| 145 |
+
"dark_sea_green3": 150,
|
| 146 |
+
"dark_slate_gray3": 116,
|
| 147 |
+
"sky_blue1": 117,
|
| 148 |
+
"chartreuse1": 118,
|
| 149 |
+
"light_green": 120,
|
| 150 |
+
"pale_green1": 156,
|
| 151 |
+
"dark_slate_gray1": 123,
|
| 152 |
+
"red3": 160,
|
| 153 |
+
"medium_violet_red": 126,
|
| 154 |
+
"magenta3": 164,
|
| 155 |
+
"dark_orange3": 166,
|
| 156 |
+
"indian_red": 167,
|
| 157 |
+
"hot_pink3": 168,
|
| 158 |
+
"medium_orchid3": 133,
|
| 159 |
+
"medium_orchid": 134,
|
| 160 |
+
"medium_purple2": 140,
|
| 161 |
+
"dark_goldenrod": 136,
|
| 162 |
+
"light_salmon3": 173,
|
| 163 |
+
"rosy_brown": 138,
|
| 164 |
+
"grey63": 139,
|
| 165 |
+
"gray63": 139,
|
| 166 |
+
"medium_purple1": 141,
|
| 167 |
+
"gold3": 178,
|
| 168 |
+
"dark_khaki": 143,
|
| 169 |
+
"navajo_white3": 144,
|
| 170 |
+
"grey69": 145,
|
| 171 |
+
"gray69": 145,
|
| 172 |
+
"light_steel_blue3": 146,
|
| 173 |
+
"light_steel_blue": 147,
|
| 174 |
+
"yellow3": 184,
|
| 175 |
+
"dark_sea_green2": 157,
|
| 176 |
+
"light_cyan3": 152,
|
| 177 |
+
"light_sky_blue1": 153,
|
| 178 |
+
"green_yellow": 154,
|
| 179 |
+
"dark_olive_green2": 155,
|
| 180 |
+
"dark_sea_green1": 193,
|
| 181 |
+
"pale_turquoise1": 159,
|
| 182 |
+
"deep_pink3": 162,
|
| 183 |
+
"magenta2": 200,
|
| 184 |
+
"hot_pink2": 169,
|
| 185 |
+
"orchid": 170,
|
| 186 |
+
"medium_orchid1": 207,
|
| 187 |
+
"orange3": 172,
|
| 188 |
+
"light_pink3": 174,
|
| 189 |
+
"pink3": 175,
|
| 190 |
+
"plum3": 176,
|
| 191 |
+
"violet": 177,
|
| 192 |
+
"light_goldenrod3": 179,
|
| 193 |
+
"tan": 180,
|
| 194 |
+
"misty_rose3": 181,
|
| 195 |
+
"thistle3": 182,
|
| 196 |
+
"plum2": 183,
|
| 197 |
+
"khaki3": 185,
|
| 198 |
+
"light_goldenrod2": 222,
|
| 199 |
+
"light_yellow3": 187,
|
| 200 |
+
"grey84": 188,
|
| 201 |
+
"gray84": 188,
|
| 202 |
+
"light_steel_blue1": 189,
|
| 203 |
+
"yellow2": 190,
|
| 204 |
+
"dark_olive_green1": 192,
|
| 205 |
+
"honeydew2": 194,
|
| 206 |
+
"light_cyan1": 195,
|
| 207 |
+
"red1": 196,
|
| 208 |
+
"deep_pink2": 197,
|
| 209 |
+
"deep_pink1": 199,
|
| 210 |
+
"magenta1": 201,
|
| 211 |
+
"orange_red1": 202,
|
| 212 |
+
"indian_red1": 204,
|
| 213 |
+
"hot_pink": 206,
|
| 214 |
+
"dark_orange": 208,
|
| 215 |
+
"salmon1": 209,
|
| 216 |
+
"light_coral": 210,
|
| 217 |
+
"pale_violet_red1": 211,
|
| 218 |
+
"orchid2": 212,
|
| 219 |
+
"orchid1": 213,
|
| 220 |
+
"orange1": 214,
|
| 221 |
+
"sandy_brown": 215,
|
| 222 |
+
"light_salmon1": 216,
|
| 223 |
+
"light_pink1": 217,
|
| 224 |
+
"pink1": 218,
|
| 225 |
+
"plum1": 219,
|
| 226 |
+
"gold1": 220,
|
| 227 |
+
"navajo_white1": 223,
|
| 228 |
+
"misty_rose1": 224,
|
| 229 |
+
"thistle1": 225,
|
| 230 |
+
"yellow1": 226,
|
| 231 |
+
"light_goldenrod1": 227,
|
| 232 |
+
"khaki1": 228,
|
| 233 |
+
"wheat1": 229,
|
| 234 |
+
"cornsilk1": 230,
|
| 235 |
+
"grey100": 231,
|
| 236 |
+
"gray100": 231,
|
| 237 |
+
"grey3": 232,
|
| 238 |
+
"gray3": 232,
|
| 239 |
+
"grey7": 233,
|
| 240 |
+
"gray7": 233,
|
| 241 |
+
"grey11": 234,
|
| 242 |
+
"gray11": 234,
|
| 243 |
+
"grey15": 235,
|
| 244 |
+
"gray15": 235,
|
| 245 |
+
"grey19": 236,
|
| 246 |
+
"gray19": 236,
|
| 247 |
+
"grey23": 237,
|
| 248 |
+
"gray23": 237,
|
| 249 |
+
"grey27": 238,
|
| 250 |
+
"gray27": 238,
|
| 251 |
+
"grey30": 239,
|
| 252 |
+
"gray30": 239,
|
| 253 |
+
"grey35": 240,
|
| 254 |
+
"gray35": 240,
|
| 255 |
+
"grey39": 241,
|
| 256 |
+
"gray39": 241,
|
| 257 |
+
"grey42": 242,
|
| 258 |
+
"gray42": 242,
|
| 259 |
+
"grey46": 243,
|
| 260 |
+
"gray46": 243,
|
| 261 |
+
"grey50": 244,
|
| 262 |
+
"gray50": 244,
|
| 263 |
+
"grey54": 245,
|
| 264 |
+
"gray54": 245,
|
| 265 |
+
"grey58": 246,
|
| 266 |
+
"gray58": 246,
|
| 267 |
+
"grey62": 247,
|
| 268 |
+
"gray62": 247,
|
| 269 |
+
"grey66": 248,
|
| 270 |
+
"gray66": 248,
|
| 271 |
+
"grey70": 249,
|
| 272 |
+
"gray70": 249,
|
| 273 |
+
"grey74": 250,
|
| 274 |
+
"gray74": 250,
|
| 275 |
+
"grey78": 251,
|
| 276 |
+
"gray78": 251,
|
| 277 |
+
"grey82": 252,
|
| 278 |
+
"gray82": 252,
|
| 279 |
+
"grey85": 253,
|
| 280 |
+
"gray85": 253,
|
| 281 |
+
"grey89": 254,
|
| 282 |
+
"gray89": 254,
|
| 283 |
+
"grey93": 255,
|
| 284 |
+
"gray93": 255,
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
class ColorParseError(Exception):
|
| 289 |
+
"""The color could not be parsed."""
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
RE_COLOR = re.compile(
|
| 293 |
+
r"""^
|
| 294 |
+
\#([0-9a-f]{6})$|
|
| 295 |
+
color\(([0-9]{1,3})\)$|
|
| 296 |
+
rgb\(([\d\s,]+)\)$
|
| 297 |
+
""",
|
| 298 |
+
re.VERBOSE,
|
| 299 |
+
)
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
@rich_repr
|
| 303 |
+
class Color(NamedTuple):
|
| 304 |
+
"""Terminal color definition."""
|
| 305 |
+
|
| 306 |
+
name: str
|
| 307 |
+
"""The name of the color (typically the input to Color.parse)."""
|
| 308 |
+
type: ColorType
|
| 309 |
+
"""The type of the color."""
|
| 310 |
+
number: Optional[int] = None
|
| 311 |
+
"""The color number, if a standard color, or None."""
|
| 312 |
+
triplet: Optional[ColorTriplet] = None
|
| 313 |
+
"""A triplet of color components, if an RGB color."""
|
| 314 |
+
|
| 315 |
+
def __rich__(self) -> "Text":
|
| 316 |
+
"""Displays the actual color if Rich printed."""
|
| 317 |
+
from .style import Style
|
| 318 |
+
from .text import Text
|
| 319 |
+
|
| 320 |
+
return Text.assemble(
|
| 321 |
+
f"<color {self.name!r} ({self.type.name.lower()})",
|
| 322 |
+
("⬤", Style(color=self)),
|
| 323 |
+
" >",
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
def __rich_repr__(self) -> Result:
|
| 327 |
+
yield self.name
|
| 328 |
+
yield self.type
|
| 329 |
+
yield "number", self.number, None
|
| 330 |
+
yield "triplet", self.triplet, None
|
| 331 |
+
|
| 332 |
+
@property
|
| 333 |
+
def system(self) -> ColorSystem:
|
| 334 |
+
"""Get the native color system for this color."""
|
| 335 |
+
if self.type == ColorType.DEFAULT:
|
| 336 |
+
return ColorSystem.STANDARD
|
| 337 |
+
return ColorSystem(int(self.type))
|
| 338 |
+
|
| 339 |
+
@property
|
| 340 |
+
def is_system_defined(self) -> bool:
|
| 341 |
+
"""Check if the color is ultimately defined by the system."""
|
| 342 |
+
return self.system not in (ColorSystem.EIGHT_BIT, ColorSystem.TRUECOLOR)
|
| 343 |
+
|
| 344 |
+
@property
|
| 345 |
+
def is_default(self) -> bool:
|
| 346 |
+
"""Check if the color is a default color."""
|
| 347 |
+
return self.type == ColorType.DEFAULT
|
| 348 |
+
|
| 349 |
+
def get_truecolor(
|
| 350 |
+
self, theme: Optional["TerminalTheme"] = None, foreground: bool = True
|
| 351 |
+
) -> ColorTriplet:
|
| 352 |
+
"""Get an equivalent color triplet for this color.
|
| 353 |
+
|
| 354 |
+
Args:
|
| 355 |
+
theme (TerminalTheme, optional): Optional terminal theme, or None to use default. Defaults to None.
|
| 356 |
+
foreground (bool, optional): True for a foreground color, or False for background. Defaults to True.
|
| 357 |
+
|
| 358 |
+
Returns:
|
| 359 |
+
ColorTriplet: A color triplet containing RGB components.
|
| 360 |
+
"""
|
| 361 |
+
|
| 362 |
+
if theme is None:
|
| 363 |
+
theme = DEFAULT_TERMINAL_THEME
|
| 364 |
+
if self.type == ColorType.TRUECOLOR:
|
| 365 |
+
assert self.triplet is not None
|
| 366 |
+
return self.triplet
|
| 367 |
+
elif self.type == ColorType.EIGHT_BIT:
|
| 368 |
+
assert self.number is not None
|
| 369 |
+
return EIGHT_BIT_PALETTE[self.number]
|
| 370 |
+
elif self.type == ColorType.STANDARD:
|
| 371 |
+
assert self.number is not None
|
| 372 |
+
return theme.ansi_colors[self.number]
|
| 373 |
+
elif self.type == ColorType.WINDOWS:
|
| 374 |
+
assert self.number is not None
|
| 375 |
+
return WINDOWS_PALETTE[self.number]
|
| 376 |
+
else: # self.type == ColorType.DEFAULT:
|
| 377 |
+
assert self.number is None
|
| 378 |
+
return theme.foreground_color if foreground else theme.background_color
|
| 379 |
+
|
| 380 |
+
@classmethod
|
| 381 |
+
def from_ansi(cls, number: int) -> "Color":
|
| 382 |
+
"""Create a Color number from it's 8-bit ansi number.
|
| 383 |
+
|
| 384 |
+
Args:
|
| 385 |
+
number (int): A number between 0-255 inclusive.
|
| 386 |
+
|
| 387 |
+
Returns:
|
| 388 |
+
Color: A new Color instance.
|
| 389 |
+
"""
|
| 390 |
+
return cls(
|
| 391 |
+
name=f"color({number})",
|
| 392 |
+
type=(ColorType.STANDARD if number < 16 else ColorType.EIGHT_BIT),
|
| 393 |
+
number=number,
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
@classmethod
|
| 397 |
+
def from_triplet(cls, triplet: "ColorTriplet") -> "Color":
|
| 398 |
+
"""Create a truecolor RGB color from a triplet of values.
|
| 399 |
+
|
| 400 |
+
Args:
|
| 401 |
+
triplet (ColorTriplet): A color triplet containing red, green and blue components.
|
| 402 |
+
|
| 403 |
+
Returns:
|
| 404 |
+
Color: A new color object.
|
| 405 |
+
"""
|
| 406 |
+
return cls(name=triplet.hex, type=ColorType.TRUECOLOR, triplet=triplet)
|
| 407 |
+
|
| 408 |
+
@classmethod
|
| 409 |
+
def from_rgb(cls, red: float, green: float, blue: float) -> "Color":
|
| 410 |
+
"""Create a truecolor from three color components in the range(0->255).
|
| 411 |
+
|
| 412 |
+
Args:
|
| 413 |
+
red (float): Red component in range 0-255.
|
| 414 |
+
green (float): Green component in range 0-255.
|
| 415 |
+
blue (float): Blue component in range 0-255.
|
| 416 |
+
|
| 417 |
+
Returns:
|
| 418 |
+
Color: A new color object.
|
| 419 |
+
"""
|
| 420 |
+
return cls.from_triplet(ColorTriplet(int(red), int(green), int(blue)))
|
| 421 |
+
|
| 422 |
+
@classmethod
|
| 423 |
+
def default(cls) -> "Color":
|
| 424 |
+
"""Get a Color instance representing the default color.
|
| 425 |
+
|
| 426 |
+
Returns:
|
| 427 |
+
Color: Default color.
|
| 428 |
+
"""
|
| 429 |
+
return cls(name="default", type=ColorType.DEFAULT)
|
| 430 |
+
|
| 431 |
+
@classmethod
|
| 432 |
+
@lru_cache(maxsize=1024)
|
| 433 |
+
def parse(cls, color: str) -> "Color":
|
| 434 |
+
"""Parse a color definition."""
|
| 435 |
+
original_color = color
|
| 436 |
+
color = color.lower().strip()
|
| 437 |
+
|
| 438 |
+
if color == "default":
|
| 439 |
+
return cls(color, type=ColorType.DEFAULT)
|
| 440 |
+
|
| 441 |
+
color_number = ANSI_COLOR_NAMES.get(color)
|
| 442 |
+
if color_number is not None:
|
| 443 |
+
return cls(
|
| 444 |
+
color,
|
| 445 |
+
type=(ColorType.STANDARD if color_number < 16 else ColorType.EIGHT_BIT),
|
| 446 |
+
number=color_number,
|
| 447 |
+
)
|
| 448 |
+
|
| 449 |
+
color_match = RE_COLOR.match(color)
|
| 450 |
+
if color_match is None:
|
| 451 |
+
raise ColorParseError(f"{original_color!r} is not a valid color")
|
| 452 |
+
|
| 453 |
+
color_24, color_8, color_rgb = color_match.groups()
|
| 454 |
+
if color_24:
|
| 455 |
+
triplet = ColorTriplet(
|
| 456 |
+
int(color_24[0:2], 16), int(color_24[2:4], 16), int(color_24[4:6], 16)
|
| 457 |
+
)
|
| 458 |
+
return cls(color, ColorType.TRUECOLOR, triplet=triplet)
|
| 459 |
+
|
| 460 |
+
elif color_8:
|
| 461 |
+
number = int(color_8)
|
| 462 |
+
if number > 255:
|
| 463 |
+
raise ColorParseError(f"color number must be <= 255 in {color!r}")
|
| 464 |
+
return cls(
|
| 465 |
+
color,
|
| 466 |
+
type=(ColorType.STANDARD if number < 16 else ColorType.EIGHT_BIT),
|
| 467 |
+
number=number,
|
| 468 |
+
)
|
| 469 |
+
|
| 470 |
+
else: # color_rgb:
|
| 471 |
+
components = color_rgb.split(",")
|
| 472 |
+
if len(components) != 3:
|
| 473 |
+
raise ColorParseError(
|
| 474 |
+
f"expected three components in {original_color!r}"
|
| 475 |
+
)
|
| 476 |
+
red, green, blue = components
|
| 477 |
+
triplet = ColorTriplet(int(red), int(green), int(blue))
|
| 478 |
+
if not all(component <= 255 for component in triplet):
|
| 479 |
+
raise ColorParseError(
|
| 480 |
+
f"color components must be <= 255 in {original_color!r}"
|
| 481 |
+
)
|
| 482 |
+
return cls(color, ColorType.TRUECOLOR, triplet=triplet)
|
| 483 |
+
|
| 484 |
+
@lru_cache(maxsize=1024)
|
| 485 |
+
def get_ansi_codes(self, foreground: bool = True) -> Tuple[str, ...]:
|
| 486 |
+
"""Get the ANSI escape codes for this color."""
|
| 487 |
+
_type = self.type
|
| 488 |
+
if _type == ColorType.DEFAULT:
|
| 489 |
+
return ("39" if foreground else "49",)
|
| 490 |
+
|
| 491 |
+
elif _type == ColorType.WINDOWS:
|
| 492 |
+
number = self.number
|
| 493 |
+
assert number is not None
|
| 494 |
+
fore, back = (30, 40) if number < 8 else (82, 92)
|
| 495 |
+
return (str(fore + number if foreground else back + number),)
|
| 496 |
+
|
| 497 |
+
elif _type == ColorType.STANDARD:
|
| 498 |
+
number = self.number
|
| 499 |
+
assert number is not None
|
| 500 |
+
fore, back = (30, 40) if number < 8 else (82, 92)
|
| 501 |
+
return (str(fore + number if foreground else back + number),)
|
| 502 |
+
|
| 503 |
+
elif _type == ColorType.EIGHT_BIT:
|
| 504 |
+
assert self.number is not None
|
| 505 |
+
return ("38" if foreground else "48", "5", str(self.number))
|
| 506 |
+
|
| 507 |
+
else: # self.standard == ColorStandard.TRUECOLOR:
|
| 508 |
+
assert self.triplet is not None
|
| 509 |
+
red, green, blue = self.triplet
|
| 510 |
+
return ("38" if foreground else "48", "2", str(red), str(green), str(blue))
|
| 511 |
+
|
| 512 |
+
@lru_cache(maxsize=1024)
|
| 513 |
+
def downgrade(self, system: ColorSystem) -> "Color":
|
| 514 |
+
"""Downgrade a color system to a system with fewer colors."""
|
| 515 |
+
|
| 516 |
+
if self.type in (ColorType.DEFAULT, system):
|
| 517 |
+
return self
|
| 518 |
+
# Convert to 8-bit color from truecolor color
|
| 519 |
+
if system == ColorSystem.EIGHT_BIT and self.system == ColorSystem.TRUECOLOR:
|
| 520 |
+
assert self.triplet is not None
|
| 521 |
+
_h, l, s = rgb_to_hls(*self.triplet.normalized)
|
| 522 |
+
# If saturation is under 15% assume it is grayscale
|
| 523 |
+
if s < 0.15:
|
| 524 |
+
gray = round(l * 25.0)
|
| 525 |
+
if gray == 0:
|
| 526 |
+
color_number = 16
|
| 527 |
+
elif gray == 25:
|
| 528 |
+
color_number = 231
|
| 529 |
+
else:
|
| 530 |
+
color_number = 231 + gray
|
| 531 |
+
return Color(self.name, ColorType.EIGHT_BIT, number=color_number)
|
| 532 |
+
|
| 533 |
+
red, green, blue = self.triplet
|
| 534 |
+
six_red = red / 95 if red < 95 else 1 + (red - 95) / 40
|
| 535 |
+
six_green = green / 95 if green < 95 else 1 + (green - 95) / 40
|
| 536 |
+
six_blue = blue / 95 if blue < 95 else 1 + (blue - 95) / 40
|
| 537 |
+
|
| 538 |
+
color_number = (
|
| 539 |
+
16 + 36 * round(six_red) + 6 * round(six_green) + round(six_blue)
|
| 540 |
+
)
|
| 541 |
+
return Color(self.name, ColorType.EIGHT_BIT, number=color_number)
|
| 542 |
+
|
| 543 |
+
# Convert to standard from truecolor or 8-bit
|
| 544 |
+
elif system == ColorSystem.STANDARD:
|
| 545 |
+
if self.system == ColorSystem.TRUECOLOR:
|
| 546 |
+
assert self.triplet is not None
|
| 547 |
+
triplet = self.triplet
|
| 548 |
+
else: # self.system == ColorSystem.EIGHT_BIT
|
| 549 |
+
assert self.number is not None
|
| 550 |
+
triplet = ColorTriplet(*EIGHT_BIT_PALETTE[self.number])
|
| 551 |
+
|
| 552 |
+
color_number = STANDARD_PALETTE.match(triplet)
|
| 553 |
+
return Color(self.name, ColorType.STANDARD, number=color_number)
|
| 554 |
+
|
| 555 |
+
elif system == ColorSystem.WINDOWS:
|
| 556 |
+
if self.system == ColorSystem.TRUECOLOR:
|
| 557 |
+
assert self.triplet is not None
|
| 558 |
+
triplet = self.triplet
|
| 559 |
+
else: # self.system == ColorSystem.EIGHT_BIT
|
| 560 |
+
assert self.number is not None
|
| 561 |
+
if self.number < 16:
|
| 562 |
+
return Color(self.name, ColorType.WINDOWS, number=self.number)
|
| 563 |
+
triplet = ColorTriplet(*EIGHT_BIT_PALETTE[self.number])
|
| 564 |
+
|
| 565 |
+
color_number = WINDOWS_PALETTE.match(triplet)
|
| 566 |
+
return Color(self.name, ColorType.WINDOWS, number=color_number)
|
| 567 |
+
|
| 568 |
+
return self
|
| 569 |
+
|
| 570 |
+
|
| 571 |
+
def parse_rgb_hex(hex_color: str) -> ColorTriplet:
|
| 572 |
+
"""Parse six hex characters in to RGB triplet."""
|
| 573 |
+
assert len(hex_color) == 6, "must be 6 characters"
|
| 574 |
+
color = ColorTriplet(
|
| 575 |
+
int(hex_color[0:2], 16), int(hex_color[2:4], 16), int(hex_color[4:6], 16)
|
| 576 |
+
)
|
| 577 |
+
return color
|
| 578 |
+
|
| 579 |
+
|
| 580 |
+
def blend_rgb(
|
| 581 |
+
color1: ColorTriplet, color2: ColorTriplet, cross_fade: float = 0.5
|
| 582 |
+
) -> ColorTriplet:
|
| 583 |
+
"""Blend one RGB color in to another."""
|
| 584 |
+
r1, g1, b1 = color1
|
| 585 |
+
r2, g2, b2 = color2
|
| 586 |
+
new_color = ColorTriplet(
|
| 587 |
+
int(r1 + (r2 - r1) * cross_fade),
|
| 588 |
+
int(g1 + (g2 - g1) * cross_fade),
|
| 589 |
+
int(b1 + (b2 - b1) * cross_fade),
|
| 590 |
+
)
|
| 591 |
+
return new_color
|
| 592 |
+
|
| 593 |
+
|
| 594 |
+
if __name__ == "__main__": # pragma: no cover
|
| 595 |
+
from .console import Console
|
| 596 |
+
from .table import Table
|
| 597 |
+
from .text import Text
|
| 598 |
+
|
| 599 |
+
console = Console()
|
| 600 |
+
|
| 601 |
+
table = Table(show_footer=False, show_edge=True)
|
| 602 |
+
table.add_column("Color", width=10, overflow="ellipsis")
|
| 603 |
+
table.add_column("Number", justify="right", style="yellow")
|
| 604 |
+
table.add_column("Name", style="green")
|
| 605 |
+
table.add_column("Hex", style="blue")
|
| 606 |
+
table.add_column("RGB", style="magenta")
|
| 607 |
+
|
| 608 |
+
colors = sorted((v, k) for k, v in ANSI_COLOR_NAMES.items())
|
| 609 |
+
for color_number, name in colors:
|
| 610 |
+
if "grey" in name:
|
| 611 |
+
continue
|
| 612 |
+
color_cell = Text(" " * 10, style=f"on {name}")
|
| 613 |
+
if color_number < 16:
|
| 614 |
+
table.add_row(color_cell, f"{color_number}", Text(f'"{name}"'))
|
| 615 |
+
else:
|
| 616 |
+
color = EIGHT_BIT_PALETTE[color_number] # type: ignore[has-type]
|
| 617 |
+
table.add_row(
|
| 618 |
+
color_cell, str(color_number), Text(f'"{name}"'), color.hex, color.rgb
|
| 619 |
+
)
|
| 620 |
+
|
| 621 |
+
console.print(table)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/color_triplet.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import NamedTuple, Tuple
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class ColorTriplet(NamedTuple):
|
| 5 |
+
"""The red, green, and blue components of a color."""
|
| 6 |
+
|
| 7 |
+
red: int
|
| 8 |
+
"""Red component in 0 to 255 range."""
|
| 9 |
+
green: int
|
| 10 |
+
"""Green component in 0 to 255 range."""
|
| 11 |
+
blue: int
|
| 12 |
+
"""Blue component in 0 to 255 range."""
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def hex(self) -> str:
|
| 16 |
+
"""get the color triplet in CSS style."""
|
| 17 |
+
red, green, blue = self
|
| 18 |
+
return f"#{red:02x}{green:02x}{blue:02x}"
|
| 19 |
+
|
| 20 |
+
@property
|
| 21 |
+
def rgb(self) -> str:
|
| 22 |
+
"""The color in RGB format.
|
| 23 |
+
|
| 24 |
+
Returns:
|
| 25 |
+
str: An rgb color, e.g. ``"rgb(100,23,255)"``.
|
| 26 |
+
"""
|
| 27 |
+
red, green, blue = self
|
| 28 |
+
return f"rgb({red},{green},{blue})"
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def normalized(self) -> Tuple[float, float, float]:
|
| 32 |
+
"""Convert components into floats between 0 and 1.
|
| 33 |
+
|
| 34 |
+
Returns:
|
| 35 |
+
Tuple[float, float, float]: A tuple of three normalized colour components.
|
| 36 |
+
"""
|
| 37 |
+
red, green, blue = self
|
| 38 |
+
return red / 255.0, green / 255.0, blue / 255.0
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/columns.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections import defaultdict
|
| 2 |
+
from itertools import chain
|
| 3 |
+
from operator import itemgetter
|
| 4 |
+
from typing import Dict, Iterable, List, Optional, Tuple
|
| 5 |
+
|
| 6 |
+
from .align import Align, AlignMethod
|
| 7 |
+
from .console import Console, ConsoleOptions, RenderableType, RenderResult
|
| 8 |
+
from .constrain import Constrain
|
| 9 |
+
from .measure import Measurement
|
| 10 |
+
from .padding import Padding, PaddingDimensions
|
| 11 |
+
from .table import Table
|
| 12 |
+
from .text import TextType
|
| 13 |
+
from .jupyter import JupyterMixin
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class Columns(JupyterMixin):
|
| 17 |
+
"""Display renderables in neat columns.
|
| 18 |
+
|
| 19 |
+
Args:
|
| 20 |
+
renderables (Iterable[RenderableType]): Any number of Rich renderables (including str).
|
| 21 |
+
width (int, optional): The desired width of the columns, or None to auto detect. Defaults to None.
|
| 22 |
+
padding (PaddingDimensions, optional): Optional padding around cells. Defaults to (0, 1).
|
| 23 |
+
expand (bool, optional): Expand columns to full width. Defaults to False.
|
| 24 |
+
equal (bool, optional): Arrange in to equal sized columns. Defaults to False.
|
| 25 |
+
column_first (bool, optional): Align items from top to bottom (rather than left to right). Defaults to False.
|
| 26 |
+
right_to_left (bool, optional): Start column from right hand side. Defaults to False.
|
| 27 |
+
align (str, optional): Align value ("left", "right", or "center") or None for default. Defaults to None.
|
| 28 |
+
title (TextType, optional): Optional title for Columns.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
def __init__(
|
| 32 |
+
self,
|
| 33 |
+
renderables: Optional[Iterable[RenderableType]] = None,
|
| 34 |
+
padding: PaddingDimensions = (0, 1),
|
| 35 |
+
*,
|
| 36 |
+
width: Optional[int] = None,
|
| 37 |
+
expand: bool = False,
|
| 38 |
+
equal: bool = False,
|
| 39 |
+
column_first: bool = False,
|
| 40 |
+
right_to_left: bool = False,
|
| 41 |
+
align: Optional[AlignMethod] = None,
|
| 42 |
+
title: Optional[TextType] = None,
|
| 43 |
+
) -> None:
|
| 44 |
+
self.renderables = list(renderables or [])
|
| 45 |
+
self.width = width
|
| 46 |
+
self.padding = padding
|
| 47 |
+
self.expand = expand
|
| 48 |
+
self.equal = equal
|
| 49 |
+
self.column_first = column_first
|
| 50 |
+
self.right_to_left = right_to_left
|
| 51 |
+
self.align: Optional[AlignMethod] = align
|
| 52 |
+
self.title = title
|
| 53 |
+
|
| 54 |
+
def add_renderable(self, renderable: RenderableType) -> None:
|
| 55 |
+
"""Add a renderable to the columns.
|
| 56 |
+
|
| 57 |
+
Args:
|
| 58 |
+
renderable (RenderableType): Any renderable object.
|
| 59 |
+
"""
|
| 60 |
+
self.renderables.append(renderable)
|
| 61 |
+
|
| 62 |
+
def __rich_console__(
|
| 63 |
+
self, console: Console, options: ConsoleOptions
|
| 64 |
+
) -> RenderResult:
|
| 65 |
+
render_str = console.render_str
|
| 66 |
+
renderables = [
|
| 67 |
+
render_str(renderable) if isinstance(renderable, str) else renderable
|
| 68 |
+
for renderable in self.renderables
|
| 69 |
+
]
|
| 70 |
+
if not renderables:
|
| 71 |
+
return
|
| 72 |
+
_top, right, _bottom, left = Padding.unpack(self.padding)
|
| 73 |
+
width_padding = max(left, right)
|
| 74 |
+
max_width = options.max_width
|
| 75 |
+
widths: Dict[int, int] = defaultdict(int)
|
| 76 |
+
column_count = len(renderables)
|
| 77 |
+
|
| 78 |
+
get_measurement = Measurement.get
|
| 79 |
+
renderable_widths = [
|
| 80 |
+
get_measurement(console, options, renderable).maximum
|
| 81 |
+
for renderable in renderables
|
| 82 |
+
]
|
| 83 |
+
if self.equal:
|
| 84 |
+
renderable_widths = [max(renderable_widths)] * len(renderable_widths)
|
| 85 |
+
|
| 86 |
+
def iter_renderables(
|
| 87 |
+
column_count: int,
|
| 88 |
+
) -> Iterable[Tuple[int, Optional[RenderableType]]]:
|
| 89 |
+
item_count = len(renderables)
|
| 90 |
+
if self.column_first:
|
| 91 |
+
width_renderables = list(zip(renderable_widths, renderables))
|
| 92 |
+
|
| 93 |
+
column_lengths: List[int] = [item_count // column_count] * column_count
|
| 94 |
+
for col_no in range(item_count % column_count):
|
| 95 |
+
column_lengths[col_no] += 1
|
| 96 |
+
|
| 97 |
+
row_count = (item_count + column_count - 1) // column_count
|
| 98 |
+
cells = [[-1] * column_count for _ in range(row_count)]
|
| 99 |
+
row = col = 0
|
| 100 |
+
for index in range(item_count):
|
| 101 |
+
cells[row][col] = index
|
| 102 |
+
column_lengths[col] -= 1
|
| 103 |
+
if column_lengths[col]:
|
| 104 |
+
row += 1
|
| 105 |
+
else:
|
| 106 |
+
col += 1
|
| 107 |
+
row = 0
|
| 108 |
+
for index in chain.from_iterable(cells):
|
| 109 |
+
if index == -1:
|
| 110 |
+
break
|
| 111 |
+
yield width_renderables[index]
|
| 112 |
+
else:
|
| 113 |
+
yield from zip(renderable_widths, renderables)
|
| 114 |
+
# Pad odd elements with spaces
|
| 115 |
+
if item_count % column_count:
|
| 116 |
+
for _ in range(column_count - (item_count % column_count)):
|
| 117 |
+
yield 0, None
|
| 118 |
+
|
| 119 |
+
table = Table.grid(padding=self.padding, collapse_padding=True, pad_edge=False)
|
| 120 |
+
table.expand = self.expand
|
| 121 |
+
table.title = self.title
|
| 122 |
+
|
| 123 |
+
if self.width is not None:
|
| 124 |
+
column_count = (max_width) // (self.width + width_padding)
|
| 125 |
+
for _ in range(column_count):
|
| 126 |
+
table.add_column(width=self.width)
|
| 127 |
+
else:
|
| 128 |
+
while column_count > 1:
|
| 129 |
+
widths.clear()
|
| 130 |
+
column_no = 0
|
| 131 |
+
for renderable_width, _ in iter_renderables(column_count):
|
| 132 |
+
widths[column_no] = max(widths[column_no], renderable_width)
|
| 133 |
+
total_width = sum(widths.values()) + width_padding * (
|
| 134 |
+
len(widths) - 1
|
| 135 |
+
)
|
| 136 |
+
if total_width > max_width:
|
| 137 |
+
column_count = len(widths) - 1
|
| 138 |
+
break
|
| 139 |
+
else:
|
| 140 |
+
column_no = (column_no + 1) % column_count
|
| 141 |
+
else:
|
| 142 |
+
break
|
| 143 |
+
|
| 144 |
+
get_renderable = itemgetter(1)
|
| 145 |
+
_renderables = [
|
| 146 |
+
get_renderable(_renderable)
|
| 147 |
+
for _renderable in iter_renderables(column_count)
|
| 148 |
+
]
|
| 149 |
+
if self.equal:
|
| 150 |
+
_renderables = [
|
| 151 |
+
None
|
| 152 |
+
if renderable is None
|
| 153 |
+
else Constrain(renderable, renderable_widths[0])
|
| 154 |
+
for renderable in _renderables
|
| 155 |
+
]
|
| 156 |
+
if self.align:
|
| 157 |
+
align = self.align
|
| 158 |
+
_Align = Align
|
| 159 |
+
_renderables = [
|
| 160 |
+
None if renderable is None else _Align(renderable, align)
|
| 161 |
+
for renderable in _renderables
|
| 162 |
+
]
|
| 163 |
+
|
| 164 |
+
right_to_left = self.right_to_left
|
| 165 |
+
add_row = table.add_row
|
| 166 |
+
for start in range(0, len(_renderables), column_count):
|
| 167 |
+
row = _renderables[start : start + column_count]
|
| 168 |
+
if right_to_left:
|
| 169 |
+
row = row[::-1]
|
| 170 |
+
add_row(*row)
|
| 171 |
+
yield table
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
if __name__ == "__main__": # pragma: no cover
|
| 175 |
+
import os
|
| 176 |
+
|
| 177 |
+
console = Console()
|
| 178 |
+
|
| 179 |
+
files = [f"{i} {s}" for i, s in enumerate(sorted(os.listdir()))]
|
| 180 |
+
columns = Columns(files, padding=(0, 1), expand=False, equal=False)
|
| 181 |
+
console.print(columns)
|
| 182 |
+
console.rule()
|
| 183 |
+
columns.column_first = True
|
| 184 |
+
console.print(columns)
|
| 185 |
+
columns.right_to_left = True
|
| 186 |
+
console.rule()
|
| 187 |
+
console.print(columns)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/console.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/constrain.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, TYPE_CHECKING
|
| 2 |
+
|
| 3 |
+
from .jupyter import JupyterMixin
|
| 4 |
+
from .measure import Measurement
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from .console import Console, ConsoleOptions, RenderableType, RenderResult
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class Constrain(JupyterMixin):
|
| 11 |
+
"""Constrain the width of a renderable to a given number of characters.
|
| 12 |
+
|
| 13 |
+
Args:
|
| 14 |
+
renderable (RenderableType): A renderable object.
|
| 15 |
+
width (int, optional): The maximum width (in characters) to render. Defaults to 80.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
def __init__(self, renderable: "RenderableType", width: Optional[int] = 80) -> None:
|
| 19 |
+
self.renderable = renderable
|
| 20 |
+
self.width = width
|
| 21 |
+
|
| 22 |
+
def __rich_console__(
|
| 23 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 24 |
+
) -> "RenderResult":
|
| 25 |
+
if self.width is None:
|
| 26 |
+
yield self.renderable
|
| 27 |
+
else:
|
| 28 |
+
child_options = options.update_width(min(self.width, options.max_width))
|
| 29 |
+
yield from console.render(self.renderable, child_options)
|
| 30 |
+
|
| 31 |
+
def __rich_measure__(
|
| 32 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 33 |
+
) -> "Measurement":
|
| 34 |
+
if self.width is not None:
|
| 35 |
+
options = options.update_width(self.width)
|
| 36 |
+
measurement = Measurement.get(console, options, self.renderable)
|
| 37 |
+
return measurement
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/containers.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from itertools import zip_longest
|
| 2 |
+
from typing import (
|
| 3 |
+
TYPE_CHECKING,
|
| 4 |
+
Iterable,
|
| 5 |
+
Iterator,
|
| 6 |
+
List,
|
| 7 |
+
Optional,
|
| 8 |
+
TypeVar,
|
| 9 |
+
Union,
|
| 10 |
+
overload,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
if TYPE_CHECKING:
|
| 14 |
+
from .console import (
|
| 15 |
+
Console,
|
| 16 |
+
ConsoleOptions,
|
| 17 |
+
JustifyMethod,
|
| 18 |
+
OverflowMethod,
|
| 19 |
+
RenderResult,
|
| 20 |
+
RenderableType,
|
| 21 |
+
)
|
| 22 |
+
from .text import Text
|
| 23 |
+
|
| 24 |
+
from .cells import cell_len
|
| 25 |
+
from .measure import Measurement
|
| 26 |
+
|
| 27 |
+
T = TypeVar("T")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Renderables:
|
| 31 |
+
"""A list subclass which renders its contents to the console."""
|
| 32 |
+
|
| 33 |
+
def __init__(
|
| 34 |
+
self, renderables: Optional[Iterable["RenderableType"]] = None
|
| 35 |
+
) -> None:
|
| 36 |
+
self._renderables: List["RenderableType"] = (
|
| 37 |
+
list(renderables) if renderables is not None else []
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
def __rich_console__(
|
| 41 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 42 |
+
) -> "RenderResult":
|
| 43 |
+
"""Console render method to insert line-breaks."""
|
| 44 |
+
yield from self._renderables
|
| 45 |
+
|
| 46 |
+
def __rich_measure__(
|
| 47 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 48 |
+
) -> "Measurement":
|
| 49 |
+
dimensions = [
|
| 50 |
+
Measurement.get(console, options, renderable)
|
| 51 |
+
for renderable in self._renderables
|
| 52 |
+
]
|
| 53 |
+
if not dimensions:
|
| 54 |
+
return Measurement(1, 1)
|
| 55 |
+
_min = max(dimension.minimum for dimension in dimensions)
|
| 56 |
+
_max = max(dimension.maximum for dimension in dimensions)
|
| 57 |
+
return Measurement(_min, _max)
|
| 58 |
+
|
| 59 |
+
def append(self, renderable: "RenderableType") -> None:
|
| 60 |
+
self._renderables.append(renderable)
|
| 61 |
+
|
| 62 |
+
def __iter__(self) -> Iterable["RenderableType"]:
|
| 63 |
+
return iter(self._renderables)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class Lines:
|
| 67 |
+
"""A list subclass which can render to the console."""
|
| 68 |
+
|
| 69 |
+
def __init__(self, lines: Iterable["Text"] = ()) -> None:
|
| 70 |
+
self._lines: List["Text"] = list(lines)
|
| 71 |
+
|
| 72 |
+
def __repr__(self) -> str:
|
| 73 |
+
return f"Lines({self._lines!r})"
|
| 74 |
+
|
| 75 |
+
def __iter__(self) -> Iterator["Text"]:
|
| 76 |
+
return iter(self._lines)
|
| 77 |
+
|
| 78 |
+
@overload
|
| 79 |
+
def __getitem__(self, index: int) -> "Text":
|
| 80 |
+
...
|
| 81 |
+
|
| 82 |
+
@overload
|
| 83 |
+
def __getitem__(self, index: slice) -> List["Text"]:
|
| 84 |
+
...
|
| 85 |
+
|
| 86 |
+
def __getitem__(self, index: Union[slice, int]) -> Union["Text", List["Text"]]:
|
| 87 |
+
return self._lines[index]
|
| 88 |
+
|
| 89 |
+
def __setitem__(self, index: int, value: "Text") -> "Lines":
|
| 90 |
+
self._lines[index] = value
|
| 91 |
+
return self
|
| 92 |
+
|
| 93 |
+
def __len__(self) -> int:
|
| 94 |
+
return self._lines.__len__()
|
| 95 |
+
|
| 96 |
+
def __rich_console__(
|
| 97 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 98 |
+
) -> "RenderResult":
|
| 99 |
+
"""Console render method to insert line-breaks."""
|
| 100 |
+
yield from self._lines
|
| 101 |
+
|
| 102 |
+
def append(self, line: "Text") -> None:
|
| 103 |
+
self._lines.append(line)
|
| 104 |
+
|
| 105 |
+
def extend(self, lines: Iterable["Text"]) -> None:
|
| 106 |
+
self._lines.extend(lines)
|
| 107 |
+
|
| 108 |
+
def pop(self, index: int = -1) -> "Text":
|
| 109 |
+
return self._lines.pop(index)
|
| 110 |
+
|
| 111 |
+
def justify(
|
| 112 |
+
self,
|
| 113 |
+
console: "Console",
|
| 114 |
+
width: int,
|
| 115 |
+
justify: "JustifyMethod" = "left",
|
| 116 |
+
overflow: "OverflowMethod" = "fold",
|
| 117 |
+
) -> None:
|
| 118 |
+
"""Justify and overflow text to a given width.
|
| 119 |
+
|
| 120 |
+
Args:
|
| 121 |
+
console (Console): Console instance.
|
| 122 |
+
width (int): Number of cells available per line.
|
| 123 |
+
justify (str, optional): Default justify method for text: "left", "center", "full" or "right". Defaults to "left".
|
| 124 |
+
overflow (str, optional): Default overflow for text: "crop", "fold", or "ellipsis". Defaults to "fold".
|
| 125 |
+
|
| 126 |
+
"""
|
| 127 |
+
from .text import Text
|
| 128 |
+
|
| 129 |
+
if justify == "left":
|
| 130 |
+
for line in self._lines:
|
| 131 |
+
line.truncate(width, overflow=overflow, pad=True)
|
| 132 |
+
elif justify == "center":
|
| 133 |
+
for line in self._lines:
|
| 134 |
+
line.rstrip()
|
| 135 |
+
line.truncate(width, overflow=overflow)
|
| 136 |
+
line.pad_left((width - cell_len(line.plain)) // 2)
|
| 137 |
+
line.pad_right(width - cell_len(line.plain))
|
| 138 |
+
elif justify == "right":
|
| 139 |
+
for line in self._lines:
|
| 140 |
+
line.rstrip()
|
| 141 |
+
line.truncate(width, overflow=overflow)
|
| 142 |
+
line.pad_left(width - cell_len(line.plain))
|
| 143 |
+
elif justify == "full":
|
| 144 |
+
for line_index, line in enumerate(self._lines):
|
| 145 |
+
if line_index == len(self._lines) - 1:
|
| 146 |
+
break
|
| 147 |
+
words = line.split(" ")
|
| 148 |
+
words_size = sum(cell_len(word.plain) for word in words)
|
| 149 |
+
num_spaces = len(words) - 1
|
| 150 |
+
spaces = [1 for _ in range(num_spaces)]
|
| 151 |
+
index = 0
|
| 152 |
+
if spaces:
|
| 153 |
+
while words_size + num_spaces < width:
|
| 154 |
+
spaces[len(spaces) - index - 1] += 1
|
| 155 |
+
num_spaces += 1
|
| 156 |
+
index = (index + 1) % len(spaces)
|
| 157 |
+
tokens: List[Text] = []
|
| 158 |
+
for index, (word, next_word) in enumerate(
|
| 159 |
+
zip_longest(words, words[1:])
|
| 160 |
+
):
|
| 161 |
+
tokens.append(word)
|
| 162 |
+
if index < len(spaces):
|
| 163 |
+
style = word.get_style_at_offset(console, -1)
|
| 164 |
+
next_style = next_word.get_style_at_offset(console, 0)
|
| 165 |
+
space_style = style if style == next_style else line.style
|
| 166 |
+
tokens.append(Text(" " * spaces[index], style=space_style))
|
| 167 |
+
self[line_index] = Text("").join(tokens)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/control.py
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Union, Final
|
| 3 |
+
|
| 4 |
+
from .segment import ControlCode, ControlType, Segment
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from .console import Console, ConsoleOptions, RenderResult
|
| 8 |
+
|
| 9 |
+
STRIP_CONTROL_CODES: Final = [
|
| 10 |
+
7, # Bell
|
| 11 |
+
8, # Backspace
|
| 12 |
+
11, # Vertical tab
|
| 13 |
+
12, # Form feed
|
| 14 |
+
13, # Carriage return
|
| 15 |
+
]
|
| 16 |
+
_CONTROL_STRIP_TRANSLATE: Final = {
|
| 17 |
+
_codepoint: None for _codepoint in STRIP_CONTROL_CODES
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
CONTROL_ESCAPE: Final = {
|
| 21 |
+
7: "\\a",
|
| 22 |
+
8: "\\b",
|
| 23 |
+
11: "\\v",
|
| 24 |
+
12: "\\f",
|
| 25 |
+
13: "\\r",
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
CONTROL_CODES_FORMAT: Dict[int, Callable[..., str]] = {
|
| 29 |
+
ControlType.BELL: lambda: "\x07",
|
| 30 |
+
ControlType.CARRIAGE_RETURN: lambda: "\r",
|
| 31 |
+
ControlType.HOME: lambda: "\x1b[H",
|
| 32 |
+
ControlType.CLEAR: lambda: "\x1b[2J",
|
| 33 |
+
ControlType.ENABLE_ALT_SCREEN: lambda: "\x1b[?1049h",
|
| 34 |
+
ControlType.DISABLE_ALT_SCREEN: lambda: "\x1b[?1049l",
|
| 35 |
+
ControlType.SHOW_CURSOR: lambda: "\x1b[?25h",
|
| 36 |
+
ControlType.HIDE_CURSOR: lambda: "\x1b[?25l",
|
| 37 |
+
ControlType.CURSOR_UP: lambda param: f"\x1b[{param}A",
|
| 38 |
+
ControlType.CURSOR_DOWN: lambda param: f"\x1b[{param}B",
|
| 39 |
+
ControlType.CURSOR_FORWARD: lambda param: f"\x1b[{param}C",
|
| 40 |
+
ControlType.CURSOR_BACKWARD: lambda param: f"\x1b[{param}D",
|
| 41 |
+
ControlType.CURSOR_MOVE_TO_COLUMN: lambda param: f"\x1b[{param+1}G",
|
| 42 |
+
ControlType.ERASE_IN_LINE: lambda param: f"\x1b[{param}K",
|
| 43 |
+
ControlType.CURSOR_MOVE_TO: lambda x, y: f"\x1b[{y+1};{x+1}H",
|
| 44 |
+
ControlType.SET_WINDOW_TITLE: lambda title: f"\x1b]0;{title}\x07",
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class Control:
|
| 49 |
+
"""A renderable that inserts a control code (non printable but may move cursor).
|
| 50 |
+
|
| 51 |
+
Args:
|
| 52 |
+
*codes (str): Positional arguments are either a :class:`~rich.segment.ControlType` enum or a
|
| 53 |
+
tuple of ControlType and an integer parameter
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
__slots__ = ["segment"]
|
| 57 |
+
|
| 58 |
+
def __init__(self, *codes: Union[ControlType, ControlCode]) -> None:
|
| 59 |
+
control_codes: List[ControlCode] = [
|
| 60 |
+
(code,) if isinstance(code, ControlType) else code for code in codes
|
| 61 |
+
]
|
| 62 |
+
_format_map = CONTROL_CODES_FORMAT
|
| 63 |
+
rendered_codes = "".join(
|
| 64 |
+
_format_map[code](*parameters) for code, *parameters in control_codes
|
| 65 |
+
)
|
| 66 |
+
self.segment = Segment(rendered_codes, None, control_codes)
|
| 67 |
+
|
| 68 |
+
@classmethod
|
| 69 |
+
def bell(cls) -> "Control":
|
| 70 |
+
"""Ring the 'bell'."""
|
| 71 |
+
return cls(ControlType.BELL)
|
| 72 |
+
|
| 73 |
+
@classmethod
|
| 74 |
+
def home(cls) -> "Control":
|
| 75 |
+
"""Move cursor to 'home' position."""
|
| 76 |
+
return cls(ControlType.HOME)
|
| 77 |
+
|
| 78 |
+
@classmethod
|
| 79 |
+
def move(cls, x: int = 0, y: int = 0) -> "Control":
|
| 80 |
+
"""Move cursor relative to current position.
|
| 81 |
+
|
| 82 |
+
Args:
|
| 83 |
+
x (int): X offset.
|
| 84 |
+
y (int): Y offset.
|
| 85 |
+
|
| 86 |
+
Returns:
|
| 87 |
+
~Control: Control object.
|
| 88 |
+
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
+
def get_codes() -> Iterable[ControlCode]:
|
| 92 |
+
control = ControlType
|
| 93 |
+
if x:
|
| 94 |
+
yield (
|
| 95 |
+
control.CURSOR_FORWARD if x > 0 else control.CURSOR_BACKWARD,
|
| 96 |
+
abs(x),
|
| 97 |
+
)
|
| 98 |
+
if y:
|
| 99 |
+
yield (
|
| 100 |
+
control.CURSOR_DOWN if y > 0 else control.CURSOR_UP,
|
| 101 |
+
abs(y),
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
control = cls(*get_codes())
|
| 105 |
+
return control
|
| 106 |
+
|
| 107 |
+
@classmethod
|
| 108 |
+
def move_to_column(cls, x: int, y: int = 0) -> "Control":
|
| 109 |
+
"""Move to the given column, optionally add offset to row.
|
| 110 |
+
|
| 111 |
+
Returns:
|
| 112 |
+
x (int): absolute x (column)
|
| 113 |
+
y (int): optional y offset (row)
|
| 114 |
+
|
| 115 |
+
Returns:
|
| 116 |
+
~Control: Control object.
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
return (
|
| 120 |
+
cls(
|
| 121 |
+
(ControlType.CURSOR_MOVE_TO_COLUMN, x),
|
| 122 |
+
(
|
| 123 |
+
ControlType.CURSOR_DOWN if y > 0 else ControlType.CURSOR_UP,
|
| 124 |
+
abs(y),
|
| 125 |
+
),
|
| 126 |
+
)
|
| 127 |
+
if y
|
| 128 |
+
else cls((ControlType.CURSOR_MOVE_TO_COLUMN, x))
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
@classmethod
|
| 132 |
+
def move_to(cls, x: int, y: int) -> "Control":
|
| 133 |
+
"""Move cursor to absolute position.
|
| 134 |
+
|
| 135 |
+
Args:
|
| 136 |
+
x (int): x offset (column)
|
| 137 |
+
y (int): y offset (row)
|
| 138 |
+
|
| 139 |
+
Returns:
|
| 140 |
+
~Control: Control object.
|
| 141 |
+
"""
|
| 142 |
+
return cls((ControlType.CURSOR_MOVE_TO, x, y))
|
| 143 |
+
|
| 144 |
+
@classmethod
|
| 145 |
+
def clear(cls) -> "Control":
|
| 146 |
+
"""Clear the screen."""
|
| 147 |
+
return cls(ControlType.CLEAR)
|
| 148 |
+
|
| 149 |
+
@classmethod
|
| 150 |
+
def show_cursor(cls, show: bool) -> "Control":
|
| 151 |
+
"""Show or hide the cursor."""
|
| 152 |
+
return cls(ControlType.SHOW_CURSOR if show else ControlType.HIDE_CURSOR)
|
| 153 |
+
|
| 154 |
+
@classmethod
|
| 155 |
+
def alt_screen(cls, enable: bool) -> "Control":
|
| 156 |
+
"""Enable or disable alt screen."""
|
| 157 |
+
if enable:
|
| 158 |
+
return cls(ControlType.ENABLE_ALT_SCREEN, ControlType.HOME)
|
| 159 |
+
else:
|
| 160 |
+
return cls(ControlType.DISABLE_ALT_SCREEN)
|
| 161 |
+
|
| 162 |
+
@classmethod
|
| 163 |
+
def title(cls, title: str) -> "Control":
|
| 164 |
+
"""Set the terminal window title
|
| 165 |
+
|
| 166 |
+
Args:
|
| 167 |
+
title (str): The new terminal window title
|
| 168 |
+
"""
|
| 169 |
+
return cls((ControlType.SET_WINDOW_TITLE, title))
|
| 170 |
+
|
| 171 |
+
def __str__(self) -> str:
|
| 172 |
+
return self.segment.text
|
| 173 |
+
|
| 174 |
+
def __rich_console__(
|
| 175 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 176 |
+
) -> "RenderResult":
|
| 177 |
+
if self.segment.text:
|
| 178 |
+
yield self.segment
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def strip_control_codes(
|
| 182 |
+
text: str, _translate_table: Dict[int, None] = _CONTROL_STRIP_TRANSLATE
|
| 183 |
+
) -> str:
|
| 184 |
+
"""Remove control codes from text.
|
| 185 |
+
|
| 186 |
+
Args:
|
| 187 |
+
text (str): A string possibly contain control codes.
|
| 188 |
+
|
| 189 |
+
Returns:
|
| 190 |
+
str: String with control codes removed.
|
| 191 |
+
"""
|
| 192 |
+
return text.translate(_translate_table)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def escape_control_codes(
|
| 196 |
+
text: str,
|
| 197 |
+
_translate_table: Dict[int, str] = CONTROL_ESCAPE,
|
| 198 |
+
) -> str:
|
| 199 |
+
"""Replace control codes with their "escaped" equivalent in the given text.
|
| 200 |
+
(e.g. "\b" becomes "\\b")
|
| 201 |
+
|
| 202 |
+
Args:
|
| 203 |
+
text (str): A string possibly containing control codes.
|
| 204 |
+
|
| 205 |
+
Returns:
|
| 206 |
+
str: String with control codes replaced with their escaped version.
|
| 207 |
+
"""
|
| 208 |
+
return text.translate(_translate_table)
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
if __name__ == "__main__": # pragma: no cover
|
| 212 |
+
from rich.console import Console
|
| 213 |
+
|
| 214 |
+
console = Console()
|
| 215 |
+
console.print("Look at the title of your terminal window ^")
|
| 216 |
+
# console.print(Control((ControlType.SET_WINDOW_TITLE, "Hello, world!")))
|
| 217 |
+
for i in range(10):
|
| 218 |
+
console.set_window_title("🚀 Loading" + "." * i)
|
| 219 |
+
time.sleep(0.5)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/default_styles.py
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict
|
| 2 |
+
|
| 3 |
+
from .style import Style
|
| 4 |
+
|
| 5 |
+
DEFAULT_STYLES: Dict[str, Style] = {
|
| 6 |
+
"none": Style.null(),
|
| 7 |
+
"reset": Style(
|
| 8 |
+
color="default",
|
| 9 |
+
bgcolor="default",
|
| 10 |
+
dim=False,
|
| 11 |
+
bold=False,
|
| 12 |
+
italic=False,
|
| 13 |
+
underline=False,
|
| 14 |
+
blink=False,
|
| 15 |
+
blink2=False,
|
| 16 |
+
reverse=False,
|
| 17 |
+
conceal=False,
|
| 18 |
+
strike=False,
|
| 19 |
+
),
|
| 20 |
+
"dim": Style(dim=True),
|
| 21 |
+
"bright": Style(dim=False),
|
| 22 |
+
"bold": Style(bold=True),
|
| 23 |
+
"strong": Style(bold=True),
|
| 24 |
+
"code": Style(reverse=True, bold=True),
|
| 25 |
+
"italic": Style(italic=True),
|
| 26 |
+
"emphasize": Style(italic=True),
|
| 27 |
+
"underline": Style(underline=True),
|
| 28 |
+
"blink": Style(blink=True),
|
| 29 |
+
"blink2": Style(blink2=True),
|
| 30 |
+
"reverse": Style(reverse=True),
|
| 31 |
+
"strike": Style(strike=True),
|
| 32 |
+
"black": Style(color="black"),
|
| 33 |
+
"red": Style(color="red"),
|
| 34 |
+
"green": Style(color="green"),
|
| 35 |
+
"yellow": Style(color="yellow"),
|
| 36 |
+
"magenta": Style(color="magenta"),
|
| 37 |
+
"cyan": Style(color="cyan"),
|
| 38 |
+
"white": Style(color="white"),
|
| 39 |
+
"inspect.attr": Style(color="yellow", italic=True),
|
| 40 |
+
"inspect.attr.dunder": Style(color="yellow", italic=True, dim=True),
|
| 41 |
+
"inspect.callable": Style(bold=True, color="red"),
|
| 42 |
+
"inspect.async_def": Style(italic=True, color="bright_cyan"),
|
| 43 |
+
"inspect.def": Style(italic=True, color="bright_cyan"),
|
| 44 |
+
"inspect.class": Style(italic=True, color="bright_cyan"),
|
| 45 |
+
"inspect.error": Style(bold=True, color="red"),
|
| 46 |
+
"inspect.equals": Style(),
|
| 47 |
+
"inspect.help": Style(color="cyan"),
|
| 48 |
+
"inspect.doc": Style(dim=True),
|
| 49 |
+
"inspect.value.border": Style(color="green"),
|
| 50 |
+
"live.ellipsis": Style(bold=True, color="red"),
|
| 51 |
+
"layout.tree.row": Style(dim=False, color="red"),
|
| 52 |
+
"layout.tree.column": Style(dim=False, color="blue"),
|
| 53 |
+
"logging.keyword": Style(bold=True, color="yellow"),
|
| 54 |
+
"logging.level.notset": Style(dim=True),
|
| 55 |
+
"logging.level.debug": Style(color="green"),
|
| 56 |
+
"logging.level.info": Style(color="blue"),
|
| 57 |
+
"logging.level.warning": Style(color="yellow"),
|
| 58 |
+
"logging.level.error": Style(color="red", bold=True),
|
| 59 |
+
"logging.level.critical": Style(color="red", bold=True, reverse=True),
|
| 60 |
+
"log.level": Style.null(),
|
| 61 |
+
"log.time": Style(color="cyan", dim=True),
|
| 62 |
+
"log.message": Style.null(),
|
| 63 |
+
"log.path": Style(dim=True),
|
| 64 |
+
"repr.ellipsis": Style(color="yellow"),
|
| 65 |
+
"repr.indent": Style(color="green", dim=True),
|
| 66 |
+
"repr.error": Style(color="red", bold=True),
|
| 67 |
+
"repr.str": Style(color="green", italic=False, bold=False),
|
| 68 |
+
"repr.brace": Style(bold=True),
|
| 69 |
+
"repr.comma": Style(bold=True),
|
| 70 |
+
"repr.ipv4": Style(bold=True, color="bright_green"),
|
| 71 |
+
"repr.ipv6": Style(bold=True, color="bright_green"),
|
| 72 |
+
"repr.eui48": Style(bold=True, color="bright_green"),
|
| 73 |
+
"repr.eui64": Style(bold=True, color="bright_green"),
|
| 74 |
+
"repr.tag_start": Style(bold=True),
|
| 75 |
+
"repr.tag_name": Style(color="bright_magenta", bold=True),
|
| 76 |
+
"repr.tag_contents": Style(color="default"),
|
| 77 |
+
"repr.tag_end": Style(bold=True),
|
| 78 |
+
"repr.attrib_name": Style(color="yellow", italic=False),
|
| 79 |
+
"repr.attrib_equal": Style(bold=True),
|
| 80 |
+
"repr.attrib_value": Style(color="magenta", italic=False),
|
| 81 |
+
"repr.number": Style(color="cyan", bold=True, italic=False),
|
| 82 |
+
"repr.number_complex": Style(color="cyan", bold=True, italic=False), # same
|
| 83 |
+
"repr.bool_true": Style(color="bright_green", italic=True),
|
| 84 |
+
"repr.bool_false": Style(color="bright_red", italic=True),
|
| 85 |
+
"repr.none": Style(color="magenta", italic=True),
|
| 86 |
+
"repr.url": Style(underline=True, color="bright_blue", italic=False, bold=False),
|
| 87 |
+
"repr.uuid": Style(color="bright_yellow", bold=False),
|
| 88 |
+
"repr.call": Style(color="magenta", bold=True),
|
| 89 |
+
"repr.path": Style(color="magenta"),
|
| 90 |
+
"repr.filename": Style(color="bright_magenta"),
|
| 91 |
+
"rule.line": Style(color="bright_green"),
|
| 92 |
+
"rule.text": Style.null(),
|
| 93 |
+
"json.brace": Style(bold=True),
|
| 94 |
+
"json.bool_true": Style(color="bright_green", italic=True),
|
| 95 |
+
"json.bool_false": Style(color="bright_red", italic=True),
|
| 96 |
+
"json.null": Style(color="magenta", italic=True),
|
| 97 |
+
"json.number": Style(color="cyan", bold=True, italic=False),
|
| 98 |
+
"json.str": Style(color="green", italic=False, bold=False),
|
| 99 |
+
"json.key": Style(color="blue", bold=True),
|
| 100 |
+
"prompt": Style.null(),
|
| 101 |
+
"prompt.choices": Style(color="magenta", bold=True),
|
| 102 |
+
"prompt.default": Style(color="cyan", bold=True),
|
| 103 |
+
"prompt.invalid": Style(color="red"),
|
| 104 |
+
"prompt.invalid.choice": Style(color="red"),
|
| 105 |
+
"pretty": Style.null(),
|
| 106 |
+
"scope.border": Style(color="blue"),
|
| 107 |
+
"scope.key": Style(color="yellow", italic=True),
|
| 108 |
+
"scope.key.special": Style(color="yellow", italic=True, dim=True),
|
| 109 |
+
"scope.equals": Style(color="red"),
|
| 110 |
+
"table.header": Style(bold=True),
|
| 111 |
+
"table.footer": Style(bold=True),
|
| 112 |
+
"table.cell": Style.null(),
|
| 113 |
+
"table.title": Style(italic=True),
|
| 114 |
+
"table.caption": Style(italic=True, dim=True),
|
| 115 |
+
"traceback.error": Style(color="red", italic=True),
|
| 116 |
+
"traceback.border.syntax_error": Style(color="bright_red"),
|
| 117 |
+
"traceback.border": Style(color="red"),
|
| 118 |
+
"traceback.text": Style.null(),
|
| 119 |
+
"traceback.title": Style(color="red", bold=True),
|
| 120 |
+
"traceback.exc_type": Style(color="bright_red", bold=True),
|
| 121 |
+
"traceback.exc_value": Style.null(),
|
| 122 |
+
"traceback.offset": Style(color="bright_red", bold=True),
|
| 123 |
+
"traceback.error_range": Style(underline=True, bold=True),
|
| 124 |
+
"traceback.note": Style(color="green", bold=True),
|
| 125 |
+
"traceback.group.border": Style(color="magenta"),
|
| 126 |
+
"bar.back": Style(color="grey23"),
|
| 127 |
+
"bar.complete": Style(color="rgb(249,38,114)"),
|
| 128 |
+
"bar.finished": Style(color="rgb(114,156,31)"),
|
| 129 |
+
"bar.pulse": Style(color="rgb(249,38,114)"),
|
| 130 |
+
"progress.description": Style.null(),
|
| 131 |
+
"progress.filesize": Style(color="green"),
|
| 132 |
+
"progress.filesize.total": Style(color="green"),
|
| 133 |
+
"progress.download": Style(color="green"),
|
| 134 |
+
"progress.elapsed": Style(color="yellow"),
|
| 135 |
+
"progress.percentage": Style(color="magenta"),
|
| 136 |
+
"progress.remaining": Style(color="cyan"),
|
| 137 |
+
"progress.data.speed": Style(color="red"),
|
| 138 |
+
"progress.spinner": Style(color="green"),
|
| 139 |
+
"status.spinner": Style(color="green"),
|
| 140 |
+
"tree": Style(),
|
| 141 |
+
"tree.line": Style(),
|
| 142 |
+
"markdown.paragraph": Style(),
|
| 143 |
+
"markdown.text": Style(),
|
| 144 |
+
"markdown.em": Style(italic=True),
|
| 145 |
+
"markdown.emph": Style(italic=True), # For commonmark backwards compatibility
|
| 146 |
+
"markdown.strong": Style(bold=True),
|
| 147 |
+
"markdown.code": Style(bold=True, color="cyan", bgcolor="black"),
|
| 148 |
+
"markdown.code_block": Style(color="cyan", bgcolor="black"),
|
| 149 |
+
"markdown.block_quote": Style(color="magenta"),
|
| 150 |
+
"markdown.list": Style(color="cyan"),
|
| 151 |
+
"markdown.item": Style(),
|
| 152 |
+
"markdown.item.bullet": Style(bold=True),
|
| 153 |
+
"markdown.item.number": Style(color="cyan"),
|
| 154 |
+
"markdown.hr": Style(dim=True),
|
| 155 |
+
"markdown.h1.border": Style(),
|
| 156 |
+
"markdown.h1": Style(bold=True, underline=True),
|
| 157 |
+
"markdown.h2": Style(color="magenta", underline=True),
|
| 158 |
+
"markdown.h3": Style(color="magenta", bold=True),
|
| 159 |
+
"markdown.h4": Style(color="magenta", italic=True),
|
| 160 |
+
"markdown.h5": Style(italic=True),
|
| 161 |
+
"markdown.h6": Style(dim=True),
|
| 162 |
+
"markdown.h7": Style(italic=True, dim=True),
|
| 163 |
+
"markdown.link": Style(color="bright_blue"),
|
| 164 |
+
"markdown.link_url": Style(color="blue", underline=True),
|
| 165 |
+
"markdown.s": Style(strike=True),
|
| 166 |
+
"markdown.table.border": Style(color="cyan"),
|
| 167 |
+
"markdown.table.header": Style(color="cyan", bold=False),
|
| 168 |
+
"markdown.kbd": Style(bold=True, color="bright_yellow"),
|
| 169 |
+
"iso8601.date": Style(color="blue"),
|
| 170 |
+
"iso8601.time": Style(color="magenta"),
|
| 171 |
+
"iso8601.timezone": Style(color="yellow"),
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__": # pragma: no cover
|
| 176 |
+
import argparse
|
| 177 |
+
import io
|
| 178 |
+
|
| 179 |
+
from rich.console import Console
|
| 180 |
+
from rich.table import Table
|
| 181 |
+
from rich.text import Text
|
| 182 |
+
|
| 183 |
+
parser = argparse.ArgumentParser()
|
| 184 |
+
parser.add_argument("--html", action="store_true", help="Export as HTML table")
|
| 185 |
+
args = parser.parse_args()
|
| 186 |
+
html: bool = args.html
|
| 187 |
+
console = Console(record=True, width=70, file=io.StringIO()) if html else Console()
|
| 188 |
+
|
| 189 |
+
table = Table("Name", "Styling")
|
| 190 |
+
|
| 191 |
+
for style_name, style in DEFAULT_STYLES.items():
|
| 192 |
+
table.add_row(Text(style_name, style=style), str(style))
|
| 193 |
+
|
| 194 |
+
console.print(table)
|
| 195 |
+
if html:
|
| 196 |
+
print(console.export_html(inline_styles=True))
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/diagnose.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import platform
|
| 3 |
+
|
| 4 |
+
from rich import inspect
|
| 5 |
+
from rich.console import Console, get_windows_console_features
|
| 6 |
+
from rich.panel import Panel
|
| 7 |
+
from rich.pretty import Pretty
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def report() -> None: # pragma: no cover
|
| 11 |
+
"""Print a report to the terminal with debugging information"""
|
| 12 |
+
console = Console()
|
| 13 |
+
inspect(console)
|
| 14 |
+
features = get_windows_console_features()
|
| 15 |
+
inspect(features)
|
| 16 |
+
|
| 17 |
+
env_names = (
|
| 18 |
+
"CLICOLOR",
|
| 19 |
+
"COLORTERM",
|
| 20 |
+
"COLUMNS",
|
| 21 |
+
"JPY_PARENT_PID",
|
| 22 |
+
"JUPYTER_COLUMNS",
|
| 23 |
+
"JUPYTER_LINES",
|
| 24 |
+
"LINES",
|
| 25 |
+
"NO_COLOR",
|
| 26 |
+
"TERM_PROGRAM",
|
| 27 |
+
"TERM",
|
| 28 |
+
"TTY_COMPATIBLE",
|
| 29 |
+
"TTY_INTERACTIVE",
|
| 30 |
+
"VSCODE_VERBOSE_LOGGING",
|
| 31 |
+
)
|
| 32 |
+
env = {name: os.getenv(name) for name in env_names}
|
| 33 |
+
console.print(Panel.fit((Pretty(env)), title="[b]Environment Variables"))
|
| 34 |
+
|
| 35 |
+
console.print(f'platform="{platform.system()}"')
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__": # pragma: no cover
|
| 39 |
+
report()
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/emoji.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from typing import TYPE_CHECKING, Literal, Optional, Union
|
| 3 |
+
|
| 4 |
+
from ._emoji_replace import _emoji_replace
|
| 5 |
+
from .jupyter import JupyterMixin
|
| 6 |
+
from .segment import Segment
|
| 7 |
+
from .style import Style
|
| 8 |
+
|
| 9 |
+
if TYPE_CHECKING:
|
| 10 |
+
from .console import Console, ConsoleOptions, RenderResult
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
EmojiVariant = Literal["emoji", "text"]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class NoEmoji(Exception):
|
| 17 |
+
"""No emoji by that name."""
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class Emoji(JupyterMixin):
|
| 21 |
+
__slots__ = ["name", "style", "_char", "variant"]
|
| 22 |
+
|
| 23 |
+
VARIANTS = {"text": "\ufe0e", "emoji": "\ufe0f"}
|
| 24 |
+
|
| 25 |
+
def __init__(
|
| 26 |
+
self,
|
| 27 |
+
name: str,
|
| 28 |
+
style: Union[str, Style] = "none",
|
| 29 |
+
variant: Optional[EmojiVariant] = None,
|
| 30 |
+
) -> None:
|
| 31 |
+
"""A single emoji character.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
name (str): Name of emoji.
|
| 35 |
+
style (Union[str, Style], optional): Optional style. Defaults to None.
|
| 36 |
+
|
| 37 |
+
Raises:
|
| 38 |
+
NoEmoji: If the emoji doesn't exist.
|
| 39 |
+
"""
|
| 40 |
+
from ._emoji_codes import EMOJI
|
| 41 |
+
|
| 42 |
+
self.name = name
|
| 43 |
+
self.style = style
|
| 44 |
+
self.variant = variant
|
| 45 |
+
try:
|
| 46 |
+
self._char = EMOJI[name]
|
| 47 |
+
except KeyError:
|
| 48 |
+
raise NoEmoji(f"No emoji called {name!r}")
|
| 49 |
+
if variant is not None:
|
| 50 |
+
self._char += self.VARIANTS.get(variant, "")
|
| 51 |
+
|
| 52 |
+
@classmethod
|
| 53 |
+
def replace(cls, text: str) -> str:
|
| 54 |
+
"""Replace emoji markup with corresponding unicode characters.
|
| 55 |
+
|
| 56 |
+
Args:
|
| 57 |
+
text (str): A string with emojis codes, e.g. "Hello :smiley:!"
|
| 58 |
+
|
| 59 |
+
Returns:
|
| 60 |
+
str: A string with emoji codes replaces with actual emoji.
|
| 61 |
+
"""
|
| 62 |
+
return _emoji_replace(text)
|
| 63 |
+
|
| 64 |
+
def __repr__(self) -> str:
|
| 65 |
+
return f"<emoji {self.name!r}>"
|
| 66 |
+
|
| 67 |
+
def __str__(self) -> str:
|
| 68 |
+
return self._char
|
| 69 |
+
|
| 70 |
+
def __rich_console__(
|
| 71 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 72 |
+
) -> "RenderResult":
|
| 73 |
+
yield Segment(self._char, console.get_style(self.style))
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
if __name__ == "__main__": # pragma: no cover
|
| 77 |
+
import sys
|
| 78 |
+
|
| 79 |
+
from rich.columns import Columns
|
| 80 |
+
from rich.console import Console
|
| 81 |
+
|
| 82 |
+
console = Console(record=True)
|
| 83 |
+
|
| 84 |
+
from ._emoji_codes import EMOJI
|
| 85 |
+
|
| 86 |
+
columns = Columns(
|
| 87 |
+
(f":{name}: {name}" for name in sorted(EMOJI.keys()) if "\u200d" not in name),
|
| 88 |
+
column_first=True,
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
console.print(columns)
|
| 92 |
+
if len(sys.argv) > 1:
|
| 93 |
+
console.save_html(sys.argv[1])
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/errors.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class ConsoleError(Exception):
|
| 2 |
+
"""An error in console operation."""
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class StyleError(Exception):
|
| 6 |
+
"""An error in styles."""
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class StyleSyntaxError(ConsoleError):
|
| 10 |
+
"""Style was badly formatted."""
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class MissingStyle(StyleError):
|
| 14 |
+
"""No such style."""
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class StyleStackError(ConsoleError):
|
| 18 |
+
"""Style stack is invalid."""
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class NotRenderableError(ConsoleError):
|
| 22 |
+
"""Object is not renderable."""
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class MarkupError(ConsoleError):
|
| 26 |
+
"""Markup was badly formatted."""
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class LiveError(ConsoleError):
|
| 30 |
+
"""Error related to Live display."""
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class NoAltScreen(ConsoleError):
|
| 34 |
+
"""Alt screen mode was required."""
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/file_proxy.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import io
|
| 2 |
+
from typing import IO, TYPE_CHECKING, Any, List
|
| 3 |
+
|
| 4 |
+
from .ansi import AnsiDecoder
|
| 5 |
+
from .text import Text
|
| 6 |
+
|
| 7 |
+
if TYPE_CHECKING:
|
| 8 |
+
from .console import Console
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class FileProxy(io.TextIOBase):
|
| 12 |
+
"""Wraps a file (e.g. sys.stdout) and redirects writes to a console."""
|
| 13 |
+
|
| 14 |
+
def __init__(self, console: "Console", file: IO[str]) -> None:
|
| 15 |
+
self.__console = console
|
| 16 |
+
self.__file = file
|
| 17 |
+
self.__buffer: List[str] = []
|
| 18 |
+
self.__ansi_decoder = AnsiDecoder()
|
| 19 |
+
|
| 20 |
+
@property
|
| 21 |
+
def rich_proxied_file(self) -> IO[str]:
|
| 22 |
+
"""Get proxied file."""
|
| 23 |
+
return self.__file
|
| 24 |
+
|
| 25 |
+
def __getattr__(self, name: str) -> Any:
|
| 26 |
+
return getattr(self.__file, name)
|
| 27 |
+
|
| 28 |
+
def write(self, text: str) -> int:
|
| 29 |
+
if not isinstance(text, str):
|
| 30 |
+
raise TypeError(f"write() argument must be str, not {type(text).__name__}")
|
| 31 |
+
buffer = self.__buffer
|
| 32 |
+
lines: List[str] = []
|
| 33 |
+
while text:
|
| 34 |
+
line, new_line, text = text.partition("\n")
|
| 35 |
+
if new_line:
|
| 36 |
+
lines.append("".join(buffer) + line)
|
| 37 |
+
buffer.clear()
|
| 38 |
+
else:
|
| 39 |
+
buffer.append(line)
|
| 40 |
+
break
|
| 41 |
+
if lines:
|
| 42 |
+
console = self.__console
|
| 43 |
+
with console:
|
| 44 |
+
output = Text("\n").join(
|
| 45 |
+
self.__ansi_decoder.decode_line(line) for line in lines
|
| 46 |
+
)
|
| 47 |
+
console.print(output)
|
| 48 |
+
return len(text)
|
| 49 |
+
|
| 50 |
+
def flush(self) -> None:
|
| 51 |
+
output = "".join(self.__buffer)
|
| 52 |
+
if output:
|
| 53 |
+
self.__console.print(output)
|
| 54 |
+
del self.__buffer[:]
|
| 55 |
+
|
| 56 |
+
def fileno(self) -> int:
|
| 57 |
+
return self.__file.fileno()
|
| 58 |
+
|
| 59 |
+
def isatty(self) -> bool:
|
| 60 |
+
return self.__file.isatty()
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/filesize.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Functions for reporting filesizes. Borrowed from https://github.com/PyFilesystem/pyfilesystem2
|
| 2 |
+
|
| 3 |
+
The functions declared in this module should cover the different
|
| 4 |
+
use cases needed to generate a string representation of a file size
|
| 5 |
+
using several different units. Since there are many standards regarding
|
| 6 |
+
file size units, three different functions have been implemented.
|
| 7 |
+
|
| 8 |
+
See Also:
|
| 9 |
+
* `Wikipedia: Binary prefix <https://en.wikipedia.org/wiki/Binary_prefix>`_
|
| 10 |
+
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
__all__ = ["decimal"]
|
| 14 |
+
|
| 15 |
+
from typing import Iterable, List, Optional, Tuple
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _to_str(
|
| 19 |
+
size: int,
|
| 20 |
+
suffixes: Iterable[str],
|
| 21 |
+
base: int,
|
| 22 |
+
*,
|
| 23 |
+
precision: Optional[int] = 1,
|
| 24 |
+
separator: Optional[str] = " ",
|
| 25 |
+
) -> str:
|
| 26 |
+
if size == 1:
|
| 27 |
+
return "1 byte"
|
| 28 |
+
elif size < base:
|
| 29 |
+
return f"{size:,} bytes"
|
| 30 |
+
|
| 31 |
+
for i, suffix in enumerate(suffixes, 2): # noqa: B007
|
| 32 |
+
unit = base**i
|
| 33 |
+
if size < unit:
|
| 34 |
+
break
|
| 35 |
+
return "{:,.{precision}f}{separator}{}".format(
|
| 36 |
+
(base * size / unit),
|
| 37 |
+
suffix,
|
| 38 |
+
precision=precision,
|
| 39 |
+
separator=separator,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def pick_unit_and_suffix(size: int, suffixes: List[str], base: int) -> Tuple[int, str]:
|
| 44 |
+
"""Pick a suffix and base for the given size."""
|
| 45 |
+
for i, suffix in enumerate(suffixes):
|
| 46 |
+
unit = base**i
|
| 47 |
+
if size < unit * base:
|
| 48 |
+
break
|
| 49 |
+
return unit, suffix
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def decimal(
|
| 53 |
+
size: int,
|
| 54 |
+
*,
|
| 55 |
+
precision: Optional[int] = 1,
|
| 56 |
+
separator: Optional[str] = " ",
|
| 57 |
+
) -> str:
|
| 58 |
+
"""Convert a filesize in to a string (powers of 1000, SI prefixes).
|
| 59 |
+
|
| 60 |
+
In this convention, ``1000 B = 1 kB``.
|
| 61 |
+
|
| 62 |
+
This is typically the format used to advertise the storage
|
| 63 |
+
capacity of USB flash drives and the like (*256 MB* meaning
|
| 64 |
+
actually a storage capacity of more than *256 000 000 B*),
|
| 65 |
+
or used by **Mac OS X** since v10.6 to report file sizes.
|
| 66 |
+
|
| 67 |
+
Arguments:
|
| 68 |
+
int (size): A file size.
|
| 69 |
+
int (precision): The number of decimal places to include (default = 1).
|
| 70 |
+
str (separator): The string to separate the value from the units (default = " ").
|
| 71 |
+
|
| 72 |
+
Returns:
|
| 73 |
+
`str`: A string containing a abbreviated file size and units.
|
| 74 |
+
|
| 75 |
+
Example:
|
| 76 |
+
>>> filesize.decimal(30000)
|
| 77 |
+
'30.0 kB'
|
| 78 |
+
>>> filesize.decimal(30000, precision=2, separator="")
|
| 79 |
+
'30.00kB'
|
| 80 |
+
|
| 81 |
+
"""
|
| 82 |
+
return _to_str(
|
| 83 |
+
size,
|
| 84 |
+
("kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"),
|
| 85 |
+
1000,
|
| 86 |
+
precision=precision,
|
| 87 |
+
separator=separator,
|
| 88 |
+
)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/highlighter.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from abc import ABC, abstractmethod
|
| 3 |
+
from typing import ClassVar, Sequence, Union
|
| 4 |
+
|
| 5 |
+
from .text import Span, Text
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _combine_regex(*regexes: str) -> str:
|
| 9 |
+
"""Combine a number of regexes in to a single regex.
|
| 10 |
+
|
| 11 |
+
Returns:
|
| 12 |
+
str: New regex with all regexes ORed together.
|
| 13 |
+
"""
|
| 14 |
+
return "|".join(regexes)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Highlighter(ABC):
|
| 18 |
+
"""Abstract base class for highlighters."""
|
| 19 |
+
|
| 20 |
+
def __call__(self, text: Union[str, Text]) -> Text:
|
| 21 |
+
"""Highlight a str or Text instance.
|
| 22 |
+
|
| 23 |
+
Args:
|
| 24 |
+
text (Union[str, ~Text]): Text to highlight.
|
| 25 |
+
|
| 26 |
+
Raises:
|
| 27 |
+
TypeError: If not called with text or str.
|
| 28 |
+
|
| 29 |
+
Returns:
|
| 30 |
+
Text: A test instance with highlighting applied.
|
| 31 |
+
"""
|
| 32 |
+
if isinstance(text, str):
|
| 33 |
+
highlight_text = Text(text)
|
| 34 |
+
elif isinstance(text, Text):
|
| 35 |
+
highlight_text = text.copy()
|
| 36 |
+
else:
|
| 37 |
+
raise TypeError(f"str or Text instance required, not {text!r}")
|
| 38 |
+
self.highlight(highlight_text)
|
| 39 |
+
return highlight_text
|
| 40 |
+
|
| 41 |
+
@abstractmethod
|
| 42 |
+
def highlight(self, text: Text) -> None:
|
| 43 |
+
"""Apply highlighting in place to text.
|
| 44 |
+
|
| 45 |
+
Args:
|
| 46 |
+
text (~Text): A text object highlight.
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class NullHighlighter(Highlighter):
|
| 51 |
+
"""A highlighter object that doesn't highlight.
|
| 52 |
+
|
| 53 |
+
May be used to disable highlighting entirely.
|
| 54 |
+
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
+
def highlight(self, text: Text) -> None:
|
| 58 |
+
"""Nothing to do"""
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class RegexHighlighter(Highlighter):
|
| 62 |
+
"""Applies highlighting from a list of regular expressions."""
|
| 63 |
+
|
| 64 |
+
highlights: ClassVar[Sequence[str]] = []
|
| 65 |
+
base_style: ClassVar[str] = ""
|
| 66 |
+
|
| 67 |
+
def highlight(self, text: Text) -> None:
|
| 68 |
+
"""Highlight :class:`rich.text.Text` using regular expressions.
|
| 69 |
+
|
| 70 |
+
Args:
|
| 71 |
+
text (~Text): Text to highlighted.
|
| 72 |
+
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
highlight_regex = text.highlight_regex
|
| 76 |
+
for re_highlight in self.highlights:
|
| 77 |
+
highlight_regex(re_highlight, style_prefix=self.base_style)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class ReprHighlighter(RegexHighlighter):
|
| 81 |
+
"""Highlights the text typically produced from ``__repr__`` methods."""
|
| 82 |
+
|
| 83 |
+
base_style = "repr."
|
| 84 |
+
highlights: ClassVar[Sequence[str]] = [
|
| 85 |
+
r"(?P<tag_start><)(?P<tag_name>[-\w.:|]*)(?P<tag_contents>[\w\W]*)(?P<tag_end>>)",
|
| 86 |
+
r'(?P<attrib_name>[\w_]{1,50})=(?P<attrib_value>"?[\w_]+"?)?',
|
| 87 |
+
r"(?P<brace>[][{}()])",
|
| 88 |
+
_combine_regex(
|
| 89 |
+
r"(?P<ipv4>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})",
|
| 90 |
+
r"(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})",
|
| 91 |
+
r"(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})",
|
| 92 |
+
r"(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})",
|
| 93 |
+
r"(?P<uuid>[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})",
|
| 94 |
+
r"(?P<call>[\w.]*?)\(",
|
| 95 |
+
r"\b(?P<bool_true>True)\b|\b(?P<bool_false>False)\b|\b(?P<none>None)\b",
|
| 96 |
+
r"(?P<ellipsis>\.\.\.)",
|
| 97 |
+
r"(?P<number_complex>(?<!\w)(?:\-?[0-9]+\.?[0-9]*(?:e[-+]?\d+?)?)(?:[-+](?:[0-9]+\.?[0-9]*(?:e[-+]?\d+)?))?j)",
|
| 98 |
+
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
|
| 99 |
+
r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
|
| 100 |
+
r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
|
| 101 |
+
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)",
|
| 102 |
+
),
|
| 103 |
+
]
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class JSONHighlighter(RegexHighlighter):
|
| 107 |
+
"""Highlights JSON"""
|
| 108 |
+
|
| 109 |
+
# Captures the start and end of JSON strings, handling escaped quotes
|
| 110 |
+
JSON_STR = r"(?<![\\\w])(?P<str>b?\".*?(?<!\\)\")"
|
| 111 |
+
JSON_WHITESPACE = {" ", "\n", "\r", "\t"}
|
| 112 |
+
|
| 113 |
+
base_style: ClassVar[str] = "json."
|
| 114 |
+
highlights: ClassVar[Sequence[str]] = [
|
| 115 |
+
_combine_regex(
|
| 116 |
+
r"(?P<brace>[\{\[\(\)\]\}])",
|
| 117 |
+
r"\b(?P<bool_true>true)\b|\b(?P<bool_false>false)\b|\b(?P<null>null)\b",
|
| 118 |
+
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[\-\+]?\d+?)?\b|0x[0-9a-fA-F]*)",
|
| 119 |
+
JSON_STR,
|
| 120 |
+
),
|
| 121 |
+
]
|
| 122 |
+
|
| 123 |
+
def highlight(self, text: Text) -> None:
|
| 124 |
+
super().highlight(text)
|
| 125 |
+
|
| 126 |
+
# Additional work to handle highlighting JSON keys
|
| 127 |
+
plain = text.plain
|
| 128 |
+
append = text.spans.append
|
| 129 |
+
whitespace = self.JSON_WHITESPACE
|
| 130 |
+
for match in re.finditer(self.JSON_STR, plain):
|
| 131 |
+
start, end = match.span()
|
| 132 |
+
cursor = end
|
| 133 |
+
while cursor < len(plain):
|
| 134 |
+
char = plain[cursor]
|
| 135 |
+
cursor += 1
|
| 136 |
+
if char == ":":
|
| 137 |
+
append(Span(start, end, "json.key"))
|
| 138 |
+
elif char in whitespace:
|
| 139 |
+
continue
|
| 140 |
+
break
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
class ISO8601Highlighter(RegexHighlighter):
|
| 144 |
+
"""Highlights the ISO8601 date time strings.
|
| 145 |
+
Regex reference: https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s07.html
|
| 146 |
+
"""
|
| 147 |
+
|
| 148 |
+
base_style: ClassVar[str] = "iso8601."
|
| 149 |
+
highlights: ClassVar[Sequence[str]] = [
|
| 150 |
+
#
|
| 151 |
+
# Dates
|
| 152 |
+
#
|
| 153 |
+
# Calendar month (e.g. 2008-08). The hyphen is required
|
| 154 |
+
r"^(?P<year>[0-9]{4})-(?P<month>1[0-2]|0[1-9])$",
|
| 155 |
+
# Calendar date w/o hyphens (e.g. 20080830)
|
| 156 |
+
r"^(?P<date>(?P<year>[0-9]{4})(?P<month>1[0-2]|0[1-9])(?P<day>3[01]|0[1-9]|[12][0-9]))$",
|
| 157 |
+
# Ordinal date (e.g. 2008-243). The hyphen is optional
|
| 158 |
+
r"^(?P<date>(?P<year>[0-9]{4})-?(?P<day>36[0-6]|3[0-5][0-9]|[12][0-9]{2}|0[1-9][0-9]|00[1-9]))$",
|
| 159 |
+
#
|
| 160 |
+
# Weeks
|
| 161 |
+
#
|
| 162 |
+
# Week of the year (e.g., 2008-W35). The hyphen is optional
|
| 163 |
+
r"^(?P<date>(?P<year>[0-9]{4})-?W(?P<week>5[0-3]|[1-4][0-9]|0[1-9]))$",
|
| 164 |
+
# Week date (e.g., 2008-W35-6). The hyphens are optional
|
| 165 |
+
r"^(?P<date>(?P<year>[0-9]{4})-?W(?P<week>5[0-3]|[1-4][0-9]|0[1-9])-?(?P<day>[1-7]))$",
|
| 166 |
+
#
|
| 167 |
+
# Times
|
| 168 |
+
#
|
| 169 |
+
# Hours and minutes (e.g., 17:21). The colon is optional
|
| 170 |
+
r"^(?P<time>(?P<hour>2[0-3]|[01][0-9]):?(?P<minute>[0-5][0-9]))$",
|
| 171 |
+
# Hours, minutes, and seconds w/o colons (e.g., 172159)
|
| 172 |
+
r"^(?P<time>(?P<hour>2[0-3]|[01][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-5][0-9]))$",
|
| 173 |
+
# Time zone designator (e.g., Z, +07 or +07:00). The colons and the minutes are optional
|
| 174 |
+
r"^(?P<timezone>(Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?))$",
|
| 175 |
+
# Hours, minutes, and seconds with time zone designator (e.g., 17:21:59+07:00).
|
| 176 |
+
# All the colons are optional. The minutes in the time zone designator are also optional
|
| 177 |
+
r"^(?P<time>(?P<hour>2[0-3]|[01][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-5][0-9]))(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?)$",
|
| 178 |
+
#
|
| 179 |
+
# Date and Time
|
| 180 |
+
#
|
| 181 |
+
# Calendar date with hours, minutes, and seconds (e.g., 2008-08-30 17:21:59 or 20080830 172159).
|
| 182 |
+
# A space is required between the date and the time. The hyphens and colons are optional.
|
| 183 |
+
# This regex matches dates and times that specify some hyphens or colons but omit others.
|
| 184 |
+
# This does not follow ISO 8601
|
| 185 |
+
r"^(?P<date>(?P<year>[0-9]{4})(?P<hyphen>-)?(?P<month>1[0-2]|0[1-9])(?(hyphen)-)(?P<day>3[01]|0[1-9]|[12][0-9])) (?P<time>(?P<hour>2[0-3]|[01][0-9])(?(hyphen):)(?P<minute>[0-5][0-9])(?(hyphen):)(?P<second>[0-5][0-9]))$",
|
| 186 |
+
#
|
| 187 |
+
# XML Schema dates and times
|
| 188 |
+
#
|
| 189 |
+
# Date, with optional time zone (e.g., 2008-08-30 or 2008-08-30+07:00).
|
| 190 |
+
# Hyphens are required. This is the XML Schema 'date' type
|
| 191 |
+
r"^(?P<date>(?P<year>-?(?:[1-9][0-9]*)?[0-9]{4})-(?P<month>1[0-2]|0[1-9])-(?P<day>3[01]|0[1-9]|[12][0-9]))(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$",
|
| 192 |
+
# Time, with optional fractional seconds and time zone (e.g., 01:45:36 or 01:45:36.123+07:00).
|
| 193 |
+
# There is no limit on the number of digits for the fractional seconds. This is the XML Schema 'time' type
|
| 194 |
+
r"^(?P<time>(?P<hour>2[0-3]|[01][0-9]):(?P<minute>[0-5][0-9]):(?P<second>[0-5][0-9])(?P<frac>\.[0-9]+)?)(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$",
|
| 195 |
+
# Date and time, with optional fractional seconds and time zone (e.g., 2008-08-30T01:45:36 or 2008-08-30T01:45:36.123Z).
|
| 196 |
+
# This is the XML Schema 'dateTime' type
|
| 197 |
+
r"^(?P<date>(?P<year>-?(?:[1-9][0-9]*)?[0-9]{4})-(?P<month>1[0-2]|0[1-9])-(?P<day>3[01]|0[1-9]|[12][0-9]))T(?P<time>(?P<hour>2[0-3]|[01][0-9]):(?P<minute>[0-5][0-9]):(?P<second>[0-5][0-9])(?P<ms>\.[0-9]+)?)(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$",
|
| 198 |
+
]
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
if __name__ == "__main__": # pragma: no cover
|
| 202 |
+
from .console import Console
|
| 203 |
+
|
| 204 |
+
console = Console()
|
| 205 |
+
console.print("[bold green]hello world![/bold green]")
|
| 206 |
+
console.print("'[bold green]hello world![/bold green]'")
|
| 207 |
+
|
| 208 |
+
console.print(" /foo")
|
| 209 |
+
console.print("/foo/")
|
| 210 |
+
console.print("/foo/bar")
|
| 211 |
+
console.print("foo/bar/baz")
|
| 212 |
+
|
| 213 |
+
console.print("/foo/bar/baz?foo=bar+egg&egg=baz")
|
| 214 |
+
console.print("/foo/bar/baz/")
|
| 215 |
+
console.print("/foo/bar/baz/egg")
|
| 216 |
+
console.print("/foo/bar/baz/egg.py")
|
| 217 |
+
console.print("/foo/bar/baz/egg.py word")
|
| 218 |
+
console.print(" /foo/bar/baz/egg.py word")
|
| 219 |
+
console.print("foo /foo/bar/baz/egg.py word")
|
| 220 |
+
console.print("foo /foo/bar/ba._++z/egg+.py word")
|
| 221 |
+
console.print("https://example.org?foo=bar#header")
|
| 222 |
+
|
| 223 |
+
console.print(1234567.34)
|
| 224 |
+
console.print(1 / 2)
|
| 225 |
+
console.print(-1 / 123123123123)
|
| 226 |
+
|
| 227 |
+
console.print(
|
| 228 |
+
"127.0.1.1 bar 192.168.1.4 2001:0db8:85a3:0000:0000:8a2e:0370:7334 foo"
|
| 229 |
+
)
|
| 230 |
+
import json
|
| 231 |
+
|
| 232 |
+
console.print_json(json.dumps(obj={"name": "apple", "count": 1}), indent=None)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/rich/json.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from json import loads, dumps
|
| 3 |
+
from typing import Any, Callable, Optional, Union
|
| 4 |
+
|
| 5 |
+
from .text import Text
|
| 6 |
+
from .highlighter import JSONHighlighter, NullHighlighter
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class JSON:
|
| 10 |
+
"""A renderable which pretty prints JSON.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
json (str): JSON encoded data.
|
| 14 |
+
indent (Union[None, int, str], optional): Number of characters to indent by. Defaults to 2.
|
| 15 |
+
highlight (bool, optional): Enable highlighting. Defaults to True.
|
| 16 |
+
skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
|
| 17 |
+
ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
|
| 18 |
+
check_circular (bool, optional): Check for circular references. Defaults to True.
|
| 19 |
+
allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
|
| 20 |
+
default (Callable, optional): A callable that converts values that can not be encoded
|
| 21 |
+
in to something that can be JSON encoded. Defaults to None.
|
| 22 |
+
sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
def __init__(
|
| 26 |
+
self,
|
| 27 |
+
json: str,
|
| 28 |
+
indent: Union[None, int, str] = 2,
|
| 29 |
+
highlight: bool = True,
|
| 30 |
+
skip_keys: bool = False,
|
| 31 |
+
ensure_ascii: bool = False,
|
| 32 |
+
check_circular: bool = True,
|
| 33 |
+
allow_nan: bool = True,
|
| 34 |
+
default: Optional[Callable[[Any], Any]] = None,
|
| 35 |
+
sort_keys: bool = False,
|
| 36 |
+
) -> None:
|
| 37 |
+
data = loads(json)
|
| 38 |
+
json = dumps(
|
| 39 |
+
data,
|
| 40 |
+
indent=indent,
|
| 41 |
+
skipkeys=skip_keys,
|
| 42 |
+
ensure_ascii=ensure_ascii,
|
| 43 |
+
check_circular=check_circular,
|
| 44 |
+
allow_nan=allow_nan,
|
| 45 |
+
default=default,
|
| 46 |
+
sort_keys=sort_keys,
|
| 47 |
+
)
|
| 48 |
+
highlighter = JSONHighlighter() if highlight else NullHighlighter()
|
| 49 |
+
self.text = highlighter(json)
|
| 50 |
+
self.text.no_wrap = True
|
| 51 |
+
self.text.overflow = None
|
| 52 |
+
|
| 53 |
+
@classmethod
|
| 54 |
+
def from_data(
|
| 55 |
+
cls,
|
| 56 |
+
data: Any,
|
| 57 |
+
indent: Union[None, int, str] = 2,
|
| 58 |
+
highlight: bool = True,
|
| 59 |
+
skip_keys: bool = False,
|
| 60 |
+
ensure_ascii: bool = False,
|
| 61 |
+
check_circular: bool = True,
|
| 62 |
+
allow_nan: bool = True,
|
| 63 |
+
default: Optional[Callable[[Any], Any]] = None,
|
| 64 |
+
sort_keys: bool = False,
|
| 65 |
+
) -> "JSON":
|
| 66 |
+
"""Encodes a JSON object from arbitrary data.
|
| 67 |
+
|
| 68 |
+
Args:
|
| 69 |
+
data (Any): An object that may be encoded in to JSON
|
| 70 |
+
indent (Union[None, int, str], optional): Number of characters to indent by. Defaults to 2.
|
| 71 |
+
highlight (bool, optional): Enable highlighting. Defaults to True.
|
| 72 |
+
default (Callable, optional): Optional callable which will be called for objects that cannot be serialized. Defaults to None.
|
| 73 |
+
skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
|
| 74 |
+
ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
|
| 75 |
+
check_circular (bool, optional): Check for circular references. Defaults to True.
|
| 76 |
+
allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
|
| 77 |
+
default (Callable, optional): A callable that converts values that can not be encoded
|
| 78 |
+
in to something that can be JSON encoded. Defaults to None.
|
| 79 |
+
sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
|
| 80 |
+
|
| 81 |
+
Returns:
|
| 82 |
+
JSON: New JSON object from the given data.
|
| 83 |
+
"""
|
| 84 |
+
json_instance: "JSON" = cls.__new__(cls)
|
| 85 |
+
json = dumps(
|
| 86 |
+
data,
|
| 87 |
+
indent=indent,
|
| 88 |
+
skipkeys=skip_keys,
|
| 89 |
+
ensure_ascii=ensure_ascii,
|
| 90 |
+
check_circular=check_circular,
|
| 91 |
+
allow_nan=allow_nan,
|
| 92 |
+
default=default,
|
| 93 |
+
sort_keys=sort_keys,
|
| 94 |
+
)
|
| 95 |
+
highlighter = JSONHighlighter() if highlight else NullHighlighter()
|
| 96 |
+
json_instance.text = highlighter(json)
|
| 97 |
+
json_instance.text.no_wrap = True
|
| 98 |
+
json_instance.text.overflow = None
|
| 99 |
+
return json_instance
|
| 100 |
+
|
| 101 |
+
def __rich__(self) -> Text:
|
| 102 |
+
return self.text
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
if __name__ == "__main__":
|
| 106 |
+
import argparse
|
| 107 |
+
import sys
|
| 108 |
+
|
| 109 |
+
parser = argparse.ArgumentParser(description="Pretty print json")
|
| 110 |
+
parser.add_argument(
|
| 111 |
+
"path",
|
| 112 |
+
metavar="PATH",
|
| 113 |
+
help="path to file, or - for stdin",
|
| 114 |
+
)
|
| 115 |
+
parser.add_argument(
|
| 116 |
+
"-i",
|
| 117 |
+
"--indent",
|
| 118 |
+
metavar="SPACES",
|
| 119 |
+
type=int,
|
| 120 |
+
help="Number of spaces in an indent",
|
| 121 |
+
default=2,
|
| 122 |
+
)
|
| 123 |
+
args = parser.parse_args()
|
| 124 |
+
|
| 125 |
+
from rich.console import Console
|
| 126 |
+
|
| 127 |
+
console = Console()
|
| 128 |
+
error_console = Console(stderr=True)
|
| 129 |
+
|
| 130 |
+
try:
|
| 131 |
+
if args.path == "-":
|
| 132 |
+
json_data = sys.stdin.read()
|
| 133 |
+
else:
|
| 134 |
+
json_data = Path(args.path).read_text()
|
| 135 |
+
except Exception as error:
|
| 136 |
+
error_console.print(f"Unable to read {args.path!r}; {error}")
|
| 137 |
+
sys.exit(-1)
|
| 138 |
+
|
| 139 |
+
console.print(JSON(json_data, indent=args.indent), soft_wrap=True)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/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 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 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("&", "&").replace("<", "<").replace(">", ">")
|
| 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)
|
qwen3.8-27b/.venv/lib/python3.12/site-packages/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 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 rich.styled import Styled
|
| 226 |
+
from rich.table import Table
|
| 227 |
+
from 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 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)
|