Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- LTA_openwebtext_dualt/logs/elfaligned_t5tokenized_8gpu_subset1k/lta_owt_t5_subset1k_adaln_adamw_wd0p1_rollin_p50_randk0_3_uniformt_temp1_synct_gbs512_8gpu_20260518_165427.log +0 -0
- LTA_openwebtext_dualt/logs/eval_fixedwrong70/ema_s128_base_argmax.log +12 -0
- LTA_openwebtext_dualt/logs/eval_fixedwrong70/fixedwrong70_step91000_ema_dirres_n16_s128.log +12 -0
- LTA_openwebtext_dualt/logs/lm1b_compact_gpt2bpe_v8192_len128_fullycoupled_4gpu/lta_lm1b_compact_gpt2bpe_v8192_len128_repro_mask1_uniformt_fp32_ddit768x12_gbs512_4gpu_1m_20260520_221739.log +0 -0
- LTA_openwebtext_dualt/logs/lm1b_compact_gpt2bpe_v8192_len128_fullycoupled_4gpu/wait_then_train.nohup.log +0 -0
- LTA_openwebtext_dualt/logs/lm1b_compact_gpt2bpe_v8192_len128_fullycoupled_4gpu/wait_then_train_20260520_221039.log +10 -0
- LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252.log +118 -0
- LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252.nohup.log +129 -0
- LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_save500_20260515_004319.log +0 -0
- LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_save500_20260515_004319.nohup.log +0 -0
- LTA_openwebtext_dualt/logs/lm1b_v8192_mask0p1_1p0/latest_run_name.txt +1 -0
- LTA_openwebtext_dualt/logs/lm1b_v8192_mask0p1_1p0/lta_lm1b_compact_gpt2bpe_v8192_len128_mask0p1-1p0_uniformt_fp32_ddit768x12_gbs512_4gpu_1m_20260520_232453.nohup.log +0 -0
- LTA_openwebtext_dualt/logs/qwen_service/qwen3p5_35b_a3b_transformers_gpu2_3_20260608_194952.log +13 -0
- LTA_openwebtext_dualt/logs/qwen_service/qwen3p5_35b_a3b_transformers_gpu2_3_20260608_200311.pid +1 -0
- LTA_openwebtext_dualt/logs/unigramwrong_debug/lta_owt_unigramwrong_smoke4gpu_20260514_160148.log +115 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/__init__.py +25 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/_manylinux.py +301 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/_musllinux.py +136 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py +304 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py +146 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/tags.py +487 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/version.py +504 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/__init__.py +177 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/__main__.py +274 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_cell_widths.py +451 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_extension.py +10 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_fileno.py +24 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_log_render.py +94 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_loop.py +43 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_null_file.py +69 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_palettes.py +309 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_pick.py +17 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_ratio.py +160 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_spinners.py +482 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_timer.py +19 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_win32_console.py +662 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_wrap.py +56 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/abc.py +33 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/align.py +311 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/ansi.py +240 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/box.py +517 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/color.py +622 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/columns.py +187 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/console.py +0 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/constrain.py +37 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/control.py +225 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/diagnose.py +37 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/emoji.py +96 -0
LTA_openwebtext_dualt/logs/elfaligned_t5tokenized_8gpu_subset1k/lta_owt_t5_subset1k_adaln_adamw_wd0p1_rollin_p50_randk0_3_uniformt_temp1_synct_gbs512_8gpu_20260518_165427.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/eval_fixedwrong70/ema_s128_base_argmax.log
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ckpt] runs/lta_owt_gpt2cached_len1024_fixedwrong70_c1024_ddit768x12_muon_ema_gbs512_8gpu_1m_20260513_171557/eval_snapshot_step_0054000_ema.pt step=54000
|
| 2 |
+
[decode-base] n=16 max_len=1024 steps=128 model_t=flow
|
| 3 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 2/16
|
| 4 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 4/16
|
| 5 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 6/16
|
| 6 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 8/16
|
| 7 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 10/16
|
| 8 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 12/16
|
| 9 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 14/16
|
| 10 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 16/16
|
| 11 |
+
[summary] {"type": "summary", "checkpoint": "runs/lta_owt_gpt2cached_len1024_fixedwrong70_c1024_ddit768x12_muon_ema_gbs512_8gpu_1m_20260513_171557/eval_snapshot_step_0054000_ema.pt", "step": 54000, "decode": {"steps": 128, "model_t_mode": "flow", "decode_rule": "dirichlet_resample", "support_power": 1.0, "semantic_power": 1.5, "anchor_mode": "state", "cfg_scale": 0.0, "cfg_power": 1.0, "cfg_start": 0.0, "cfg_prior": "uniform", "decode_freq_penalty_alpha": 0.0, "decode_freq_penalty_beta": 0.0, "decode_freq_penalty_floor": 0.0, "decode_freq_penalty_start": 0.0, "decode_freq_penalty_end": 1.0, "decode_freq_penalty_power": 1.0, "start_t": 0.0, "start_init": "noise", "noise_init": "dirichlet", "noise_sigma": -1.0, "dirichlet_concentration": 1.0, "concentration_min": 1.0, "concentration_max": 1024.0, "target_prob": 1.0, "endpoint_temp": 1.45, "final_from": "blend", "final_sample_mode": "argmax", "final_sample_temp": 1.0, "final_top_k": 64, "final_top_p": 0.95, "final_freq_penalty_alpha": 0.0, "final_freq_penalty_beta": 0.0, "final_freq_penalty_floor": 0.0, "lock_bos": false, "n_samples": 16, "seed": 20260514}, "raw_genppl": {"ppl": 14.594980172824288, "nll_per_token": 2.680677645814185, "tokens": 4080, "kept_samples": 16, "total_samples": 16, "empty_rate": 0.0, "skipped_samples": 0}, "stripped_genppl": {"ppl": 18.101966298558825, "nll_per_token": 2.8960205676508886, "tokens": 4080, "kept_samples": 16, "total_samples": 16, "empty_rate": 0.0, "skipped_samples": 0}, "diversity": {"sample_entropy": 3.339288358907395, "unique_tokens": 344, "token_count": 16384, "distinct_1": 0.02099609375, "distinct_2": 0.20821114369501467, "top_token_mass": 0.15087890625}}
|
| 12 |
+
[done] docs/lta_samples/metrics_20260514/fixedwrong70_decode_sweep_fast/ema_s128_base_argmax.jsonl
|
LTA_openwebtext_dualt/logs/eval_fixedwrong70/fixedwrong70_step91000_ema_dirres_n16_s128.log
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ckpt] runs/lta_owt_gpt2cached_len1024_fixedwrong70_c1024_ddit768x12_muon_ema_gbs512_8gpu_1m_20260513_171557/eval_snapshot_step_0091000_ema.pt step=91000
|
| 2 |
+
[decode-base] n=16 max_len=1024 steps=128 model_t=flow
|
| 3 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 2/16
|
| 4 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 4/16
|
| 5 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 6/16
|
| 6 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 8/16
|
| 7 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 10/16
|
| 8 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 12/16
|
| 9 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 14/16
|
| 10 |
+
[decode] temp=1.45 final=blend rule=dirichlet_resample support=1 semantic=1.5 anchor=state cfg=0/1@0:uniform decode_freq_penalty=0/0/0-1^1 final_sample=argmax/1/k64/p0.95 freq_penalty=0/0/0 start_t=0 start_init=noise generated 16/16
|
| 11 |
+
[summary] {"type": "summary", "checkpoint": "runs/lta_owt_gpt2cached_len1024_fixedwrong70_c1024_ddit768x12_muon_ema_gbs512_8gpu_1m_20260513_171557/eval_snapshot_step_0091000_ema.pt", "step": 91000, "decode": {"steps": 128, "model_t_mode": "flow", "decode_rule": "dirichlet_resample", "support_power": 1.0, "semantic_power": 1.5, "anchor_mode": "state", "cfg_scale": 0.0, "cfg_power": 1.0, "cfg_start": 0.0, "cfg_prior": "uniform", "decode_freq_penalty_alpha": 0.0, "decode_freq_penalty_beta": 0.0, "decode_freq_penalty_floor": 0.0, "decode_freq_penalty_start": 0.0, "decode_freq_penalty_end": 1.0, "decode_freq_penalty_power": 1.0, "start_t": 0.0, "start_init": "noise", "noise_init": "dirichlet", "noise_sigma": -1.0, "dirichlet_concentration": 1.0, "concentration_min": 1.0, "concentration_max": 1024.0, "target_prob": 1.0, "endpoint_temp": 1.45, "final_from": "blend", "final_sample_mode": "argmax", "final_sample_temp": 1.0, "final_top_k": 64, "final_top_p": 0.95, "final_freq_penalty_alpha": 0.0, "final_freq_penalty_beta": 0.0, "final_freq_penalty_floor": 0.0, "lock_bos": false, "n_samples": 16, "seed": 20260514}, "raw_genppl": {"ppl": 9.15153130996079, "nll_per_token": 2.2139212215647976, "tokens": 4080, "kept_samples": 16, "total_samples": 16, "empty_rate": 0.0, "skipped_samples": 0}, "stripped_genppl": {"ppl": 11.897193857793793, "nll_per_token": 2.4763025620404413, "tokens": 4080, "kept_samples": 16, "total_samples": 16, "empty_rate": 0.0, "skipped_samples": 0}, "diversity": {"sample_entropy": 2.4467596776773615, "unique_tokens": 209, "token_count": 16384, "distinct_1": 0.01275634765625, "distinct_2": 0.09567448680351906, "top_token_mass": 0.2486572265625}}
|
| 12 |
+
[done] docs/lta_samples/metrics_20260514/fixedwrong70_latest_step91000/fixedwrong70_step91000_ema_dirres_n16_s128.jsonl
|
LTA_openwebtext_dualt/logs/lm1b_compact_gpt2bpe_v8192_len128_fullycoupled_4gpu/lta_lm1b_compact_gpt2bpe_v8192_len128_repro_mask1_uniformt_fp32_ddit768x12_gbs512_4gpu_1m_20260520_221739.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/lm1b_compact_gpt2bpe_v8192_len128_fullycoupled_4gpu/wait_then_train.nohup.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/lm1b_compact_gpt2bpe_v8192_len128_fullycoupled_4gpu/wait_then_train_20260520_221039.log
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[watcher] waiting for /e2e-data/evad-tech-vla/wanghan58/data/embedded-language-flows/lm1b-compact-gpt2bpe-v8192-stream128/elf_multi_part_meta.json
|
| 2 |
+
[watcher] 2026-05-20_22:10:39 completed_parts=1/10
|
| 3 |
+
[watcher] 2026-05-20_22:11:39 completed_parts=1/10
|
| 4 |
+
[watcher] 2026-05-20_22:12:39 completed_parts=1/10
|
| 5 |
+
[watcher] 2026-05-20_22:13:39 completed_parts=9/10
|
| 6 |
+
[watcher] 2026-05-20_22:14:39 completed_parts=9/10
|
| 7 |
+
[watcher] 2026-05-20_22:15:39 completed_parts=9/10
|
| 8 |
+
[watcher] 2026-05-20_22:16:39 completed_parts=9/10
|
| 9 |
+
[watcher] dataset ready {'num_examples': 8386051, 'total_tokens': 1073413951, 'mean_length': 127.999931195267, 'num_parts': 10}
|
| 10 |
+
[watcher] launching lta_lm1b_compact_gpt2bpe_v8192_len128_repro_mask1_uniformt_fp32_ddit768x12_gbs512_4gpu_1m_20260520_221739
|
LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252.log
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NCCL version 2.25.1+cuda12.8
|
| 2 |
+
{
|
| 3 |
+
"device": "cuda:0",
|
| 4 |
+
"rank": 0,
|
| 5 |
+
"world_size": 4,
|
| 6 |
+
"samples": "wrapped_stream",
|
| 7 |
+
"vocab_size": 30522,
|
| 8 |
+
"tokenizer_vocab_size": 30522,
|
| 9 |
+
"save_dir": "runs/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252",
|
| 10 |
+
"batch_size": 32,
|
| 11 |
+
"grad_accum": 4,
|
| 12 |
+
"effective_batch_size": 512,
|
| 13 |
+
"global_batch_size": 512,
|
| 14 |
+
"lr_schedule": "cosine",
|
| 15 |
+
"optimizer": "adamw",
|
| 16 |
+
"warmup_steps": 2000,
|
| 17 |
+
"min_lr": 6e-05,
|
| 18 |
+
"weight_decay": 0.1,
|
| 19 |
+
"output_weight_decay": -1.0,
|
| 20 |
+
"adamw_param_groups": "nanogpt",
|
| 21 |
+
"adam_beta1": 0.9,
|
| 22 |
+
"adam_beta2": 0.95,
|
| 23 |
+
"adam_eps": 1e-08,
|
| 24 |
+
"muon_momentum": 0.95,
|
| 25 |
+
"muon_ns_steps": 5,
|
| 26 |
+
"muon_update_scale": 1.0,
|
| 27 |
+
"ema_decay": 0.0,
|
| 28 |
+
"ema_start_step": 0,
|
| 29 |
+
"model_type": "ddit",
|
| 30 |
+
"output_bias": false,
|
| 31 |
+
"norm_type": "rmsnorm",
|
| 32 |
+
"t_sampling_mode": "uniform",
|
| 33 |
+
"t_sampling_power": 1.0,
|
| 34 |
+
"t_sampling_eps": 0.0001,
|
| 35 |
+
"dual_t": true,
|
| 36 |
+
"corrupt_t_mode": "same",
|
| 37 |
+
"corrupt_min_t": 0.0,
|
| 38 |
+
"corrupt_max_t": 1.0,
|
| 39 |
+
"prefix_block_prob": 0.0,
|
| 40 |
+
"prefix_block_len": 128,
|
| 41 |
+
"mask_ratio_floor_schedule": "none",
|
| 42 |
+
"dirichlet_endpoint_mode": "categorical_dual_t",
|
| 43 |
+
"dirichlet_semantic_t_mode": "same",
|
| 44 |
+
"dirichlet_semantic_t_value": 0.0,
|
| 45 |
+
"dirichlet_semantic_t_curve": "linear",
|
| 46 |
+
"dirichlet_semantic_t_power": 1.0,
|
| 47 |
+
"endpoint_sequence_random_prob_alpha": 0.0,
|
| 48 |
+
"categorical_wrong_from_full_vocab": true,
|
| 49 |
+
"categorical_wrong_from_batch_valid_tokens": false,
|
| 50 |
+
"categorical_wrong_basin_token_ids": "",
|
| 51 |
+
"categorical_wrong_basin_prob": 0.0,
|
| 52 |
+
"categorical_wrong_unigram_prob": 0.0,
|
| 53 |
+
"categorical_wrong_uniform_prob": 0.0,
|
| 54 |
+
"categorical_wrong_corpus_unigram_path": "",
|
| 55 |
+
"categorical_wrong_corpus_unigram_alpha": 1.0,
|
| 56 |
+
"categorical_wrong_basin_shared_prob": 0.0,
|
| 57 |
+
"categorical_wrong_unigram_shared_prob": 0.0,
|
| 58 |
+
"mask_mixture_original_prob": 0.0,
|
| 59 |
+
"mask_mixture_lowk_prob": 0.0,
|
| 60 |
+
"mask_mixture_lowcorrupt_prob": 0.0,
|
| 61 |
+
"mask_mixture_block_prob": 0.0,
|
| 62 |
+
"mask_mixture_all_prob": 0.0,
|
| 63 |
+
"mask_mixture_lowk_clean_tokens": "1,2,4,8,16,32,64",
|
| 64 |
+
"mask_mixture_lowcorrupt_tokens": "1,2,4,8,16,32,64",
|
| 65 |
+
"mask_mixture_block_tokens": "64,128",
|
| 66 |
+
"simplex_bridge_sampler": "dirichlet",
|
| 67 |
+
"logistic_normal_sigma_min": 0.18,
|
| 68 |
+
"logistic_normal_sigma_max": 2.2,
|
| 69 |
+
"logistic_normal_tau_min": 0.65,
|
| 70 |
+
"logistic_normal_tau_max": 1.15,
|
| 71 |
+
"torch_compile": false,
|
| 72 |
+
"compile_mode": "max-autotune",
|
| 73 |
+
"state_format": "prob",
|
| 74 |
+
"target_loss": "hard_ce",
|
| 75 |
+
"meanflow_weight": 0.0,
|
| 76 |
+
"rollout_train_prob": 0.0,
|
| 77 |
+
"rollout_train_steps": 1,
|
| 78 |
+
"rollout_train_infer_steps": 64,
|
| 79 |
+
"rollout_train_temp": 1.45,
|
| 80 |
+
"rollout_train_max_gamma": 1.0,
|
| 81 |
+
"rollout_train_corrupt_only": true,
|
| 82 |
+
"rollout_train_samplewise": false,
|
| 83 |
+
"rollout_train_compute_always": false,
|
| 84 |
+
"bridge_noise_init": "logistic_normal",
|
| 85 |
+
"noise_sigma": -1.0,
|
| 86 |
+
"allow_tf32": true,
|
| 87 |
+
"activation_checkpointing": false,
|
| 88 |
+
"activation_checkpoint_interval": 1,
|
| 89 |
+
"activation_checkpoint_scope": "block",
|
| 90 |
+
"ddp_static_graph": false,
|
| 91 |
+
"ddp_gradient_as_bucket_view": true,
|
| 92 |
+
"blocking_data_transfer": false,
|
| 93 |
+
"dataloader_prefetch_factor": 2,
|
| 94 |
+
"full_train_stats": false,
|
| 95 |
+
"record_pad_truncate": false,
|
| 96 |
+
"record_add_eos": false,
|
| 97 |
+
"record_add_special_tokens": false,
|
| 98 |
+
"record_pad_token": "pad",
|
| 99 |
+
"record_shuffle_buffer": 10000,
|
| 100 |
+
"wrap": true,
|
| 101 |
+
"wrap_mode": "stream",
|
| 102 |
+
"wrap_record_buffer_size": 200,
|
| 103 |
+
"owt_cached_chunks": false,
|
| 104 |
+
"owt_chunk_cache_dir": "",
|
| 105 |
+
"owt_chunk_cache_rebuild": false,
|
| 106 |
+
"owt_chunk_cache_write_batch": 4096,
|
| 107 |
+
"owt_exact_repeat_per_chunk": 0,
|
| 108 |
+
"online_chunk_shuffle": false,
|
| 109 |
+
"online_chunk_shuffle_buffer": 10000,
|
| 110 |
+
"openwebtext_split": "all",
|
| 111 |
+
"detokenizer": "auto",
|
| 112 |
+
"resolved_detokenizer": "lm1b",
|
| 113 |
+
"num_workers": 0,
|
| 114 |
+
"latest_every": 1000,
|
| 115 |
+
"resume_path": ""
|
| 116 |
+
}
|
| 117 |
+
step=50 micro_steps=200 elapsed=267.4s lr=1.530000e-05 loss=10.2707 loss_recon=10.2707 loss_meanflow=0.0000 mean_model_t=0.4957 mean_corrupt_t=0.4957 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.6827 corrupt_frac=0.5441 acc_corrupt=0.4500 loss_corrupt=10.2707 wrong_frac=0.5072 init_acc_corrupt=0.4580 acc_corrupt_t_0p0_0p2=0.0353 corrupt_frac_t_0p0_0p2=0.2091 acc_corrupt_t_0p2_0p4=0.2381 corrupt_frac_t_0p2_0p4=0.1997 acc_corrupt_t_0p4_0p6=0.4743 corrupt_frac_t_0p4_0p6=0.2015 acc_corrupt_t_0p6_0p8=0.6742 corrupt_frac_t_0p6_0p8=0.1933 acc_corrupt_t_0p8_1p0=0.8618 corrupt_frac_t_0p8_1p0=0.1963 out_w_norm=0.4520 out_g_norm=0.9094 loss_all=10.0676 init_gold_top10=0.4926 init_gold_top100=0.4970
|
| 118 |
+
step=100 micro_steps=400 elapsed=289.2s lr=3.030000e-05 loss=9.5867 loss_recon=9.5867 loss_meanflow=0.0000 mean_model_t=0.4967 mean_corrupt_t=0.4967 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.2468 corrupt_frac=0.5492 acc_corrupt=0.1477 loss_corrupt=9.5867 wrong_frac=0.5006 init_acc_corrupt=0.4653 acc_corrupt_t_0p0_0p2=0.0497 corrupt_frac_t_0p0_0p2=0.1962 acc_corrupt_t_0p2_0p4=0.0723 corrupt_frac_t_0p2_0p4=0.2040 acc_corrupt_t_0p4_0p6=0.1212 corrupt_frac_t_0p4_0p6=0.2022 acc_corrupt_t_0p6_0p8=0.1904 corrupt_frac_t_0p6_0p8=0.1979 acc_corrupt_t_0p8_1p0=0.3056 corrupt_frac_t_0p8_1p0=0.1996 out_w_norm=3.7134 out_g_norm=1.7010 loss_all=8.9889 init_gold_top10=0.5681 init_gold_top100=0.5714
|
LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252.nohup.log
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[launch] method=lm1b_fullycoupled_adamw_wd0p1_nanogpt_fp32 host=di-20260411014000-djqhq time=2026-05-15T00:32:52+00:00
|
| 2 |
+
[launch] run_name=lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252
|
| 3 |
+
[launch] save_dir=runs/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252
|
| 4 |
+
[launch] log_file=logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252.log
|
| 5 |
+
[launch] data_path=data/lm1b_train_parquet
|
| 6 |
+
[launch] tokenizer_path=/e2e-data/evad-tech-vla/wanghan58/workspace/imagenet_handoff_20260327/nlp_dts_light/assets/distilbert-base-uncased/tokenizer.json
|
| 7 |
+
[launch] fp32=true bf16=false tf32=true norm_type=rmsnorm output_bias=false max_len=1024
|
| 8 |
+
[launch] batch=512 per_gpu=32 save_every=1000 latest_every=1000 total_steps=10000
|
| 9 |
+
[launch] optimizer=adamw lr=6e-4 min_lr=6e-5 wd=0.1 output_wd=-1 param_groups=nanogpt
|
| 10 |
+
[launch] t_sampling_mode=uniform t_sampling_power=1.0 loss_t_weight_mode=none
|
| 11 |
+
NCCL version 2.25.1+cuda12.8
|
| 12 |
+
{
|
| 13 |
+
"device": "cuda:0",
|
| 14 |
+
"rank": 0,
|
| 15 |
+
"world_size": 4,
|
| 16 |
+
"samples": "wrapped_stream",
|
| 17 |
+
"vocab_size": 30522,
|
| 18 |
+
"tokenizer_vocab_size": 30522,
|
| 19 |
+
"save_dir": "runs/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_20260515_003252",
|
| 20 |
+
"batch_size": 32,
|
| 21 |
+
"grad_accum": 4,
|
| 22 |
+
"effective_batch_size": 512,
|
| 23 |
+
"global_batch_size": 512,
|
| 24 |
+
"lr_schedule": "cosine",
|
| 25 |
+
"optimizer": "adamw",
|
| 26 |
+
"warmup_steps": 2000,
|
| 27 |
+
"min_lr": 6e-05,
|
| 28 |
+
"weight_decay": 0.1,
|
| 29 |
+
"output_weight_decay": -1.0,
|
| 30 |
+
"adamw_param_groups": "nanogpt",
|
| 31 |
+
"adam_beta1": 0.9,
|
| 32 |
+
"adam_beta2": 0.95,
|
| 33 |
+
"adam_eps": 1e-08,
|
| 34 |
+
"muon_momentum": 0.95,
|
| 35 |
+
"muon_ns_steps": 5,
|
| 36 |
+
"muon_update_scale": 1.0,
|
| 37 |
+
"ema_decay": 0.0,
|
| 38 |
+
"ema_start_step": 0,
|
| 39 |
+
"model_type": "ddit",
|
| 40 |
+
"output_bias": false,
|
| 41 |
+
"norm_type": "rmsnorm",
|
| 42 |
+
"t_sampling_mode": "uniform",
|
| 43 |
+
"t_sampling_power": 1.0,
|
| 44 |
+
"t_sampling_eps": 0.0001,
|
| 45 |
+
"dual_t": true,
|
| 46 |
+
"corrupt_t_mode": "same",
|
| 47 |
+
"corrupt_min_t": 0.0,
|
| 48 |
+
"corrupt_max_t": 1.0,
|
| 49 |
+
"prefix_block_prob": 0.0,
|
| 50 |
+
"prefix_block_len": 128,
|
| 51 |
+
"mask_ratio_floor_schedule": "none",
|
| 52 |
+
"dirichlet_endpoint_mode": "categorical_dual_t",
|
| 53 |
+
"dirichlet_semantic_t_mode": "same",
|
| 54 |
+
"dirichlet_semantic_t_value": 0.0,
|
| 55 |
+
"dirichlet_semantic_t_curve": "linear",
|
| 56 |
+
"dirichlet_semantic_t_power": 1.0,
|
| 57 |
+
"endpoint_sequence_random_prob_alpha": 0.0,
|
| 58 |
+
"categorical_wrong_from_full_vocab": true,
|
| 59 |
+
"categorical_wrong_from_batch_valid_tokens": false,
|
| 60 |
+
"categorical_wrong_basin_token_ids": "",
|
| 61 |
+
"categorical_wrong_basin_prob": 0.0,
|
| 62 |
+
"categorical_wrong_unigram_prob": 0.0,
|
| 63 |
+
"categorical_wrong_uniform_prob": 0.0,
|
| 64 |
+
"categorical_wrong_corpus_unigram_path": "",
|
| 65 |
+
"categorical_wrong_corpus_unigram_alpha": 1.0,
|
| 66 |
+
"categorical_wrong_basin_shared_prob": 0.0,
|
| 67 |
+
"categorical_wrong_unigram_shared_prob": 0.0,
|
| 68 |
+
"mask_mixture_original_prob": 0.0,
|
| 69 |
+
"mask_mixture_lowk_prob": 0.0,
|
| 70 |
+
"mask_mixture_lowcorrupt_prob": 0.0,
|
| 71 |
+
"mask_mixture_block_prob": 0.0,
|
| 72 |
+
"mask_mixture_all_prob": 0.0,
|
| 73 |
+
"mask_mixture_lowk_clean_tokens": "1,2,4,8,16,32,64",
|
| 74 |
+
"mask_mixture_lowcorrupt_tokens": "1,2,4,8,16,32,64",
|
| 75 |
+
"mask_mixture_block_tokens": "64,128",
|
| 76 |
+
"simplex_bridge_sampler": "dirichlet",
|
| 77 |
+
"logistic_normal_sigma_min": 0.18,
|
| 78 |
+
"logistic_normal_sigma_max": 2.2,
|
| 79 |
+
"logistic_normal_tau_min": 0.65,
|
| 80 |
+
"logistic_normal_tau_max": 1.15,
|
| 81 |
+
"torch_compile": false,
|
| 82 |
+
"compile_mode": "max-autotune",
|
| 83 |
+
"state_format": "prob",
|
| 84 |
+
"target_loss": "hard_ce",
|
| 85 |
+
"meanflow_weight": 0.0,
|
| 86 |
+
"rollout_train_prob": 0.0,
|
| 87 |
+
"rollout_train_steps": 1,
|
| 88 |
+
"rollout_train_infer_steps": 64,
|
| 89 |
+
"rollout_train_temp": 1.45,
|
| 90 |
+
"rollout_train_max_gamma": 1.0,
|
| 91 |
+
"rollout_train_corrupt_only": true,
|
| 92 |
+
"rollout_train_samplewise": false,
|
| 93 |
+
"rollout_train_compute_always": false,
|
| 94 |
+
"bridge_noise_init": "logistic_normal",
|
| 95 |
+
"noise_sigma": -1.0,
|
| 96 |
+
"allow_tf32": true,
|
| 97 |
+
"activation_checkpointing": false,
|
| 98 |
+
"activation_checkpoint_interval": 1,
|
| 99 |
+
"activation_checkpoint_scope": "block",
|
| 100 |
+
"ddp_static_graph": false,
|
| 101 |
+
"ddp_gradient_as_bucket_view": true,
|
| 102 |
+
"blocking_data_transfer": false,
|
| 103 |
+
"dataloader_prefetch_factor": 2,
|
| 104 |
+
"full_train_stats": false,
|
| 105 |
+
"record_pad_truncate": false,
|
| 106 |
+
"record_add_eos": false,
|
| 107 |
+
"record_add_special_tokens": false,
|
| 108 |
+
"record_pad_token": "pad",
|
| 109 |
+
"record_shuffle_buffer": 10000,
|
| 110 |
+
"wrap": true,
|
| 111 |
+
"wrap_mode": "stream",
|
| 112 |
+
"wrap_record_buffer_size": 200,
|
| 113 |
+
"owt_cached_chunks": false,
|
| 114 |
+
"owt_chunk_cache_dir": "",
|
| 115 |
+
"owt_chunk_cache_rebuild": false,
|
| 116 |
+
"owt_chunk_cache_write_batch": 4096,
|
| 117 |
+
"owt_exact_repeat_per_chunk": 0,
|
| 118 |
+
"online_chunk_shuffle": false,
|
| 119 |
+
"online_chunk_shuffle_buffer": 10000,
|
| 120 |
+
"openwebtext_split": "all",
|
| 121 |
+
"detokenizer": "auto",
|
| 122 |
+
"resolved_detokenizer": "lm1b",
|
| 123 |
+
"num_workers": 0,
|
| 124 |
+
"latest_every": 1000,
|
| 125 |
+
"resume_path": ""
|
| 126 |
+
}
|
| 127 |
+
step=50 micro_steps=200 elapsed=267.4s lr=1.530000e-05 loss=10.2707 loss_recon=10.2707 loss_meanflow=0.0000 mean_model_t=0.4957 mean_corrupt_t=0.4957 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.6827 corrupt_frac=0.5441 acc_corrupt=0.4500 loss_corrupt=10.2707 wrong_frac=0.5072 init_acc_corrupt=0.4580 acc_corrupt_t_0p0_0p2=0.0353 corrupt_frac_t_0p0_0p2=0.2091 acc_corrupt_t_0p2_0p4=0.2381 corrupt_frac_t_0p2_0p4=0.1997 acc_corrupt_t_0p4_0p6=0.4743 corrupt_frac_t_0p4_0p6=0.2015 acc_corrupt_t_0p6_0p8=0.6742 corrupt_frac_t_0p6_0p8=0.1933 acc_corrupt_t_0p8_1p0=0.8618 corrupt_frac_t_0p8_1p0=0.1963 out_w_norm=0.4520 out_g_norm=0.9094 loss_all=10.0676 init_gold_top10=0.4926 init_gold_top100=0.4970
|
| 128 |
+
step=100 micro_steps=400 elapsed=289.2s lr=3.030000e-05 loss=9.5867 loss_recon=9.5867 loss_meanflow=0.0000 mean_model_t=0.4967 mean_corrupt_t=0.4967 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.2468 corrupt_frac=0.5492 acc_corrupt=0.1477 loss_corrupt=9.5867 wrong_frac=0.5006 init_acc_corrupt=0.4653 acc_corrupt_t_0p0_0p2=0.0497 corrupt_frac_t_0p0_0p2=0.1962 acc_corrupt_t_0p2_0p4=0.0723 corrupt_frac_t_0p2_0p4=0.2040 acc_corrupt_t_0p4_0p6=0.1212 corrupt_frac_t_0p4_0p6=0.2022 acc_corrupt_t_0p6_0p8=0.1904 corrupt_frac_t_0p6_0p8=0.1979 acc_corrupt_t_0p8_1p0=0.3056 corrupt_frac_t_0p8_1p0=0.1996 out_w_norm=3.7134 out_g_norm=1.7010 loss_all=8.9889 init_gold_top10=0.5681 init_gold_top100=0.5714
|
| 129 |
+
Terminated
|
LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_save500_20260515_004319.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/lm1b_fullycoupled_wd0p1_fp32_4gpu/lta_lm1b_distilbert_len1024_fullycoupled_rmsnorm_nobias_adamw_wd0p1_nanogpt_tf32_ddit768x12_gbs512_4gpu_10k_save500_20260515_004319.nohup.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/lm1b_v8192_mask0p1_1p0/latest_run_name.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
lta_lm1b_compact_gpt2bpe_v8192_len128_mask0p1-1p0_uniformt_fp32_ddit768x12_gbs512_4gpu_1m_20260520_232453
|
LTA_openwebtext_dualt/logs/lm1b_v8192_mask0p1_1p0/lta_lm1b_compact_gpt2bpe_v8192_len128_mask0p1-1p0_uniformt_fp32_ddit768x12_gbs512_4gpu_1m_20260520_232453.nohup.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/qwen_service/qwen3p5_35b_a3b_transformers_gpu2_3_20260608_194952.log
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[transformers] `torch_dtype` is deprecated! Use `dtype` instead!
|
| 2 |
+
[transformers] The fast path is not available because one of the required library is not installed. Falling back to torch implementation. To install follow https://github.com/fla-org/flash-linear-attention#installation and https://github.com/Dao-AILab/causal-conv1d
|
| 3 |
+
|
| 4 |
+
INFO: Started server process [811404]
|
| 5 |
+
INFO: Waiting for application startup.
|
| 6 |
+
INFO: Application startup complete.
|
| 7 |
+
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
|
| 8 |
+
INFO: 127.0.0.1:53406 - "GET /v1/models HTTP/1.1" 200 OK
|
| 9 |
+
INFO: 127.0.0.1:53418 - "POST /v1/chat/completions HTTP/1.1" 200 OK
|
| 10 |
+
INFO: Shutting down
|
| 11 |
+
INFO: Waiting for application shutdown.
|
| 12 |
+
INFO: Application shutdown complete.
|
| 13 |
+
INFO: Finished server process [811404]
|
LTA_openwebtext_dualt/logs/qwen_service/qwen3p5_35b_a3b_transformers_gpu2_3_20260608_200311.pid
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
817067
|
LTA_openwebtext_dualt/logs/unigramwrong_debug/lta_owt_unigramwrong_smoke4gpu_20260514_160148.log
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
loaded_categorical_wrong_corpus_unigram=/e2e-data/evad-tech-vla/wanghan58/data/small_benchmarks/langflow_2604_11748/openwebtext_lta_cached_chunks/gpt2_len1024_train_minus_100k/unigram_counts_1mchunks_i64.pt alpha=0.7 top=11:6.845e-03,262:6.806e-03,13:6.620e-03,198:6.598e-03,284:4.382e-03,286:4.253e-03,290:4.018e-03,257:3.764e-03,287:3.238e-03,447:3.083e-03
|
| 2 |
+
{
|
| 3 |
+
"device": "cuda:0",
|
| 4 |
+
"rank": 0,
|
| 5 |
+
"world_size": 4,
|
| 6 |
+
"samples": "owt_cached_chunks:8734897",
|
| 7 |
+
"vocab_size": 50257,
|
| 8 |
+
"tokenizer_vocab_size": 50257,
|
| 9 |
+
"save_dir": "runs_debug/lta_owt_unigramwrong_smoke4gpu_20260514_160148",
|
| 10 |
+
"batch_size": 4,
|
| 11 |
+
"grad_accum": 1,
|
| 12 |
+
"effective_batch_size": 16,
|
| 13 |
+
"global_batch_size": 16,
|
| 14 |
+
"lr_schedule": "constant_warmup",
|
| 15 |
+
"optimizer": "adamw",
|
| 16 |
+
"warmup_steps": 2,
|
| 17 |
+
"min_lr": 0.0,
|
| 18 |
+
"weight_decay": 0.0,
|
| 19 |
+
"adamw_param_groups": "nanogpt",
|
| 20 |
+
"adam_beta1": 0.9,
|
| 21 |
+
"adam_beta2": 0.95,
|
| 22 |
+
"adam_eps": 1e-08,
|
| 23 |
+
"muon_momentum": 0.95,
|
| 24 |
+
"muon_ns_steps": 5,
|
| 25 |
+
"muon_update_scale": 1.0,
|
| 26 |
+
"ema_decay": 0.0,
|
| 27 |
+
"ema_start_step": 0,
|
| 28 |
+
"model_type": "ddit",
|
| 29 |
+
"dual_t": true,
|
| 30 |
+
"corrupt_t_mode": "same",
|
| 31 |
+
"corrupt_min_t": null,
|
| 32 |
+
"corrupt_max_t": null,
|
| 33 |
+
"prefix_block_prob": 0.0,
|
| 34 |
+
"prefix_block_len": 128,
|
| 35 |
+
"mask_ratio_floor_schedule": "none",
|
| 36 |
+
"dirichlet_endpoint_mode": "categorical_dual_t",
|
| 37 |
+
"dirichlet_semantic_t_mode": "same",
|
| 38 |
+
"dirichlet_semantic_t_value": 0.0,
|
| 39 |
+
"dirichlet_semantic_t_curve": "linear",
|
| 40 |
+
"dirichlet_semantic_t_power": 1.0,
|
| 41 |
+
"endpoint_sequence_random_prob_alpha": 0.0,
|
| 42 |
+
"categorical_wrong_from_full_vocab": false,
|
| 43 |
+
"categorical_wrong_from_batch_valid_tokens": false,
|
| 44 |
+
"categorical_wrong_basin_token_ids": "",
|
| 45 |
+
"categorical_wrong_basin_prob": 0.0,
|
| 46 |
+
"categorical_wrong_unigram_prob": 0.7,
|
| 47 |
+
"categorical_wrong_uniform_prob": 0.2,
|
| 48 |
+
"categorical_wrong_corpus_unigram_path": "/e2e-data/evad-tech-vla/wanghan58/data/small_benchmarks/langflow_2604_11748/openwebtext_lta_cached_chunks/gpt2_len1024_train_minus_100k/unigram_counts_1mchunks_i64.pt",
|
| 49 |
+
"categorical_wrong_corpus_unigram_alpha": 0.7,
|
| 50 |
+
"categorical_wrong_basin_shared_prob": 0.0,
|
| 51 |
+
"categorical_wrong_unigram_shared_prob": 0.1,
|
| 52 |
+
"mask_mixture_original_prob": 0.0,
|
| 53 |
+
"mask_mixture_lowk_prob": 0.0,
|
| 54 |
+
"mask_mixture_lowcorrupt_prob": 0.0,
|
| 55 |
+
"mask_mixture_block_prob": 0.0,
|
| 56 |
+
"mask_mixture_all_prob": 0.0,
|
| 57 |
+
"mask_mixture_lowk_clean_tokens": "1,2,4,8,16,32,64",
|
| 58 |
+
"mask_mixture_lowcorrupt_tokens": "1,2,4,8,16,32,64",
|
| 59 |
+
"mask_mixture_block_tokens": "64,128",
|
| 60 |
+
"simplex_bridge_sampler": "dirichlet",
|
| 61 |
+
"logistic_normal_sigma_min": 0.18,
|
| 62 |
+
"logistic_normal_sigma_max": 2.2,
|
| 63 |
+
"logistic_normal_tau_min": 0.65,
|
| 64 |
+
"logistic_normal_tau_max": 1.15,
|
| 65 |
+
"torch_compile": false,
|
| 66 |
+
"compile_mode": "max-autotune",
|
| 67 |
+
"state_format": "prob",
|
| 68 |
+
"target_loss": "hard_ce",
|
| 69 |
+
"meanflow_weight": 0.0,
|
| 70 |
+
"rollout_train_prob": 0.0,
|
| 71 |
+
"rollout_train_steps": 1,
|
| 72 |
+
"rollout_train_infer_steps": 64,
|
| 73 |
+
"rollout_train_temp": 1.45,
|
| 74 |
+
"rollout_train_max_gamma": 1.0,
|
| 75 |
+
"rollout_train_corrupt_only": true,
|
| 76 |
+
"rollout_train_samplewise": false,
|
| 77 |
+
"rollout_train_compute_always": false,
|
| 78 |
+
"bridge_noise_init": "logistic_normal",
|
| 79 |
+
"noise_sigma": -1.0,
|
| 80 |
+
"allow_tf32": true,
|
| 81 |
+
"activation_checkpointing": false,
|
| 82 |
+
"activation_checkpoint_interval": 1,
|
| 83 |
+
"activation_checkpoint_scope": "block",
|
| 84 |
+
"ddp_static_graph": false,
|
| 85 |
+
"ddp_gradient_as_bucket_view": true,
|
| 86 |
+
"blocking_data_transfer": false,
|
| 87 |
+
"dataloader_prefetch_factor": 2,
|
| 88 |
+
"full_train_stats": false,
|
| 89 |
+
"record_pad_truncate": false,
|
| 90 |
+
"record_add_eos": false,
|
| 91 |
+
"record_add_special_tokens": false,
|
| 92 |
+
"record_pad_token": "pad",
|
| 93 |
+
"record_shuffle_buffer": 10000,
|
| 94 |
+
"wrap": true,
|
| 95 |
+
"wrap_mode": "stream",
|
| 96 |
+
"wrap_record_buffer_size": 200,
|
| 97 |
+
"owt_cached_chunks": true,
|
| 98 |
+
"owt_chunk_cache_dir": "/e2e-data/evad-tech-vla/wanghan58/data/small_benchmarks/langflow_2604_11748/openwebtext_lta_cached_chunks/gpt2_len1024_train_minus_100k",
|
| 99 |
+
"owt_chunk_cache_rebuild": false,
|
| 100 |
+
"owt_chunk_cache_write_batch": 4096,
|
| 101 |
+
"owt_exact_repeat_per_chunk": 0,
|
| 102 |
+
"online_chunk_shuffle": false,
|
| 103 |
+
"online_chunk_shuffle_buffer": 10000,
|
| 104 |
+
"openwebtext_split": "train_minus_100k",
|
| 105 |
+
"detokenizer": "auto",
|
| 106 |
+
"resolved_detokenizer": null,
|
| 107 |
+
"num_workers": 0,
|
| 108 |
+
"latest_every": 1000,
|
| 109 |
+
"resume_path": ""
|
| 110 |
+
}
|
| 111 |
+
step=1 micro_steps=1 elapsed=1.2s lr=3.000000e-04 loss=10.8125 loss_recon=10.8125 loss_meanflow=0.0000 mean_model_t=0.2654 mean_corrupt_t=0.2654 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 out_w_norm=0.0000 out_g_norm=0.3924 acc_all=0.0010 acc_corrupt=0.0008 corrupt_frac=0.5942 loss_all=10.8125 loss_corrupt=10.8125 acc_corrupt_t_0p0_0p2=0.0000 corrupt_frac_t_0p0_0p2=0.3365 acc_corrupt_t_0p2_0p4=0.0016 corrupt_frac_t_0p2_0p4=0.2494 acc_corrupt_t_0p6_0p8=0.0010 corrupt_frac_t_0p6_0p8=0.4141 wrong_frac=0.6352 init_acc_corrupt=0.3492 init_gold_top10=0.3562 init_gold_top100=0.3919
|
| 112 |
+
step=2 micro_steps=2 elapsed=0.0s lr=3.000000e-04 loss=10.8125 loss_recon=10.8125 loss_meanflow=0.0000 mean_model_t=0.1699 mean_corrupt_t=0.1699 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 out_w_norm=0.3724 out_g_norm=0.4023 acc_all=0.2183 acc_corrupt=0.0400 corrupt_frac=0.4944 loss_all=10.8125 loss_corrupt=10.8125 acc_corrupt_t_0p0_0p2=0.0011 corrupt_frac_t_0p0_0p2=0.4484 acc_corrupt_t_0p2_0p4=0.0716 corrupt_frac_t_0p2_0p4=0.5516 wrong_frac=0.8602 init_acc_corrupt=0.0657 init_gold_top10=0.1328 init_gold_top100=0.2519
|
| 113 |
+
step=3 micro_steps=3 elapsed=0.0s lr=3.000000e-04 loss=10.8014 loss_recon=10.8014 loss_meanflow=0.0000 mean_model_t=0.5906 mean_corrupt_t=0.5906 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 out_w_norm=0.9480 out_g_norm=0.4448 acc_all=0.5015 acc_corrupt=0.2560 corrupt_frac=0.2937 loss_all=10.7898 loss_corrupt=10.8014 acc_corrupt_t_0p0_0p2=0.0352 corrupt_frac_t_0p0_0p2=0.4963 acc_corrupt_t_0p2_0p4=0.2587 corrupt_frac_t_0p2_0p4=0.1189 acc_corrupt_t_0p8_1p0=0.5400 corrupt_frac_t_0p8_1p0=0.3849 wrong_frac=0.5353 init_acc_corrupt=0.4090 init_gold_top10=0.4447 init_gold_top100=0.4996
|
| 114 |
+
step=4 micro_steps=4 elapsed=0.0s lr=3.000000e-04 loss=10.7817 loss_recon=10.7817 loss_meanflow=0.0000 mean_model_t=0.7003 mean_corrupt_t=0.7003 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 out_w_norm=1.4974 out_g_norm=0.5704 acc_all=0.5215 acc_corrupt=0.4367 corrupt_frac=0.4780 loss_all=10.7751 loss_corrupt=10.7817 acc_corrupt_t_0p4_0p6=0.3706 corrupt_frac_t_0p4_0p6=0.1461 acc_corrupt_t_0p6_0p8=0.4360 corrupt_frac_t_0p6_0p8=0.6900 acc_corrupt_t_0p8_1p0=0.4984 corrupt_frac_t_0p8_1p0=0.1639 wrong_frac=0.3172 init_acc_corrupt=0.6828 init_gold_top10=0.6828 init_gold_top100=0.6844
|
| 115 |
+
step=5 micro_steps=5 elapsed=0.0s lr=3.000000e-04 loss=10.7927 loss_recon=10.7927 loss_meanflow=0.0000 mean_model_t=0.3884 mean_corrupt_t=0.3884 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 out_w_norm=2.0579 out_g_norm=0.4211 acc_all=0.3484 acc_corrupt=0.2287 corrupt_frac=0.6951 loss_all=10.7805 loss_corrupt=10.7927 acc_corrupt_t_0p0_0p2=0.0395 corrupt_frac_t_0p0_0p2=0.2311 acc_corrupt_t_0p4_0p6=0.2855 corrupt_frac_t_0p4_0p6=0.7689 wrong_frac=0.6098 init_acc_corrupt=0.3628 init_gold_top10=0.3860 init_gold_top100=0.4110
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/__init__.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is dual licensed under the terms of the Apache License, Version
|
| 2 |
+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
| 3 |
+
# for complete details.
|
| 4 |
+
|
| 5 |
+
from .__about__ import (
|
| 6 |
+
__author__,
|
| 7 |
+
__copyright__,
|
| 8 |
+
__email__,
|
| 9 |
+
__license__,
|
| 10 |
+
__summary__,
|
| 11 |
+
__title__,
|
| 12 |
+
__uri__,
|
| 13 |
+
__version__,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
__all__ = [
|
| 17 |
+
"__title__",
|
| 18 |
+
"__summary__",
|
| 19 |
+
"__uri__",
|
| 20 |
+
"__version__",
|
| 21 |
+
"__author__",
|
| 22 |
+
"__email__",
|
| 23 |
+
"__license__",
|
| 24 |
+
"__copyright__",
|
| 25 |
+
]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/_manylinux.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import collections
|
| 2 |
+
import functools
|
| 3 |
+
import os
|
| 4 |
+
import re
|
| 5 |
+
import struct
|
| 6 |
+
import sys
|
| 7 |
+
import warnings
|
| 8 |
+
from typing import IO, Dict, Iterator, NamedTuple, Optional, Tuple
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# Python does not provide platform information at sufficient granularity to
|
| 12 |
+
# identify the architecture of the running executable in some cases, so we
|
| 13 |
+
# determine it dynamically by reading the information from the running
|
| 14 |
+
# process. This only applies on Linux, which uses the ELF format.
|
| 15 |
+
class _ELFFileHeader:
|
| 16 |
+
# https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
|
| 17 |
+
class _InvalidELFFileHeader(ValueError):
|
| 18 |
+
"""
|
| 19 |
+
An invalid ELF file header was found.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
ELF_MAGIC_NUMBER = 0x7F454C46
|
| 23 |
+
ELFCLASS32 = 1
|
| 24 |
+
ELFCLASS64 = 2
|
| 25 |
+
ELFDATA2LSB = 1
|
| 26 |
+
ELFDATA2MSB = 2
|
| 27 |
+
EM_386 = 3
|
| 28 |
+
EM_S390 = 22
|
| 29 |
+
EM_ARM = 40
|
| 30 |
+
EM_X86_64 = 62
|
| 31 |
+
EF_ARM_ABIMASK = 0xFF000000
|
| 32 |
+
EF_ARM_ABI_VER5 = 0x05000000
|
| 33 |
+
EF_ARM_ABI_FLOAT_HARD = 0x00000400
|
| 34 |
+
|
| 35 |
+
def __init__(self, file: IO[bytes]) -> None:
|
| 36 |
+
def unpack(fmt: str) -> int:
|
| 37 |
+
try:
|
| 38 |
+
data = file.read(struct.calcsize(fmt))
|
| 39 |
+
result: Tuple[int, ...] = struct.unpack(fmt, data)
|
| 40 |
+
except struct.error:
|
| 41 |
+
raise _ELFFileHeader._InvalidELFFileHeader()
|
| 42 |
+
return result[0]
|
| 43 |
+
|
| 44 |
+
self.e_ident_magic = unpack(">I")
|
| 45 |
+
if self.e_ident_magic != self.ELF_MAGIC_NUMBER:
|
| 46 |
+
raise _ELFFileHeader._InvalidELFFileHeader()
|
| 47 |
+
self.e_ident_class = unpack("B")
|
| 48 |
+
if self.e_ident_class not in {self.ELFCLASS32, self.ELFCLASS64}:
|
| 49 |
+
raise _ELFFileHeader._InvalidELFFileHeader()
|
| 50 |
+
self.e_ident_data = unpack("B")
|
| 51 |
+
if self.e_ident_data not in {self.ELFDATA2LSB, self.ELFDATA2MSB}:
|
| 52 |
+
raise _ELFFileHeader._InvalidELFFileHeader()
|
| 53 |
+
self.e_ident_version = unpack("B")
|
| 54 |
+
self.e_ident_osabi = unpack("B")
|
| 55 |
+
self.e_ident_abiversion = unpack("B")
|
| 56 |
+
self.e_ident_pad = file.read(7)
|
| 57 |
+
format_h = "<H" if self.e_ident_data == self.ELFDATA2LSB else ">H"
|
| 58 |
+
format_i = "<I" if self.e_ident_data == self.ELFDATA2LSB else ">I"
|
| 59 |
+
format_q = "<Q" if self.e_ident_data == self.ELFDATA2LSB else ">Q"
|
| 60 |
+
format_p = format_i if self.e_ident_class == self.ELFCLASS32 else format_q
|
| 61 |
+
self.e_type = unpack(format_h)
|
| 62 |
+
self.e_machine = unpack(format_h)
|
| 63 |
+
self.e_version = unpack(format_i)
|
| 64 |
+
self.e_entry = unpack(format_p)
|
| 65 |
+
self.e_phoff = unpack(format_p)
|
| 66 |
+
self.e_shoff = unpack(format_p)
|
| 67 |
+
self.e_flags = unpack(format_i)
|
| 68 |
+
self.e_ehsize = unpack(format_h)
|
| 69 |
+
self.e_phentsize = unpack(format_h)
|
| 70 |
+
self.e_phnum = unpack(format_h)
|
| 71 |
+
self.e_shentsize = unpack(format_h)
|
| 72 |
+
self.e_shnum = unpack(format_h)
|
| 73 |
+
self.e_shstrndx = unpack(format_h)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def _get_elf_header() -> Optional[_ELFFileHeader]:
|
| 77 |
+
try:
|
| 78 |
+
with open(sys.executable, "rb") as f:
|
| 79 |
+
elf_header = _ELFFileHeader(f)
|
| 80 |
+
except (OSError, TypeError, _ELFFileHeader._InvalidELFFileHeader):
|
| 81 |
+
return None
|
| 82 |
+
return elf_header
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def _is_linux_armhf() -> bool:
|
| 86 |
+
# hard-float ABI can be detected from the ELF header of the running
|
| 87 |
+
# process
|
| 88 |
+
# https://static.docs.arm.com/ihi0044/g/aaelf32.pdf
|
| 89 |
+
elf_header = _get_elf_header()
|
| 90 |
+
if elf_header is None:
|
| 91 |
+
return False
|
| 92 |
+
result = elf_header.e_ident_class == elf_header.ELFCLASS32
|
| 93 |
+
result &= elf_header.e_ident_data == elf_header.ELFDATA2LSB
|
| 94 |
+
result &= elf_header.e_machine == elf_header.EM_ARM
|
| 95 |
+
result &= (
|
| 96 |
+
elf_header.e_flags & elf_header.EF_ARM_ABIMASK
|
| 97 |
+
) == elf_header.EF_ARM_ABI_VER5
|
| 98 |
+
result &= (
|
| 99 |
+
elf_header.e_flags & elf_header.EF_ARM_ABI_FLOAT_HARD
|
| 100 |
+
) == elf_header.EF_ARM_ABI_FLOAT_HARD
|
| 101 |
+
return result
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def _is_linux_i686() -> bool:
|
| 105 |
+
elf_header = _get_elf_header()
|
| 106 |
+
if elf_header is None:
|
| 107 |
+
return False
|
| 108 |
+
result = elf_header.e_ident_class == elf_header.ELFCLASS32
|
| 109 |
+
result &= elf_header.e_ident_data == elf_header.ELFDATA2LSB
|
| 110 |
+
result &= elf_header.e_machine == elf_header.EM_386
|
| 111 |
+
return result
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def _have_compatible_abi(arch: str) -> bool:
|
| 115 |
+
if arch == "armv7l":
|
| 116 |
+
return _is_linux_armhf()
|
| 117 |
+
if arch == "i686":
|
| 118 |
+
return _is_linux_i686()
|
| 119 |
+
return arch in {"x86_64", "aarch64", "ppc64", "ppc64le", "s390x"}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
# If glibc ever changes its major version, we need to know what the last
|
| 123 |
+
# minor version was, so we can build the complete list of all versions.
|
| 124 |
+
# For now, guess what the highest minor version might be, assume it will
|
| 125 |
+
# be 50 for testing. Once this actually happens, update the dictionary
|
| 126 |
+
# with the actual value.
|
| 127 |
+
_LAST_GLIBC_MINOR: Dict[int, int] = collections.defaultdict(lambda: 50)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
class _GLibCVersion(NamedTuple):
|
| 131 |
+
major: int
|
| 132 |
+
minor: int
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def _glibc_version_string_confstr() -> Optional[str]:
|
| 136 |
+
"""
|
| 137 |
+
Primary implementation of glibc_version_string using os.confstr.
|
| 138 |
+
"""
|
| 139 |
+
# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
|
| 140 |
+
# to be broken or missing. This strategy is used in the standard library
|
| 141 |
+
# platform module.
|
| 142 |
+
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c/Lib/platform.py#L175-L183
|
| 143 |
+
try:
|
| 144 |
+
# os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17".
|
| 145 |
+
version_string = os.confstr("CS_GNU_LIBC_VERSION")
|
| 146 |
+
assert version_string is not None
|
| 147 |
+
_, version = version_string.split()
|
| 148 |
+
except (AssertionError, AttributeError, OSError, ValueError):
|
| 149 |
+
# os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
|
| 150 |
+
return None
|
| 151 |
+
return version
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def _glibc_version_string_ctypes() -> Optional[str]:
|
| 155 |
+
"""
|
| 156 |
+
Fallback implementation of glibc_version_string using ctypes.
|
| 157 |
+
"""
|
| 158 |
+
try:
|
| 159 |
+
import ctypes
|
| 160 |
+
except ImportError:
|
| 161 |
+
return None
|
| 162 |
+
|
| 163 |
+
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
|
| 164 |
+
# manpage says, "If filename is NULL, then the returned handle is for the
|
| 165 |
+
# main program". This way we can let the linker do the work to figure out
|
| 166 |
+
# which libc our process is actually using.
|
| 167 |
+
#
|
| 168 |
+
# We must also handle the special case where the executable is not a
|
| 169 |
+
# dynamically linked executable. This can occur when using musl libc,
|
| 170 |
+
# for example. In this situation, dlopen() will error, leading to an
|
| 171 |
+
# OSError. Interestingly, at least in the case of musl, there is no
|
| 172 |
+
# errno set on the OSError. The single string argument used to construct
|
| 173 |
+
# OSError comes from libc itself and is therefore not portable to
|
| 174 |
+
# hard code here. In any case, failure to call dlopen() means we
|
| 175 |
+
# can proceed, so we bail on our attempt.
|
| 176 |
+
try:
|
| 177 |
+
process_namespace = ctypes.CDLL(None)
|
| 178 |
+
except OSError:
|
| 179 |
+
return None
|
| 180 |
+
|
| 181 |
+
try:
|
| 182 |
+
gnu_get_libc_version = process_namespace.gnu_get_libc_version
|
| 183 |
+
except AttributeError:
|
| 184 |
+
# Symbol doesn't exist -> therefore, we are not linked to
|
| 185 |
+
# glibc.
|
| 186 |
+
return None
|
| 187 |
+
|
| 188 |
+
# Call gnu_get_libc_version, which returns a string like "2.5"
|
| 189 |
+
gnu_get_libc_version.restype = ctypes.c_char_p
|
| 190 |
+
version_str: str = gnu_get_libc_version()
|
| 191 |
+
# py2 / py3 compatibility:
|
| 192 |
+
if not isinstance(version_str, str):
|
| 193 |
+
version_str = version_str.decode("ascii")
|
| 194 |
+
|
| 195 |
+
return version_str
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def _glibc_version_string() -> Optional[str]:
|
| 199 |
+
"""Returns glibc version string, or None if not using glibc."""
|
| 200 |
+
return _glibc_version_string_confstr() or _glibc_version_string_ctypes()
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _parse_glibc_version(version_str: str) -> Tuple[int, int]:
|
| 204 |
+
"""Parse glibc version.
|
| 205 |
+
|
| 206 |
+
We use a regexp instead of str.split because we want to discard any
|
| 207 |
+
random junk that might come after the minor version -- this might happen
|
| 208 |
+
in patched/forked versions of glibc (e.g. Linaro's version of glibc
|
| 209 |
+
uses version strings like "2.20-2014.11"). See gh-3588.
|
| 210 |
+
"""
|
| 211 |
+
m = re.match(r"(?P<major>[0-9]+)\.(?P<minor>[0-9]+)", version_str)
|
| 212 |
+
if not m:
|
| 213 |
+
warnings.warn(
|
| 214 |
+
"Expected glibc version with 2 components major.minor,"
|
| 215 |
+
" got: %s" % version_str,
|
| 216 |
+
RuntimeWarning,
|
| 217 |
+
)
|
| 218 |
+
return -1, -1
|
| 219 |
+
return int(m.group("major")), int(m.group("minor"))
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
@functools.lru_cache()
|
| 223 |
+
def _get_glibc_version() -> Tuple[int, int]:
|
| 224 |
+
version_str = _glibc_version_string()
|
| 225 |
+
if version_str is None:
|
| 226 |
+
return (-1, -1)
|
| 227 |
+
return _parse_glibc_version(version_str)
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
# From PEP 513, PEP 600
|
| 231 |
+
def _is_compatible(name: str, arch: str, version: _GLibCVersion) -> bool:
|
| 232 |
+
sys_glibc = _get_glibc_version()
|
| 233 |
+
if sys_glibc < version:
|
| 234 |
+
return False
|
| 235 |
+
# Check for presence of _manylinux module.
|
| 236 |
+
try:
|
| 237 |
+
import _manylinux # noqa
|
| 238 |
+
except ImportError:
|
| 239 |
+
return True
|
| 240 |
+
if hasattr(_manylinux, "manylinux_compatible"):
|
| 241 |
+
result = _manylinux.manylinux_compatible(version[0], version[1], arch)
|
| 242 |
+
if result is not None:
|
| 243 |
+
return bool(result)
|
| 244 |
+
return True
|
| 245 |
+
if version == _GLibCVersion(2, 5):
|
| 246 |
+
if hasattr(_manylinux, "manylinux1_compatible"):
|
| 247 |
+
return bool(_manylinux.manylinux1_compatible)
|
| 248 |
+
if version == _GLibCVersion(2, 12):
|
| 249 |
+
if hasattr(_manylinux, "manylinux2010_compatible"):
|
| 250 |
+
return bool(_manylinux.manylinux2010_compatible)
|
| 251 |
+
if version == _GLibCVersion(2, 17):
|
| 252 |
+
if hasattr(_manylinux, "manylinux2014_compatible"):
|
| 253 |
+
return bool(_manylinux.manylinux2014_compatible)
|
| 254 |
+
return True
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
_LEGACY_MANYLINUX_MAP = {
|
| 258 |
+
# CentOS 7 w/ glibc 2.17 (PEP 599)
|
| 259 |
+
(2, 17): "manylinux2014",
|
| 260 |
+
# CentOS 6 w/ glibc 2.12 (PEP 571)
|
| 261 |
+
(2, 12): "manylinux2010",
|
| 262 |
+
# CentOS 5 w/ glibc 2.5 (PEP 513)
|
| 263 |
+
(2, 5): "manylinux1",
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def platform_tags(linux: str, arch: str) -> Iterator[str]:
|
| 268 |
+
if not _have_compatible_abi(arch):
|
| 269 |
+
return
|
| 270 |
+
# Oldest glibc to be supported regardless of architecture is (2, 17).
|
| 271 |
+
too_old_glibc2 = _GLibCVersion(2, 16)
|
| 272 |
+
if arch in {"x86_64", "i686"}:
|
| 273 |
+
# On x86/i686 also oldest glibc to be supported is (2, 5).
|
| 274 |
+
too_old_glibc2 = _GLibCVersion(2, 4)
|
| 275 |
+
current_glibc = _GLibCVersion(*_get_glibc_version())
|
| 276 |
+
glibc_max_list = [current_glibc]
|
| 277 |
+
# We can assume compatibility across glibc major versions.
|
| 278 |
+
# https://sourceware.org/bugzilla/show_bug.cgi?id=24636
|
| 279 |
+
#
|
| 280 |
+
# Build a list of maximum glibc versions so that we can
|
| 281 |
+
# output the canonical list of all glibc from current_glibc
|
| 282 |
+
# down to too_old_glibc2, including all intermediary versions.
|
| 283 |
+
for glibc_major in range(current_glibc.major - 1, 1, -1):
|
| 284 |
+
glibc_minor = _LAST_GLIBC_MINOR[glibc_major]
|
| 285 |
+
glibc_max_list.append(_GLibCVersion(glibc_major, glibc_minor))
|
| 286 |
+
for glibc_max in glibc_max_list:
|
| 287 |
+
if glibc_max.major == too_old_glibc2.major:
|
| 288 |
+
min_minor = too_old_glibc2.minor
|
| 289 |
+
else:
|
| 290 |
+
# For other glibc major versions oldest supported is (x, 0).
|
| 291 |
+
min_minor = -1
|
| 292 |
+
for glibc_minor in range(glibc_max.minor, min_minor, -1):
|
| 293 |
+
glibc_version = _GLibCVersion(glibc_max.major, glibc_minor)
|
| 294 |
+
tag = "manylinux_{}_{}".format(*glibc_version)
|
| 295 |
+
if _is_compatible(tag, arch, glibc_version):
|
| 296 |
+
yield linux.replace("linux", tag)
|
| 297 |
+
# Handle the legacy manylinux1, manylinux2010, manylinux2014 tags.
|
| 298 |
+
if glibc_version in _LEGACY_MANYLINUX_MAP:
|
| 299 |
+
legacy_tag = _LEGACY_MANYLINUX_MAP[glibc_version]
|
| 300 |
+
if _is_compatible(legacy_tag, arch, glibc_version):
|
| 301 |
+
yield linux.replace("linux", legacy_tag)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/_musllinux.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""PEP 656 support.
|
| 2 |
+
|
| 3 |
+
This module implements logic to detect if the currently running Python is
|
| 4 |
+
linked against musl, and what musl version is used.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import contextlib
|
| 8 |
+
import functools
|
| 9 |
+
import operator
|
| 10 |
+
import os
|
| 11 |
+
import re
|
| 12 |
+
import struct
|
| 13 |
+
import subprocess
|
| 14 |
+
import sys
|
| 15 |
+
from typing import IO, Iterator, NamedTuple, Optional, Tuple
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _read_unpacked(f: IO[bytes], fmt: str) -> Tuple[int, ...]:
|
| 19 |
+
return struct.unpack(fmt, f.read(struct.calcsize(fmt)))
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _parse_ld_musl_from_elf(f: IO[bytes]) -> Optional[str]:
|
| 23 |
+
"""Detect musl libc location by parsing the Python executable.
|
| 24 |
+
|
| 25 |
+
Based on: https://gist.github.com/lyssdod/f51579ae8d93c8657a5564aefc2ffbca
|
| 26 |
+
ELF header: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
|
| 27 |
+
"""
|
| 28 |
+
f.seek(0)
|
| 29 |
+
try:
|
| 30 |
+
ident = _read_unpacked(f, "16B")
|
| 31 |
+
except struct.error:
|
| 32 |
+
return None
|
| 33 |
+
if ident[:4] != tuple(b"\x7fELF"): # Invalid magic, not ELF.
|
| 34 |
+
return None
|
| 35 |
+
f.seek(struct.calcsize("HHI"), 1) # Skip file type, machine, and version.
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
# e_fmt: Format for program header.
|
| 39 |
+
# p_fmt: Format for section header.
|
| 40 |
+
# p_idx: Indexes to find p_type, p_offset, and p_filesz.
|
| 41 |
+
e_fmt, p_fmt, p_idx = {
|
| 42 |
+
1: ("IIIIHHH", "IIIIIIII", (0, 1, 4)), # 32-bit.
|
| 43 |
+
2: ("QQQIHHH", "IIQQQQQQ", (0, 2, 5)), # 64-bit.
|
| 44 |
+
}[ident[4]]
|
| 45 |
+
except KeyError:
|
| 46 |
+
return None
|
| 47 |
+
else:
|
| 48 |
+
p_get = operator.itemgetter(*p_idx)
|
| 49 |
+
|
| 50 |
+
# Find the interpreter section and return its content.
|
| 51 |
+
try:
|
| 52 |
+
_, e_phoff, _, _, _, e_phentsize, e_phnum = _read_unpacked(f, e_fmt)
|
| 53 |
+
except struct.error:
|
| 54 |
+
return None
|
| 55 |
+
for i in range(e_phnum + 1):
|
| 56 |
+
f.seek(e_phoff + e_phentsize * i)
|
| 57 |
+
try:
|
| 58 |
+
p_type, p_offset, p_filesz = p_get(_read_unpacked(f, p_fmt))
|
| 59 |
+
except struct.error:
|
| 60 |
+
return None
|
| 61 |
+
if p_type != 3: # Not PT_INTERP.
|
| 62 |
+
continue
|
| 63 |
+
f.seek(p_offset)
|
| 64 |
+
interpreter = os.fsdecode(f.read(p_filesz)).strip("\0")
|
| 65 |
+
if "musl" not in interpreter:
|
| 66 |
+
return None
|
| 67 |
+
return interpreter
|
| 68 |
+
return None
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class _MuslVersion(NamedTuple):
|
| 72 |
+
major: int
|
| 73 |
+
minor: int
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def _parse_musl_version(output: str) -> Optional[_MuslVersion]:
|
| 77 |
+
lines = [n for n in (n.strip() for n in output.splitlines()) if n]
|
| 78 |
+
if len(lines) < 2 or lines[0][:4] != "musl":
|
| 79 |
+
return None
|
| 80 |
+
m = re.match(r"Version (\d+)\.(\d+)", lines[1])
|
| 81 |
+
if not m:
|
| 82 |
+
return None
|
| 83 |
+
return _MuslVersion(major=int(m.group(1)), minor=int(m.group(2)))
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
@functools.lru_cache()
|
| 87 |
+
def _get_musl_version(executable: str) -> Optional[_MuslVersion]:
|
| 88 |
+
"""Detect currently-running musl runtime version.
|
| 89 |
+
|
| 90 |
+
This is done by checking the specified executable's dynamic linking
|
| 91 |
+
information, and invoking the loader to parse its output for a version
|
| 92 |
+
string. If the loader is musl, the output would be something like::
|
| 93 |
+
|
| 94 |
+
musl libc (x86_64)
|
| 95 |
+
Version 1.2.2
|
| 96 |
+
Dynamic Program Loader
|
| 97 |
+
"""
|
| 98 |
+
with contextlib.ExitStack() as stack:
|
| 99 |
+
try:
|
| 100 |
+
f = stack.enter_context(open(executable, "rb"))
|
| 101 |
+
except OSError:
|
| 102 |
+
return None
|
| 103 |
+
ld = _parse_ld_musl_from_elf(f)
|
| 104 |
+
if not ld:
|
| 105 |
+
return None
|
| 106 |
+
proc = subprocess.run([ld], stderr=subprocess.PIPE, universal_newlines=True)
|
| 107 |
+
return _parse_musl_version(proc.stderr)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def platform_tags(arch: str) -> Iterator[str]:
|
| 111 |
+
"""Generate musllinux tags compatible to the current platform.
|
| 112 |
+
|
| 113 |
+
:param arch: Should be the part of platform tag after the ``linux_``
|
| 114 |
+
prefix, e.g. ``x86_64``. The ``linux_`` prefix is assumed as a
|
| 115 |
+
prerequisite for the current platform to be musllinux-compatible.
|
| 116 |
+
|
| 117 |
+
:returns: An iterator of compatible musllinux tags.
|
| 118 |
+
"""
|
| 119 |
+
sys_musl = _get_musl_version(sys.executable)
|
| 120 |
+
if sys_musl is None: # Python not dynamically linked against musl.
|
| 121 |
+
return
|
| 122 |
+
for minor in range(sys_musl.minor, -1, -1):
|
| 123 |
+
yield f"musllinux_{sys_musl.major}_{minor}_{arch}"
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__": # pragma: no cover
|
| 127 |
+
import sysconfig
|
| 128 |
+
|
| 129 |
+
plat = sysconfig.get_platform()
|
| 130 |
+
assert plat.startswith("linux-"), "not linux"
|
| 131 |
+
|
| 132 |
+
print("plat:", plat)
|
| 133 |
+
print("musl:", _get_musl_version(sys.executable))
|
| 134 |
+
print("tags:", end=" ")
|
| 135 |
+
for t in platform_tags(re.sub(r"[.-]", "_", plat.split("-", 1)[-1])):
|
| 136 |
+
print(t, end="\n ")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is dual licensed under the terms of the Apache License, Version
|
| 2 |
+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
| 3 |
+
# for complete details.
|
| 4 |
+
|
| 5 |
+
import operator
|
| 6 |
+
import os
|
| 7 |
+
import platform
|
| 8 |
+
import sys
|
| 9 |
+
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
| 10 |
+
|
| 11 |
+
from pip._vendor.pyparsing import ( # noqa: N817
|
| 12 |
+
Forward,
|
| 13 |
+
Group,
|
| 14 |
+
Literal as L,
|
| 15 |
+
ParseException,
|
| 16 |
+
ParseResults,
|
| 17 |
+
QuotedString,
|
| 18 |
+
ZeroOrMore,
|
| 19 |
+
stringEnd,
|
| 20 |
+
stringStart,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from .specifiers import InvalidSpecifier, Specifier
|
| 24 |
+
|
| 25 |
+
__all__ = [
|
| 26 |
+
"InvalidMarker",
|
| 27 |
+
"UndefinedComparison",
|
| 28 |
+
"UndefinedEnvironmentName",
|
| 29 |
+
"Marker",
|
| 30 |
+
"default_environment",
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
Operator = Callable[[str, str], bool]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class InvalidMarker(ValueError):
|
| 37 |
+
"""
|
| 38 |
+
An invalid marker was found, users should refer to PEP 508.
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class UndefinedComparison(ValueError):
|
| 43 |
+
"""
|
| 44 |
+
An invalid operation was attempted on a value that doesn't support it.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class UndefinedEnvironmentName(ValueError):
|
| 49 |
+
"""
|
| 50 |
+
A name was attempted to be used that does not exist inside of the
|
| 51 |
+
environment.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class Node:
|
| 56 |
+
def __init__(self, value: Any) -> None:
|
| 57 |
+
self.value = value
|
| 58 |
+
|
| 59 |
+
def __str__(self) -> str:
|
| 60 |
+
return str(self.value)
|
| 61 |
+
|
| 62 |
+
def __repr__(self) -> str:
|
| 63 |
+
return f"<{self.__class__.__name__}('{self}')>"
|
| 64 |
+
|
| 65 |
+
def serialize(self) -> str:
|
| 66 |
+
raise NotImplementedError
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class Variable(Node):
|
| 70 |
+
def serialize(self) -> str:
|
| 71 |
+
return str(self)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class Value(Node):
|
| 75 |
+
def serialize(self) -> str:
|
| 76 |
+
return f'"{self}"'
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class Op(Node):
|
| 80 |
+
def serialize(self) -> str:
|
| 81 |
+
return str(self)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
VARIABLE = (
|
| 85 |
+
L("implementation_version")
|
| 86 |
+
| L("platform_python_implementation")
|
| 87 |
+
| L("implementation_name")
|
| 88 |
+
| L("python_full_version")
|
| 89 |
+
| L("platform_release")
|
| 90 |
+
| L("platform_version")
|
| 91 |
+
| L("platform_machine")
|
| 92 |
+
| L("platform_system")
|
| 93 |
+
| L("python_version")
|
| 94 |
+
| L("sys_platform")
|
| 95 |
+
| L("os_name")
|
| 96 |
+
| L("os.name") # PEP-345
|
| 97 |
+
| L("sys.platform") # PEP-345
|
| 98 |
+
| L("platform.version") # PEP-345
|
| 99 |
+
| L("platform.machine") # PEP-345
|
| 100 |
+
| L("platform.python_implementation") # PEP-345
|
| 101 |
+
| L("python_implementation") # undocumented setuptools legacy
|
| 102 |
+
| L("extra") # PEP-508
|
| 103 |
+
)
|
| 104 |
+
ALIASES = {
|
| 105 |
+
"os.name": "os_name",
|
| 106 |
+
"sys.platform": "sys_platform",
|
| 107 |
+
"platform.version": "platform_version",
|
| 108 |
+
"platform.machine": "platform_machine",
|
| 109 |
+
"platform.python_implementation": "platform_python_implementation",
|
| 110 |
+
"python_implementation": "platform_python_implementation",
|
| 111 |
+
}
|
| 112 |
+
VARIABLE.setParseAction(lambda s, l, t: Variable(ALIASES.get(t[0], t[0])))
|
| 113 |
+
|
| 114 |
+
VERSION_CMP = (
|
| 115 |
+
L("===") | L("==") | L(">=") | L("<=") | L("!=") | L("~=") | L(">") | L("<")
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
MARKER_OP = VERSION_CMP | L("not in") | L("in")
|
| 119 |
+
MARKER_OP.setParseAction(lambda s, l, t: Op(t[0]))
|
| 120 |
+
|
| 121 |
+
MARKER_VALUE = QuotedString("'") | QuotedString('"')
|
| 122 |
+
MARKER_VALUE.setParseAction(lambda s, l, t: Value(t[0]))
|
| 123 |
+
|
| 124 |
+
BOOLOP = L("and") | L("or")
|
| 125 |
+
|
| 126 |
+
MARKER_VAR = VARIABLE | MARKER_VALUE
|
| 127 |
+
|
| 128 |
+
MARKER_ITEM = Group(MARKER_VAR + MARKER_OP + MARKER_VAR)
|
| 129 |
+
MARKER_ITEM.setParseAction(lambda s, l, t: tuple(t[0]))
|
| 130 |
+
|
| 131 |
+
LPAREN = L("(").suppress()
|
| 132 |
+
RPAREN = L(")").suppress()
|
| 133 |
+
|
| 134 |
+
MARKER_EXPR = Forward()
|
| 135 |
+
MARKER_ATOM = MARKER_ITEM | Group(LPAREN + MARKER_EXPR + RPAREN)
|
| 136 |
+
MARKER_EXPR << MARKER_ATOM + ZeroOrMore(BOOLOP + MARKER_EXPR)
|
| 137 |
+
|
| 138 |
+
MARKER = stringStart + MARKER_EXPR + stringEnd
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def _coerce_parse_result(results: Union[ParseResults, List[Any]]) -> List[Any]:
|
| 142 |
+
if isinstance(results, ParseResults):
|
| 143 |
+
return [_coerce_parse_result(i) for i in results]
|
| 144 |
+
else:
|
| 145 |
+
return results
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def _format_marker(
|
| 149 |
+
marker: Union[List[str], Tuple[Node, ...], str], first: Optional[bool] = True
|
| 150 |
+
) -> str:
|
| 151 |
+
|
| 152 |
+
assert isinstance(marker, (list, tuple, str))
|
| 153 |
+
|
| 154 |
+
# Sometimes we have a structure like [[...]] which is a single item list
|
| 155 |
+
# where the single item is itself it's own list. In that case we want skip
|
| 156 |
+
# the rest of this function so that we don't get extraneous () on the
|
| 157 |
+
# outside.
|
| 158 |
+
if (
|
| 159 |
+
isinstance(marker, list)
|
| 160 |
+
and len(marker) == 1
|
| 161 |
+
and isinstance(marker[0], (list, tuple))
|
| 162 |
+
):
|
| 163 |
+
return _format_marker(marker[0])
|
| 164 |
+
|
| 165 |
+
if isinstance(marker, list):
|
| 166 |
+
inner = (_format_marker(m, first=False) for m in marker)
|
| 167 |
+
if first:
|
| 168 |
+
return " ".join(inner)
|
| 169 |
+
else:
|
| 170 |
+
return "(" + " ".join(inner) + ")"
|
| 171 |
+
elif isinstance(marker, tuple):
|
| 172 |
+
return " ".join([m.serialize() for m in marker])
|
| 173 |
+
else:
|
| 174 |
+
return marker
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
_operators: Dict[str, Operator] = {
|
| 178 |
+
"in": lambda lhs, rhs: lhs in rhs,
|
| 179 |
+
"not in": lambda lhs, rhs: lhs not in rhs,
|
| 180 |
+
"<": operator.lt,
|
| 181 |
+
"<=": operator.le,
|
| 182 |
+
"==": operator.eq,
|
| 183 |
+
"!=": operator.ne,
|
| 184 |
+
">=": operator.ge,
|
| 185 |
+
">": operator.gt,
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def _eval_op(lhs: str, op: Op, rhs: str) -> bool:
|
| 190 |
+
try:
|
| 191 |
+
spec = Specifier("".join([op.serialize(), rhs]))
|
| 192 |
+
except InvalidSpecifier:
|
| 193 |
+
pass
|
| 194 |
+
else:
|
| 195 |
+
return spec.contains(lhs)
|
| 196 |
+
|
| 197 |
+
oper: Optional[Operator] = _operators.get(op.serialize())
|
| 198 |
+
if oper is None:
|
| 199 |
+
raise UndefinedComparison(f"Undefined {op!r} on {lhs!r} and {rhs!r}.")
|
| 200 |
+
|
| 201 |
+
return oper(lhs, rhs)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
class Undefined:
|
| 205 |
+
pass
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
_undefined = Undefined()
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def _get_env(environment: Dict[str, str], name: str) -> str:
|
| 212 |
+
value: Union[str, Undefined] = environment.get(name, _undefined)
|
| 213 |
+
|
| 214 |
+
if isinstance(value, Undefined):
|
| 215 |
+
raise UndefinedEnvironmentName(
|
| 216 |
+
f"{name!r} does not exist in evaluation environment."
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
return value
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def _evaluate_markers(markers: List[Any], environment: Dict[str, str]) -> bool:
|
| 223 |
+
groups: List[List[bool]] = [[]]
|
| 224 |
+
|
| 225 |
+
for marker in markers:
|
| 226 |
+
assert isinstance(marker, (list, tuple, str))
|
| 227 |
+
|
| 228 |
+
if isinstance(marker, list):
|
| 229 |
+
groups[-1].append(_evaluate_markers(marker, environment))
|
| 230 |
+
elif isinstance(marker, tuple):
|
| 231 |
+
lhs, op, rhs = marker
|
| 232 |
+
|
| 233 |
+
if isinstance(lhs, Variable):
|
| 234 |
+
lhs_value = _get_env(environment, lhs.value)
|
| 235 |
+
rhs_value = rhs.value
|
| 236 |
+
else:
|
| 237 |
+
lhs_value = lhs.value
|
| 238 |
+
rhs_value = _get_env(environment, rhs.value)
|
| 239 |
+
|
| 240 |
+
groups[-1].append(_eval_op(lhs_value, op, rhs_value))
|
| 241 |
+
else:
|
| 242 |
+
assert marker in ["and", "or"]
|
| 243 |
+
if marker == "or":
|
| 244 |
+
groups.append([])
|
| 245 |
+
|
| 246 |
+
return any(all(item) for item in groups)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def format_full_version(info: "sys._version_info") -> str:
|
| 250 |
+
version = "{0.major}.{0.minor}.{0.micro}".format(info)
|
| 251 |
+
kind = info.releaselevel
|
| 252 |
+
if kind != "final":
|
| 253 |
+
version += kind[0] + str(info.serial)
|
| 254 |
+
return version
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def default_environment() -> Dict[str, str]:
|
| 258 |
+
iver = format_full_version(sys.implementation.version)
|
| 259 |
+
implementation_name = sys.implementation.name
|
| 260 |
+
return {
|
| 261 |
+
"implementation_name": implementation_name,
|
| 262 |
+
"implementation_version": iver,
|
| 263 |
+
"os_name": os.name,
|
| 264 |
+
"platform_machine": platform.machine(),
|
| 265 |
+
"platform_release": platform.release(),
|
| 266 |
+
"platform_system": platform.system(),
|
| 267 |
+
"platform_version": platform.version(),
|
| 268 |
+
"python_full_version": platform.python_version(),
|
| 269 |
+
"platform_python_implementation": platform.python_implementation(),
|
| 270 |
+
"python_version": ".".join(platform.python_version_tuple()[:2]),
|
| 271 |
+
"sys_platform": sys.platform,
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
class Marker:
|
| 276 |
+
def __init__(self, marker: str) -> None:
|
| 277 |
+
try:
|
| 278 |
+
self._markers = _coerce_parse_result(MARKER.parseString(marker))
|
| 279 |
+
except ParseException as e:
|
| 280 |
+
raise InvalidMarker(
|
| 281 |
+
f"Invalid marker: {marker!r}, parse error at "
|
| 282 |
+
f"{marker[e.loc : e.loc + 8]!r}"
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
def __str__(self) -> str:
|
| 286 |
+
return _format_marker(self._markers)
|
| 287 |
+
|
| 288 |
+
def __repr__(self) -> str:
|
| 289 |
+
return f"<Marker('{self}')>"
|
| 290 |
+
|
| 291 |
+
def evaluate(self, environment: Optional[Dict[str, str]] = None) -> bool:
|
| 292 |
+
"""Evaluate a marker.
|
| 293 |
+
|
| 294 |
+
Return the boolean from evaluating the given marker against the
|
| 295 |
+
environment. environment is an optional argument to override all or
|
| 296 |
+
part of the determined environment.
|
| 297 |
+
|
| 298 |
+
The environment is determined from the current Python process.
|
| 299 |
+
"""
|
| 300 |
+
current_environment = default_environment()
|
| 301 |
+
if environment is not None:
|
| 302 |
+
current_environment.update(environment)
|
| 303 |
+
|
| 304 |
+
return _evaluate_markers(self._markers, current_environment)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is dual licensed under the terms of the Apache License, Version
|
| 2 |
+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
| 3 |
+
# for complete details.
|
| 4 |
+
|
| 5 |
+
import re
|
| 6 |
+
import string
|
| 7 |
+
import urllib.parse
|
| 8 |
+
from typing import List, Optional as TOptional, Set
|
| 9 |
+
|
| 10 |
+
from pip._vendor.pyparsing import ( # noqa
|
| 11 |
+
Combine,
|
| 12 |
+
Literal as L,
|
| 13 |
+
Optional,
|
| 14 |
+
ParseException,
|
| 15 |
+
Regex,
|
| 16 |
+
Word,
|
| 17 |
+
ZeroOrMore,
|
| 18 |
+
originalTextFor,
|
| 19 |
+
stringEnd,
|
| 20 |
+
stringStart,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from .markers import MARKER_EXPR, Marker
|
| 24 |
+
from .specifiers import LegacySpecifier, Specifier, SpecifierSet
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class InvalidRequirement(ValueError):
|
| 28 |
+
"""
|
| 29 |
+
An invalid requirement was found, users should refer to PEP 508.
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
ALPHANUM = Word(string.ascii_letters + string.digits)
|
| 34 |
+
|
| 35 |
+
LBRACKET = L("[").suppress()
|
| 36 |
+
RBRACKET = L("]").suppress()
|
| 37 |
+
LPAREN = L("(").suppress()
|
| 38 |
+
RPAREN = L(")").suppress()
|
| 39 |
+
COMMA = L(",").suppress()
|
| 40 |
+
SEMICOLON = L(";").suppress()
|
| 41 |
+
AT = L("@").suppress()
|
| 42 |
+
|
| 43 |
+
PUNCTUATION = Word("-_.")
|
| 44 |
+
IDENTIFIER_END = ALPHANUM | (ZeroOrMore(PUNCTUATION) + ALPHANUM)
|
| 45 |
+
IDENTIFIER = Combine(ALPHANUM + ZeroOrMore(IDENTIFIER_END))
|
| 46 |
+
|
| 47 |
+
NAME = IDENTIFIER("name")
|
| 48 |
+
EXTRA = IDENTIFIER
|
| 49 |
+
|
| 50 |
+
URI = Regex(r"[^ ]+")("url")
|
| 51 |
+
URL = AT + URI
|
| 52 |
+
|
| 53 |
+
EXTRAS_LIST = EXTRA + ZeroOrMore(COMMA + EXTRA)
|
| 54 |
+
EXTRAS = (LBRACKET + Optional(EXTRAS_LIST) + RBRACKET)("extras")
|
| 55 |
+
|
| 56 |
+
VERSION_PEP440 = Regex(Specifier._regex_str, re.VERBOSE | re.IGNORECASE)
|
| 57 |
+
VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE)
|
| 58 |
+
|
| 59 |
+
VERSION_ONE = VERSION_PEP440 ^ VERSION_LEGACY
|
| 60 |
+
VERSION_MANY = Combine(
|
| 61 |
+
VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE), joinString=",", adjacent=False
|
| 62 |
+
)("_raw_spec")
|
| 63 |
+
_VERSION_SPEC = Optional((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY)
|
| 64 |
+
_VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or "")
|
| 65 |
+
|
| 66 |
+
VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier")
|
| 67 |
+
VERSION_SPEC.setParseAction(lambda s, l, t: t[1])
|
| 68 |
+
|
| 69 |
+
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
|
| 70 |
+
MARKER_EXPR.setParseAction(
|
| 71 |
+
lambda s, l, t: Marker(s[t._original_start : t._original_end])
|
| 72 |
+
)
|
| 73 |
+
MARKER_SEPARATOR = SEMICOLON
|
| 74 |
+
MARKER = MARKER_SEPARATOR + MARKER_EXPR
|
| 75 |
+
|
| 76 |
+
VERSION_AND_MARKER = VERSION_SPEC + Optional(MARKER)
|
| 77 |
+
URL_AND_MARKER = URL + Optional(MARKER)
|
| 78 |
+
|
| 79 |
+
NAMED_REQUIREMENT = NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER)
|
| 80 |
+
|
| 81 |
+
REQUIREMENT = stringStart + NAMED_REQUIREMENT + stringEnd
|
| 82 |
+
# pyparsing isn't thread safe during initialization, so we do it eagerly, see
|
| 83 |
+
# issue #104
|
| 84 |
+
REQUIREMENT.parseString("x[]")
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class Requirement:
|
| 88 |
+
"""Parse a requirement.
|
| 89 |
+
|
| 90 |
+
Parse a given requirement string into its parts, such as name, specifier,
|
| 91 |
+
URL, and extras. Raises InvalidRequirement on a badly-formed requirement
|
| 92 |
+
string.
|
| 93 |
+
"""
|
| 94 |
+
|
| 95 |
+
# TODO: Can we test whether something is contained within a requirement?
|
| 96 |
+
# If so how do we do that? Do we need to test against the _name_ of
|
| 97 |
+
# the thing as well as the version? What about the markers?
|
| 98 |
+
# TODO: Can we normalize the name and extra name?
|
| 99 |
+
|
| 100 |
+
def __init__(self, requirement_string: str) -> None:
|
| 101 |
+
try:
|
| 102 |
+
req = REQUIREMENT.parseString(requirement_string)
|
| 103 |
+
except ParseException as e:
|
| 104 |
+
raise InvalidRequirement(
|
| 105 |
+
f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
self.name: str = req.name
|
| 109 |
+
if req.url:
|
| 110 |
+
parsed_url = urllib.parse.urlparse(req.url)
|
| 111 |
+
if parsed_url.scheme == "file":
|
| 112 |
+
if urllib.parse.urlunparse(parsed_url) != req.url:
|
| 113 |
+
raise InvalidRequirement("Invalid URL given")
|
| 114 |
+
elif not (parsed_url.scheme and parsed_url.netloc) or (
|
| 115 |
+
not parsed_url.scheme and not parsed_url.netloc
|
| 116 |
+
):
|
| 117 |
+
raise InvalidRequirement(f"Invalid URL: {req.url}")
|
| 118 |
+
self.url: TOptional[str] = req.url
|
| 119 |
+
else:
|
| 120 |
+
self.url = None
|
| 121 |
+
self.extras: Set[str] = set(req.extras.asList() if req.extras else [])
|
| 122 |
+
self.specifier: SpecifierSet = SpecifierSet(req.specifier)
|
| 123 |
+
self.marker: TOptional[Marker] = req.marker if req.marker else None
|
| 124 |
+
|
| 125 |
+
def __str__(self) -> str:
|
| 126 |
+
parts: List[str] = [self.name]
|
| 127 |
+
|
| 128 |
+
if self.extras:
|
| 129 |
+
formatted_extras = ",".join(sorted(self.extras))
|
| 130 |
+
parts.append(f"[{formatted_extras}]")
|
| 131 |
+
|
| 132 |
+
if self.specifier:
|
| 133 |
+
parts.append(str(self.specifier))
|
| 134 |
+
|
| 135 |
+
if self.url:
|
| 136 |
+
parts.append(f"@ {self.url}")
|
| 137 |
+
if self.marker:
|
| 138 |
+
parts.append(" ")
|
| 139 |
+
|
| 140 |
+
if self.marker:
|
| 141 |
+
parts.append(f"; {self.marker}")
|
| 142 |
+
|
| 143 |
+
return "".join(parts)
|
| 144 |
+
|
| 145 |
+
def __repr__(self) -> str:
|
| 146 |
+
return f"<Requirement('{self}')>"
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/tags.py
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is dual licensed under the terms of the Apache License, Version
|
| 2 |
+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
| 3 |
+
# for complete details.
|
| 4 |
+
|
| 5 |
+
import logging
|
| 6 |
+
import platform
|
| 7 |
+
import sys
|
| 8 |
+
import sysconfig
|
| 9 |
+
from importlib.machinery import EXTENSION_SUFFIXES
|
| 10 |
+
from typing import (
|
| 11 |
+
Dict,
|
| 12 |
+
FrozenSet,
|
| 13 |
+
Iterable,
|
| 14 |
+
Iterator,
|
| 15 |
+
List,
|
| 16 |
+
Optional,
|
| 17 |
+
Sequence,
|
| 18 |
+
Tuple,
|
| 19 |
+
Union,
|
| 20 |
+
cast,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from . import _manylinux, _musllinux
|
| 24 |
+
|
| 25 |
+
logger = logging.getLogger(__name__)
|
| 26 |
+
|
| 27 |
+
PythonVersion = Sequence[int]
|
| 28 |
+
MacVersion = Tuple[int, int]
|
| 29 |
+
|
| 30 |
+
INTERPRETER_SHORT_NAMES: Dict[str, str] = {
|
| 31 |
+
"python": "py", # Generic.
|
| 32 |
+
"cpython": "cp",
|
| 33 |
+
"pypy": "pp",
|
| 34 |
+
"ironpython": "ip",
|
| 35 |
+
"jython": "jy",
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
_32_BIT_INTERPRETER = sys.maxsize <= 2 ** 32
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class Tag:
|
| 43 |
+
"""
|
| 44 |
+
A representation of the tag triple for a wheel.
|
| 45 |
+
|
| 46 |
+
Instances are considered immutable and thus are hashable. Equality checking
|
| 47 |
+
is also supported.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
__slots__ = ["_interpreter", "_abi", "_platform", "_hash"]
|
| 51 |
+
|
| 52 |
+
def __init__(self, interpreter: str, abi: str, platform: str) -> None:
|
| 53 |
+
self._interpreter = interpreter.lower()
|
| 54 |
+
self._abi = abi.lower()
|
| 55 |
+
self._platform = platform.lower()
|
| 56 |
+
# The __hash__ of every single element in a Set[Tag] will be evaluated each time
|
| 57 |
+
# that a set calls its `.disjoint()` method, which may be called hundreds of
|
| 58 |
+
# times when scanning a page of links for packages with tags matching that
|
| 59 |
+
# Set[Tag]. Pre-computing the value here produces significant speedups for
|
| 60 |
+
# downstream consumers.
|
| 61 |
+
self._hash = hash((self._interpreter, self._abi, self._platform))
|
| 62 |
+
|
| 63 |
+
@property
|
| 64 |
+
def interpreter(self) -> str:
|
| 65 |
+
return self._interpreter
|
| 66 |
+
|
| 67 |
+
@property
|
| 68 |
+
def abi(self) -> str:
|
| 69 |
+
return self._abi
|
| 70 |
+
|
| 71 |
+
@property
|
| 72 |
+
def platform(self) -> str:
|
| 73 |
+
return self._platform
|
| 74 |
+
|
| 75 |
+
def __eq__(self, other: object) -> bool:
|
| 76 |
+
if not isinstance(other, Tag):
|
| 77 |
+
return NotImplemented
|
| 78 |
+
|
| 79 |
+
return (
|
| 80 |
+
(self._hash == other._hash) # Short-circuit ASAP for perf reasons.
|
| 81 |
+
and (self._platform == other._platform)
|
| 82 |
+
and (self._abi == other._abi)
|
| 83 |
+
and (self._interpreter == other._interpreter)
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
def __hash__(self) -> int:
|
| 87 |
+
return self._hash
|
| 88 |
+
|
| 89 |
+
def __str__(self) -> str:
|
| 90 |
+
return f"{self._interpreter}-{self._abi}-{self._platform}"
|
| 91 |
+
|
| 92 |
+
def __repr__(self) -> str:
|
| 93 |
+
return f"<{self} @ {id(self)}>"
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def parse_tag(tag: str) -> FrozenSet[Tag]:
|
| 97 |
+
"""
|
| 98 |
+
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
|
| 99 |
+
|
| 100 |
+
Returning a set is required due to the possibility that the tag is a
|
| 101 |
+
compressed tag set.
|
| 102 |
+
"""
|
| 103 |
+
tags = set()
|
| 104 |
+
interpreters, abis, platforms = tag.split("-")
|
| 105 |
+
for interpreter in interpreters.split("."):
|
| 106 |
+
for abi in abis.split("."):
|
| 107 |
+
for platform_ in platforms.split("."):
|
| 108 |
+
tags.add(Tag(interpreter, abi, platform_))
|
| 109 |
+
return frozenset(tags)
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def _get_config_var(name: str, warn: bool = False) -> Union[int, str, None]:
|
| 113 |
+
value = sysconfig.get_config_var(name)
|
| 114 |
+
if value is None and warn:
|
| 115 |
+
logger.debug(
|
| 116 |
+
"Config variable '%s' is unset, Python ABI tag may be incorrect", name
|
| 117 |
+
)
|
| 118 |
+
return value
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def _normalize_string(string: str) -> str:
|
| 122 |
+
return string.replace(".", "_").replace("-", "_")
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def _abi3_applies(python_version: PythonVersion) -> bool:
|
| 126 |
+
"""
|
| 127 |
+
Determine if the Python version supports abi3.
|
| 128 |
+
|
| 129 |
+
PEP 384 was first implemented in Python 3.2.
|
| 130 |
+
"""
|
| 131 |
+
return len(python_version) > 1 and tuple(python_version) >= (3, 2)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def _cpython_abis(py_version: PythonVersion, warn: bool = False) -> List[str]:
|
| 135 |
+
py_version = tuple(py_version) # To allow for version comparison.
|
| 136 |
+
abis = []
|
| 137 |
+
version = _version_nodot(py_version[:2])
|
| 138 |
+
debug = pymalloc = ucs4 = ""
|
| 139 |
+
with_debug = _get_config_var("Py_DEBUG", warn)
|
| 140 |
+
has_refcount = hasattr(sys, "gettotalrefcount")
|
| 141 |
+
# Windows doesn't set Py_DEBUG, so checking for support of debug-compiled
|
| 142 |
+
# extension modules is the best option.
|
| 143 |
+
# https://github.com/pypa/pip/issues/3383#issuecomment-173267692
|
| 144 |
+
has_ext = "_d.pyd" in EXTENSION_SUFFIXES
|
| 145 |
+
if with_debug or (with_debug is None and (has_refcount or has_ext)):
|
| 146 |
+
debug = "d"
|
| 147 |
+
if py_version < (3, 8):
|
| 148 |
+
with_pymalloc = _get_config_var("WITH_PYMALLOC", warn)
|
| 149 |
+
if with_pymalloc or with_pymalloc is None:
|
| 150 |
+
pymalloc = "m"
|
| 151 |
+
if py_version < (3, 3):
|
| 152 |
+
unicode_size = _get_config_var("Py_UNICODE_SIZE", warn)
|
| 153 |
+
if unicode_size == 4 or (
|
| 154 |
+
unicode_size is None and sys.maxunicode == 0x10FFFF
|
| 155 |
+
):
|
| 156 |
+
ucs4 = "u"
|
| 157 |
+
elif debug:
|
| 158 |
+
# Debug builds can also load "normal" extension modules.
|
| 159 |
+
# We can also assume no UCS-4 or pymalloc requirement.
|
| 160 |
+
abis.append(f"cp{version}")
|
| 161 |
+
abis.insert(
|
| 162 |
+
0,
|
| 163 |
+
"cp{version}{debug}{pymalloc}{ucs4}".format(
|
| 164 |
+
version=version, debug=debug, pymalloc=pymalloc, ucs4=ucs4
|
| 165 |
+
),
|
| 166 |
+
)
|
| 167 |
+
return abis
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def cpython_tags(
|
| 171 |
+
python_version: Optional[PythonVersion] = None,
|
| 172 |
+
abis: Optional[Iterable[str]] = None,
|
| 173 |
+
platforms: Optional[Iterable[str]] = None,
|
| 174 |
+
*,
|
| 175 |
+
warn: bool = False,
|
| 176 |
+
) -> Iterator[Tag]:
|
| 177 |
+
"""
|
| 178 |
+
Yields the tags for a CPython interpreter.
|
| 179 |
+
|
| 180 |
+
The tags consist of:
|
| 181 |
+
- cp<python_version>-<abi>-<platform>
|
| 182 |
+
- cp<python_version>-abi3-<platform>
|
| 183 |
+
- cp<python_version>-none-<platform>
|
| 184 |
+
- cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2.
|
| 185 |
+
|
| 186 |
+
If python_version only specifies a major version then user-provided ABIs and
|
| 187 |
+
the 'none' ABItag will be used.
|
| 188 |
+
|
| 189 |
+
If 'abi3' or 'none' are specified in 'abis' then they will be yielded at
|
| 190 |
+
their normal position and not at the beginning.
|
| 191 |
+
"""
|
| 192 |
+
if not python_version:
|
| 193 |
+
python_version = sys.version_info[:2]
|
| 194 |
+
|
| 195 |
+
interpreter = f"cp{_version_nodot(python_version[:2])}"
|
| 196 |
+
|
| 197 |
+
if abis is None:
|
| 198 |
+
if len(python_version) > 1:
|
| 199 |
+
abis = _cpython_abis(python_version, warn)
|
| 200 |
+
else:
|
| 201 |
+
abis = []
|
| 202 |
+
abis = list(abis)
|
| 203 |
+
# 'abi3' and 'none' are explicitly handled later.
|
| 204 |
+
for explicit_abi in ("abi3", "none"):
|
| 205 |
+
try:
|
| 206 |
+
abis.remove(explicit_abi)
|
| 207 |
+
except ValueError:
|
| 208 |
+
pass
|
| 209 |
+
|
| 210 |
+
platforms = list(platforms or platform_tags())
|
| 211 |
+
for abi in abis:
|
| 212 |
+
for platform_ in platforms:
|
| 213 |
+
yield Tag(interpreter, abi, platform_)
|
| 214 |
+
if _abi3_applies(python_version):
|
| 215 |
+
yield from (Tag(interpreter, "abi3", platform_) for platform_ in platforms)
|
| 216 |
+
yield from (Tag(interpreter, "none", platform_) for platform_ in platforms)
|
| 217 |
+
|
| 218 |
+
if _abi3_applies(python_version):
|
| 219 |
+
for minor_version in range(python_version[1] - 1, 1, -1):
|
| 220 |
+
for platform_ in platforms:
|
| 221 |
+
interpreter = "cp{version}".format(
|
| 222 |
+
version=_version_nodot((python_version[0], minor_version))
|
| 223 |
+
)
|
| 224 |
+
yield Tag(interpreter, "abi3", platform_)
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def _generic_abi() -> Iterator[str]:
|
| 228 |
+
abi = sysconfig.get_config_var("SOABI")
|
| 229 |
+
if abi:
|
| 230 |
+
yield _normalize_string(abi)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def generic_tags(
|
| 234 |
+
interpreter: Optional[str] = None,
|
| 235 |
+
abis: Optional[Iterable[str]] = None,
|
| 236 |
+
platforms: Optional[Iterable[str]] = None,
|
| 237 |
+
*,
|
| 238 |
+
warn: bool = False,
|
| 239 |
+
) -> Iterator[Tag]:
|
| 240 |
+
"""
|
| 241 |
+
Yields the tags for a generic interpreter.
|
| 242 |
+
|
| 243 |
+
The tags consist of:
|
| 244 |
+
- <interpreter>-<abi>-<platform>
|
| 245 |
+
|
| 246 |
+
The "none" ABI will be added if it was not explicitly provided.
|
| 247 |
+
"""
|
| 248 |
+
if not interpreter:
|
| 249 |
+
interp_name = interpreter_name()
|
| 250 |
+
interp_version = interpreter_version(warn=warn)
|
| 251 |
+
interpreter = "".join([interp_name, interp_version])
|
| 252 |
+
if abis is None:
|
| 253 |
+
abis = _generic_abi()
|
| 254 |
+
platforms = list(platforms or platform_tags())
|
| 255 |
+
abis = list(abis)
|
| 256 |
+
if "none" not in abis:
|
| 257 |
+
abis.append("none")
|
| 258 |
+
for abi in abis:
|
| 259 |
+
for platform_ in platforms:
|
| 260 |
+
yield Tag(interpreter, abi, platform_)
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def _py_interpreter_range(py_version: PythonVersion) -> Iterator[str]:
|
| 264 |
+
"""
|
| 265 |
+
Yields Python versions in descending order.
|
| 266 |
+
|
| 267 |
+
After the latest version, the major-only version will be yielded, and then
|
| 268 |
+
all previous versions of that major version.
|
| 269 |
+
"""
|
| 270 |
+
if len(py_version) > 1:
|
| 271 |
+
yield f"py{_version_nodot(py_version[:2])}"
|
| 272 |
+
yield f"py{py_version[0]}"
|
| 273 |
+
if len(py_version) > 1:
|
| 274 |
+
for minor in range(py_version[1] - 1, -1, -1):
|
| 275 |
+
yield f"py{_version_nodot((py_version[0], minor))}"
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def compatible_tags(
|
| 279 |
+
python_version: Optional[PythonVersion] = None,
|
| 280 |
+
interpreter: Optional[str] = None,
|
| 281 |
+
platforms: Optional[Iterable[str]] = None,
|
| 282 |
+
) -> Iterator[Tag]:
|
| 283 |
+
"""
|
| 284 |
+
Yields the sequence of tags that are compatible with a specific version of Python.
|
| 285 |
+
|
| 286 |
+
The tags consist of:
|
| 287 |
+
- py*-none-<platform>
|
| 288 |
+
- <interpreter>-none-any # ... if `interpreter` is provided.
|
| 289 |
+
- py*-none-any
|
| 290 |
+
"""
|
| 291 |
+
if not python_version:
|
| 292 |
+
python_version = sys.version_info[:2]
|
| 293 |
+
platforms = list(platforms or platform_tags())
|
| 294 |
+
for version in _py_interpreter_range(python_version):
|
| 295 |
+
for platform_ in platforms:
|
| 296 |
+
yield Tag(version, "none", platform_)
|
| 297 |
+
if interpreter:
|
| 298 |
+
yield Tag(interpreter, "none", "any")
|
| 299 |
+
for version in _py_interpreter_range(python_version):
|
| 300 |
+
yield Tag(version, "none", "any")
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def _mac_arch(arch: str, is_32bit: bool = _32_BIT_INTERPRETER) -> str:
|
| 304 |
+
if not is_32bit:
|
| 305 |
+
return arch
|
| 306 |
+
|
| 307 |
+
if arch.startswith("ppc"):
|
| 308 |
+
return "ppc"
|
| 309 |
+
|
| 310 |
+
return "i386"
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> List[str]:
|
| 314 |
+
formats = [cpu_arch]
|
| 315 |
+
if cpu_arch == "x86_64":
|
| 316 |
+
if version < (10, 4):
|
| 317 |
+
return []
|
| 318 |
+
formats.extend(["intel", "fat64", "fat32"])
|
| 319 |
+
|
| 320 |
+
elif cpu_arch == "i386":
|
| 321 |
+
if version < (10, 4):
|
| 322 |
+
return []
|
| 323 |
+
formats.extend(["intel", "fat32", "fat"])
|
| 324 |
+
|
| 325 |
+
elif cpu_arch == "ppc64":
|
| 326 |
+
# TODO: Need to care about 32-bit PPC for ppc64 through 10.2?
|
| 327 |
+
if version > (10, 5) or version < (10, 4):
|
| 328 |
+
return []
|
| 329 |
+
formats.append("fat64")
|
| 330 |
+
|
| 331 |
+
elif cpu_arch == "ppc":
|
| 332 |
+
if version > (10, 6):
|
| 333 |
+
return []
|
| 334 |
+
formats.extend(["fat32", "fat"])
|
| 335 |
+
|
| 336 |
+
if cpu_arch in {"arm64", "x86_64"}:
|
| 337 |
+
formats.append("universal2")
|
| 338 |
+
|
| 339 |
+
if cpu_arch in {"x86_64", "i386", "ppc64", "ppc", "intel"}:
|
| 340 |
+
formats.append("universal")
|
| 341 |
+
|
| 342 |
+
return formats
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
def mac_platforms(
|
| 346 |
+
version: Optional[MacVersion] = None, arch: Optional[str] = None
|
| 347 |
+
) -> Iterator[str]:
|
| 348 |
+
"""
|
| 349 |
+
Yields the platform tags for a macOS system.
|
| 350 |
+
|
| 351 |
+
The `version` parameter is a two-item tuple specifying the macOS version to
|
| 352 |
+
generate platform tags for. The `arch` parameter is the CPU architecture to
|
| 353 |
+
generate platform tags for. Both parameters default to the appropriate value
|
| 354 |
+
for the current system.
|
| 355 |
+
"""
|
| 356 |
+
version_str, _, cpu_arch = platform.mac_ver()
|
| 357 |
+
if version is None:
|
| 358 |
+
version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2])))
|
| 359 |
+
else:
|
| 360 |
+
version = version
|
| 361 |
+
if arch is None:
|
| 362 |
+
arch = _mac_arch(cpu_arch)
|
| 363 |
+
else:
|
| 364 |
+
arch = arch
|
| 365 |
+
|
| 366 |
+
if (10, 0) <= version and version < (11, 0):
|
| 367 |
+
# Prior to Mac OS 11, each yearly release of Mac OS bumped the
|
| 368 |
+
# "minor" version number. The major version was always 10.
|
| 369 |
+
for minor_version in range(version[1], -1, -1):
|
| 370 |
+
compat_version = 10, minor_version
|
| 371 |
+
binary_formats = _mac_binary_formats(compat_version, arch)
|
| 372 |
+
for binary_format in binary_formats:
|
| 373 |
+
yield "macosx_{major}_{minor}_{binary_format}".format(
|
| 374 |
+
major=10, minor=minor_version, binary_format=binary_format
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
if version >= (11, 0):
|
| 378 |
+
# Starting with Mac OS 11, each yearly release bumps the major version
|
| 379 |
+
# number. The minor versions are now the midyear updates.
|
| 380 |
+
for major_version in range(version[0], 10, -1):
|
| 381 |
+
compat_version = major_version, 0
|
| 382 |
+
binary_formats = _mac_binary_formats(compat_version, arch)
|
| 383 |
+
for binary_format in binary_formats:
|
| 384 |
+
yield "macosx_{major}_{minor}_{binary_format}".format(
|
| 385 |
+
major=major_version, minor=0, binary_format=binary_format
|
| 386 |
+
)
|
| 387 |
+
|
| 388 |
+
if version >= (11, 0):
|
| 389 |
+
# Mac OS 11 on x86_64 is compatible with binaries from previous releases.
|
| 390 |
+
# Arm64 support was introduced in 11.0, so no Arm binaries from previous
|
| 391 |
+
# releases exist.
|
| 392 |
+
#
|
| 393 |
+
# However, the "universal2" binary format can have a
|
| 394 |
+
# macOS version earlier than 11.0 when the x86_64 part of the binary supports
|
| 395 |
+
# that version of macOS.
|
| 396 |
+
if arch == "x86_64":
|
| 397 |
+
for minor_version in range(16, 3, -1):
|
| 398 |
+
compat_version = 10, minor_version
|
| 399 |
+
binary_formats = _mac_binary_formats(compat_version, arch)
|
| 400 |
+
for binary_format in binary_formats:
|
| 401 |
+
yield "macosx_{major}_{minor}_{binary_format}".format(
|
| 402 |
+
major=compat_version[0],
|
| 403 |
+
minor=compat_version[1],
|
| 404 |
+
binary_format=binary_format,
|
| 405 |
+
)
|
| 406 |
+
else:
|
| 407 |
+
for minor_version in range(16, 3, -1):
|
| 408 |
+
compat_version = 10, minor_version
|
| 409 |
+
binary_format = "universal2"
|
| 410 |
+
yield "macosx_{major}_{minor}_{binary_format}".format(
|
| 411 |
+
major=compat_version[0],
|
| 412 |
+
minor=compat_version[1],
|
| 413 |
+
binary_format=binary_format,
|
| 414 |
+
)
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
|
| 418 |
+
linux = _normalize_string(sysconfig.get_platform())
|
| 419 |
+
if is_32bit:
|
| 420 |
+
if linux == "linux_x86_64":
|
| 421 |
+
linux = "linux_i686"
|
| 422 |
+
elif linux == "linux_aarch64":
|
| 423 |
+
linux = "linux_armv7l"
|
| 424 |
+
_, arch = linux.split("_", 1)
|
| 425 |
+
yield from _manylinux.platform_tags(linux, arch)
|
| 426 |
+
yield from _musllinux.platform_tags(arch)
|
| 427 |
+
yield linux
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
def _generic_platforms() -> Iterator[str]:
|
| 431 |
+
yield _normalize_string(sysconfig.get_platform())
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
def platform_tags() -> Iterator[str]:
|
| 435 |
+
"""
|
| 436 |
+
Provides the platform tags for this installation.
|
| 437 |
+
"""
|
| 438 |
+
if platform.system() == "Darwin":
|
| 439 |
+
return mac_platforms()
|
| 440 |
+
elif platform.system() == "Linux":
|
| 441 |
+
return _linux_platforms()
|
| 442 |
+
else:
|
| 443 |
+
return _generic_platforms()
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
def interpreter_name() -> str:
|
| 447 |
+
"""
|
| 448 |
+
Returns the name of the running interpreter.
|
| 449 |
+
"""
|
| 450 |
+
name = sys.implementation.name
|
| 451 |
+
return INTERPRETER_SHORT_NAMES.get(name) or name
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
def interpreter_version(*, warn: bool = False) -> str:
|
| 455 |
+
"""
|
| 456 |
+
Returns the version of the running interpreter.
|
| 457 |
+
"""
|
| 458 |
+
version = _get_config_var("py_version_nodot", warn=warn)
|
| 459 |
+
if version:
|
| 460 |
+
version = str(version)
|
| 461 |
+
else:
|
| 462 |
+
version = _version_nodot(sys.version_info[:2])
|
| 463 |
+
return version
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
def _version_nodot(version: PythonVersion) -> str:
|
| 467 |
+
return "".join(map(str, version))
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
def sys_tags(*, warn: bool = False) -> Iterator[Tag]:
|
| 471 |
+
"""
|
| 472 |
+
Returns the sequence of tag triples for the running interpreter.
|
| 473 |
+
|
| 474 |
+
The order of the sequence corresponds to priority order for the
|
| 475 |
+
interpreter, from most to least important.
|
| 476 |
+
"""
|
| 477 |
+
|
| 478 |
+
interp_name = interpreter_name()
|
| 479 |
+
if interp_name == "cp":
|
| 480 |
+
yield from cpython_tags(warn=warn)
|
| 481 |
+
else:
|
| 482 |
+
yield from generic_tags()
|
| 483 |
+
|
| 484 |
+
if interp_name == "pp":
|
| 485 |
+
yield from compatible_tags(interpreter="pp3")
|
| 486 |
+
else:
|
| 487 |
+
yield from compatible_tags()
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/packaging/version.py
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is dual licensed under the terms of the Apache License, Version
|
| 2 |
+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
| 3 |
+
# for complete details.
|
| 4 |
+
|
| 5 |
+
import collections
|
| 6 |
+
import itertools
|
| 7 |
+
import re
|
| 8 |
+
import warnings
|
| 9 |
+
from typing import Callable, Iterator, List, Optional, SupportsInt, Tuple, Union
|
| 10 |
+
|
| 11 |
+
from ._structures import Infinity, InfinityType, NegativeInfinity, NegativeInfinityType
|
| 12 |
+
|
| 13 |
+
__all__ = ["parse", "Version", "LegacyVersion", "InvalidVersion", "VERSION_PATTERN"]
|
| 14 |
+
|
| 15 |
+
InfiniteTypes = Union[InfinityType, NegativeInfinityType]
|
| 16 |
+
PrePostDevType = Union[InfiniteTypes, Tuple[str, int]]
|
| 17 |
+
SubLocalType = Union[InfiniteTypes, int, str]
|
| 18 |
+
LocalType = Union[
|
| 19 |
+
NegativeInfinityType,
|
| 20 |
+
Tuple[
|
| 21 |
+
Union[
|
| 22 |
+
SubLocalType,
|
| 23 |
+
Tuple[SubLocalType, str],
|
| 24 |
+
Tuple[NegativeInfinityType, SubLocalType],
|
| 25 |
+
],
|
| 26 |
+
...,
|
| 27 |
+
],
|
| 28 |
+
]
|
| 29 |
+
CmpKey = Tuple[
|
| 30 |
+
int, Tuple[int, ...], PrePostDevType, PrePostDevType, PrePostDevType, LocalType
|
| 31 |
+
]
|
| 32 |
+
LegacyCmpKey = Tuple[int, Tuple[str, ...]]
|
| 33 |
+
VersionComparisonMethod = Callable[
|
| 34 |
+
[Union[CmpKey, LegacyCmpKey], Union[CmpKey, LegacyCmpKey]], bool
|
| 35 |
+
]
|
| 36 |
+
|
| 37 |
+
_Version = collections.namedtuple(
|
| 38 |
+
"_Version", ["epoch", "release", "dev", "pre", "post", "local"]
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def parse(version: str) -> Union["LegacyVersion", "Version"]:
|
| 43 |
+
"""
|
| 44 |
+
Parse the given version string and return either a :class:`Version` object
|
| 45 |
+
or a :class:`LegacyVersion` object depending on if the given version is
|
| 46 |
+
a valid PEP 440 version or a legacy version.
|
| 47 |
+
"""
|
| 48 |
+
try:
|
| 49 |
+
return Version(version)
|
| 50 |
+
except InvalidVersion:
|
| 51 |
+
return LegacyVersion(version)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class InvalidVersion(ValueError):
|
| 55 |
+
"""
|
| 56 |
+
An invalid version was found, users should refer to PEP 440.
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class _BaseVersion:
|
| 61 |
+
_key: Union[CmpKey, LegacyCmpKey]
|
| 62 |
+
|
| 63 |
+
def __hash__(self) -> int:
|
| 64 |
+
return hash(self._key)
|
| 65 |
+
|
| 66 |
+
# Please keep the duplicated `isinstance` check
|
| 67 |
+
# in the six comparisons hereunder
|
| 68 |
+
# unless you find a way to avoid adding overhead function calls.
|
| 69 |
+
def __lt__(self, other: "_BaseVersion") -> bool:
|
| 70 |
+
if not isinstance(other, _BaseVersion):
|
| 71 |
+
return NotImplemented
|
| 72 |
+
|
| 73 |
+
return self._key < other._key
|
| 74 |
+
|
| 75 |
+
def __le__(self, other: "_BaseVersion") -> bool:
|
| 76 |
+
if not isinstance(other, _BaseVersion):
|
| 77 |
+
return NotImplemented
|
| 78 |
+
|
| 79 |
+
return self._key <= other._key
|
| 80 |
+
|
| 81 |
+
def __eq__(self, other: object) -> bool:
|
| 82 |
+
if not isinstance(other, _BaseVersion):
|
| 83 |
+
return NotImplemented
|
| 84 |
+
|
| 85 |
+
return self._key == other._key
|
| 86 |
+
|
| 87 |
+
def __ge__(self, other: "_BaseVersion") -> bool:
|
| 88 |
+
if not isinstance(other, _BaseVersion):
|
| 89 |
+
return NotImplemented
|
| 90 |
+
|
| 91 |
+
return self._key >= other._key
|
| 92 |
+
|
| 93 |
+
def __gt__(self, other: "_BaseVersion") -> bool:
|
| 94 |
+
if not isinstance(other, _BaseVersion):
|
| 95 |
+
return NotImplemented
|
| 96 |
+
|
| 97 |
+
return self._key > other._key
|
| 98 |
+
|
| 99 |
+
def __ne__(self, other: object) -> bool:
|
| 100 |
+
if not isinstance(other, _BaseVersion):
|
| 101 |
+
return NotImplemented
|
| 102 |
+
|
| 103 |
+
return self._key != other._key
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class LegacyVersion(_BaseVersion):
|
| 107 |
+
def __init__(self, version: str) -> None:
|
| 108 |
+
self._version = str(version)
|
| 109 |
+
self._key = _legacy_cmpkey(self._version)
|
| 110 |
+
|
| 111 |
+
warnings.warn(
|
| 112 |
+
"Creating a LegacyVersion has been deprecated and will be "
|
| 113 |
+
"removed in the next major release",
|
| 114 |
+
DeprecationWarning,
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
def __str__(self) -> str:
|
| 118 |
+
return self._version
|
| 119 |
+
|
| 120 |
+
def __repr__(self) -> str:
|
| 121 |
+
return f"<LegacyVersion('{self}')>"
|
| 122 |
+
|
| 123 |
+
@property
|
| 124 |
+
def public(self) -> str:
|
| 125 |
+
return self._version
|
| 126 |
+
|
| 127 |
+
@property
|
| 128 |
+
def base_version(self) -> str:
|
| 129 |
+
return self._version
|
| 130 |
+
|
| 131 |
+
@property
|
| 132 |
+
def epoch(self) -> int:
|
| 133 |
+
return -1
|
| 134 |
+
|
| 135 |
+
@property
|
| 136 |
+
def release(self) -> None:
|
| 137 |
+
return None
|
| 138 |
+
|
| 139 |
+
@property
|
| 140 |
+
def pre(self) -> None:
|
| 141 |
+
return None
|
| 142 |
+
|
| 143 |
+
@property
|
| 144 |
+
def post(self) -> None:
|
| 145 |
+
return None
|
| 146 |
+
|
| 147 |
+
@property
|
| 148 |
+
def dev(self) -> None:
|
| 149 |
+
return None
|
| 150 |
+
|
| 151 |
+
@property
|
| 152 |
+
def local(self) -> None:
|
| 153 |
+
return None
|
| 154 |
+
|
| 155 |
+
@property
|
| 156 |
+
def is_prerelease(self) -> bool:
|
| 157 |
+
return False
|
| 158 |
+
|
| 159 |
+
@property
|
| 160 |
+
def is_postrelease(self) -> bool:
|
| 161 |
+
return False
|
| 162 |
+
|
| 163 |
+
@property
|
| 164 |
+
def is_devrelease(self) -> bool:
|
| 165 |
+
return False
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
_legacy_version_component_re = re.compile(r"(\d+ | [a-z]+ | \.| -)", re.VERBOSE)
|
| 169 |
+
|
| 170 |
+
_legacy_version_replacement_map = {
|
| 171 |
+
"pre": "c",
|
| 172 |
+
"preview": "c",
|
| 173 |
+
"-": "final-",
|
| 174 |
+
"rc": "c",
|
| 175 |
+
"dev": "@",
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def _parse_version_parts(s: str) -> Iterator[str]:
|
| 180 |
+
for part in _legacy_version_component_re.split(s):
|
| 181 |
+
part = _legacy_version_replacement_map.get(part, part)
|
| 182 |
+
|
| 183 |
+
if not part or part == ".":
|
| 184 |
+
continue
|
| 185 |
+
|
| 186 |
+
if part[:1] in "0123456789":
|
| 187 |
+
# pad for numeric comparison
|
| 188 |
+
yield part.zfill(8)
|
| 189 |
+
else:
|
| 190 |
+
yield "*" + part
|
| 191 |
+
|
| 192 |
+
# ensure that alpha/beta/candidate are before final
|
| 193 |
+
yield "*final"
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def _legacy_cmpkey(version: str) -> LegacyCmpKey:
|
| 197 |
+
|
| 198 |
+
# We hardcode an epoch of -1 here. A PEP 440 version can only have a epoch
|
| 199 |
+
# greater than or equal to 0. This will effectively put the LegacyVersion,
|
| 200 |
+
# which uses the defacto standard originally implemented by setuptools,
|
| 201 |
+
# as before all PEP 440 versions.
|
| 202 |
+
epoch = -1
|
| 203 |
+
|
| 204 |
+
# This scheme is taken from pkg_resources.parse_version setuptools prior to
|
| 205 |
+
# it's adoption of the packaging library.
|
| 206 |
+
parts: List[str] = []
|
| 207 |
+
for part in _parse_version_parts(version.lower()):
|
| 208 |
+
if part.startswith("*"):
|
| 209 |
+
# remove "-" before a prerelease tag
|
| 210 |
+
if part < "*final":
|
| 211 |
+
while parts and parts[-1] == "*final-":
|
| 212 |
+
parts.pop()
|
| 213 |
+
|
| 214 |
+
# remove trailing zeros from each series of numeric parts
|
| 215 |
+
while parts and parts[-1] == "00000000":
|
| 216 |
+
parts.pop()
|
| 217 |
+
|
| 218 |
+
parts.append(part)
|
| 219 |
+
|
| 220 |
+
return epoch, tuple(parts)
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
# Deliberately not anchored to the start and end of the string, to make it
|
| 224 |
+
# easier for 3rd party code to reuse
|
| 225 |
+
VERSION_PATTERN = r"""
|
| 226 |
+
v?
|
| 227 |
+
(?:
|
| 228 |
+
(?:(?P<epoch>[0-9]+)!)? # epoch
|
| 229 |
+
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
|
| 230 |
+
(?P<pre> # pre-release
|
| 231 |
+
[-_\.]?
|
| 232 |
+
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
|
| 233 |
+
[-_\.]?
|
| 234 |
+
(?P<pre_n>[0-9]+)?
|
| 235 |
+
)?
|
| 236 |
+
(?P<post> # post release
|
| 237 |
+
(?:-(?P<post_n1>[0-9]+))
|
| 238 |
+
|
|
| 239 |
+
(?:
|
| 240 |
+
[-_\.]?
|
| 241 |
+
(?P<post_l>post|rev|r)
|
| 242 |
+
[-_\.]?
|
| 243 |
+
(?P<post_n2>[0-9]+)?
|
| 244 |
+
)
|
| 245 |
+
)?
|
| 246 |
+
(?P<dev> # dev release
|
| 247 |
+
[-_\.]?
|
| 248 |
+
(?P<dev_l>dev)
|
| 249 |
+
[-_\.]?
|
| 250 |
+
(?P<dev_n>[0-9]+)?
|
| 251 |
+
)?
|
| 252 |
+
)
|
| 253 |
+
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
|
| 254 |
+
"""
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
class Version(_BaseVersion):
|
| 258 |
+
|
| 259 |
+
_regex = re.compile(r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
| 260 |
+
|
| 261 |
+
def __init__(self, version: str) -> None:
|
| 262 |
+
|
| 263 |
+
# Validate the version and parse it into pieces
|
| 264 |
+
match = self._regex.search(version)
|
| 265 |
+
if not match:
|
| 266 |
+
raise InvalidVersion(f"Invalid version: '{version}'")
|
| 267 |
+
|
| 268 |
+
# Store the parsed out pieces of the version
|
| 269 |
+
self._version = _Version(
|
| 270 |
+
epoch=int(match.group("epoch")) if match.group("epoch") else 0,
|
| 271 |
+
release=tuple(int(i) for i in match.group("release").split(".")),
|
| 272 |
+
pre=_parse_letter_version(match.group("pre_l"), match.group("pre_n")),
|
| 273 |
+
post=_parse_letter_version(
|
| 274 |
+
match.group("post_l"), match.group("post_n1") or match.group("post_n2")
|
| 275 |
+
),
|
| 276 |
+
dev=_parse_letter_version(match.group("dev_l"), match.group("dev_n")),
|
| 277 |
+
local=_parse_local_version(match.group("local")),
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
# Generate a key which will be used for sorting
|
| 281 |
+
self._key = _cmpkey(
|
| 282 |
+
self._version.epoch,
|
| 283 |
+
self._version.release,
|
| 284 |
+
self._version.pre,
|
| 285 |
+
self._version.post,
|
| 286 |
+
self._version.dev,
|
| 287 |
+
self._version.local,
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
def __repr__(self) -> str:
|
| 291 |
+
return f"<Version('{self}')>"
|
| 292 |
+
|
| 293 |
+
def __str__(self) -> str:
|
| 294 |
+
parts = []
|
| 295 |
+
|
| 296 |
+
# Epoch
|
| 297 |
+
if self.epoch != 0:
|
| 298 |
+
parts.append(f"{self.epoch}!")
|
| 299 |
+
|
| 300 |
+
# Release segment
|
| 301 |
+
parts.append(".".join(str(x) for x in self.release))
|
| 302 |
+
|
| 303 |
+
# Pre-release
|
| 304 |
+
if self.pre is not None:
|
| 305 |
+
parts.append("".join(str(x) for x in self.pre))
|
| 306 |
+
|
| 307 |
+
# Post-release
|
| 308 |
+
if self.post is not None:
|
| 309 |
+
parts.append(f".post{self.post}")
|
| 310 |
+
|
| 311 |
+
# Development release
|
| 312 |
+
if self.dev is not None:
|
| 313 |
+
parts.append(f".dev{self.dev}")
|
| 314 |
+
|
| 315 |
+
# Local version segment
|
| 316 |
+
if self.local is not None:
|
| 317 |
+
parts.append(f"+{self.local}")
|
| 318 |
+
|
| 319 |
+
return "".join(parts)
|
| 320 |
+
|
| 321 |
+
@property
|
| 322 |
+
def epoch(self) -> int:
|
| 323 |
+
_epoch: int = self._version.epoch
|
| 324 |
+
return _epoch
|
| 325 |
+
|
| 326 |
+
@property
|
| 327 |
+
def release(self) -> Tuple[int, ...]:
|
| 328 |
+
_release: Tuple[int, ...] = self._version.release
|
| 329 |
+
return _release
|
| 330 |
+
|
| 331 |
+
@property
|
| 332 |
+
def pre(self) -> Optional[Tuple[str, int]]:
|
| 333 |
+
_pre: Optional[Tuple[str, int]] = self._version.pre
|
| 334 |
+
return _pre
|
| 335 |
+
|
| 336 |
+
@property
|
| 337 |
+
def post(self) -> Optional[int]:
|
| 338 |
+
return self._version.post[1] if self._version.post else None
|
| 339 |
+
|
| 340 |
+
@property
|
| 341 |
+
def dev(self) -> Optional[int]:
|
| 342 |
+
return self._version.dev[1] if self._version.dev else None
|
| 343 |
+
|
| 344 |
+
@property
|
| 345 |
+
def local(self) -> Optional[str]:
|
| 346 |
+
if self._version.local:
|
| 347 |
+
return ".".join(str(x) for x in self._version.local)
|
| 348 |
+
else:
|
| 349 |
+
return None
|
| 350 |
+
|
| 351 |
+
@property
|
| 352 |
+
def public(self) -> str:
|
| 353 |
+
return str(self).split("+", 1)[0]
|
| 354 |
+
|
| 355 |
+
@property
|
| 356 |
+
def base_version(self) -> str:
|
| 357 |
+
parts = []
|
| 358 |
+
|
| 359 |
+
# Epoch
|
| 360 |
+
if self.epoch != 0:
|
| 361 |
+
parts.append(f"{self.epoch}!")
|
| 362 |
+
|
| 363 |
+
# Release segment
|
| 364 |
+
parts.append(".".join(str(x) for x in self.release))
|
| 365 |
+
|
| 366 |
+
return "".join(parts)
|
| 367 |
+
|
| 368 |
+
@property
|
| 369 |
+
def is_prerelease(self) -> bool:
|
| 370 |
+
return self.dev is not None or self.pre is not None
|
| 371 |
+
|
| 372 |
+
@property
|
| 373 |
+
def is_postrelease(self) -> bool:
|
| 374 |
+
return self.post is not None
|
| 375 |
+
|
| 376 |
+
@property
|
| 377 |
+
def is_devrelease(self) -> bool:
|
| 378 |
+
return self.dev is not None
|
| 379 |
+
|
| 380 |
+
@property
|
| 381 |
+
def major(self) -> int:
|
| 382 |
+
return self.release[0] if len(self.release) >= 1 else 0
|
| 383 |
+
|
| 384 |
+
@property
|
| 385 |
+
def minor(self) -> int:
|
| 386 |
+
return self.release[1] if len(self.release) >= 2 else 0
|
| 387 |
+
|
| 388 |
+
@property
|
| 389 |
+
def micro(self) -> int:
|
| 390 |
+
return self.release[2] if len(self.release) >= 3 else 0
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def _parse_letter_version(
|
| 394 |
+
letter: str, number: Union[str, bytes, SupportsInt]
|
| 395 |
+
) -> Optional[Tuple[str, int]]:
|
| 396 |
+
|
| 397 |
+
if letter:
|
| 398 |
+
# We consider there to be an implicit 0 in a pre-release if there is
|
| 399 |
+
# not a numeral associated with it.
|
| 400 |
+
if number is None:
|
| 401 |
+
number = 0
|
| 402 |
+
|
| 403 |
+
# We normalize any letters to their lower case form
|
| 404 |
+
letter = letter.lower()
|
| 405 |
+
|
| 406 |
+
# We consider some words to be alternate spellings of other words and
|
| 407 |
+
# in those cases we want to normalize the spellings to our preferred
|
| 408 |
+
# spelling.
|
| 409 |
+
if letter == "alpha":
|
| 410 |
+
letter = "a"
|
| 411 |
+
elif letter == "beta":
|
| 412 |
+
letter = "b"
|
| 413 |
+
elif letter in ["c", "pre", "preview"]:
|
| 414 |
+
letter = "rc"
|
| 415 |
+
elif letter in ["rev", "r"]:
|
| 416 |
+
letter = "post"
|
| 417 |
+
|
| 418 |
+
return letter, int(number)
|
| 419 |
+
if not letter and number:
|
| 420 |
+
# We assume if we are given a number, but we are not given a letter
|
| 421 |
+
# then this is using the implicit post release syntax (e.g. 1.0-1)
|
| 422 |
+
letter = "post"
|
| 423 |
+
|
| 424 |
+
return letter, int(number)
|
| 425 |
+
|
| 426 |
+
return None
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
_local_version_separators = re.compile(r"[\._-]")
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
def _parse_local_version(local: str) -> Optional[LocalType]:
|
| 433 |
+
"""
|
| 434 |
+
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
|
| 435 |
+
"""
|
| 436 |
+
if local is not None:
|
| 437 |
+
return tuple(
|
| 438 |
+
part.lower() if not part.isdigit() else int(part)
|
| 439 |
+
for part in _local_version_separators.split(local)
|
| 440 |
+
)
|
| 441 |
+
return None
|
| 442 |
+
|
| 443 |
+
|
| 444 |
+
def _cmpkey(
|
| 445 |
+
epoch: int,
|
| 446 |
+
release: Tuple[int, ...],
|
| 447 |
+
pre: Optional[Tuple[str, int]],
|
| 448 |
+
post: Optional[Tuple[str, int]],
|
| 449 |
+
dev: Optional[Tuple[str, int]],
|
| 450 |
+
local: Optional[Tuple[SubLocalType]],
|
| 451 |
+
) -> CmpKey:
|
| 452 |
+
|
| 453 |
+
# When we compare a release version, we want to compare it with all of the
|
| 454 |
+
# trailing zeros removed. So we'll use a reverse the list, drop all the now
|
| 455 |
+
# leading zeros until we come to something non zero, then take the rest
|
| 456 |
+
# re-reverse it back into the correct order and make it a tuple and use
|
| 457 |
+
# that for our sorting key.
|
| 458 |
+
_release = tuple(
|
| 459 |
+
reversed(list(itertools.dropwhile(lambda x: x == 0, reversed(release))))
|
| 460 |
+
)
|
| 461 |
+
|
| 462 |
+
# We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
|
| 463 |
+
# We'll do this by abusing the pre segment, but we _only_ want to do this
|
| 464 |
+
# if there is not a pre or a post segment. If we have one of those then
|
| 465 |
+
# the normal sorting rules will handle this case correctly.
|
| 466 |
+
if pre is None and post is None and dev is not None:
|
| 467 |
+
_pre: PrePostDevType = NegativeInfinity
|
| 468 |
+
# Versions without a pre-release (except as noted above) should sort after
|
| 469 |
+
# those with one.
|
| 470 |
+
elif pre is None:
|
| 471 |
+
_pre = Infinity
|
| 472 |
+
else:
|
| 473 |
+
_pre = pre
|
| 474 |
+
|
| 475 |
+
# Versions without a post segment should sort before those with one.
|
| 476 |
+
if post is None:
|
| 477 |
+
_post: PrePostDevType = NegativeInfinity
|
| 478 |
+
|
| 479 |
+
else:
|
| 480 |
+
_post = post
|
| 481 |
+
|
| 482 |
+
# Versions without a development segment should sort after those with one.
|
| 483 |
+
if dev is None:
|
| 484 |
+
_dev: PrePostDevType = Infinity
|
| 485 |
+
|
| 486 |
+
else:
|
| 487 |
+
_dev = dev
|
| 488 |
+
|
| 489 |
+
if local is None:
|
| 490 |
+
# Versions without a local segment should sort before those with one.
|
| 491 |
+
_local: LocalType = NegativeInfinity
|
| 492 |
+
else:
|
| 493 |
+
# Versions with a local segment need that segment parsed to implement
|
| 494 |
+
# the sorting rules in PEP440.
|
| 495 |
+
# - Alpha numeric segments sort before numeric segments
|
| 496 |
+
# - Alpha numeric segments sort lexicographically
|
| 497 |
+
# - Numeric segments sort numerically
|
| 498 |
+
# - Shorter versions sort before longer versions when the prefixes
|
| 499 |
+
# match exactly
|
| 500 |
+
_local = tuple(
|
| 501 |
+
(i, "") if isinstance(i, int) else (NegativeInfinity, i) for i in local
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
return epoch, _release, _pre, _post, _dev, _local
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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 pip._vendor.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. 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 pip._vendor.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**")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/__main__.py
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
| 1 |
+
import colorsys
|
| 2 |
+
import io
|
| 3 |
+
from time import process_time
|
| 4 |
+
|
| 5 |
+
from pip._vendor.rich import box
|
| 6 |
+
from pip._vendor.rich.color import Color
|
| 7 |
+
from pip._vendor.rich.console import Console, ConsoleOptions, Group, RenderableType, RenderResult
|
| 8 |
+
from pip._vendor.rich.markdown import Markdown
|
| 9 |
+
from pip._vendor.rich.measure import Measurement
|
| 10 |
+
from pip._vendor.rich.pretty import Pretty
|
| 11 |
+
from pip._vendor.rich.segment import Segment
|
| 12 |
+
from pip._vendor.rich.style import Style
|
| 13 |
+
from pip._vendor.rich.syntax import Syntax
|
| 14 |
+
from pip._vendor.rich.table import Table
|
| 15 |
+
from pip._vendor.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 |
+
|
| 211 |
+
console = Console(
|
| 212 |
+
file=io.StringIO(),
|
| 213 |
+
force_terminal=True,
|
| 214 |
+
)
|
| 215 |
+
test_card = make_test_card()
|
| 216 |
+
|
| 217 |
+
# Print once to warm cache
|
| 218 |
+
start = process_time()
|
| 219 |
+
console.print(test_card)
|
| 220 |
+
pre_cache_taken = round((process_time() - start) * 1000.0, 1)
|
| 221 |
+
|
| 222 |
+
console.file = io.StringIO()
|
| 223 |
+
|
| 224 |
+
start = process_time()
|
| 225 |
+
console.print(test_card)
|
| 226 |
+
taken = round((process_time() - start) * 1000.0, 1)
|
| 227 |
+
|
| 228 |
+
c = Console(record=True)
|
| 229 |
+
c.print(test_card)
|
| 230 |
+
|
| 231 |
+
print(f"rendered in {pre_cache_taken}ms (cold cache)")
|
| 232 |
+
print(f"rendered in {taken}ms (warm cache)")
|
| 233 |
+
|
| 234 |
+
from pip._vendor.rich.panel import Panel
|
| 235 |
+
|
| 236 |
+
console = Console()
|
| 237 |
+
|
| 238 |
+
sponsor_message = Table.grid(padding=1)
|
| 239 |
+
sponsor_message.add_column(style="green", justify="right")
|
| 240 |
+
sponsor_message.add_column(no_wrap=True)
|
| 241 |
+
|
| 242 |
+
sponsor_message.add_row(
|
| 243 |
+
"Textualize",
|
| 244 |
+
"[u blue link=https://github.com/textualize]https://github.com/textualize",
|
| 245 |
+
)
|
| 246 |
+
sponsor_message.add_row(
|
| 247 |
+
"Twitter",
|
| 248 |
+
"[u blue link=https://twitter.com/willmcgugan]https://twitter.com/willmcgugan",
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
intro_message = Text.from_markup(
|
| 252 |
+
"""\
|
| 253 |
+
We hope you enjoy using Rich!
|
| 254 |
+
|
| 255 |
+
Rich is maintained with [red]:heart:[/] by [link=https://www.textualize.io]Textualize.io[/]
|
| 256 |
+
|
| 257 |
+
- Will McGugan"""
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
message = Table.grid(padding=2)
|
| 261 |
+
message.add_column()
|
| 262 |
+
message.add_column(no_wrap=True)
|
| 263 |
+
message.add_row(intro_message, sponsor_message)
|
| 264 |
+
|
| 265 |
+
console.print(
|
| 266 |
+
Panel.fit(
|
| 267 |
+
message,
|
| 268 |
+
box=box.ROUNDED,
|
| 269 |
+
padding=(1, 2),
|
| 270 |
+
title="[b red]Thanks for trying out Rich!",
|
| 271 |
+
border_style="bright_blue",
|
| 272 |
+
),
|
| 273 |
+
justify="center",
|
| 274 |
+
)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_cell_widths.py
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto generated by make_terminal_widths.py
|
| 2 |
+
|
| 3 |
+
CELL_WIDTHS = [
|
| 4 |
+
(0, 0, 0),
|
| 5 |
+
(1, 31, -1),
|
| 6 |
+
(127, 159, -1),
|
| 7 |
+
(768, 879, 0),
|
| 8 |
+
(1155, 1161, 0),
|
| 9 |
+
(1425, 1469, 0),
|
| 10 |
+
(1471, 1471, 0),
|
| 11 |
+
(1473, 1474, 0),
|
| 12 |
+
(1476, 1477, 0),
|
| 13 |
+
(1479, 1479, 0),
|
| 14 |
+
(1552, 1562, 0),
|
| 15 |
+
(1611, 1631, 0),
|
| 16 |
+
(1648, 1648, 0),
|
| 17 |
+
(1750, 1756, 0),
|
| 18 |
+
(1759, 1764, 0),
|
| 19 |
+
(1767, 1768, 0),
|
| 20 |
+
(1770, 1773, 0),
|
| 21 |
+
(1809, 1809, 0),
|
| 22 |
+
(1840, 1866, 0),
|
| 23 |
+
(1958, 1968, 0),
|
| 24 |
+
(2027, 2035, 0),
|
| 25 |
+
(2045, 2045, 0),
|
| 26 |
+
(2070, 2073, 0),
|
| 27 |
+
(2075, 2083, 0),
|
| 28 |
+
(2085, 2087, 0),
|
| 29 |
+
(2089, 2093, 0),
|
| 30 |
+
(2137, 2139, 0),
|
| 31 |
+
(2259, 2273, 0),
|
| 32 |
+
(2275, 2306, 0),
|
| 33 |
+
(2362, 2362, 0),
|
| 34 |
+
(2364, 2364, 0),
|
| 35 |
+
(2369, 2376, 0),
|
| 36 |
+
(2381, 2381, 0),
|
| 37 |
+
(2385, 2391, 0),
|
| 38 |
+
(2402, 2403, 0),
|
| 39 |
+
(2433, 2433, 0),
|
| 40 |
+
(2492, 2492, 0),
|
| 41 |
+
(2497, 2500, 0),
|
| 42 |
+
(2509, 2509, 0),
|
| 43 |
+
(2530, 2531, 0),
|
| 44 |
+
(2558, 2558, 0),
|
| 45 |
+
(2561, 2562, 0),
|
| 46 |
+
(2620, 2620, 0),
|
| 47 |
+
(2625, 2626, 0),
|
| 48 |
+
(2631, 2632, 0),
|
| 49 |
+
(2635, 2637, 0),
|
| 50 |
+
(2641, 2641, 0),
|
| 51 |
+
(2672, 2673, 0),
|
| 52 |
+
(2677, 2677, 0),
|
| 53 |
+
(2689, 2690, 0),
|
| 54 |
+
(2748, 2748, 0),
|
| 55 |
+
(2753, 2757, 0),
|
| 56 |
+
(2759, 2760, 0),
|
| 57 |
+
(2765, 2765, 0),
|
| 58 |
+
(2786, 2787, 0),
|
| 59 |
+
(2810, 2815, 0),
|
| 60 |
+
(2817, 2817, 0),
|
| 61 |
+
(2876, 2876, 0),
|
| 62 |
+
(2879, 2879, 0),
|
| 63 |
+
(2881, 2884, 0),
|
| 64 |
+
(2893, 2893, 0),
|
| 65 |
+
(2901, 2902, 0),
|
| 66 |
+
(2914, 2915, 0),
|
| 67 |
+
(2946, 2946, 0),
|
| 68 |
+
(3008, 3008, 0),
|
| 69 |
+
(3021, 3021, 0),
|
| 70 |
+
(3072, 3072, 0),
|
| 71 |
+
(3076, 3076, 0),
|
| 72 |
+
(3134, 3136, 0),
|
| 73 |
+
(3142, 3144, 0),
|
| 74 |
+
(3146, 3149, 0),
|
| 75 |
+
(3157, 3158, 0),
|
| 76 |
+
(3170, 3171, 0),
|
| 77 |
+
(3201, 3201, 0),
|
| 78 |
+
(3260, 3260, 0),
|
| 79 |
+
(3263, 3263, 0),
|
| 80 |
+
(3270, 3270, 0),
|
| 81 |
+
(3276, 3277, 0),
|
| 82 |
+
(3298, 3299, 0),
|
| 83 |
+
(3328, 3329, 0),
|
| 84 |
+
(3387, 3388, 0),
|
| 85 |
+
(3393, 3396, 0),
|
| 86 |
+
(3405, 3405, 0),
|
| 87 |
+
(3426, 3427, 0),
|
| 88 |
+
(3457, 3457, 0),
|
| 89 |
+
(3530, 3530, 0),
|
| 90 |
+
(3538, 3540, 0),
|
| 91 |
+
(3542, 3542, 0),
|
| 92 |
+
(3633, 3633, 0),
|
| 93 |
+
(3636, 3642, 0),
|
| 94 |
+
(3655, 3662, 0),
|
| 95 |
+
(3761, 3761, 0),
|
| 96 |
+
(3764, 3772, 0),
|
| 97 |
+
(3784, 3789, 0),
|
| 98 |
+
(3864, 3865, 0),
|
| 99 |
+
(3893, 3893, 0),
|
| 100 |
+
(3895, 3895, 0),
|
| 101 |
+
(3897, 3897, 0),
|
| 102 |
+
(3953, 3966, 0),
|
| 103 |
+
(3968, 3972, 0),
|
| 104 |
+
(3974, 3975, 0),
|
| 105 |
+
(3981, 3991, 0),
|
| 106 |
+
(3993, 4028, 0),
|
| 107 |
+
(4038, 4038, 0),
|
| 108 |
+
(4141, 4144, 0),
|
| 109 |
+
(4146, 4151, 0),
|
| 110 |
+
(4153, 4154, 0),
|
| 111 |
+
(4157, 4158, 0),
|
| 112 |
+
(4184, 4185, 0),
|
| 113 |
+
(4190, 4192, 0),
|
| 114 |
+
(4209, 4212, 0),
|
| 115 |
+
(4226, 4226, 0),
|
| 116 |
+
(4229, 4230, 0),
|
| 117 |
+
(4237, 4237, 0),
|
| 118 |
+
(4253, 4253, 0),
|
| 119 |
+
(4352, 4447, 2),
|
| 120 |
+
(4957, 4959, 0),
|
| 121 |
+
(5906, 5908, 0),
|
| 122 |
+
(5938, 5940, 0),
|
| 123 |
+
(5970, 5971, 0),
|
| 124 |
+
(6002, 6003, 0),
|
| 125 |
+
(6068, 6069, 0),
|
| 126 |
+
(6071, 6077, 0),
|
| 127 |
+
(6086, 6086, 0),
|
| 128 |
+
(6089, 6099, 0),
|
| 129 |
+
(6109, 6109, 0),
|
| 130 |
+
(6155, 6157, 0),
|
| 131 |
+
(6277, 6278, 0),
|
| 132 |
+
(6313, 6313, 0),
|
| 133 |
+
(6432, 6434, 0),
|
| 134 |
+
(6439, 6440, 0),
|
| 135 |
+
(6450, 6450, 0),
|
| 136 |
+
(6457, 6459, 0),
|
| 137 |
+
(6679, 6680, 0),
|
| 138 |
+
(6683, 6683, 0),
|
| 139 |
+
(6742, 6742, 0),
|
| 140 |
+
(6744, 6750, 0),
|
| 141 |
+
(6752, 6752, 0),
|
| 142 |
+
(6754, 6754, 0),
|
| 143 |
+
(6757, 6764, 0),
|
| 144 |
+
(6771, 6780, 0),
|
| 145 |
+
(6783, 6783, 0),
|
| 146 |
+
(6832, 6848, 0),
|
| 147 |
+
(6912, 6915, 0),
|
| 148 |
+
(6964, 6964, 0),
|
| 149 |
+
(6966, 6970, 0),
|
| 150 |
+
(6972, 6972, 0),
|
| 151 |
+
(6978, 6978, 0),
|
| 152 |
+
(7019, 7027, 0),
|
| 153 |
+
(7040, 7041, 0),
|
| 154 |
+
(7074, 7077, 0),
|
| 155 |
+
(7080, 7081, 0),
|
| 156 |
+
(7083, 7085, 0),
|
| 157 |
+
(7142, 7142, 0),
|
| 158 |
+
(7144, 7145, 0),
|
| 159 |
+
(7149, 7149, 0),
|
| 160 |
+
(7151, 7153, 0),
|
| 161 |
+
(7212, 7219, 0),
|
| 162 |
+
(7222, 7223, 0),
|
| 163 |
+
(7376, 7378, 0),
|
| 164 |
+
(7380, 7392, 0),
|
| 165 |
+
(7394, 7400, 0),
|
| 166 |
+
(7405, 7405, 0),
|
| 167 |
+
(7412, 7412, 0),
|
| 168 |
+
(7416, 7417, 0),
|
| 169 |
+
(7616, 7673, 0),
|
| 170 |
+
(7675, 7679, 0),
|
| 171 |
+
(8203, 8207, 0),
|
| 172 |
+
(8232, 8238, 0),
|
| 173 |
+
(8288, 8291, 0),
|
| 174 |
+
(8400, 8432, 0),
|
| 175 |
+
(8986, 8987, 2),
|
| 176 |
+
(9001, 9002, 2),
|
| 177 |
+
(9193, 9196, 2),
|
| 178 |
+
(9200, 9200, 2),
|
| 179 |
+
(9203, 9203, 2),
|
| 180 |
+
(9725, 9726, 2),
|
| 181 |
+
(9748, 9749, 2),
|
| 182 |
+
(9800, 9811, 2),
|
| 183 |
+
(9855, 9855, 2),
|
| 184 |
+
(9875, 9875, 2),
|
| 185 |
+
(9889, 9889, 2),
|
| 186 |
+
(9898, 9899, 2),
|
| 187 |
+
(9917, 9918, 2),
|
| 188 |
+
(9924, 9925, 2),
|
| 189 |
+
(9934, 9934, 2),
|
| 190 |
+
(9940, 9940, 2),
|
| 191 |
+
(9962, 9962, 2),
|
| 192 |
+
(9970, 9971, 2),
|
| 193 |
+
(9973, 9973, 2),
|
| 194 |
+
(9978, 9978, 2),
|
| 195 |
+
(9981, 9981, 2),
|
| 196 |
+
(9989, 9989, 2),
|
| 197 |
+
(9994, 9995, 2),
|
| 198 |
+
(10024, 10024, 2),
|
| 199 |
+
(10060, 10060, 2),
|
| 200 |
+
(10062, 10062, 2),
|
| 201 |
+
(10067, 10069, 2),
|
| 202 |
+
(10071, 10071, 2),
|
| 203 |
+
(10133, 10135, 2),
|
| 204 |
+
(10160, 10160, 2),
|
| 205 |
+
(10175, 10175, 2),
|
| 206 |
+
(11035, 11036, 2),
|
| 207 |
+
(11088, 11088, 2),
|
| 208 |
+
(11093, 11093, 2),
|
| 209 |
+
(11503, 11505, 0),
|
| 210 |
+
(11647, 11647, 0),
|
| 211 |
+
(11744, 11775, 0),
|
| 212 |
+
(11904, 11929, 2),
|
| 213 |
+
(11931, 12019, 2),
|
| 214 |
+
(12032, 12245, 2),
|
| 215 |
+
(12272, 12283, 2),
|
| 216 |
+
(12288, 12329, 2),
|
| 217 |
+
(12330, 12333, 0),
|
| 218 |
+
(12334, 12350, 2),
|
| 219 |
+
(12353, 12438, 2),
|
| 220 |
+
(12441, 12442, 0),
|
| 221 |
+
(12443, 12543, 2),
|
| 222 |
+
(12549, 12591, 2),
|
| 223 |
+
(12593, 12686, 2),
|
| 224 |
+
(12688, 12771, 2),
|
| 225 |
+
(12784, 12830, 2),
|
| 226 |
+
(12832, 12871, 2),
|
| 227 |
+
(12880, 19903, 2),
|
| 228 |
+
(19968, 42124, 2),
|
| 229 |
+
(42128, 42182, 2),
|
| 230 |
+
(42607, 42610, 0),
|
| 231 |
+
(42612, 42621, 0),
|
| 232 |
+
(42654, 42655, 0),
|
| 233 |
+
(42736, 42737, 0),
|
| 234 |
+
(43010, 43010, 0),
|
| 235 |
+
(43014, 43014, 0),
|
| 236 |
+
(43019, 43019, 0),
|
| 237 |
+
(43045, 43046, 0),
|
| 238 |
+
(43052, 43052, 0),
|
| 239 |
+
(43204, 43205, 0),
|
| 240 |
+
(43232, 43249, 0),
|
| 241 |
+
(43263, 43263, 0),
|
| 242 |
+
(43302, 43309, 0),
|
| 243 |
+
(43335, 43345, 0),
|
| 244 |
+
(43360, 43388, 2),
|
| 245 |
+
(43392, 43394, 0),
|
| 246 |
+
(43443, 43443, 0),
|
| 247 |
+
(43446, 43449, 0),
|
| 248 |
+
(43452, 43453, 0),
|
| 249 |
+
(43493, 43493, 0),
|
| 250 |
+
(43561, 43566, 0),
|
| 251 |
+
(43569, 43570, 0),
|
| 252 |
+
(43573, 43574, 0),
|
| 253 |
+
(43587, 43587, 0),
|
| 254 |
+
(43596, 43596, 0),
|
| 255 |
+
(43644, 43644, 0),
|
| 256 |
+
(43696, 43696, 0),
|
| 257 |
+
(43698, 43700, 0),
|
| 258 |
+
(43703, 43704, 0),
|
| 259 |
+
(43710, 43711, 0),
|
| 260 |
+
(43713, 43713, 0),
|
| 261 |
+
(43756, 43757, 0),
|
| 262 |
+
(43766, 43766, 0),
|
| 263 |
+
(44005, 44005, 0),
|
| 264 |
+
(44008, 44008, 0),
|
| 265 |
+
(44013, 44013, 0),
|
| 266 |
+
(44032, 55203, 2),
|
| 267 |
+
(63744, 64255, 2),
|
| 268 |
+
(64286, 64286, 0),
|
| 269 |
+
(65024, 65039, 0),
|
| 270 |
+
(65040, 65049, 2),
|
| 271 |
+
(65056, 65071, 0),
|
| 272 |
+
(65072, 65106, 2),
|
| 273 |
+
(65108, 65126, 2),
|
| 274 |
+
(65128, 65131, 2),
|
| 275 |
+
(65281, 65376, 2),
|
| 276 |
+
(65504, 65510, 2),
|
| 277 |
+
(66045, 66045, 0),
|
| 278 |
+
(66272, 66272, 0),
|
| 279 |
+
(66422, 66426, 0),
|
| 280 |
+
(68097, 68099, 0),
|
| 281 |
+
(68101, 68102, 0),
|
| 282 |
+
(68108, 68111, 0),
|
| 283 |
+
(68152, 68154, 0),
|
| 284 |
+
(68159, 68159, 0),
|
| 285 |
+
(68325, 68326, 0),
|
| 286 |
+
(68900, 68903, 0),
|
| 287 |
+
(69291, 69292, 0),
|
| 288 |
+
(69446, 69456, 0),
|
| 289 |
+
(69633, 69633, 0),
|
| 290 |
+
(69688, 69702, 0),
|
| 291 |
+
(69759, 69761, 0),
|
| 292 |
+
(69811, 69814, 0),
|
| 293 |
+
(69817, 69818, 0),
|
| 294 |
+
(69888, 69890, 0),
|
| 295 |
+
(69927, 69931, 0),
|
| 296 |
+
(69933, 69940, 0),
|
| 297 |
+
(70003, 70003, 0),
|
| 298 |
+
(70016, 70017, 0),
|
| 299 |
+
(70070, 70078, 0),
|
| 300 |
+
(70089, 70092, 0),
|
| 301 |
+
(70095, 70095, 0),
|
| 302 |
+
(70191, 70193, 0),
|
| 303 |
+
(70196, 70196, 0),
|
| 304 |
+
(70198, 70199, 0),
|
| 305 |
+
(70206, 70206, 0),
|
| 306 |
+
(70367, 70367, 0),
|
| 307 |
+
(70371, 70378, 0),
|
| 308 |
+
(70400, 70401, 0),
|
| 309 |
+
(70459, 70460, 0),
|
| 310 |
+
(70464, 70464, 0),
|
| 311 |
+
(70502, 70508, 0),
|
| 312 |
+
(70512, 70516, 0),
|
| 313 |
+
(70712, 70719, 0),
|
| 314 |
+
(70722, 70724, 0),
|
| 315 |
+
(70726, 70726, 0),
|
| 316 |
+
(70750, 70750, 0),
|
| 317 |
+
(70835, 70840, 0),
|
| 318 |
+
(70842, 70842, 0),
|
| 319 |
+
(70847, 70848, 0),
|
| 320 |
+
(70850, 70851, 0),
|
| 321 |
+
(71090, 71093, 0),
|
| 322 |
+
(71100, 71101, 0),
|
| 323 |
+
(71103, 71104, 0),
|
| 324 |
+
(71132, 71133, 0),
|
| 325 |
+
(71219, 71226, 0),
|
| 326 |
+
(71229, 71229, 0),
|
| 327 |
+
(71231, 71232, 0),
|
| 328 |
+
(71339, 71339, 0),
|
| 329 |
+
(71341, 71341, 0),
|
| 330 |
+
(71344, 71349, 0),
|
| 331 |
+
(71351, 71351, 0),
|
| 332 |
+
(71453, 71455, 0),
|
| 333 |
+
(71458, 71461, 0),
|
| 334 |
+
(71463, 71467, 0),
|
| 335 |
+
(71727, 71735, 0),
|
| 336 |
+
(71737, 71738, 0),
|
| 337 |
+
(71995, 71996, 0),
|
| 338 |
+
(71998, 71998, 0),
|
| 339 |
+
(72003, 72003, 0),
|
| 340 |
+
(72148, 72151, 0),
|
| 341 |
+
(72154, 72155, 0),
|
| 342 |
+
(72160, 72160, 0),
|
| 343 |
+
(72193, 72202, 0),
|
| 344 |
+
(72243, 72248, 0),
|
| 345 |
+
(72251, 72254, 0),
|
| 346 |
+
(72263, 72263, 0),
|
| 347 |
+
(72273, 72278, 0),
|
| 348 |
+
(72281, 72283, 0),
|
| 349 |
+
(72330, 72342, 0),
|
| 350 |
+
(72344, 72345, 0),
|
| 351 |
+
(72752, 72758, 0),
|
| 352 |
+
(72760, 72765, 0),
|
| 353 |
+
(72767, 72767, 0),
|
| 354 |
+
(72850, 72871, 0),
|
| 355 |
+
(72874, 72880, 0),
|
| 356 |
+
(72882, 72883, 0),
|
| 357 |
+
(72885, 72886, 0),
|
| 358 |
+
(73009, 73014, 0),
|
| 359 |
+
(73018, 73018, 0),
|
| 360 |
+
(73020, 73021, 0),
|
| 361 |
+
(73023, 73029, 0),
|
| 362 |
+
(73031, 73031, 0),
|
| 363 |
+
(73104, 73105, 0),
|
| 364 |
+
(73109, 73109, 0),
|
| 365 |
+
(73111, 73111, 0),
|
| 366 |
+
(73459, 73460, 0),
|
| 367 |
+
(92912, 92916, 0),
|
| 368 |
+
(92976, 92982, 0),
|
| 369 |
+
(94031, 94031, 0),
|
| 370 |
+
(94095, 94098, 0),
|
| 371 |
+
(94176, 94179, 2),
|
| 372 |
+
(94180, 94180, 0),
|
| 373 |
+
(94192, 94193, 2),
|
| 374 |
+
(94208, 100343, 2),
|
| 375 |
+
(100352, 101589, 2),
|
| 376 |
+
(101632, 101640, 2),
|
| 377 |
+
(110592, 110878, 2),
|
| 378 |
+
(110928, 110930, 2),
|
| 379 |
+
(110948, 110951, 2),
|
| 380 |
+
(110960, 111355, 2),
|
| 381 |
+
(113821, 113822, 0),
|
| 382 |
+
(119143, 119145, 0),
|
| 383 |
+
(119163, 119170, 0),
|
| 384 |
+
(119173, 119179, 0),
|
| 385 |
+
(119210, 119213, 0),
|
| 386 |
+
(119362, 119364, 0),
|
| 387 |
+
(121344, 121398, 0),
|
| 388 |
+
(121403, 121452, 0),
|
| 389 |
+
(121461, 121461, 0),
|
| 390 |
+
(121476, 121476, 0),
|
| 391 |
+
(121499, 121503, 0),
|
| 392 |
+
(121505, 121519, 0),
|
| 393 |
+
(122880, 122886, 0),
|
| 394 |
+
(122888, 122904, 0),
|
| 395 |
+
(122907, 122913, 0),
|
| 396 |
+
(122915, 122916, 0),
|
| 397 |
+
(122918, 122922, 0),
|
| 398 |
+
(123184, 123190, 0),
|
| 399 |
+
(123628, 123631, 0),
|
| 400 |
+
(125136, 125142, 0),
|
| 401 |
+
(125252, 125258, 0),
|
| 402 |
+
(126980, 126980, 2),
|
| 403 |
+
(127183, 127183, 2),
|
| 404 |
+
(127374, 127374, 2),
|
| 405 |
+
(127377, 127386, 2),
|
| 406 |
+
(127488, 127490, 2),
|
| 407 |
+
(127504, 127547, 2),
|
| 408 |
+
(127552, 127560, 2),
|
| 409 |
+
(127568, 127569, 2),
|
| 410 |
+
(127584, 127589, 2),
|
| 411 |
+
(127744, 127776, 2),
|
| 412 |
+
(127789, 127797, 2),
|
| 413 |
+
(127799, 127868, 2),
|
| 414 |
+
(127870, 127891, 2),
|
| 415 |
+
(127904, 127946, 2),
|
| 416 |
+
(127951, 127955, 2),
|
| 417 |
+
(127968, 127984, 2),
|
| 418 |
+
(127988, 127988, 2),
|
| 419 |
+
(127992, 128062, 2),
|
| 420 |
+
(128064, 128064, 2),
|
| 421 |
+
(128066, 128252, 2),
|
| 422 |
+
(128255, 128317, 2),
|
| 423 |
+
(128331, 128334, 2),
|
| 424 |
+
(128336, 128359, 2),
|
| 425 |
+
(128378, 128378, 2),
|
| 426 |
+
(128405, 128406, 2),
|
| 427 |
+
(128420, 128420, 2),
|
| 428 |
+
(128507, 128591, 2),
|
| 429 |
+
(128640, 128709, 2),
|
| 430 |
+
(128716, 128716, 2),
|
| 431 |
+
(128720, 128722, 2),
|
| 432 |
+
(128725, 128727, 2),
|
| 433 |
+
(128747, 128748, 2),
|
| 434 |
+
(128756, 128764, 2),
|
| 435 |
+
(128992, 129003, 2),
|
| 436 |
+
(129292, 129338, 2),
|
| 437 |
+
(129340, 129349, 2),
|
| 438 |
+
(129351, 129400, 2),
|
| 439 |
+
(129402, 129483, 2),
|
| 440 |
+
(129485, 129535, 2),
|
| 441 |
+
(129648, 129652, 2),
|
| 442 |
+
(129656, 129658, 2),
|
| 443 |
+
(129664, 129670, 2),
|
| 444 |
+
(129680, 129704, 2),
|
| 445 |
+
(129712, 129718, 2),
|
| 446 |
+
(129728, 129730, 2),
|
| 447 |
+
(129744, 129750, 2),
|
| 448 |
+
(131072, 196605, 2),
|
| 449 |
+
(196608, 262141, 2),
|
| 450 |
+
(917760, 917999, 0),
|
| 451 |
+
]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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 pip._vendor.rich.pretty import install
|
| 7 |
+
from pip._vendor.rich.traceback import install as tr_install
|
| 8 |
+
|
| 9 |
+
install()
|
| 10 |
+
tr_install()
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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 pip._vendor.rich.console import Console
|
| 91 |
+
|
| 92 |
+
c = Console()
|
| 93 |
+
c.print("[on blue]Hello", justify="right")
|
| 94 |
+
c.log("[on blue]hello", justify="right")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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 |
+
pass
|
| 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()
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_palettes.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .palette import Palette
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# Taken from https://en.wikipedia.org/wiki/ANSI_escape_code (Windows 10 column)
|
| 5 |
+
WINDOWS_PALETTE = Palette(
|
| 6 |
+
[
|
| 7 |
+
(12, 12, 12),
|
| 8 |
+
(197, 15, 31),
|
| 9 |
+
(19, 161, 14),
|
| 10 |
+
(193, 156, 0),
|
| 11 |
+
(0, 55, 218),
|
| 12 |
+
(136, 23, 152),
|
| 13 |
+
(58, 150, 221),
|
| 14 |
+
(204, 204, 204),
|
| 15 |
+
(118, 118, 118),
|
| 16 |
+
(231, 72, 86),
|
| 17 |
+
(22, 198, 12),
|
| 18 |
+
(249, 241, 165),
|
| 19 |
+
(59, 120, 255),
|
| 20 |
+
(180, 0, 158),
|
| 21 |
+
(97, 214, 214),
|
| 22 |
+
(242, 242, 242),
|
| 23 |
+
]
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# # The standard ansi colors (including bright variants)
|
| 27 |
+
STANDARD_PALETTE = Palette(
|
| 28 |
+
[
|
| 29 |
+
(0, 0, 0),
|
| 30 |
+
(170, 0, 0),
|
| 31 |
+
(0, 170, 0),
|
| 32 |
+
(170, 85, 0),
|
| 33 |
+
(0, 0, 170),
|
| 34 |
+
(170, 0, 170),
|
| 35 |
+
(0, 170, 170),
|
| 36 |
+
(170, 170, 170),
|
| 37 |
+
(85, 85, 85),
|
| 38 |
+
(255, 85, 85),
|
| 39 |
+
(85, 255, 85),
|
| 40 |
+
(255, 255, 85),
|
| 41 |
+
(85, 85, 255),
|
| 42 |
+
(255, 85, 255),
|
| 43 |
+
(85, 255, 255),
|
| 44 |
+
(255, 255, 255),
|
| 45 |
+
]
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# The 256 color palette
|
| 50 |
+
EIGHT_BIT_PALETTE = Palette(
|
| 51 |
+
[
|
| 52 |
+
(0, 0, 0),
|
| 53 |
+
(128, 0, 0),
|
| 54 |
+
(0, 128, 0),
|
| 55 |
+
(128, 128, 0),
|
| 56 |
+
(0, 0, 128),
|
| 57 |
+
(128, 0, 128),
|
| 58 |
+
(0, 128, 128),
|
| 59 |
+
(192, 192, 192),
|
| 60 |
+
(128, 128, 128),
|
| 61 |
+
(255, 0, 0),
|
| 62 |
+
(0, 255, 0),
|
| 63 |
+
(255, 255, 0),
|
| 64 |
+
(0, 0, 255),
|
| 65 |
+
(255, 0, 255),
|
| 66 |
+
(0, 255, 255),
|
| 67 |
+
(255, 255, 255),
|
| 68 |
+
(0, 0, 0),
|
| 69 |
+
(0, 0, 95),
|
| 70 |
+
(0, 0, 135),
|
| 71 |
+
(0, 0, 175),
|
| 72 |
+
(0, 0, 215),
|
| 73 |
+
(0, 0, 255),
|
| 74 |
+
(0, 95, 0),
|
| 75 |
+
(0, 95, 95),
|
| 76 |
+
(0, 95, 135),
|
| 77 |
+
(0, 95, 175),
|
| 78 |
+
(0, 95, 215),
|
| 79 |
+
(0, 95, 255),
|
| 80 |
+
(0, 135, 0),
|
| 81 |
+
(0, 135, 95),
|
| 82 |
+
(0, 135, 135),
|
| 83 |
+
(0, 135, 175),
|
| 84 |
+
(0, 135, 215),
|
| 85 |
+
(0, 135, 255),
|
| 86 |
+
(0, 175, 0),
|
| 87 |
+
(0, 175, 95),
|
| 88 |
+
(0, 175, 135),
|
| 89 |
+
(0, 175, 175),
|
| 90 |
+
(0, 175, 215),
|
| 91 |
+
(0, 175, 255),
|
| 92 |
+
(0, 215, 0),
|
| 93 |
+
(0, 215, 95),
|
| 94 |
+
(0, 215, 135),
|
| 95 |
+
(0, 215, 175),
|
| 96 |
+
(0, 215, 215),
|
| 97 |
+
(0, 215, 255),
|
| 98 |
+
(0, 255, 0),
|
| 99 |
+
(0, 255, 95),
|
| 100 |
+
(0, 255, 135),
|
| 101 |
+
(0, 255, 175),
|
| 102 |
+
(0, 255, 215),
|
| 103 |
+
(0, 255, 255),
|
| 104 |
+
(95, 0, 0),
|
| 105 |
+
(95, 0, 95),
|
| 106 |
+
(95, 0, 135),
|
| 107 |
+
(95, 0, 175),
|
| 108 |
+
(95, 0, 215),
|
| 109 |
+
(95, 0, 255),
|
| 110 |
+
(95, 95, 0),
|
| 111 |
+
(95, 95, 95),
|
| 112 |
+
(95, 95, 135),
|
| 113 |
+
(95, 95, 175),
|
| 114 |
+
(95, 95, 215),
|
| 115 |
+
(95, 95, 255),
|
| 116 |
+
(95, 135, 0),
|
| 117 |
+
(95, 135, 95),
|
| 118 |
+
(95, 135, 135),
|
| 119 |
+
(95, 135, 175),
|
| 120 |
+
(95, 135, 215),
|
| 121 |
+
(95, 135, 255),
|
| 122 |
+
(95, 175, 0),
|
| 123 |
+
(95, 175, 95),
|
| 124 |
+
(95, 175, 135),
|
| 125 |
+
(95, 175, 175),
|
| 126 |
+
(95, 175, 215),
|
| 127 |
+
(95, 175, 255),
|
| 128 |
+
(95, 215, 0),
|
| 129 |
+
(95, 215, 95),
|
| 130 |
+
(95, 215, 135),
|
| 131 |
+
(95, 215, 175),
|
| 132 |
+
(95, 215, 215),
|
| 133 |
+
(95, 215, 255),
|
| 134 |
+
(95, 255, 0),
|
| 135 |
+
(95, 255, 95),
|
| 136 |
+
(95, 255, 135),
|
| 137 |
+
(95, 255, 175),
|
| 138 |
+
(95, 255, 215),
|
| 139 |
+
(95, 255, 255),
|
| 140 |
+
(135, 0, 0),
|
| 141 |
+
(135, 0, 95),
|
| 142 |
+
(135, 0, 135),
|
| 143 |
+
(135, 0, 175),
|
| 144 |
+
(135, 0, 215),
|
| 145 |
+
(135, 0, 255),
|
| 146 |
+
(135, 95, 0),
|
| 147 |
+
(135, 95, 95),
|
| 148 |
+
(135, 95, 135),
|
| 149 |
+
(135, 95, 175),
|
| 150 |
+
(135, 95, 215),
|
| 151 |
+
(135, 95, 255),
|
| 152 |
+
(135, 135, 0),
|
| 153 |
+
(135, 135, 95),
|
| 154 |
+
(135, 135, 135),
|
| 155 |
+
(135, 135, 175),
|
| 156 |
+
(135, 135, 215),
|
| 157 |
+
(135, 135, 255),
|
| 158 |
+
(135, 175, 0),
|
| 159 |
+
(135, 175, 95),
|
| 160 |
+
(135, 175, 135),
|
| 161 |
+
(135, 175, 175),
|
| 162 |
+
(135, 175, 215),
|
| 163 |
+
(135, 175, 255),
|
| 164 |
+
(135, 215, 0),
|
| 165 |
+
(135, 215, 95),
|
| 166 |
+
(135, 215, 135),
|
| 167 |
+
(135, 215, 175),
|
| 168 |
+
(135, 215, 215),
|
| 169 |
+
(135, 215, 255),
|
| 170 |
+
(135, 255, 0),
|
| 171 |
+
(135, 255, 95),
|
| 172 |
+
(135, 255, 135),
|
| 173 |
+
(135, 255, 175),
|
| 174 |
+
(135, 255, 215),
|
| 175 |
+
(135, 255, 255),
|
| 176 |
+
(175, 0, 0),
|
| 177 |
+
(175, 0, 95),
|
| 178 |
+
(175, 0, 135),
|
| 179 |
+
(175, 0, 175),
|
| 180 |
+
(175, 0, 215),
|
| 181 |
+
(175, 0, 255),
|
| 182 |
+
(175, 95, 0),
|
| 183 |
+
(175, 95, 95),
|
| 184 |
+
(175, 95, 135),
|
| 185 |
+
(175, 95, 175),
|
| 186 |
+
(175, 95, 215),
|
| 187 |
+
(175, 95, 255),
|
| 188 |
+
(175, 135, 0),
|
| 189 |
+
(175, 135, 95),
|
| 190 |
+
(175, 135, 135),
|
| 191 |
+
(175, 135, 175),
|
| 192 |
+
(175, 135, 215),
|
| 193 |
+
(175, 135, 255),
|
| 194 |
+
(175, 175, 0),
|
| 195 |
+
(175, 175, 95),
|
| 196 |
+
(175, 175, 135),
|
| 197 |
+
(175, 175, 175),
|
| 198 |
+
(175, 175, 215),
|
| 199 |
+
(175, 175, 255),
|
| 200 |
+
(175, 215, 0),
|
| 201 |
+
(175, 215, 95),
|
| 202 |
+
(175, 215, 135),
|
| 203 |
+
(175, 215, 175),
|
| 204 |
+
(175, 215, 215),
|
| 205 |
+
(175, 215, 255),
|
| 206 |
+
(175, 255, 0),
|
| 207 |
+
(175, 255, 95),
|
| 208 |
+
(175, 255, 135),
|
| 209 |
+
(175, 255, 175),
|
| 210 |
+
(175, 255, 215),
|
| 211 |
+
(175, 255, 255),
|
| 212 |
+
(215, 0, 0),
|
| 213 |
+
(215, 0, 95),
|
| 214 |
+
(215, 0, 135),
|
| 215 |
+
(215, 0, 175),
|
| 216 |
+
(215, 0, 215),
|
| 217 |
+
(215, 0, 255),
|
| 218 |
+
(215, 95, 0),
|
| 219 |
+
(215, 95, 95),
|
| 220 |
+
(215, 95, 135),
|
| 221 |
+
(215, 95, 175),
|
| 222 |
+
(215, 95, 215),
|
| 223 |
+
(215, 95, 255),
|
| 224 |
+
(215, 135, 0),
|
| 225 |
+
(215, 135, 95),
|
| 226 |
+
(215, 135, 135),
|
| 227 |
+
(215, 135, 175),
|
| 228 |
+
(215, 135, 215),
|
| 229 |
+
(215, 135, 255),
|
| 230 |
+
(215, 175, 0),
|
| 231 |
+
(215, 175, 95),
|
| 232 |
+
(215, 175, 135),
|
| 233 |
+
(215, 175, 175),
|
| 234 |
+
(215, 175, 215),
|
| 235 |
+
(215, 175, 255),
|
| 236 |
+
(215, 215, 0),
|
| 237 |
+
(215, 215, 95),
|
| 238 |
+
(215, 215, 135),
|
| 239 |
+
(215, 215, 175),
|
| 240 |
+
(215, 215, 215),
|
| 241 |
+
(215, 215, 255),
|
| 242 |
+
(215, 255, 0),
|
| 243 |
+
(215, 255, 95),
|
| 244 |
+
(215, 255, 135),
|
| 245 |
+
(215, 255, 175),
|
| 246 |
+
(215, 255, 215),
|
| 247 |
+
(215, 255, 255),
|
| 248 |
+
(255, 0, 0),
|
| 249 |
+
(255, 0, 95),
|
| 250 |
+
(255, 0, 135),
|
| 251 |
+
(255, 0, 175),
|
| 252 |
+
(255, 0, 215),
|
| 253 |
+
(255, 0, 255),
|
| 254 |
+
(255, 95, 0),
|
| 255 |
+
(255, 95, 95),
|
| 256 |
+
(255, 95, 135),
|
| 257 |
+
(255, 95, 175),
|
| 258 |
+
(255, 95, 215),
|
| 259 |
+
(255, 95, 255),
|
| 260 |
+
(255, 135, 0),
|
| 261 |
+
(255, 135, 95),
|
| 262 |
+
(255, 135, 135),
|
| 263 |
+
(255, 135, 175),
|
| 264 |
+
(255, 135, 215),
|
| 265 |
+
(255, 135, 255),
|
| 266 |
+
(255, 175, 0),
|
| 267 |
+
(255, 175, 95),
|
| 268 |
+
(255, 175, 135),
|
| 269 |
+
(255, 175, 175),
|
| 270 |
+
(255, 175, 215),
|
| 271 |
+
(255, 175, 255),
|
| 272 |
+
(255, 215, 0),
|
| 273 |
+
(255, 215, 95),
|
| 274 |
+
(255, 215, 135),
|
| 275 |
+
(255, 215, 175),
|
| 276 |
+
(255, 215, 215),
|
| 277 |
+
(255, 215, 255),
|
| 278 |
+
(255, 255, 0),
|
| 279 |
+
(255, 255, 95),
|
| 280 |
+
(255, 255, 135),
|
| 281 |
+
(255, 255, 175),
|
| 282 |
+
(255, 255, 215),
|
| 283 |
+
(255, 255, 255),
|
| 284 |
+
(8, 8, 8),
|
| 285 |
+
(18, 18, 18),
|
| 286 |
+
(28, 28, 28),
|
| 287 |
+
(38, 38, 38),
|
| 288 |
+
(48, 48, 48),
|
| 289 |
+
(58, 58, 58),
|
| 290 |
+
(68, 68, 68),
|
| 291 |
+
(78, 78, 78),
|
| 292 |
+
(88, 88, 88),
|
| 293 |
+
(98, 98, 98),
|
| 294 |
+
(108, 108, 108),
|
| 295 |
+
(118, 118, 118),
|
| 296 |
+
(128, 128, 128),
|
| 297 |
+
(138, 138, 138),
|
| 298 |
+
(148, 148, 148),
|
| 299 |
+
(158, 158, 158),
|
| 300 |
+
(168, 168, 168),
|
| 301 |
+
(178, 178, 178),
|
| 302 |
+
(188, 188, 188),
|
| 303 |
+
(198, 198, 198),
|
| 304 |
+
(208, 208, 208),
|
| 305 |
+
(218, 218, 218),
|
| 306 |
+
(228, 228, 228),
|
| 307 |
+
(238, 238, 238),
|
| 308 |
+
]
|
| 309 |
+
)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from fractions import Fraction
|
| 3 |
+
from math import ceil
|
| 4 |
+
from typing import cast, List, Optional, Sequence
|
| 5 |
+
|
| 6 |
+
if sys.version_info >= (3, 8):
|
| 7 |
+
from typing import Protocol
|
| 8 |
+
else:
|
| 9 |
+
from pip._vendor.typing_extensions import Protocol # pragma: no cover
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class Edge(Protocol):
|
| 13 |
+
"""Any object that defines an edge (such as Layout)."""
|
| 14 |
+
|
| 15 |
+
size: Optional[int] = None
|
| 16 |
+
ratio: int = 1
|
| 17 |
+
minimum_size: int = 1
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def ratio_resolve(total: int, edges: Sequence[Edge]) -> List[int]:
|
| 21 |
+
"""Divide total space to satisfy size, ratio, and minimum_size, constraints.
|
| 22 |
+
|
| 23 |
+
The returned list of integers should add up to total in most cases, unless it is
|
| 24 |
+
impossible to satisfy all the constraints. For instance, if there are two edges
|
| 25 |
+
with a minimum size of 20 each and `total` is 30 then the returned list will be
|
| 26 |
+
greater than total. In practice, this would mean that a Layout object would
|
| 27 |
+
clip the rows that would overflow the screen height.
|
| 28 |
+
|
| 29 |
+
Args:
|
| 30 |
+
total (int): Total number of characters.
|
| 31 |
+
edges (List[Edge]): Edges within total space.
|
| 32 |
+
|
| 33 |
+
Returns:
|
| 34 |
+
List[int]: Number of characters for each edge.
|
| 35 |
+
"""
|
| 36 |
+
# Size of edge or None for yet to be determined
|
| 37 |
+
sizes = [(edge.size or None) for edge in edges]
|
| 38 |
+
|
| 39 |
+
_Fraction = Fraction
|
| 40 |
+
|
| 41 |
+
# While any edges haven't been calculated
|
| 42 |
+
while None in sizes:
|
| 43 |
+
# Get flexible edges and index to map these back on to sizes list
|
| 44 |
+
flexible_edges = [
|
| 45 |
+
(index, edge)
|
| 46 |
+
for index, (size, edge) in enumerate(zip(sizes, edges))
|
| 47 |
+
if size is None
|
| 48 |
+
]
|
| 49 |
+
# Remaining space in total
|
| 50 |
+
remaining = total - sum(size or 0 for size in sizes)
|
| 51 |
+
if remaining <= 0:
|
| 52 |
+
# No room for flexible edges
|
| 53 |
+
return [
|
| 54 |
+
((edge.minimum_size or 1) if size is None else size)
|
| 55 |
+
for size, edge in zip(sizes, edges)
|
| 56 |
+
]
|
| 57 |
+
# Calculate number of characters in a ratio portion
|
| 58 |
+
portion = _Fraction(
|
| 59 |
+
remaining, sum((edge.ratio or 1) for _, edge in flexible_edges)
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# If any edges will be less than their minimum, replace size with the minimum
|
| 63 |
+
for index, edge in flexible_edges:
|
| 64 |
+
if portion * edge.ratio <= edge.minimum_size:
|
| 65 |
+
sizes[index] = edge.minimum_size
|
| 66 |
+
# New fixed size will invalidate calculations, so we need to repeat the process
|
| 67 |
+
break
|
| 68 |
+
else:
|
| 69 |
+
# Distribute flexible space and compensate for rounding error
|
| 70 |
+
# Since edge sizes can only be integers we need to add the remainder
|
| 71 |
+
# to the following line
|
| 72 |
+
remainder = _Fraction(0)
|
| 73 |
+
for index, edge in flexible_edges:
|
| 74 |
+
size, remainder = divmod(portion * edge.ratio + remainder, 1)
|
| 75 |
+
sizes[index] = size
|
| 76 |
+
break
|
| 77 |
+
# Sizes now contains integers only
|
| 78 |
+
return cast(List[int], sizes)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def ratio_reduce(
|
| 82 |
+
total: int, ratios: List[int], maximums: List[int], values: List[int]
|
| 83 |
+
) -> List[int]:
|
| 84 |
+
"""Divide an integer total in to parts based on ratios.
|
| 85 |
+
|
| 86 |
+
Args:
|
| 87 |
+
total (int): The total to divide.
|
| 88 |
+
ratios (List[int]): A list of integer ratios.
|
| 89 |
+
maximums (List[int]): List of maximums values for each slot.
|
| 90 |
+
values (List[int]): List of values
|
| 91 |
+
|
| 92 |
+
Returns:
|
| 93 |
+
List[int]: A list of integers guaranteed to sum to total.
|
| 94 |
+
"""
|
| 95 |
+
ratios = [ratio if _max else 0 for ratio, _max in zip(ratios, maximums)]
|
| 96 |
+
total_ratio = sum(ratios)
|
| 97 |
+
if not total_ratio:
|
| 98 |
+
return values[:]
|
| 99 |
+
total_remaining = total
|
| 100 |
+
result: List[int] = []
|
| 101 |
+
append = result.append
|
| 102 |
+
for ratio, maximum, value in zip(ratios, maximums, values):
|
| 103 |
+
if ratio and total_ratio > 0:
|
| 104 |
+
distributed = min(maximum, round(ratio * total_remaining / total_ratio))
|
| 105 |
+
append(value - distributed)
|
| 106 |
+
total_remaining -= distributed
|
| 107 |
+
total_ratio -= ratio
|
| 108 |
+
else:
|
| 109 |
+
append(value)
|
| 110 |
+
return result
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def ratio_distribute(
|
| 114 |
+
total: int, ratios: List[int], minimums: Optional[List[int]] = None
|
| 115 |
+
) -> List[int]:
|
| 116 |
+
"""Distribute an integer total in to parts based on ratios.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
total (int): The total to divide.
|
| 120 |
+
ratios (List[int]): A list of integer ratios.
|
| 121 |
+
minimums (List[int]): List of minimum values for each slot.
|
| 122 |
+
|
| 123 |
+
Returns:
|
| 124 |
+
List[int]: A list of integers guaranteed to sum to total.
|
| 125 |
+
"""
|
| 126 |
+
if minimums:
|
| 127 |
+
ratios = [ratio if _min else 0 for ratio, _min in zip(ratios, minimums)]
|
| 128 |
+
total_ratio = sum(ratios)
|
| 129 |
+
assert total_ratio > 0, "Sum of ratios must be > 0"
|
| 130 |
+
|
| 131 |
+
total_remaining = total
|
| 132 |
+
distributed_total: List[int] = []
|
| 133 |
+
append = distributed_total.append
|
| 134 |
+
if minimums is None:
|
| 135 |
+
_minimums = [0] * len(ratios)
|
| 136 |
+
else:
|
| 137 |
+
_minimums = minimums
|
| 138 |
+
for ratio, minimum in zip(ratios, _minimums):
|
| 139 |
+
if total_ratio > 0:
|
| 140 |
+
distributed = max(minimum, ceil(ratio * total_remaining / total_ratio))
|
| 141 |
+
else:
|
| 142 |
+
distributed = total_remaining
|
| 143 |
+
append(distributed)
|
| 144 |
+
total_ratio -= ratio
|
| 145 |
+
total_remaining -= distributed
|
| 146 |
+
return distributed_total
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
if __name__ == "__main__":
|
| 150 |
+
from dataclasses import dataclass
|
| 151 |
+
|
| 152 |
+
@dataclass
|
| 153 |
+
class E:
|
| 154 |
+
|
| 155 |
+
size: Optional[int] = None
|
| 156 |
+
ratio: int = 1
|
| 157 |
+
minimum_size: int = 1
|
| 158 |
+
|
| 159 |
+
resolved = ratio_resolve(110, [E(None, 1, 1), E(None, 1, 1), E(None, 1, 1)])
|
| 160 |
+
print(sum(resolved))
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_spinners.py
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Spinners are from:
|
| 3 |
+
* cli-spinners:
|
| 4 |
+
MIT License
|
| 5 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
| 6 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 7 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 8 |
+
in the Software without restriction, including without limitation the rights to
|
| 9 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 10 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 11 |
+
subject to the following conditions:
|
| 12 |
+
The above copyright notice and this permission notice shall be included
|
| 13 |
+
in all copies or substantial portions of the Software.
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
| 15 |
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
| 16 |
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
| 17 |
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 18 |
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
| 19 |
+
IN THE SOFTWARE.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
SPINNERS = {
|
| 23 |
+
"dots": {
|
| 24 |
+
"interval": 80,
|
| 25 |
+
"frames": "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏",
|
| 26 |
+
},
|
| 27 |
+
"dots2": {"interval": 80, "frames": "⣾⣽⣻⢿⡿⣟⣯⣷"},
|
| 28 |
+
"dots3": {
|
| 29 |
+
"interval": 80,
|
| 30 |
+
"frames": "⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓",
|
| 31 |
+
},
|
| 32 |
+
"dots4": {
|
| 33 |
+
"interval": 80,
|
| 34 |
+
"frames": "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆",
|
| 35 |
+
},
|
| 36 |
+
"dots5": {
|
| 37 |
+
"interval": 80,
|
| 38 |
+
"frames": "⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋",
|
| 39 |
+
},
|
| 40 |
+
"dots6": {
|
| 41 |
+
"interval": 80,
|
| 42 |
+
"frames": "⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁",
|
| 43 |
+
},
|
| 44 |
+
"dots7": {
|
| 45 |
+
"interval": 80,
|
| 46 |
+
"frames": "⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈",
|
| 47 |
+
},
|
| 48 |
+
"dots8": {
|
| 49 |
+
"interval": 80,
|
| 50 |
+
"frames": "⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈",
|
| 51 |
+
},
|
| 52 |
+
"dots9": {"interval": 80, "frames": "⢹⢺⢼⣸⣇⡧⡗⡏"},
|
| 53 |
+
"dots10": {"interval": 80, "frames": "⢄⢂⢁⡁⡈⡐⡠"},
|
| 54 |
+
"dots11": {"interval": 100, "frames": "⠁⠂⠄⡀⢀⠠⠐⠈"},
|
| 55 |
+
"dots12": {
|
| 56 |
+
"interval": 80,
|
| 57 |
+
"frames": [
|
| 58 |
+
"⢀⠀",
|
| 59 |
+
"⡀⠀",
|
| 60 |
+
"⠄⠀",
|
| 61 |
+
"⢂⠀",
|
| 62 |
+
"⡂⠀",
|
| 63 |
+
"⠅⠀",
|
| 64 |
+
"⢃⠀",
|
| 65 |
+
"⡃⠀",
|
| 66 |
+
"⠍⠀",
|
| 67 |
+
"⢋⠀",
|
| 68 |
+
"⡋⠀",
|
| 69 |
+
"⠍⠁",
|
| 70 |
+
"⢋⠁",
|
| 71 |
+
"⡋⠁",
|
| 72 |
+
"⠍⠉",
|
| 73 |
+
"⠋⠉",
|
| 74 |
+
"⠋⠉",
|
| 75 |
+
"⠉⠙",
|
| 76 |
+
"⠉⠙",
|
| 77 |
+
"⠉⠩",
|
| 78 |
+
"⠈⢙",
|
| 79 |
+
"⠈⡙",
|
| 80 |
+
"⢈⠩",
|
| 81 |
+
"⡀⢙",
|
| 82 |
+
"⠄⡙",
|
| 83 |
+
"⢂⠩",
|
| 84 |
+
"⡂⢘",
|
| 85 |
+
"⠅⡘",
|
| 86 |
+
"⢃⠨",
|
| 87 |
+
"⡃⢐",
|
| 88 |
+
"⠍⡐",
|
| 89 |
+
"⢋⠠",
|
| 90 |
+
"⡋⢀",
|
| 91 |
+
"⠍⡁",
|
| 92 |
+
"⢋⠁",
|
| 93 |
+
"⡋⠁",
|
| 94 |
+
"⠍⠉",
|
| 95 |
+
"⠋⠉",
|
| 96 |
+
"⠋⠉",
|
| 97 |
+
"⠉⠙",
|
| 98 |
+
"⠉⠙",
|
| 99 |
+
"⠉⠩",
|
| 100 |
+
"⠈⢙",
|
| 101 |
+
"⠈⡙",
|
| 102 |
+
"⠈⠩",
|
| 103 |
+
"⠀⢙",
|
| 104 |
+
"⠀⡙",
|
| 105 |
+
"⠀⠩",
|
| 106 |
+
"⠀⢘",
|
| 107 |
+
"⠀⡘",
|
| 108 |
+
"⠀⠨",
|
| 109 |
+
"⠀⢐",
|
| 110 |
+
"⠀⡐",
|
| 111 |
+
"⠀⠠",
|
| 112 |
+
"⠀⢀",
|
| 113 |
+
"⠀⡀",
|
| 114 |
+
],
|
| 115 |
+
},
|
| 116 |
+
"dots8Bit": {
|
| 117 |
+
"interval": 80,
|
| 118 |
+
"frames": "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙"
|
| 119 |
+
"⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻"
|
| 120 |
+
"⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕"
|
| 121 |
+
"⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷"
|
| 122 |
+
"⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿",
|
| 123 |
+
},
|
| 124 |
+
"line": {"interval": 130, "frames": ["-", "\\", "|", "/"]},
|
| 125 |
+
"line2": {"interval": 100, "frames": "⠂-–—–-"},
|
| 126 |
+
"pipe": {"interval": 100, "frames": "┤┘┴└├┌┬┐"},
|
| 127 |
+
"simpleDots": {"interval": 400, "frames": [". ", ".. ", "...", " "]},
|
| 128 |
+
"simpleDotsScrolling": {
|
| 129 |
+
"interval": 200,
|
| 130 |
+
"frames": [". ", ".. ", "...", " ..", " .", " "],
|
| 131 |
+
},
|
| 132 |
+
"star": {"interval": 70, "frames": "✶✸✹✺✹✷"},
|
| 133 |
+
"star2": {"interval": 80, "frames": "+x*"},
|
| 134 |
+
"flip": {
|
| 135 |
+
"interval": 70,
|
| 136 |
+
"frames": "___-``'´-___",
|
| 137 |
+
},
|
| 138 |
+
"hamburger": {"interval": 100, "frames": "☱☲☴"},
|
| 139 |
+
"growVertical": {
|
| 140 |
+
"interval": 120,
|
| 141 |
+
"frames": "▁▃▄▅▆▇▆▅▄▃",
|
| 142 |
+
},
|
| 143 |
+
"growHorizontal": {
|
| 144 |
+
"interval": 120,
|
| 145 |
+
"frames": "▏▎▍▌▋▊▉▊▋▌▍▎",
|
| 146 |
+
},
|
| 147 |
+
"balloon": {"interval": 140, "frames": " .oO@* "},
|
| 148 |
+
"balloon2": {"interval": 120, "frames": ".oO°Oo."},
|
| 149 |
+
"noise": {"interval": 100, "frames": "▓▒░"},
|
| 150 |
+
"bounce": {"interval": 120, "frames": "⠁⠂⠄⠂"},
|
| 151 |
+
"boxBounce": {"interval": 120, "frames": "▖▘▝▗"},
|
| 152 |
+
"boxBounce2": {"interval": 100, "frames": "▌▀▐▄"},
|
| 153 |
+
"triangle": {"interval": 50, "frames": "◢◣◤◥"},
|
| 154 |
+
"arc": {"interval": 100, "frames": "◜◠◝◞◡◟"},
|
| 155 |
+
"circle": {"interval": 120, "frames": "◡⊙◠"},
|
| 156 |
+
"squareCorners": {"interval": 180, "frames": "◰◳◲◱"},
|
| 157 |
+
"circleQuarters": {"interval": 120, "frames": "◴◷◶◵"},
|
| 158 |
+
"circleHalves": {"interval": 50, "frames": "◐◓◑◒"},
|
| 159 |
+
"squish": {"interval": 100, "frames": "╫╪"},
|
| 160 |
+
"toggle": {"interval": 250, "frames": "⊶⊷"},
|
| 161 |
+
"toggle2": {"interval": 80, "frames": "▫▪"},
|
| 162 |
+
"toggle3": {"interval": 120, "frames": "□■"},
|
| 163 |
+
"toggle4": {"interval": 100, "frames": "■□▪▫"},
|
| 164 |
+
"toggle5": {"interval": 100, "frames": "▮▯"},
|
| 165 |
+
"toggle6": {"interval": 300, "frames": "ဝ၀"},
|
| 166 |
+
"toggle7": {"interval": 80, "frames": "⦾⦿"},
|
| 167 |
+
"toggle8": {"interval": 100, "frames": "◍◌"},
|
| 168 |
+
"toggle9": {"interval": 100, "frames": "◉◎"},
|
| 169 |
+
"toggle10": {"interval": 100, "frames": "㊂㊀㊁"},
|
| 170 |
+
"toggle11": {"interval": 50, "frames": "⧇⧆"},
|
| 171 |
+
"toggle12": {"interval": 120, "frames": "☗☖"},
|
| 172 |
+
"toggle13": {"interval": 80, "frames": "=*-"},
|
| 173 |
+
"arrow": {"interval": 100, "frames": "←↖↑↗→↘↓↙"},
|
| 174 |
+
"arrow2": {
|
| 175 |
+
"interval": 80,
|
| 176 |
+
"frames": ["⬆️ ", "↗️ ", "➡️ ", "↘️ ", "⬇️ ", "↙️ ", "⬅️ ", "↖️ "],
|
| 177 |
+
},
|
| 178 |
+
"arrow3": {
|
| 179 |
+
"interval": 120,
|
| 180 |
+
"frames": ["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"],
|
| 181 |
+
},
|
| 182 |
+
"bouncingBar": {
|
| 183 |
+
"interval": 80,
|
| 184 |
+
"frames": [
|
| 185 |
+
"[ ]",
|
| 186 |
+
"[= ]",
|
| 187 |
+
"[== ]",
|
| 188 |
+
"[=== ]",
|
| 189 |
+
"[ ===]",
|
| 190 |
+
"[ ==]",
|
| 191 |
+
"[ =]",
|
| 192 |
+
"[ ]",
|
| 193 |
+
"[ =]",
|
| 194 |
+
"[ ==]",
|
| 195 |
+
"[ ===]",
|
| 196 |
+
"[====]",
|
| 197 |
+
"[=== ]",
|
| 198 |
+
"[== ]",
|
| 199 |
+
"[= ]",
|
| 200 |
+
],
|
| 201 |
+
},
|
| 202 |
+
"bouncingBall": {
|
| 203 |
+
"interval": 80,
|
| 204 |
+
"frames": [
|
| 205 |
+
"( ● )",
|
| 206 |
+
"( ● )",
|
| 207 |
+
"( ● )",
|
| 208 |
+
"( ● )",
|
| 209 |
+
"( ●)",
|
| 210 |
+
"( ● )",
|
| 211 |
+
"( ● )",
|
| 212 |
+
"( ● )",
|
| 213 |
+
"( ● )",
|
| 214 |
+
"(● )",
|
| 215 |
+
],
|
| 216 |
+
},
|
| 217 |
+
"smiley": {"interval": 200, "frames": ["😄 ", "😝 "]},
|
| 218 |
+
"monkey": {"interval": 300, "frames": ["🙈 ", "🙈 ", "🙉 ", "🙊 "]},
|
| 219 |
+
"hearts": {"interval": 100, "frames": ["💛 ", "💙 ", "💜 ", "💚 ", "❤️ "]},
|
| 220 |
+
"clock": {
|
| 221 |
+
"interval": 100,
|
| 222 |
+
"frames": [
|
| 223 |
+
"🕛 ",
|
| 224 |
+
"🕐 ",
|
| 225 |
+
"🕑 ",
|
| 226 |
+
"🕒 ",
|
| 227 |
+
"🕓 ",
|
| 228 |
+
"🕔 ",
|
| 229 |
+
"🕕 ",
|
| 230 |
+
"🕖 ",
|
| 231 |
+
"🕗 ",
|
| 232 |
+
"🕘 ",
|
| 233 |
+
"🕙 ",
|
| 234 |
+
"🕚 ",
|
| 235 |
+
],
|
| 236 |
+
},
|
| 237 |
+
"earth": {"interval": 180, "frames": ["🌍 ", "🌎 ", "🌏 "]},
|
| 238 |
+
"material": {
|
| 239 |
+
"interval": 17,
|
| 240 |
+
"frames": [
|
| 241 |
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 242 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 243 |
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 244 |
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 245 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 246 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 247 |
+
"███████▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 248 |
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 249 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 250 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 251 |
+
"██████████▁▁▁▁▁▁▁▁▁▁",
|
| 252 |
+
"███████████▁▁▁▁▁▁▁▁▁",
|
| 253 |
+
"█████████████▁▁▁▁▁▁▁",
|
| 254 |
+
"██████████████▁▁▁▁▁▁",
|
| 255 |
+
"██████████████▁▁▁▁▁▁",
|
| 256 |
+
"▁██████████████▁▁▁▁▁",
|
| 257 |
+
"▁██████████████▁▁▁▁▁",
|
| 258 |
+
"▁██████████████▁▁▁▁▁",
|
| 259 |
+
"▁▁██████████████▁▁▁▁",
|
| 260 |
+
"▁▁▁██████████████▁▁▁",
|
| 261 |
+
"▁▁▁▁█████████████▁▁▁",
|
| 262 |
+
"▁▁▁▁██████████████▁▁",
|
| 263 |
+
"▁▁▁▁██████████████▁▁",
|
| 264 |
+
"▁▁▁▁▁██████████████▁",
|
| 265 |
+
"▁▁▁▁▁██████████████▁",
|
| 266 |
+
"▁▁▁▁▁██████████████▁",
|
| 267 |
+
"▁▁▁▁▁▁██████████████",
|
| 268 |
+
"▁▁▁▁▁▁██████████████",
|
| 269 |
+
"▁▁▁▁▁▁▁█████████████",
|
| 270 |
+
"▁▁▁▁▁▁▁█████████████",
|
| 271 |
+
"▁▁▁▁▁▁▁▁████████████",
|
| 272 |
+
"▁▁▁▁▁▁▁▁████████████",
|
| 273 |
+
"▁▁▁▁▁▁▁▁▁███████████",
|
| 274 |
+
"▁▁▁▁▁▁▁▁▁███████████",
|
| 275 |
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
| 276 |
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
| 277 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁████████",
|
| 278 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 279 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████",
|
| 280 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 281 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 282 |
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 283 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 284 |
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 285 |
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 286 |
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 287 |
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 288 |
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 289 |
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 290 |
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 291 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 292 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 293 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 294 |
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
| 295 |
+
"███████████▁▁▁▁▁▁▁▁▁",
|
| 296 |
+
"████████████▁▁▁▁▁▁▁▁",
|
| 297 |
+
"████████████▁▁▁▁▁▁▁▁",
|
| 298 |
+
"██████████████▁▁▁▁▁▁",
|
| 299 |
+
"██████████████▁▁▁▁▁▁",
|
| 300 |
+
"▁██████████████▁▁▁▁▁",
|
| 301 |
+
"▁██████████████▁▁▁▁▁",
|
| 302 |
+
"▁▁▁█████████████▁▁▁▁",
|
| 303 |
+
"▁▁▁▁▁████████████▁▁▁",
|
| 304 |
+
"▁▁▁▁▁████████████▁▁▁",
|
| 305 |
+
"▁▁▁▁▁▁███████████▁▁▁",
|
| 306 |
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
| 307 |
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
| 308 |
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
| 309 |
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
| 310 |
+
"▁▁▁▁▁▁▁▁▁▁█████████▁",
|
| 311 |
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
| 312 |
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
| 313 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
| 314 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
| 315 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 316 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
| 317 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
| 318 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 319 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 320 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
| 321 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 322 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
| 323 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 324 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 325 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
| 326 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 327 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 328 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
| 329 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 330 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 331 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 332 |
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
| 333 |
+
],
|
| 334 |
+
},
|
| 335 |
+
"moon": {
|
| 336 |
+
"interval": 80,
|
| 337 |
+
"frames": ["🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "],
|
| 338 |
+
},
|
| 339 |
+
"runner": {"interval": 140, "frames": ["🚶 ", "🏃 "]},
|
| 340 |
+
"pong": {
|
| 341 |
+
"interval": 80,
|
| 342 |
+
"frames": [
|
| 343 |
+
"▐⠂ ▌",
|
| 344 |
+
"▐⠈ ▌",
|
| 345 |
+
"▐ ⠂ ▌",
|
| 346 |
+
"▐ ⠠ ▌",
|
| 347 |
+
"▐ ⡀ ▌",
|
| 348 |
+
"▐ ⠠ ▌",
|
| 349 |
+
"▐ ⠂ ▌",
|
| 350 |
+
"▐ ⠈ ▌",
|
| 351 |
+
"▐ ⠂ ▌",
|
| 352 |
+
"▐ ⠠ ▌",
|
| 353 |
+
"▐ ⡀ ▌",
|
| 354 |
+
"▐ ⠠ ▌",
|
| 355 |
+
"▐ ⠂ ▌",
|
| 356 |
+
"▐ ⠈ ▌",
|
| 357 |
+
"▐ ⠂▌",
|
| 358 |
+
"▐ ⠠▌",
|
| 359 |
+
"▐ ⡀▌",
|
| 360 |
+
"▐ ⠠ ▌",
|
| 361 |
+
"▐ ⠂ ▌",
|
| 362 |
+
"▐ ⠈ ▌",
|
| 363 |
+
"▐ ⠂ ▌",
|
| 364 |
+
"▐ ⠠ ▌",
|
| 365 |
+
"▐ ⡀ ▌",
|
| 366 |
+
"▐ ⠠ ▌",
|
| 367 |
+
"▐ ⠂ ▌",
|
| 368 |
+
"▐ ⠈ ▌",
|
| 369 |
+
"▐ ⠂ ▌",
|
| 370 |
+
"▐ ⠠ ▌",
|
| 371 |
+
"▐ ⡀ ▌",
|
| 372 |
+
"▐⠠ ▌",
|
| 373 |
+
],
|
| 374 |
+
},
|
| 375 |
+
"shark": {
|
| 376 |
+
"interval": 120,
|
| 377 |
+
"frames": [
|
| 378 |
+
"▐|\\____________▌",
|
| 379 |
+
"▐_|\\___________▌",
|
| 380 |
+
"▐__|\\__________▌",
|
| 381 |
+
"▐___|\\_________▌",
|
| 382 |
+
"▐____|\\________▌",
|
| 383 |
+
"▐_____|\\_______▌",
|
| 384 |
+
"▐______|\\______▌",
|
| 385 |
+
"▐_______|\\_____▌",
|
| 386 |
+
"▐________|\\____▌",
|
| 387 |
+
"▐_________|\\___▌",
|
| 388 |
+
"▐__________|\\__▌",
|
| 389 |
+
"▐___________|\\_▌",
|
| 390 |
+
"▐____________|\\▌",
|
| 391 |
+
"▐____________/|▌",
|
| 392 |
+
"▐___________/|_▌",
|
| 393 |
+
"▐__________/|__▌",
|
| 394 |
+
"▐_________/|___▌",
|
| 395 |
+
"▐________/|____▌",
|
| 396 |
+
"▐_______/|_____▌",
|
| 397 |
+
"▐______/|______▌",
|
| 398 |
+
"▐_____/|_______▌",
|
| 399 |
+
"▐____/|________▌",
|
| 400 |
+
"▐___/|_________▌",
|
| 401 |
+
"▐__/|__________▌",
|
| 402 |
+
"▐_/|___________▌",
|
| 403 |
+
"▐/|____________▌",
|
| 404 |
+
],
|
| 405 |
+
},
|
| 406 |
+
"dqpb": {"interval": 100, "frames": "dqpb"},
|
| 407 |
+
"weather": {
|
| 408 |
+
"interval": 100,
|
| 409 |
+
"frames": [
|
| 410 |
+
"☀️ ",
|
| 411 |
+
"☀️ ",
|
| 412 |
+
"☀️ ",
|
| 413 |
+
"🌤 ",
|
| 414 |
+
"⛅️ ",
|
| 415 |
+
"🌥 ",
|
| 416 |
+
"☁️ ",
|
| 417 |
+
"🌧 ",
|
| 418 |
+
"🌨 ",
|
| 419 |
+
"🌧 ",
|
| 420 |
+
"🌨 ",
|
| 421 |
+
"🌧 ",
|
| 422 |
+
"🌨 ",
|
| 423 |
+
"⛈ ",
|
| 424 |
+
"🌨 ",
|
| 425 |
+
"🌧 ",
|
| 426 |
+
"🌨 ",
|
| 427 |
+
"☁️ ",
|
| 428 |
+
"🌥 ",
|
| 429 |
+
"⛅️ ",
|
| 430 |
+
"🌤 ",
|
| 431 |
+
"☀️ ",
|
| 432 |
+
"☀️ ",
|
| 433 |
+
],
|
| 434 |
+
},
|
| 435 |
+
"christmas": {"interval": 400, "frames": "🌲🎄"},
|
| 436 |
+
"grenade": {
|
| 437 |
+
"interval": 80,
|
| 438 |
+
"frames": [
|
| 439 |
+
"، ",
|
| 440 |
+
"′ ",
|
| 441 |
+
" ´ ",
|
| 442 |
+
" ‾ ",
|
| 443 |
+
" ⸌",
|
| 444 |
+
" ⸊",
|
| 445 |
+
" |",
|
| 446 |
+
" ⁎",
|
| 447 |
+
" ⁕",
|
| 448 |
+
" ෴ ",
|
| 449 |
+
" ⁓",
|
| 450 |
+
" ",
|
| 451 |
+
" ",
|
| 452 |
+
" ",
|
| 453 |
+
],
|
| 454 |
+
},
|
| 455 |
+
"point": {"interval": 125, "frames": ["∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"]},
|
| 456 |
+
"layer": {"interval": 150, "frames": "-=≡"},
|
| 457 |
+
"betaWave": {
|
| 458 |
+
"interval": 80,
|
| 459 |
+
"frames": [
|
| 460 |
+
"ρββββββ",
|
| 461 |
+
"βρβββββ",
|
| 462 |
+
"ββρββββ",
|
| 463 |
+
"βββρβββ",
|
| 464 |
+
"ββββρββ",
|
| 465 |
+
"βββββρβ",
|
| 466 |
+
"ββββββρ",
|
| 467 |
+
],
|
| 468 |
+
},
|
| 469 |
+
"aesthetic": {
|
| 470 |
+
"interval": 80,
|
| 471 |
+
"frames": [
|
| 472 |
+
"▰▱▱▱▱▱▱",
|
| 473 |
+
"▰▰▱▱▱▱▱",
|
| 474 |
+
"▰▰▰▱▱▱▱",
|
| 475 |
+
"▰▰▰▰▱▱▱",
|
| 476 |
+
"▰▰▰▰▰▱▱",
|
| 477 |
+
"▰▰▰▰▰▰▱",
|
| 478 |
+
"▰▰▰▰▰▰▰",
|
| 479 |
+
"▰▱▱▱▱▱▱",
|
| 480 |
+
],
|
| 481 |
+
},
|
| 482 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_win32_console.py
ADDED
|
@@ -0,0 +1,662 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Light wrapper around the Win32 Console API - this module should only be imported on Windows
|
| 2 |
+
|
| 3 |
+
The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
|
| 4 |
+
"""
|
| 5 |
+
import ctypes
|
| 6 |
+
import sys
|
| 7 |
+
from typing import Any
|
| 8 |
+
|
| 9 |
+
windll: Any = None
|
| 10 |
+
if sys.platform == "win32":
|
| 11 |
+
windll = ctypes.LibraryLoader(ctypes.WinDLL)
|
| 12 |
+
else:
|
| 13 |
+
raise ImportError(f"{__name__} can only be imported on Windows")
|
| 14 |
+
|
| 15 |
+
import time
|
| 16 |
+
from ctypes import Structure, byref, wintypes
|
| 17 |
+
from typing import IO, NamedTuple, Type, cast
|
| 18 |
+
|
| 19 |
+
from pip._vendor.rich.color import ColorSystem
|
| 20 |
+
from pip._vendor.rich.style import Style
|
| 21 |
+
|
| 22 |
+
STDOUT = -11
|
| 23 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
|
| 24 |
+
|
| 25 |
+
COORD = wintypes._COORD
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class LegacyWindowsError(Exception):
|
| 29 |
+
pass
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class WindowsCoordinates(NamedTuple):
|
| 33 |
+
"""Coordinates in the Windows Console API are (y, x), not (x, y).
|
| 34 |
+
This class is intended to prevent that confusion.
|
| 35 |
+
Rows and columns are indexed from 0.
|
| 36 |
+
This class can be used in place of wintypes._COORD in arguments and argtypes.
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
row: int
|
| 40 |
+
col: int
|
| 41 |
+
|
| 42 |
+
@classmethod
|
| 43 |
+
def from_param(cls, value: "WindowsCoordinates") -> COORD:
|
| 44 |
+
"""Converts a WindowsCoordinates into a wintypes _COORD structure.
|
| 45 |
+
This classmethod is internally called by ctypes to perform the conversion.
|
| 46 |
+
|
| 47 |
+
Args:
|
| 48 |
+
value (WindowsCoordinates): The input coordinates to convert.
|
| 49 |
+
|
| 50 |
+
Returns:
|
| 51 |
+
wintypes._COORD: The converted coordinates struct.
|
| 52 |
+
"""
|
| 53 |
+
return COORD(value.col, value.row)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
| 57 |
+
_fields_ = [
|
| 58 |
+
("dwSize", COORD),
|
| 59 |
+
("dwCursorPosition", COORD),
|
| 60 |
+
("wAttributes", wintypes.WORD),
|
| 61 |
+
("srWindow", wintypes.SMALL_RECT),
|
| 62 |
+
("dwMaximumWindowSize", COORD),
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class CONSOLE_CURSOR_INFO(ctypes.Structure):
|
| 67 |
+
_fields_ = [("dwSize", wintypes.DWORD), ("bVisible", wintypes.BOOL)]
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
_GetStdHandle = windll.kernel32.GetStdHandle
|
| 71 |
+
_GetStdHandle.argtypes = [
|
| 72 |
+
wintypes.DWORD,
|
| 73 |
+
]
|
| 74 |
+
_GetStdHandle.restype = wintypes.HANDLE
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def GetStdHandle(handle: int = STDOUT) -> wintypes.HANDLE:
|
| 78 |
+
"""Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
|
| 79 |
+
|
| 80 |
+
Args:
|
| 81 |
+
handle (int): Integer identifier for the handle. Defaults to -11 (stdout).
|
| 82 |
+
|
| 83 |
+
Returns:
|
| 84 |
+
wintypes.HANDLE: The handle
|
| 85 |
+
"""
|
| 86 |
+
return cast(wintypes.HANDLE, _GetStdHandle(handle))
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
_GetConsoleMode = windll.kernel32.GetConsoleMode
|
| 90 |
+
_GetConsoleMode.argtypes = [wintypes.HANDLE, wintypes.LPDWORD]
|
| 91 |
+
_GetConsoleMode.restype = wintypes.BOOL
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def GetConsoleMode(std_handle: wintypes.HANDLE) -> int:
|
| 95 |
+
"""Retrieves the current input mode of a console's input buffer
|
| 96 |
+
or the current output mode of a console screen buffer.
|
| 97 |
+
|
| 98 |
+
Args:
|
| 99 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 100 |
+
|
| 101 |
+
Raises:
|
| 102 |
+
LegacyWindowsError: If any error occurs while calling the Windows console API.
|
| 103 |
+
|
| 104 |
+
Returns:
|
| 105 |
+
int: Value representing the current console mode as documented at
|
| 106 |
+
https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
console_mode = wintypes.DWORD()
|
| 110 |
+
success = bool(_GetConsoleMode(std_handle, console_mode))
|
| 111 |
+
if not success:
|
| 112 |
+
raise LegacyWindowsError("Unable to get legacy Windows Console Mode")
|
| 113 |
+
return console_mode.value
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
_FillConsoleOutputCharacterW = windll.kernel32.FillConsoleOutputCharacterW
|
| 117 |
+
_FillConsoleOutputCharacterW.argtypes = [
|
| 118 |
+
wintypes.HANDLE,
|
| 119 |
+
ctypes.c_char,
|
| 120 |
+
wintypes.DWORD,
|
| 121 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 122 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 123 |
+
]
|
| 124 |
+
_FillConsoleOutputCharacterW.restype = wintypes.BOOL
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def FillConsoleOutputCharacter(
|
| 128 |
+
std_handle: wintypes.HANDLE,
|
| 129 |
+
char: str,
|
| 130 |
+
length: int,
|
| 131 |
+
start: WindowsCoordinates,
|
| 132 |
+
) -> int:
|
| 133 |
+
"""Writes a character to the console screen buffer a specified number of times, beginning at the specified coordinates.
|
| 134 |
+
|
| 135 |
+
Args:
|
| 136 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 137 |
+
char (str): The character to write. Must be a string of length 1.
|
| 138 |
+
length (int): The number of times to write the character.
|
| 139 |
+
start (WindowsCoordinates): The coordinates to start writing at.
|
| 140 |
+
|
| 141 |
+
Returns:
|
| 142 |
+
int: The number of characters written.
|
| 143 |
+
"""
|
| 144 |
+
character = ctypes.c_char(char.encode())
|
| 145 |
+
num_characters = wintypes.DWORD(length)
|
| 146 |
+
num_written = wintypes.DWORD(0)
|
| 147 |
+
_FillConsoleOutputCharacterW(
|
| 148 |
+
std_handle,
|
| 149 |
+
character,
|
| 150 |
+
num_characters,
|
| 151 |
+
start,
|
| 152 |
+
byref(num_written),
|
| 153 |
+
)
|
| 154 |
+
return num_written.value
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
|
| 158 |
+
_FillConsoleOutputAttribute.argtypes = [
|
| 159 |
+
wintypes.HANDLE,
|
| 160 |
+
wintypes.WORD,
|
| 161 |
+
wintypes.DWORD,
|
| 162 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 163 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 164 |
+
]
|
| 165 |
+
_FillConsoleOutputAttribute.restype = wintypes.BOOL
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def FillConsoleOutputAttribute(
|
| 169 |
+
std_handle: wintypes.HANDLE,
|
| 170 |
+
attributes: int,
|
| 171 |
+
length: int,
|
| 172 |
+
start: WindowsCoordinates,
|
| 173 |
+
) -> int:
|
| 174 |
+
"""Sets the character attributes for a specified number of character cells,
|
| 175 |
+
beginning at the specified coordinates in a screen buffer.
|
| 176 |
+
|
| 177 |
+
Args:
|
| 178 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 179 |
+
attributes (int): Integer value representing the foreground and background colours of the cells.
|
| 180 |
+
length (int): The number of cells to set the output attribute of.
|
| 181 |
+
start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set.
|
| 182 |
+
|
| 183 |
+
Returns:
|
| 184 |
+
int: The number of cells whose attributes were actually set.
|
| 185 |
+
"""
|
| 186 |
+
num_cells = wintypes.DWORD(length)
|
| 187 |
+
style_attrs = wintypes.WORD(attributes)
|
| 188 |
+
num_written = wintypes.DWORD(0)
|
| 189 |
+
_FillConsoleOutputAttribute(
|
| 190 |
+
std_handle, style_attrs, num_cells, start, byref(num_written)
|
| 191 |
+
)
|
| 192 |
+
return num_written.value
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
|
| 196 |
+
_SetConsoleTextAttribute.argtypes = [
|
| 197 |
+
wintypes.HANDLE,
|
| 198 |
+
wintypes.WORD,
|
| 199 |
+
]
|
| 200 |
+
_SetConsoleTextAttribute.restype = wintypes.BOOL
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def SetConsoleTextAttribute(
|
| 204 |
+
std_handle: wintypes.HANDLE, attributes: wintypes.WORD
|
| 205 |
+
) -> bool:
|
| 206 |
+
"""Set the colour attributes for all text written after this function is called.
|
| 207 |
+
|
| 208 |
+
Args:
|
| 209 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 210 |
+
attributes (int): Integer value representing the foreground and background colours.
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
Returns:
|
| 214 |
+
bool: True if the attribute was set successfully, otherwise False.
|
| 215 |
+
"""
|
| 216 |
+
return bool(_SetConsoleTextAttribute(std_handle, attributes))
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
|
| 220 |
+
_GetConsoleScreenBufferInfo.argtypes = [
|
| 221 |
+
wintypes.HANDLE,
|
| 222 |
+
ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO),
|
| 223 |
+
]
|
| 224 |
+
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def GetConsoleScreenBufferInfo(
|
| 228 |
+
std_handle: wintypes.HANDLE,
|
| 229 |
+
) -> CONSOLE_SCREEN_BUFFER_INFO:
|
| 230 |
+
"""Retrieves information about the specified console screen buffer.
|
| 231 |
+
|
| 232 |
+
Args:
|
| 233 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 234 |
+
|
| 235 |
+
Returns:
|
| 236 |
+
CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about
|
| 237 |
+
screen size, cursor position, colour attributes, and more."""
|
| 238 |
+
console_screen_buffer_info = CONSOLE_SCREEN_BUFFER_INFO()
|
| 239 |
+
_GetConsoleScreenBufferInfo(std_handle, byref(console_screen_buffer_info))
|
| 240 |
+
return console_screen_buffer_info
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
|
| 244 |
+
_SetConsoleCursorPosition.argtypes = [
|
| 245 |
+
wintypes.HANDLE,
|
| 246 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 247 |
+
]
|
| 248 |
+
_SetConsoleCursorPosition.restype = wintypes.BOOL
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def SetConsoleCursorPosition(
|
| 252 |
+
std_handle: wintypes.HANDLE, coords: WindowsCoordinates
|
| 253 |
+
) -> bool:
|
| 254 |
+
"""Set the position of the cursor in the console screen
|
| 255 |
+
|
| 256 |
+
Args:
|
| 257 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 258 |
+
coords (WindowsCoordinates): The coordinates to move the cursor to.
|
| 259 |
+
|
| 260 |
+
Returns:
|
| 261 |
+
bool: True if the function succeeds, otherwise False.
|
| 262 |
+
"""
|
| 263 |
+
return bool(_SetConsoleCursorPosition(std_handle, coords))
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
_GetConsoleCursorInfo = windll.kernel32.GetConsoleCursorInfo
|
| 267 |
+
_GetConsoleCursorInfo.argtypes = [
|
| 268 |
+
wintypes.HANDLE,
|
| 269 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 270 |
+
]
|
| 271 |
+
_GetConsoleCursorInfo.restype = wintypes.BOOL
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
def GetConsoleCursorInfo(
|
| 275 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 276 |
+
) -> bool:
|
| 277 |
+
"""Get the cursor info - used to get cursor visibility and width
|
| 278 |
+
|
| 279 |
+
Args:
|
| 280 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 281 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information
|
| 282 |
+
about the console's cursor.
|
| 283 |
+
|
| 284 |
+
Returns:
|
| 285 |
+
bool: True if the function succeeds, otherwise False.
|
| 286 |
+
"""
|
| 287 |
+
return bool(_GetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
_SetConsoleCursorInfo = windll.kernel32.SetConsoleCursorInfo
|
| 291 |
+
_SetConsoleCursorInfo.argtypes = [
|
| 292 |
+
wintypes.HANDLE,
|
| 293 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 294 |
+
]
|
| 295 |
+
_SetConsoleCursorInfo.restype = wintypes.BOOL
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def SetConsoleCursorInfo(
|
| 299 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 300 |
+
) -> bool:
|
| 301 |
+
"""Set the cursor info - used for adjusting cursor visibility and width
|
| 302 |
+
|
| 303 |
+
Args:
|
| 304 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 305 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info.
|
| 306 |
+
|
| 307 |
+
Returns:
|
| 308 |
+
bool: True if the function succeeds, otherwise False.
|
| 309 |
+
"""
|
| 310 |
+
return bool(_SetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
_SetConsoleTitle = windll.kernel32.SetConsoleTitleW
|
| 314 |
+
_SetConsoleTitle.argtypes = [wintypes.LPCWSTR]
|
| 315 |
+
_SetConsoleTitle.restype = wintypes.BOOL
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
def SetConsoleTitle(title: str) -> bool:
|
| 319 |
+
"""Sets the title of the current console window
|
| 320 |
+
|
| 321 |
+
Args:
|
| 322 |
+
title (str): The new title of the console window.
|
| 323 |
+
|
| 324 |
+
Returns:
|
| 325 |
+
bool: True if the function succeeds, otherwise False.
|
| 326 |
+
"""
|
| 327 |
+
return bool(_SetConsoleTitle(title))
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
class LegacyWindowsTerm:
|
| 331 |
+
"""This class allows interaction with the legacy Windows Console API. It should only be used in the context
|
| 332 |
+
of environments where virtual terminal processing is not available. However, if it is used in a Windows environment,
|
| 333 |
+
the entire API should work.
|
| 334 |
+
|
| 335 |
+
Args:
|
| 336 |
+
file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout.
|
| 337 |
+
"""
|
| 338 |
+
|
| 339 |
+
BRIGHT_BIT = 8
|
| 340 |
+
|
| 341 |
+
# Indices are ANSI color numbers, values are the corresponding Windows Console API color numbers
|
| 342 |
+
ANSI_TO_WINDOWS = [
|
| 343 |
+
0, # black The Windows colours are defined in wincon.h as follows:
|
| 344 |
+
4, # red define FOREGROUND_BLUE 0x0001 -- 0000 0001
|
| 345 |
+
2, # green define FOREGROUND_GREEN 0x0002 -- 0000 0010
|
| 346 |
+
6, # yellow define FOREGROUND_RED 0x0004 -- 0000 0100
|
| 347 |
+
1, # blue define FOREGROUND_INTENSITY 0x0008 -- 0000 1000
|
| 348 |
+
5, # magenta define BACKGROUND_BLUE 0x0010 -- 0001 0000
|
| 349 |
+
3, # cyan define BACKGROUND_GREEN 0x0020 -- 0010 0000
|
| 350 |
+
7, # white define BACKGROUND_RED 0x0040 -- 0100 0000
|
| 351 |
+
8, # bright black (grey) define BACKGROUND_INTENSITY 0x0080 -- 1000 0000
|
| 352 |
+
12, # bright red
|
| 353 |
+
10, # bright green
|
| 354 |
+
14, # bright yellow
|
| 355 |
+
9, # bright blue
|
| 356 |
+
13, # bright magenta
|
| 357 |
+
11, # bright cyan
|
| 358 |
+
15, # bright white
|
| 359 |
+
]
|
| 360 |
+
|
| 361 |
+
def __init__(self, file: "IO[str]") -> None:
|
| 362 |
+
handle = GetStdHandle(STDOUT)
|
| 363 |
+
self._handle = handle
|
| 364 |
+
default_text = GetConsoleScreenBufferInfo(handle).wAttributes
|
| 365 |
+
self._default_text = default_text
|
| 366 |
+
|
| 367 |
+
self._default_fore = default_text & 7
|
| 368 |
+
self._default_back = (default_text >> 4) & 7
|
| 369 |
+
self._default_attrs = self._default_fore | (self._default_back << 4)
|
| 370 |
+
|
| 371 |
+
self._file = file
|
| 372 |
+
self.write = file.write
|
| 373 |
+
self.flush = file.flush
|
| 374 |
+
|
| 375 |
+
@property
|
| 376 |
+
def cursor_position(self) -> WindowsCoordinates:
|
| 377 |
+
"""Returns the current position of the cursor (0-based)
|
| 378 |
+
|
| 379 |
+
Returns:
|
| 380 |
+
WindowsCoordinates: The current cursor position.
|
| 381 |
+
"""
|
| 382 |
+
coord: COORD = GetConsoleScreenBufferInfo(self._handle).dwCursorPosition
|
| 383 |
+
return WindowsCoordinates(row=cast(int, coord.Y), col=cast(int, coord.X))
|
| 384 |
+
|
| 385 |
+
@property
|
| 386 |
+
def screen_size(self) -> WindowsCoordinates:
|
| 387 |
+
"""Returns the current size of the console screen buffer, in character columns and rows
|
| 388 |
+
|
| 389 |
+
Returns:
|
| 390 |
+
WindowsCoordinates: The width and height of the screen as WindowsCoordinates.
|
| 391 |
+
"""
|
| 392 |
+
screen_size: COORD = GetConsoleScreenBufferInfo(self._handle).dwSize
|
| 393 |
+
return WindowsCoordinates(
|
| 394 |
+
row=cast(int, screen_size.Y), col=cast(int, screen_size.X)
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
def write_text(self, text: str) -> None:
|
| 398 |
+
"""Write text directly to the terminal without any modification of styles
|
| 399 |
+
|
| 400 |
+
Args:
|
| 401 |
+
text (str): The text to write to the console
|
| 402 |
+
"""
|
| 403 |
+
self.write(text)
|
| 404 |
+
self.flush()
|
| 405 |
+
|
| 406 |
+
def write_styled(self, text: str, style: Style) -> None:
|
| 407 |
+
"""Write styled text to the terminal.
|
| 408 |
+
|
| 409 |
+
Args:
|
| 410 |
+
text (str): The text to write
|
| 411 |
+
style (Style): The style of the text
|
| 412 |
+
"""
|
| 413 |
+
color = style.color
|
| 414 |
+
bgcolor = style.bgcolor
|
| 415 |
+
if style.reverse:
|
| 416 |
+
color, bgcolor = bgcolor, color
|
| 417 |
+
|
| 418 |
+
if color:
|
| 419 |
+
fore = color.downgrade(ColorSystem.WINDOWS).number
|
| 420 |
+
fore = fore if fore is not None else 7 # Default to ANSI 7: White
|
| 421 |
+
if style.bold:
|
| 422 |
+
fore = fore | self.BRIGHT_BIT
|
| 423 |
+
if style.dim:
|
| 424 |
+
fore = fore & ~self.BRIGHT_BIT
|
| 425 |
+
fore = self.ANSI_TO_WINDOWS[fore]
|
| 426 |
+
else:
|
| 427 |
+
fore = self._default_fore
|
| 428 |
+
|
| 429 |
+
if bgcolor:
|
| 430 |
+
back = bgcolor.downgrade(ColorSystem.WINDOWS).number
|
| 431 |
+
back = back if back is not None else 0 # Default to ANSI 0: Black
|
| 432 |
+
back = self.ANSI_TO_WINDOWS[back]
|
| 433 |
+
else:
|
| 434 |
+
back = self._default_back
|
| 435 |
+
|
| 436 |
+
assert fore is not None
|
| 437 |
+
assert back is not None
|
| 438 |
+
|
| 439 |
+
SetConsoleTextAttribute(
|
| 440 |
+
self._handle, attributes=ctypes.c_ushort(fore | (back << 4))
|
| 441 |
+
)
|
| 442 |
+
self.write_text(text)
|
| 443 |
+
SetConsoleTextAttribute(self._handle, attributes=self._default_text)
|
| 444 |
+
|
| 445 |
+
def move_cursor_to(self, new_position: WindowsCoordinates) -> None:
|
| 446 |
+
"""Set the position of the cursor
|
| 447 |
+
|
| 448 |
+
Args:
|
| 449 |
+
new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor.
|
| 450 |
+
"""
|
| 451 |
+
if new_position.col < 0 or new_position.row < 0:
|
| 452 |
+
return
|
| 453 |
+
SetConsoleCursorPosition(self._handle, coords=new_position)
|
| 454 |
+
|
| 455 |
+
def erase_line(self) -> None:
|
| 456 |
+
"""Erase all content on the line the cursor is currently located at"""
|
| 457 |
+
screen_size = self.screen_size
|
| 458 |
+
cursor_position = self.cursor_position
|
| 459 |
+
cells_to_erase = screen_size.col
|
| 460 |
+
start_coordinates = WindowsCoordinates(row=cursor_position.row, col=0)
|
| 461 |
+
FillConsoleOutputCharacter(
|
| 462 |
+
self._handle, " ", length=cells_to_erase, start=start_coordinates
|
| 463 |
+
)
|
| 464 |
+
FillConsoleOutputAttribute(
|
| 465 |
+
self._handle,
|
| 466 |
+
self._default_attrs,
|
| 467 |
+
length=cells_to_erase,
|
| 468 |
+
start=start_coordinates,
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
def erase_end_of_line(self) -> None:
|
| 472 |
+
"""Erase all content from the cursor position to the end of that line"""
|
| 473 |
+
cursor_position = self.cursor_position
|
| 474 |
+
cells_to_erase = self.screen_size.col - cursor_position.col
|
| 475 |
+
FillConsoleOutputCharacter(
|
| 476 |
+
self._handle, " ", length=cells_to_erase, start=cursor_position
|
| 477 |
+
)
|
| 478 |
+
FillConsoleOutputAttribute(
|
| 479 |
+
self._handle,
|
| 480 |
+
self._default_attrs,
|
| 481 |
+
length=cells_to_erase,
|
| 482 |
+
start=cursor_position,
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
def erase_start_of_line(self) -> None:
|
| 486 |
+
"""Erase all content from the cursor position to the start of that line"""
|
| 487 |
+
row, col = self.cursor_position
|
| 488 |
+
start = WindowsCoordinates(row, 0)
|
| 489 |
+
FillConsoleOutputCharacter(self._handle, " ", length=col, start=start)
|
| 490 |
+
FillConsoleOutputAttribute(
|
| 491 |
+
self._handle, self._default_attrs, length=col, start=start
|
| 492 |
+
)
|
| 493 |
+
|
| 494 |
+
def move_cursor_up(self) -> None:
|
| 495 |
+
"""Move the cursor up a single cell"""
|
| 496 |
+
cursor_position = self.cursor_position
|
| 497 |
+
SetConsoleCursorPosition(
|
| 498 |
+
self._handle,
|
| 499 |
+
coords=WindowsCoordinates(
|
| 500 |
+
row=cursor_position.row - 1, col=cursor_position.col
|
| 501 |
+
),
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
def move_cursor_down(self) -> None:
|
| 505 |
+
"""Move the cursor down a single cell"""
|
| 506 |
+
cursor_position = self.cursor_position
|
| 507 |
+
SetConsoleCursorPosition(
|
| 508 |
+
self._handle,
|
| 509 |
+
coords=WindowsCoordinates(
|
| 510 |
+
row=cursor_position.row + 1,
|
| 511 |
+
col=cursor_position.col,
|
| 512 |
+
),
|
| 513 |
+
)
|
| 514 |
+
|
| 515 |
+
def move_cursor_forward(self) -> None:
|
| 516 |
+
"""Move the cursor forward a single cell. Wrap to the next line if required."""
|
| 517 |
+
row, col = self.cursor_position
|
| 518 |
+
if col == self.screen_size.col - 1:
|
| 519 |
+
row += 1
|
| 520 |
+
col = 0
|
| 521 |
+
else:
|
| 522 |
+
col += 1
|
| 523 |
+
SetConsoleCursorPosition(
|
| 524 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 525 |
+
)
|
| 526 |
+
|
| 527 |
+
def move_cursor_to_column(self, column: int) -> None:
|
| 528 |
+
"""Move cursor to the column specified by the zero-based column index, staying on the same row
|
| 529 |
+
|
| 530 |
+
Args:
|
| 531 |
+
column (int): The zero-based column index to move the cursor to.
|
| 532 |
+
"""
|
| 533 |
+
row, _ = self.cursor_position
|
| 534 |
+
SetConsoleCursorPosition(self._handle, coords=WindowsCoordinates(row, column))
|
| 535 |
+
|
| 536 |
+
def move_cursor_backward(self) -> None:
|
| 537 |
+
"""Move the cursor backward a single cell. Wrap to the previous line if required."""
|
| 538 |
+
row, col = self.cursor_position
|
| 539 |
+
if col == 0:
|
| 540 |
+
row -= 1
|
| 541 |
+
col = self.screen_size.col - 1
|
| 542 |
+
else:
|
| 543 |
+
col -= 1
|
| 544 |
+
SetConsoleCursorPosition(
|
| 545 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 546 |
+
)
|
| 547 |
+
|
| 548 |
+
def hide_cursor(self) -> None:
|
| 549 |
+
"""Hide the cursor"""
|
| 550 |
+
current_cursor_size = self._get_cursor_size()
|
| 551 |
+
invisible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=0)
|
| 552 |
+
SetConsoleCursorInfo(self._handle, cursor_info=invisible_cursor)
|
| 553 |
+
|
| 554 |
+
def show_cursor(self) -> None:
|
| 555 |
+
"""Show the cursor"""
|
| 556 |
+
current_cursor_size = self._get_cursor_size()
|
| 557 |
+
visible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=1)
|
| 558 |
+
SetConsoleCursorInfo(self._handle, cursor_info=visible_cursor)
|
| 559 |
+
|
| 560 |
+
def set_title(self, title: str) -> None:
|
| 561 |
+
"""Set the title of the terminal window
|
| 562 |
+
|
| 563 |
+
Args:
|
| 564 |
+
title (str): The new title of the console window
|
| 565 |
+
"""
|
| 566 |
+
assert len(title) < 255, "Console title must be less than 255 characters"
|
| 567 |
+
SetConsoleTitle(title)
|
| 568 |
+
|
| 569 |
+
def _get_cursor_size(self) -> int:
|
| 570 |
+
"""Get the percentage of the character cell that is filled by the cursor"""
|
| 571 |
+
cursor_info = CONSOLE_CURSOR_INFO()
|
| 572 |
+
GetConsoleCursorInfo(self._handle, cursor_info=cursor_info)
|
| 573 |
+
return int(cursor_info.dwSize)
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+
if __name__ == "__main__":
|
| 577 |
+
handle = GetStdHandle()
|
| 578 |
+
|
| 579 |
+
from pip._vendor.rich.console import Console
|
| 580 |
+
|
| 581 |
+
console = Console()
|
| 582 |
+
|
| 583 |
+
term = LegacyWindowsTerm(sys.stdout)
|
| 584 |
+
term.set_title("Win32 Console Examples")
|
| 585 |
+
|
| 586 |
+
style = Style(color="black", bgcolor="red")
|
| 587 |
+
|
| 588 |
+
heading = Style.parse("black on green")
|
| 589 |
+
|
| 590 |
+
# Check colour output
|
| 591 |
+
console.rule("Checking colour output")
|
| 592 |
+
console.print("[on red]on red!")
|
| 593 |
+
console.print("[blue]blue!")
|
| 594 |
+
console.print("[yellow]yellow!")
|
| 595 |
+
console.print("[bold yellow]bold yellow!")
|
| 596 |
+
console.print("[bright_yellow]bright_yellow!")
|
| 597 |
+
console.print("[dim bright_yellow]dim bright_yellow!")
|
| 598 |
+
console.print("[italic cyan]italic cyan!")
|
| 599 |
+
console.print("[bold white on blue]bold white on blue!")
|
| 600 |
+
console.print("[reverse bold white on blue]reverse bold white on blue!")
|
| 601 |
+
console.print("[bold black on cyan]bold black on cyan!")
|
| 602 |
+
console.print("[black on green]black on green!")
|
| 603 |
+
console.print("[blue on green]blue on green!")
|
| 604 |
+
console.print("[white on black]white on black!")
|
| 605 |
+
console.print("[black on white]black on white!")
|
| 606 |
+
console.print("[#1BB152 on #DA812D]#1BB152 on #DA812D!")
|
| 607 |
+
|
| 608 |
+
# Check cursor movement
|
| 609 |
+
console.rule("Checking cursor movement")
|
| 610 |
+
console.print()
|
| 611 |
+
term.move_cursor_backward()
|
| 612 |
+
term.move_cursor_backward()
|
| 613 |
+
term.write_text("went back and wrapped to prev line")
|
| 614 |
+
time.sleep(1)
|
| 615 |
+
term.move_cursor_up()
|
| 616 |
+
term.write_text("we go up")
|
| 617 |
+
time.sleep(1)
|
| 618 |
+
term.move_cursor_down()
|
| 619 |
+
term.write_text("and down")
|
| 620 |
+
time.sleep(1)
|
| 621 |
+
term.move_cursor_up()
|
| 622 |
+
term.move_cursor_backward()
|
| 623 |
+
term.move_cursor_backward()
|
| 624 |
+
term.write_text("we went up and back 2")
|
| 625 |
+
time.sleep(1)
|
| 626 |
+
term.move_cursor_down()
|
| 627 |
+
term.move_cursor_backward()
|
| 628 |
+
term.move_cursor_backward()
|
| 629 |
+
term.write_text("we went down and back 2")
|
| 630 |
+
time.sleep(1)
|
| 631 |
+
|
| 632 |
+
# Check erasing of lines
|
| 633 |
+
term.hide_cursor()
|
| 634 |
+
console.print()
|
| 635 |
+
console.rule("Checking line erasing")
|
| 636 |
+
console.print("\n...Deleting to the start of the line...")
|
| 637 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 638 |
+
time.sleep(1)
|
| 639 |
+
term.move_cursor_to_column(16)
|
| 640 |
+
term.write_styled("<", Style.parse("black on red"))
|
| 641 |
+
term.move_cursor_backward()
|
| 642 |
+
time.sleep(1)
|
| 643 |
+
term.erase_start_of_line()
|
| 644 |
+
time.sleep(1)
|
| 645 |
+
|
| 646 |
+
console.print("\n\n...And to the end of the line...")
|
| 647 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 648 |
+
time.sleep(1)
|
| 649 |
+
|
| 650 |
+
term.move_cursor_to_column(16)
|
| 651 |
+
term.write_styled(">", Style.parse("black on red"))
|
| 652 |
+
time.sleep(1)
|
| 653 |
+
term.erase_end_of_line()
|
| 654 |
+
time.sleep(1)
|
| 655 |
+
|
| 656 |
+
console.print("\n\n...Now the whole line will be erased...")
|
| 657 |
+
term.write_styled("I'm going to disappear!", style=Style.parse("black on cyan"))
|
| 658 |
+
time.sleep(1)
|
| 659 |
+
term.erase_line()
|
| 660 |
+
|
| 661 |
+
term.show_cursor()
|
| 662 |
+
print("\n")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_windows_renderer.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Iterable, Sequence, Tuple, cast
|
| 2 |
+
|
| 3 |
+
from pip._vendor.rich._win32_console import LegacyWindowsTerm, WindowsCoordinates
|
| 4 |
+
from pip._vendor.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)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/_wrap.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Iterable, List, Tuple
|
| 3 |
+
|
| 4 |
+
from ._loop import loop_last
|
| 5 |
+
from .cells import cell_len, chop_cells
|
| 6 |
+
|
| 7 |
+
re_word = re.compile(r"\s*\S+\s*")
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def words(text: str) -> Iterable[Tuple[int, int, str]]:
|
| 11 |
+
position = 0
|
| 12 |
+
word_match = re_word.match(text, position)
|
| 13 |
+
while word_match is not None:
|
| 14 |
+
start, end = word_match.span()
|
| 15 |
+
word = word_match.group(0)
|
| 16 |
+
yield start, end, word
|
| 17 |
+
word_match = re_word.match(text, end)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def divide_line(text: str, width: int, fold: bool = True) -> List[int]:
|
| 21 |
+
divides: List[int] = []
|
| 22 |
+
append = divides.append
|
| 23 |
+
line_position = 0
|
| 24 |
+
_cell_len = cell_len
|
| 25 |
+
for start, _end, word in words(text):
|
| 26 |
+
word_length = _cell_len(word.rstrip())
|
| 27 |
+
if line_position + word_length > width:
|
| 28 |
+
if word_length > width:
|
| 29 |
+
if fold:
|
| 30 |
+
chopped_words = chop_cells(word, max_size=width, position=0)
|
| 31 |
+
for last, line in loop_last(chopped_words):
|
| 32 |
+
if start:
|
| 33 |
+
append(start)
|
| 34 |
+
|
| 35 |
+
if last:
|
| 36 |
+
line_position = _cell_len(line)
|
| 37 |
+
else:
|
| 38 |
+
start += len(line)
|
| 39 |
+
else:
|
| 40 |
+
if start:
|
| 41 |
+
append(start)
|
| 42 |
+
line_position = _cell_len(word)
|
| 43 |
+
elif line_position and start:
|
| 44 |
+
append(start)
|
| 45 |
+
line_position = _cell_len(word)
|
| 46 |
+
else:
|
| 47 |
+
line_position += _cell_len(word)
|
| 48 |
+
return divides
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if __name__ == "__main__": # pragma: no cover
|
| 52 |
+
from .console import Console
|
| 53 |
+
|
| 54 |
+
console = Console(width=10)
|
| 55 |
+
console.print("12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345")
|
| 56 |
+
print(chop_cells("abcdefghijklmnopqrstuvwxyz", 10, position=2))
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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 pip._vendor.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))
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/align.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from itertools import chain
|
| 3 |
+
from typing import TYPE_CHECKING, Iterable, Optional
|
| 4 |
+
|
| 5 |
+
if sys.version_info >= (3, 8):
|
| 6 |
+
from typing import Literal
|
| 7 |
+
else:
|
| 8 |
+
from pip._vendor.typing_extensions import Literal # pragma: no cover
|
| 9 |
+
|
| 10 |
+
from .constrain import Constrain
|
| 11 |
+
from .jupyter import JupyterMixin
|
| 12 |
+
from .measure import Measurement
|
| 13 |
+
from .segment import Segment
|
| 14 |
+
from .style import StyleType
|
| 15 |
+
|
| 16 |
+
if TYPE_CHECKING:
|
| 17 |
+
from .console import Console, ConsoleOptions, RenderableType, RenderResult
|
| 18 |
+
|
| 19 |
+
AlignMethod = Literal["left", "center", "right"]
|
| 20 |
+
VerticalAlignMethod = Literal["top", "middle", "bottom"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Align(JupyterMixin):
|
| 24 |
+
"""Align a renderable by adding spaces if necessary.
|
| 25 |
+
|
| 26 |
+
Args:
|
| 27 |
+
renderable (RenderableType): A console renderable.
|
| 28 |
+
align (AlignMethod): One of "left", "center", or "right""
|
| 29 |
+
style (StyleType, optional): An optional style to apply to the background.
|
| 30 |
+
vertical (Optional[VerticalAlginMethod], optional): Optional vertical align, one of "top", "middle", or "bottom". Defaults to None.
|
| 31 |
+
pad (bool, optional): Pad the right with spaces. Defaults to True.
|
| 32 |
+
width (int, optional): Restrict contents to given width, or None to use default width. Defaults to None.
|
| 33 |
+
height (int, optional): Set height of align renderable, or None to fit to contents. Defaults to None.
|
| 34 |
+
|
| 35 |
+
Raises:
|
| 36 |
+
ValueError: if ``align`` is not one of the expected values.
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
def __init__(
|
| 40 |
+
self,
|
| 41 |
+
renderable: "RenderableType",
|
| 42 |
+
align: AlignMethod = "left",
|
| 43 |
+
style: Optional[StyleType] = None,
|
| 44 |
+
*,
|
| 45 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 46 |
+
pad: bool = True,
|
| 47 |
+
width: Optional[int] = None,
|
| 48 |
+
height: Optional[int] = None,
|
| 49 |
+
) -> None:
|
| 50 |
+
if align not in ("left", "center", "right"):
|
| 51 |
+
raise ValueError(
|
| 52 |
+
f'invalid value for align, expected "left", "center", or "right" (not {align!r})'
|
| 53 |
+
)
|
| 54 |
+
if vertical is not None and vertical not in ("top", "middle", "bottom"):
|
| 55 |
+
raise ValueError(
|
| 56 |
+
f'invalid value for vertical, expected "top", "middle", or "bottom" (not {vertical!r})'
|
| 57 |
+
)
|
| 58 |
+
self.renderable = renderable
|
| 59 |
+
self.align = align
|
| 60 |
+
self.style = style
|
| 61 |
+
self.vertical = vertical
|
| 62 |
+
self.pad = pad
|
| 63 |
+
self.width = width
|
| 64 |
+
self.height = height
|
| 65 |
+
|
| 66 |
+
def __repr__(self) -> str:
|
| 67 |
+
return f"Align({self.renderable!r}, {self.align!r})"
|
| 68 |
+
|
| 69 |
+
@classmethod
|
| 70 |
+
def left(
|
| 71 |
+
cls,
|
| 72 |
+
renderable: "RenderableType",
|
| 73 |
+
style: Optional[StyleType] = None,
|
| 74 |
+
*,
|
| 75 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 76 |
+
pad: bool = True,
|
| 77 |
+
width: Optional[int] = None,
|
| 78 |
+
height: Optional[int] = None,
|
| 79 |
+
) -> "Align":
|
| 80 |
+
"""Align a renderable to the left."""
|
| 81 |
+
return cls(
|
| 82 |
+
renderable,
|
| 83 |
+
"left",
|
| 84 |
+
style=style,
|
| 85 |
+
vertical=vertical,
|
| 86 |
+
pad=pad,
|
| 87 |
+
width=width,
|
| 88 |
+
height=height,
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
@classmethod
|
| 92 |
+
def center(
|
| 93 |
+
cls,
|
| 94 |
+
renderable: "RenderableType",
|
| 95 |
+
style: Optional[StyleType] = None,
|
| 96 |
+
*,
|
| 97 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 98 |
+
pad: bool = True,
|
| 99 |
+
width: Optional[int] = None,
|
| 100 |
+
height: Optional[int] = None,
|
| 101 |
+
) -> "Align":
|
| 102 |
+
"""Align a renderable to the center."""
|
| 103 |
+
return cls(
|
| 104 |
+
renderable,
|
| 105 |
+
"center",
|
| 106 |
+
style=style,
|
| 107 |
+
vertical=vertical,
|
| 108 |
+
pad=pad,
|
| 109 |
+
width=width,
|
| 110 |
+
height=height,
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
@classmethod
|
| 114 |
+
def right(
|
| 115 |
+
cls,
|
| 116 |
+
renderable: "RenderableType",
|
| 117 |
+
style: Optional[StyleType] = None,
|
| 118 |
+
*,
|
| 119 |
+
vertical: Optional[VerticalAlignMethod] = None,
|
| 120 |
+
pad: bool = True,
|
| 121 |
+
width: Optional[int] = None,
|
| 122 |
+
height: Optional[int] = None,
|
| 123 |
+
) -> "Align":
|
| 124 |
+
"""Align a renderable to the right."""
|
| 125 |
+
return cls(
|
| 126 |
+
renderable,
|
| 127 |
+
"right",
|
| 128 |
+
style=style,
|
| 129 |
+
vertical=vertical,
|
| 130 |
+
pad=pad,
|
| 131 |
+
width=width,
|
| 132 |
+
height=height,
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
def __rich_console__(
|
| 136 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 137 |
+
) -> "RenderResult":
|
| 138 |
+
align = self.align
|
| 139 |
+
width = console.measure(self.renderable, options=options).maximum
|
| 140 |
+
rendered = console.render(
|
| 141 |
+
Constrain(
|
| 142 |
+
self.renderable, width if self.width is None else min(width, self.width)
|
| 143 |
+
),
|
| 144 |
+
options.update(height=None),
|
| 145 |
+
)
|
| 146 |
+
lines = list(Segment.split_lines(rendered))
|
| 147 |
+
width, height = Segment.get_shape(lines)
|
| 148 |
+
lines = Segment.set_shape(lines, width, height)
|
| 149 |
+
new_line = Segment.line()
|
| 150 |
+
excess_space = options.max_width - width
|
| 151 |
+
style = console.get_style(self.style) if self.style is not None else None
|
| 152 |
+
|
| 153 |
+
def generate_segments() -> Iterable[Segment]:
|
| 154 |
+
if excess_space <= 0:
|
| 155 |
+
# Exact fit
|
| 156 |
+
for line in lines:
|
| 157 |
+
yield from line
|
| 158 |
+
yield new_line
|
| 159 |
+
|
| 160 |
+
elif align == "left":
|
| 161 |
+
# Pad on the right
|
| 162 |
+
pad = Segment(" " * excess_space, style) if self.pad else None
|
| 163 |
+
for line in lines:
|
| 164 |
+
yield from line
|
| 165 |
+
if pad:
|
| 166 |
+
yield pad
|
| 167 |
+
yield new_line
|
| 168 |
+
|
| 169 |
+
elif align == "center":
|
| 170 |
+
# Pad left and right
|
| 171 |
+
left = excess_space // 2
|
| 172 |
+
pad = Segment(" " * left, style)
|
| 173 |
+
pad_right = (
|
| 174 |
+
Segment(" " * (excess_space - left), style) if self.pad else None
|
| 175 |
+
)
|
| 176 |
+
for line in lines:
|
| 177 |
+
if left:
|
| 178 |
+
yield pad
|
| 179 |
+
yield from line
|
| 180 |
+
if pad_right:
|
| 181 |
+
yield pad_right
|
| 182 |
+
yield new_line
|
| 183 |
+
|
| 184 |
+
elif align == "right":
|
| 185 |
+
# Padding on left
|
| 186 |
+
pad = Segment(" " * excess_space, style)
|
| 187 |
+
for line in lines:
|
| 188 |
+
yield pad
|
| 189 |
+
yield from line
|
| 190 |
+
yield new_line
|
| 191 |
+
|
| 192 |
+
blank_line = (
|
| 193 |
+
Segment(f"{' ' * (self.width or options.max_width)}\n", style)
|
| 194 |
+
if self.pad
|
| 195 |
+
else Segment("\n")
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
def blank_lines(count: int) -> Iterable[Segment]:
|
| 199 |
+
if count > 0:
|
| 200 |
+
for _ in range(count):
|
| 201 |
+
yield blank_line
|
| 202 |
+
|
| 203 |
+
vertical_height = self.height or options.height
|
| 204 |
+
iter_segments: Iterable[Segment]
|
| 205 |
+
if self.vertical and vertical_height is not None:
|
| 206 |
+
if self.vertical == "top":
|
| 207 |
+
bottom_space = vertical_height - height
|
| 208 |
+
iter_segments = chain(generate_segments(), blank_lines(bottom_space))
|
| 209 |
+
elif self.vertical == "middle":
|
| 210 |
+
top_space = (vertical_height - height) // 2
|
| 211 |
+
bottom_space = vertical_height - top_space - height
|
| 212 |
+
iter_segments = chain(
|
| 213 |
+
blank_lines(top_space),
|
| 214 |
+
generate_segments(),
|
| 215 |
+
blank_lines(bottom_space),
|
| 216 |
+
)
|
| 217 |
+
else: # self.vertical == "bottom":
|
| 218 |
+
top_space = vertical_height - height
|
| 219 |
+
iter_segments = chain(blank_lines(top_space), generate_segments())
|
| 220 |
+
else:
|
| 221 |
+
iter_segments = generate_segments()
|
| 222 |
+
if self.style:
|
| 223 |
+
style = console.get_style(self.style)
|
| 224 |
+
iter_segments = Segment.apply_style(iter_segments, style)
|
| 225 |
+
yield from iter_segments
|
| 226 |
+
|
| 227 |
+
def __rich_measure__(
|
| 228 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 229 |
+
) -> Measurement:
|
| 230 |
+
measurement = Measurement.get(console, options, self.renderable)
|
| 231 |
+
return measurement
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
class VerticalCenter(JupyterMixin):
|
| 235 |
+
"""Vertically aligns a renderable.
|
| 236 |
+
|
| 237 |
+
Warn:
|
| 238 |
+
This class is deprecated and may be removed in a future version. Use Align class with
|
| 239 |
+
`vertical="middle"`.
|
| 240 |
+
|
| 241 |
+
Args:
|
| 242 |
+
renderable (RenderableType): A renderable object.
|
| 243 |
+
"""
|
| 244 |
+
|
| 245 |
+
def __init__(
|
| 246 |
+
self,
|
| 247 |
+
renderable: "RenderableType",
|
| 248 |
+
style: Optional[StyleType] = None,
|
| 249 |
+
) -> None:
|
| 250 |
+
self.renderable = renderable
|
| 251 |
+
self.style = style
|
| 252 |
+
|
| 253 |
+
def __repr__(self) -> str:
|
| 254 |
+
return f"VerticalCenter({self.renderable!r})"
|
| 255 |
+
|
| 256 |
+
def __rich_console__(
|
| 257 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 258 |
+
) -> "RenderResult":
|
| 259 |
+
style = console.get_style(self.style) if self.style is not None else None
|
| 260 |
+
lines = console.render_lines(
|
| 261 |
+
self.renderable, options.update(height=None), pad=False
|
| 262 |
+
)
|
| 263 |
+
width, _height = Segment.get_shape(lines)
|
| 264 |
+
new_line = Segment.line()
|
| 265 |
+
height = options.height or options.size.height
|
| 266 |
+
top_space = (height - len(lines)) // 2
|
| 267 |
+
bottom_space = height - top_space - len(lines)
|
| 268 |
+
blank_line = Segment(f"{' ' * width}", style)
|
| 269 |
+
|
| 270 |
+
def blank_lines(count: int) -> Iterable[Segment]:
|
| 271 |
+
for _ in range(count):
|
| 272 |
+
yield blank_line
|
| 273 |
+
yield new_line
|
| 274 |
+
|
| 275 |
+
if top_space > 0:
|
| 276 |
+
yield from blank_lines(top_space)
|
| 277 |
+
for line in lines:
|
| 278 |
+
yield from line
|
| 279 |
+
yield new_line
|
| 280 |
+
if bottom_space > 0:
|
| 281 |
+
yield from blank_lines(bottom_space)
|
| 282 |
+
|
| 283 |
+
def __rich_measure__(
|
| 284 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 285 |
+
) -> Measurement:
|
| 286 |
+
measurement = Measurement.get(console, options, self.renderable)
|
| 287 |
+
return measurement
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
if __name__ == "__main__": # pragma: no cover
|
| 291 |
+
from pip._vendor.rich.console import Console, Group
|
| 292 |
+
from pip._vendor.rich.highlighter import ReprHighlighter
|
| 293 |
+
from pip._vendor.rich.panel import Panel
|
| 294 |
+
|
| 295 |
+
highlighter = ReprHighlighter()
|
| 296 |
+
console = Console()
|
| 297 |
+
|
| 298 |
+
panel = Panel(
|
| 299 |
+
Group(
|
| 300 |
+
Align.left(highlighter("align='left'")),
|
| 301 |
+
Align.center(highlighter("align='center'")),
|
| 302 |
+
Align.right(highlighter("align='right'")),
|
| 303 |
+
),
|
| 304 |
+
width=60,
|
| 305 |
+
style="on dark_blue",
|
| 306 |
+
title="Align",
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
+
console.print(
|
| 310 |
+
Align.center(panel, vertical="middle", style="on red", height=console.height)
|
| 311 |
+
)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/ansi.py
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
from .text import Text
|
| 9 |
+
|
| 10 |
+
re_ansi = re.compile(
|
| 11 |
+
r"""
|
| 12 |
+
(?:\x1b\](.*?)\x1b\\)|
|
| 13 |
+
(?:\x1b([(@-Z\\-_]|\[[0-?]*[ -/]*[@-~]))
|
| 14 |
+
""",
|
| 15 |
+
re.VERBOSE,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class _AnsiToken(NamedTuple):
|
| 20 |
+
"""Result of ansi tokenized string."""
|
| 21 |
+
|
| 22 |
+
plain: str = ""
|
| 23 |
+
sgr: Optional[str] = ""
|
| 24 |
+
osc: Optional[str] = ""
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _ansi_tokenize(ansi_text: str) -> Iterable[_AnsiToken]:
|
| 28 |
+
"""Tokenize a string in to plain text and ANSI codes.
|
| 29 |
+
|
| 30 |
+
Args:
|
| 31 |
+
ansi_text (str): A String containing ANSI codes.
|
| 32 |
+
|
| 33 |
+
Yields:
|
| 34 |
+
AnsiToken: A named tuple of (plain, sgr, osc)
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
position = 0
|
| 38 |
+
sgr: Optional[str]
|
| 39 |
+
osc: Optional[str]
|
| 40 |
+
for match in re_ansi.finditer(ansi_text):
|
| 41 |
+
start, end = match.span(0)
|
| 42 |
+
osc, sgr = match.groups()
|
| 43 |
+
if start > position:
|
| 44 |
+
yield _AnsiToken(ansi_text[position:start])
|
| 45 |
+
if sgr:
|
| 46 |
+
if sgr == "(":
|
| 47 |
+
position = end + 1
|
| 48 |
+
continue
|
| 49 |
+
if sgr.endswith("m"):
|
| 50 |
+
yield _AnsiToken("", sgr[1:-1], osc)
|
| 51 |
+
else:
|
| 52 |
+
yield _AnsiToken("", sgr, osc)
|
| 53 |
+
position = end
|
| 54 |
+
if position < len(ansi_text):
|
| 55 |
+
yield _AnsiToken(ansi_text[position:])
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
SGR_STYLE_MAP = {
|
| 59 |
+
1: "bold",
|
| 60 |
+
2: "dim",
|
| 61 |
+
3: "italic",
|
| 62 |
+
4: "underline",
|
| 63 |
+
5: "blink",
|
| 64 |
+
6: "blink2",
|
| 65 |
+
7: "reverse",
|
| 66 |
+
8: "conceal",
|
| 67 |
+
9: "strike",
|
| 68 |
+
21: "underline2",
|
| 69 |
+
22: "not dim not bold",
|
| 70 |
+
23: "not italic",
|
| 71 |
+
24: "not underline",
|
| 72 |
+
25: "not blink",
|
| 73 |
+
26: "not blink2",
|
| 74 |
+
27: "not reverse",
|
| 75 |
+
28: "not conceal",
|
| 76 |
+
29: "not strike",
|
| 77 |
+
30: "color(0)",
|
| 78 |
+
31: "color(1)",
|
| 79 |
+
32: "color(2)",
|
| 80 |
+
33: "color(3)",
|
| 81 |
+
34: "color(4)",
|
| 82 |
+
35: "color(5)",
|
| 83 |
+
36: "color(6)",
|
| 84 |
+
37: "color(7)",
|
| 85 |
+
39: "default",
|
| 86 |
+
40: "on color(0)",
|
| 87 |
+
41: "on color(1)",
|
| 88 |
+
42: "on color(2)",
|
| 89 |
+
43: "on color(3)",
|
| 90 |
+
44: "on color(4)",
|
| 91 |
+
45: "on color(5)",
|
| 92 |
+
46: "on color(6)",
|
| 93 |
+
47: "on color(7)",
|
| 94 |
+
49: "on default",
|
| 95 |
+
51: "frame",
|
| 96 |
+
52: "encircle",
|
| 97 |
+
53: "overline",
|
| 98 |
+
54: "not frame not encircle",
|
| 99 |
+
55: "not overline",
|
| 100 |
+
90: "color(8)",
|
| 101 |
+
91: "color(9)",
|
| 102 |
+
92: "color(10)",
|
| 103 |
+
93: "color(11)",
|
| 104 |
+
94: "color(12)",
|
| 105 |
+
95: "color(13)",
|
| 106 |
+
96: "color(14)",
|
| 107 |
+
97: "color(15)",
|
| 108 |
+
100: "on color(8)",
|
| 109 |
+
101: "on color(9)",
|
| 110 |
+
102: "on color(10)",
|
| 111 |
+
103: "on color(11)",
|
| 112 |
+
104: "on color(12)",
|
| 113 |
+
105: "on color(13)",
|
| 114 |
+
106: "on color(14)",
|
| 115 |
+
107: "on color(15)",
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class AnsiDecoder:
|
| 120 |
+
"""Translate ANSI code in to styled Text."""
|
| 121 |
+
|
| 122 |
+
def __init__(self) -> None:
|
| 123 |
+
self.style = Style.null()
|
| 124 |
+
|
| 125 |
+
def decode(self, terminal_text: str) -> Iterable[Text]:
|
| 126 |
+
"""Decode ANSI codes in an iterable of lines.
|
| 127 |
+
|
| 128 |
+
Args:
|
| 129 |
+
lines (Iterable[str]): An iterable of lines of terminal output.
|
| 130 |
+
|
| 131 |
+
Yields:
|
| 132 |
+
Text: Marked up Text.
|
| 133 |
+
"""
|
| 134 |
+
for line in terminal_text.splitlines():
|
| 135 |
+
yield self.decode_line(line)
|
| 136 |
+
|
| 137 |
+
def decode_line(self, line: str) -> Text:
|
| 138 |
+
"""Decode a line containing ansi codes.
|
| 139 |
+
|
| 140 |
+
Args:
|
| 141 |
+
line (str): A line of terminal output.
|
| 142 |
+
|
| 143 |
+
Returns:
|
| 144 |
+
Text: A Text instance marked up according to ansi codes.
|
| 145 |
+
"""
|
| 146 |
+
from_ansi = Color.from_ansi
|
| 147 |
+
from_rgb = Color.from_rgb
|
| 148 |
+
_Style = Style
|
| 149 |
+
text = Text()
|
| 150 |
+
append = text.append
|
| 151 |
+
line = line.rsplit("\r", 1)[-1]
|
| 152 |
+
for plain_text, sgr, osc in _ansi_tokenize(line):
|
| 153 |
+
if plain_text:
|
| 154 |
+
append(plain_text, self.style or None)
|
| 155 |
+
elif osc is not None:
|
| 156 |
+
if osc.startswith("8;"):
|
| 157 |
+
_params, semicolon, link = osc[2:].partition(";")
|
| 158 |
+
if semicolon:
|
| 159 |
+
self.style = self.style.update_link(link or None)
|
| 160 |
+
elif sgr is not None:
|
| 161 |
+
# Translate in to semi-colon separated codes
|
| 162 |
+
# Ignore invalid codes, because we want to be lenient
|
| 163 |
+
codes = [
|
| 164 |
+
min(255, int(_code) if _code else 0)
|
| 165 |
+
for _code in sgr.split(";")
|
| 166 |
+
if _code.isdigit() or _code == ""
|
| 167 |
+
]
|
| 168 |
+
iter_codes = iter(codes)
|
| 169 |
+
for code in iter_codes:
|
| 170 |
+
if code == 0:
|
| 171 |
+
# reset
|
| 172 |
+
self.style = _Style.null()
|
| 173 |
+
elif code in SGR_STYLE_MAP:
|
| 174 |
+
# styles
|
| 175 |
+
self.style += _Style.parse(SGR_STYLE_MAP[code])
|
| 176 |
+
elif code == 38:
|
| 177 |
+
# Foreground
|
| 178 |
+
with suppress(StopIteration):
|
| 179 |
+
color_type = next(iter_codes)
|
| 180 |
+
if color_type == 5:
|
| 181 |
+
self.style += _Style.from_color(
|
| 182 |
+
from_ansi(next(iter_codes))
|
| 183 |
+
)
|
| 184 |
+
elif color_type == 2:
|
| 185 |
+
self.style += _Style.from_color(
|
| 186 |
+
from_rgb(
|
| 187 |
+
next(iter_codes),
|
| 188 |
+
next(iter_codes),
|
| 189 |
+
next(iter_codes),
|
| 190 |
+
)
|
| 191 |
+
)
|
| 192 |
+
elif code == 48:
|
| 193 |
+
# Background
|
| 194 |
+
with suppress(StopIteration):
|
| 195 |
+
color_type = next(iter_codes)
|
| 196 |
+
if color_type == 5:
|
| 197 |
+
self.style += _Style.from_color(
|
| 198 |
+
None, from_ansi(next(iter_codes))
|
| 199 |
+
)
|
| 200 |
+
elif color_type == 2:
|
| 201 |
+
self.style += _Style.from_color(
|
| 202 |
+
None,
|
| 203 |
+
from_rgb(
|
| 204 |
+
next(iter_codes),
|
| 205 |
+
next(iter_codes),
|
| 206 |
+
next(iter_codes),
|
| 207 |
+
),
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
return text
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
if sys.platform != "win32" and __name__ == "__main__": # pragma: no cover
|
| 214 |
+
import io
|
| 215 |
+
import os
|
| 216 |
+
import pty
|
| 217 |
+
import sys
|
| 218 |
+
|
| 219 |
+
decoder = AnsiDecoder()
|
| 220 |
+
|
| 221 |
+
stdout = io.BytesIO()
|
| 222 |
+
|
| 223 |
+
def read(fd: int) -> bytes:
|
| 224 |
+
data = os.read(fd, 1024)
|
| 225 |
+
stdout.write(data)
|
| 226 |
+
return data
|
| 227 |
+
|
| 228 |
+
pty.spawn(sys.argv[1:], read)
|
| 229 |
+
|
| 230 |
+
from .console import Console
|
| 231 |
+
|
| 232 |
+
console = Console(record=True)
|
| 233 |
+
|
| 234 |
+
stdout_result = stdout.getvalue().decode("utf-8")
|
| 235 |
+
print(stdout_result)
|
| 236 |
+
|
| 237 |
+
for line in decoder.decode(stdout_result):
|
| 238 |
+
console.print(line)
|
| 239 |
+
|
| 240 |
+
console.save_html("stdout.html")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/box.py
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from typing import TYPE_CHECKING, Iterable, List
|
| 3 |
+
|
| 4 |
+
if sys.version_info >= (3, 8):
|
| 5 |
+
from typing import Literal
|
| 6 |
+
else:
|
| 7 |
+
from pip._vendor.typing_extensions import Literal # pragma: no cover
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
from ._loop import loop_last
|
| 11 |
+
|
| 12 |
+
if TYPE_CHECKING:
|
| 13 |
+
from pip._vendor.rich.console import ConsoleOptions
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class Box:
|
| 17 |
+
"""Defines characters to render boxes.
|
| 18 |
+
|
| 19 |
+
┌─┬┐ top
|
| 20 |
+
│ ││ head
|
| 21 |
+
├─┼┤ head_row
|
| 22 |
+
│ ││ mid
|
| 23 |
+
├─┼┤ row
|
| 24 |
+
├─┼┤ foot_row
|
| 25 |
+
│ ││ foot
|
| 26 |
+
└─┴┘ bottom
|
| 27 |
+
|
| 28 |
+
Args:
|
| 29 |
+
box (str): Characters making up box.
|
| 30 |
+
ascii (bool, optional): True if this box uses ascii characters only. Default is False.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
def __init__(self, box: str, *, ascii: bool = False) -> None:
|
| 34 |
+
self._box = box
|
| 35 |
+
self.ascii = ascii
|
| 36 |
+
line1, line2, line3, line4, line5, line6, line7, line8 = box.splitlines()
|
| 37 |
+
# top
|
| 38 |
+
self.top_left, self.top, self.top_divider, self.top_right = iter(line1)
|
| 39 |
+
# head
|
| 40 |
+
self.head_left, _, self.head_vertical, self.head_right = iter(line2)
|
| 41 |
+
# head_row
|
| 42 |
+
(
|
| 43 |
+
self.head_row_left,
|
| 44 |
+
self.head_row_horizontal,
|
| 45 |
+
self.head_row_cross,
|
| 46 |
+
self.head_row_right,
|
| 47 |
+
) = iter(line3)
|
| 48 |
+
|
| 49 |
+
# mid
|
| 50 |
+
self.mid_left, _, self.mid_vertical, self.mid_right = iter(line4)
|
| 51 |
+
# row
|
| 52 |
+
self.row_left, self.row_horizontal, self.row_cross, self.row_right = iter(line5)
|
| 53 |
+
# foot_row
|
| 54 |
+
(
|
| 55 |
+
self.foot_row_left,
|
| 56 |
+
self.foot_row_horizontal,
|
| 57 |
+
self.foot_row_cross,
|
| 58 |
+
self.foot_row_right,
|
| 59 |
+
) = iter(line6)
|
| 60 |
+
# foot
|
| 61 |
+
self.foot_left, _, self.foot_vertical, self.foot_right = iter(line7)
|
| 62 |
+
# bottom
|
| 63 |
+
self.bottom_left, self.bottom, self.bottom_divider, self.bottom_right = iter(
|
| 64 |
+
line8
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
def __repr__(self) -> str:
|
| 68 |
+
return "Box(...)"
|
| 69 |
+
|
| 70 |
+
def __str__(self) -> str:
|
| 71 |
+
return self._box
|
| 72 |
+
|
| 73 |
+
def substitute(self, options: "ConsoleOptions", safe: bool = True) -> "Box":
|
| 74 |
+
"""Substitute this box for another if it won't render due to platform issues.
|
| 75 |
+
|
| 76 |
+
Args:
|
| 77 |
+
options (ConsoleOptions): Console options used in rendering.
|
| 78 |
+
safe (bool, optional): Substitute this for another Box if there are known problems
|
| 79 |
+
displaying on the platform (currently only relevant on Windows). Default is True.
|
| 80 |
+
|
| 81 |
+
Returns:
|
| 82 |
+
Box: A different Box or the same Box.
|
| 83 |
+
"""
|
| 84 |
+
box = self
|
| 85 |
+
if options.legacy_windows and safe:
|
| 86 |
+
box = LEGACY_WINDOWS_SUBSTITUTIONS.get(box, box)
|
| 87 |
+
if options.ascii_only and not box.ascii:
|
| 88 |
+
box = ASCII
|
| 89 |
+
return box
|
| 90 |
+
|
| 91 |
+
def get_plain_headed_box(self) -> "Box":
|
| 92 |
+
"""If this box uses special characters for the borders of the header, then
|
| 93 |
+
return the equivalent box that does not.
|
| 94 |
+
|
| 95 |
+
Returns:
|
| 96 |
+
Box: The most similar Box that doesn't use header-specific box characters.
|
| 97 |
+
If the current Box already satisfies this criterion, then it's returned.
|
| 98 |
+
"""
|
| 99 |
+
return PLAIN_HEADED_SUBSTITUTIONS.get(self, self)
|
| 100 |
+
|
| 101 |
+
def get_top(self, widths: Iterable[int]) -> str:
|
| 102 |
+
"""Get the top of a simple box.
|
| 103 |
+
|
| 104 |
+
Args:
|
| 105 |
+
widths (List[int]): Widths of columns.
|
| 106 |
+
|
| 107 |
+
Returns:
|
| 108 |
+
str: A string of box characters.
|
| 109 |
+
"""
|
| 110 |
+
|
| 111 |
+
parts: List[str] = []
|
| 112 |
+
append = parts.append
|
| 113 |
+
append(self.top_left)
|
| 114 |
+
for last, width in loop_last(widths):
|
| 115 |
+
append(self.top * width)
|
| 116 |
+
if not last:
|
| 117 |
+
append(self.top_divider)
|
| 118 |
+
append(self.top_right)
|
| 119 |
+
return "".join(parts)
|
| 120 |
+
|
| 121 |
+
def get_row(
|
| 122 |
+
self,
|
| 123 |
+
widths: Iterable[int],
|
| 124 |
+
level: Literal["head", "row", "foot", "mid"] = "row",
|
| 125 |
+
edge: bool = True,
|
| 126 |
+
) -> str:
|
| 127 |
+
"""Get the top of a simple box.
|
| 128 |
+
|
| 129 |
+
Args:
|
| 130 |
+
width (List[int]): Widths of columns.
|
| 131 |
+
|
| 132 |
+
Returns:
|
| 133 |
+
str: A string of box characters.
|
| 134 |
+
"""
|
| 135 |
+
if level == "head":
|
| 136 |
+
left = self.head_row_left
|
| 137 |
+
horizontal = self.head_row_horizontal
|
| 138 |
+
cross = self.head_row_cross
|
| 139 |
+
right = self.head_row_right
|
| 140 |
+
elif level == "row":
|
| 141 |
+
left = self.row_left
|
| 142 |
+
horizontal = self.row_horizontal
|
| 143 |
+
cross = self.row_cross
|
| 144 |
+
right = self.row_right
|
| 145 |
+
elif level == "mid":
|
| 146 |
+
left = self.mid_left
|
| 147 |
+
horizontal = " "
|
| 148 |
+
cross = self.mid_vertical
|
| 149 |
+
right = self.mid_right
|
| 150 |
+
elif level == "foot":
|
| 151 |
+
left = self.foot_row_left
|
| 152 |
+
horizontal = self.foot_row_horizontal
|
| 153 |
+
cross = self.foot_row_cross
|
| 154 |
+
right = self.foot_row_right
|
| 155 |
+
else:
|
| 156 |
+
raise ValueError("level must be 'head', 'row' or 'foot'")
|
| 157 |
+
|
| 158 |
+
parts: List[str] = []
|
| 159 |
+
append = parts.append
|
| 160 |
+
if edge:
|
| 161 |
+
append(left)
|
| 162 |
+
for last, width in loop_last(widths):
|
| 163 |
+
append(horizontal * width)
|
| 164 |
+
if not last:
|
| 165 |
+
append(cross)
|
| 166 |
+
if edge:
|
| 167 |
+
append(right)
|
| 168 |
+
return "".join(parts)
|
| 169 |
+
|
| 170 |
+
def get_bottom(self, widths: Iterable[int]) -> str:
|
| 171 |
+
"""Get the bottom of a simple box.
|
| 172 |
+
|
| 173 |
+
Args:
|
| 174 |
+
widths (List[int]): Widths of columns.
|
| 175 |
+
|
| 176 |
+
Returns:
|
| 177 |
+
str: A string of box characters.
|
| 178 |
+
"""
|
| 179 |
+
|
| 180 |
+
parts: List[str] = []
|
| 181 |
+
append = parts.append
|
| 182 |
+
append(self.bottom_left)
|
| 183 |
+
for last, width in loop_last(widths):
|
| 184 |
+
append(self.bottom * width)
|
| 185 |
+
if not last:
|
| 186 |
+
append(self.bottom_divider)
|
| 187 |
+
append(self.bottom_right)
|
| 188 |
+
return "".join(parts)
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
ASCII: Box = Box(
|
| 192 |
+
"""\
|
| 193 |
+
+--+
|
| 194 |
+
| ||
|
| 195 |
+
|-+|
|
| 196 |
+
| ||
|
| 197 |
+
|-+|
|
| 198 |
+
|-+|
|
| 199 |
+
| ||
|
| 200 |
+
+--+
|
| 201 |
+
""",
|
| 202 |
+
ascii=True,
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
ASCII2: Box = Box(
|
| 206 |
+
"""\
|
| 207 |
+
+-++
|
| 208 |
+
| ||
|
| 209 |
+
+-++
|
| 210 |
+
| ||
|
| 211 |
+
+-++
|
| 212 |
+
+-++
|
| 213 |
+
| ||
|
| 214 |
+
+-++
|
| 215 |
+
""",
|
| 216 |
+
ascii=True,
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
ASCII_DOUBLE_HEAD: Box = Box(
|
| 220 |
+
"""\
|
| 221 |
+
+-++
|
| 222 |
+
| ||
|
| 223 |
+
+=++
|
| 224 |
+
| ||
|
| 225 |
+
+-++
|
| 226 |
+
+-++
|
| 227 |
+
| ||
|
| 228 |
+
+-++
|
| 229 |
+
""",
|
| 230 |
+
ascii=True,
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
SQUARE: Box = Box(
|
| 234 |
+
"""\
|
| 235 |
+
┌─┬┐
|
| 236 |
+
│ ││
|
| 237 |
+
├─┼┤
|
| 238 |
+
│ ││
|
| 239 |
+
├─┼┤
|
| 240 |
+
├─┼┤
|
| 241 |
+
│ ││
|
| 242 |
+
└─┴┘
|
| 243 |
+
"""
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
SQUARE_DOUBLE_HEAD: Box = Box(
|
| 247 |
+
"""\
|
| 248 |
+
┌─┬┐
|
| 249 |
+
│ ││
|
| 250 |
+
╞═╪╡
|
| 251 |
+
│ ││
|
| 252 |
+
├─┼┤
|
| 253 |
+
├─┼┤
|
| 254 |
+
│ ││
|
| 255 |
+
└─┴┘
|
| 256 |
+
"""
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
MINIMAL: Box = Box(
|
| 260 |
+
"""\
|
| 261 |
+
╷
|
| 262 |
+
│
|
| 263 |
+
╶─┼╴
|
| 264 |
+
│
|
| 265 |
+
╶─┼╴
|
| 266 |
+
╶─┼╴
|
| 267 |
+
│
|
| 268 |
+
╵
|
| 269 |
+
"""
|
| 270 |
+
)
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
MINIMAL_HEAVY_HEAD: Box = Box(
|
| 274 |
+
"""\
|
| 275 |
+
╷
|
| 276 |
+
│
|
| 277 |
+
╺━┿╸
|
| 278 |
+
│
|
| 279 |
+
╶─┼╴
|
| 280 |
+
╶─┼╴
|
| 281 |
+
│
|
| 282 |
+
╵
|
| 283 |
+
"""
|
| 284 |
+
)
|
| 285 |
+
|
| 286 |
+
MINIMAL_DOUBLE_HEAD: Box = Box(
|
| 287 |
+
"""\
|
| 288 |
+
╷
|
| 289 |
+
│
|
| 290 |
+
═╪
|
| 291 |
+
│
|
| 292 |
+
─┼
|
| 293 |
+
─┼
|
| 294 |
+
│
|
| 295 |
+
╵
|
| 296 |
+
"""
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
SIMPLE: Box = Box(
|
| 301 |
+
"""\
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
──
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
──
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
"""
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
SIMPLE_HEAD: Box = Box(
|
| 314 |
+
"""\
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
──
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
"""
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
SIMPLE_HEAVY: Box = Box(
|
| 328 |
+
"""\
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
━━
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
━━
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
"""
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
HORIZONTALS: Box = Box(
|
| 342 |
+
"""\
|
| 343 |
+
──
|
| 344 |
+
|
| 345 |
+
──
|
| 346 |
+
|
| 347 |
+
──
|
| 348 |
+
──
|
| 349 |
+
|
| 350 |
+
──
|
| 351 |
+
"""
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
ROUNDED: Box = Box(
|
| 355 |
+
"""\
|
| 356 |
+
╭─┬╮
|
| 357 |
+
│ ││
|
| 358 |
+
├─┼┤
|
| 359 |
+
│ ││
|
| 360 |
+
├─┼┤
|
| 361 |
+
├─┼┤
|
| 362 |
+
│ ││
|
| 363 |
+
╰─┴╯
|
| 364 |
+
"""
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
HEAVY: Box = Box(
|
| 368 |
+
"""\
|
| 369 |
+
┏━┳┓
|
| 370 |
+
┃ ┃┃
|
| 371 |
+
┣━╋┫
|
| 372 |
+
┃ ┃┃
|
| 373 |
+
┣━╋┫
|
| 374 |
+
┣━╋┫
|
| 375 |
+
┃ ┃┃
|
| 376 |
+
┗━┻┛
|
| 377 |
+
"""
|
| 378 |
+
)
|
| 379 |
+
|
| 380 |
+
HEAVY_EDGE: Box = Box(
|
| 381 |
+
"""\
|
| 382 |
+
┏━┯┓
|
| 383 |
+
┃ │┃
|
| 384 |
+
┠─┼┨
|
| 385 |
+
┃ │┃
|
| 386 |
+
┠─┼┨
|
| 387 |
+
┠─┼┨
|
| 388 |
+
┃ │┃
|
| 389 |
+
┗━┷┛
|
| 390 |
+
"""
|
| 391 |
+
)
|
| 392 |
+
|
| 393 |
+
HEAVY_HEAD: Box = Box(
|
| 394 |
+
"""\
|
| 395 |
+
┏━┳┓
|
| 396 |
+
┃ ┃┃
|
| 397 |
+
┡━╇┩
|
| 398 |
+
│ ││
|
| 399 |
+
├─┼┤
|
| 400 |
+
├─┼┤
|
| 401 |
+
│ ││
|
| 402 |
+
└─┴┘
|
| 403 |
+
"""
|
| 404 |
+
)
|
| 405 |
+
|
| 406 |
+
DOUBLE: Box = Box(
|
| 407 |
+
"""\
|
| 408 |
+
╔═╦╗
|
| 409 |
+
║ ║║
|
| 410 |
+
╠═╬╣
|
| 411 |
+
║ ║║
|
| 412 |
+
╠═╬╣
|
| 413 |
+
╠═╬╣
|
| 414 |
+
║ ║║
|
| 415 |
+
╚═╩╝
|
| 416 |
+
"""
|
| 417 |
+
)
|
| 418 |
+
|
| 419 |
+
DOUBLE_EDGE: Box = Box(
|
| 420 |
+
"""\
|
| 421 |
+
╔═╤╗
|
| 422 |
+
║ │║
|
| 423 |
+
╟─┼╢
|
| 424 |
+
║ │║
|
| 425 |
+
╟─┼╢
|
| 426 |
+
╟─┼╢
|
| 427 |
+
║ │║
|
| 428 |
+
╚═╧╝
|
| 429 |
+
"""
|
| 430 |
+
)
|
| 431 |
+
|
| 432 |
+
MARKDOWN: Box = Box(
|
| 433 |
+
"""\
|
| 434 |
+
|
| 435 |
+
| ||
|
| 436 |
+
|-||
|
| 437 |
+
| ||
|
| 438 |
+
|-||
|
| 439 |
+
|-||
|
| 440 |
+
| ||
|
| 441 |
+
|
| 442 |
+
""",
|
| 443 |
+
ascii=True,
|
| 444 |
+
)
|
| 445 |
+
|
| 446 |
+
# Map Boxes that don't render with raster fonts on to equivalent that do
|
| 447 |
+
LEGACY_WINDOWS_SUBSTITUTIONS = {
|
| 448 |
+
ROUNDED: SQUARE,
|
| 449 |
+
MINIMAL_HEAVY_HEAD: MINIMAL,
|
| 450 |
+
SIMPLE_HEAVY: SIMPLE,
|
| 451 |
+
HEAVY: SQUARE,
|
| 452 |
+
HEAVY_EDGE: SQUARE,
|
| 453 |
+
HEAVY_HEAD: SQUARE,
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
# Map headed boxes to their headerless equivalents
|
| 457 |
+
PLAIN_HEADED_SUBSTITUTIONS = {
|
| 458 |
+
HEAVY_HEAD: SQUARE,
|
| 459 |
+
SQUARE_DOUBLE_HEAD: SQUARE,
|
| 460 |
+
MINIMAL_DOUBLE_HEAD: MINIMAL,
|
| 461 |
+
MINIMAL_HEAVY_HEAD: MINIMAL,
|
| 462 |
+
ASCII_DOUBLE_HEAD: ASCII2,
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
if __name__ == "__main__": # pragma: no cover
|
| 467 |
+
|
| 468 |
+
from pip._vendor.rich.columns import Columns
|
| 469 |
+
from pip._vendor.rich.panel import Panel
|
| 470 |
+
|
| 471 |
+
from . import box as box
|
| 472 |
+
from .console import Console
|
| 473 |
+
from .table import Table
|
| 474 |
+
from .text import Text
|
| 475 |
+
|
| 476 |
+
console = Console(record=True)
|
| 477 |
+
|
| 478 |
+
BOXES = [
|
| 479 |
+
"ASCII",
|
| 480 |
+
"ASCII2",
|
| 481 |
+
"ASCII_DOUBLE_HEAD",
|
| 482 |
+
"SQUARE",
|
| 483 |
+
"SQUARE_DOUBLE_HEAD",
|
| 484 |
+
"MINIMAL",
|
| 485 |
+
"MINIMAL_HEAVY_HEAD",
|
| 486 |
+
"MINIMAL_DOUBLE_HEAD",
|
| 487 |
+
"SIMPLE",
|
| 488 |
+
"SIMPLE_HEAD",
|
| 489 |
+
"SIMPLE_HEAVY",
|
| 490 |
+
"HORIZONTALS",
|
| 491 |
+
"ROUNDED",
|
| 492 |
+
"HEAVY",
|
| 493 |
+
"HEAVY_EDGE",
|
| 494 |
+
"HEAVY_HEAD",
|
| 495 |
+
"DOUBLE",
|
| 496 |
+
"DOUBLE_EDGE",
|
| 497 |
+
"MARKDOWN",
|
| 498 |
+
]
|
| 499 |
+
|
| 500 |
+
console.print(Panel("[bold green]Box Constants", style="green"), justify="center")
|
| 501 |
+
console.print()
|
| 502 |
+
|
| 503 |
+
columns = Columns(expand=True, padding=2)
|
| 504 |
+
for box_name in sorted(BOXES):
|
| 505 |
+
table = Table(
|
| 506 |
+
show_footer=True, style="dim", border_style="not dim", expand=True
|
| 507 |
+
)
|
| 508 |
+
table.add_column("Header 1", "Footer 1")
|
| 509 |
+
table.add_column("Header 2", "Footer 2")
|
| 510 |
+
table.add_row("Cell", "Cell")
|
| 511 |
+
table.add_row("Cell", "Cell")
|
| 512 |
+
table.box = getattr(box, box_name)
|
| 513 |
+
table.title = Text(f"box.{box_name}", style="magenta")
|
| 514 |
+
columns.add_renderable(table)
|
| 515 |
+
console.print(columns)
|
| 516 |
+
|
| 517 |
+
# console.save_svg("box.svg")
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/color.py
ADDED
|
@@ -0,0 +1,622 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import platform
|
| 2 |
+
import re
|
| 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 = platform.system() == "Windows"
|
| 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 |
+
|
| 596 |
+
from .console import Console
|
| 597 |
+
from .table import Table
|
| 598 |
+
from .text import Text
|
| 599 |
+
|
| 600 |
+
console = Console()
|
| 601 |
+
|
| 602 |
+
table = Table(show_footer=False, show_edge=True)
|
| 603 |
+
table.add_column("Color", width=10, overflow="ellipsis")
|
| 604 |
+
table.add_column("Number", justify="right", style="yellow")
|
| 605 |
+
table.add_column("Name", style="green")
|
| 606 |
+
table.add_column("Hex", style="blue")
|
| 607 |
+
table.add_column("RGB", style="magenta")
|
| 608 |
+
|
| 609 |
+
colors = sorted((v, k) for k, v in ANSI_COLOR_NAMES.items())
|
| 610 |
+
for color_number, name in colors:
|
| 611 |
+
if "grey" in name:
|
| 612 |
+
continue
|
| 613 |
+
color_cell = Text(" " * 10, style=f"on {name}")
|
| 614 |
+
if color_number < 16:
|
| 615 |
+
table.add_row(color_cell, f"{color_number}", Text(f'"{name}"'))
|
| 616 |
+
else:
|
| 617 |
+
color = EIGHT_BIT_PALETTE[color_number] # type: ignore[has-type]
|
| 618 |
+
table.add_row(
|
| 619 |
+
color_cell, str(color_number), Text(f'"{name}"'), color.hex, color.rgb
|
| 620 |
+
)
|
| 621 |
+
|
| 622 |
+
console.print(table)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/console.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/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
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/control.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 4 |
+
|
| 5 |
+
if sys.version_info >= (3, 8):
|
| 6 |
+
from typing import Final
|
| 7 |
+
else:
|
| 8 |
+
from pip._vendor.typing_extensions import Final # pragma: no cover
|
| 9 |
+
|
| 10 |
+
from .segment import ControlCode, ControlType, Segment
|
| 11 |
+
|
| 12 |
+
if TYPE_CHECKING:
|
| 13 |
+
from .console import Console, ConsoleOptions, RenderResult
|
| 14 |
+
|
| 15 |
+
STRIP_CONTROL_CODES: Final = [
|
| 16 |
+
7, # Bell
|
| 17 |
+
8, # Backspace
|
| 18 |
+
11, # Vertical tab
|
| 19 |
+
12, # Form feed
|
| 20 |
+
13, # Carriage return
|
| 21 |
+
]
|
| 22 |
+
_CONTROL_STRIP_TRANSLATE: Final = {
|
| 23 |
+
_codepoint: None for _codepoint in STRIP_CONTROL_CODES
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
CONTROL_ESCAPE: Final = {
|
| 27 |
+
7: "\\a",
|
| 28 |
+
8: "\\b",
|
| 29 |
+
11: "\\v",
|
| 30 |
+
12: "\\f",
|
| 31 |
+
13: "\\r",
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
CONTROL_CODES_FORMAT: Dict[int, Callable[..., str]] = {
|
| 35 |
+
ControlType.BELL: lambda: "\x07",
|
| 36 |
+
ControlType.CARRIAGE_RETURN: lambda: "\r",
|
| 37 |
+
ControlType.HOME: lambda: "\x1b[H",
|
| 38 |
+
ControlType.CLEAR: lambda: "\x1b[2J",
|
| 39 |
+
ControlType.ENABLE_ALT_SCREEN: lambda: "\x1b[?1049h",
|
| 40 |
+
ControlType.DISABLE_ALT_SCREEN: lambda: "\x1b[?1049l",
|
| 41 |
+
ControlType.SHOW_CURSOR: lambda: "\x1b[?25h",
|
| 42 |
+
ControlType.HIDE_CURSOR: lambda: "\x1b[?25l",
|
| 43 |
+
ControlType.CURSOR_UP: lambda param: f"\x1b[{param}A",
|
| 44 |
+
ControlType.CURSOR_DOWN: lambda param: f"\x1b[{param}B",
|
| 45 |
+
ControlType.CURSOR_FORWARD: lambda param: f"\x1b[{param}C",
|
| 46 |
+
ControlType.CURSOR_BACKWARD: lambda param: f"\x1b[{param}D",
|
| 47 |
+
ControlType.CURSOR_MOVE_TO_COLUMN: lambda param: f"\x1b[{param+1}G",
|
| 48 |
+
ControlType.ERASE_IN_LINE: lambda param: f"\x1b[{param}K",
|
| 49 |
+
ControlType.CURSOR_MOVE_TO: lambda x, y: f"\x1b[{y+1};{x+1}H",
|
| 50 |
+
ControlType.SET_WINDOW_TITLE: lambda title: f"\x1b]0;{title}\x07",
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class Control:
|
| 55 |
+
"""A renderable that inserts a control code (non printable but may move cursor).
|
| 56 |
+
|
| 57 |
+
Args:
|
| 58 |
+
*codes (str): Positional arguments are either a :class:`~rich.segment.ControlType` enum or a
|
| 59 |
+
tuple of ControlType and an integer parameter
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
__slots__ = ["segment"]
|
| 63 |
+
|
| 64 |
+
def __init__(self, *codes: Union[ControlType, ControlCode]) -> None:
|
| 65 |
+
control_codes: List[ControlCode] = [
|
| 66 |
+
(code,) if isinstance(code, ControlType) else code for code in codes
|
| 67 |
+
]
|
| 68 |
+
_format_map = CONTROL_CODES_FORMAT
|
| 69 |
+
rendered_codes = "".join(
|
| 70 |
+
_format_map[code](*parameters) for code, *parameters in control_codes
|
| 71 |
+
)
|
| 72 |
+
self.segment = Segment(rendered_codes, None, control_codes)
|
| 73 |
+
|
| 74 |
+
@classmethod
|
| 75 |
+
def bell(cls) -> "Control":
|
| 76 |
+
"""Ring the 'bell'."""
|
| 77 |
+
return cls(ControlType.BELL)
|
| 78 |
+
|
| 79 |
+
@classmethod
|
| 80 |
+
def home(cls) -> "Control":
|
| 81 |
+
"""Move cursor to 'home' position."""
|
| 82 |
+
return cls(ControlType.HOME)
|
| 83 |
+
|
| 84 |
+
@classmethod
|
| 85 |
+
def move(cls, x: int = 0, y: int = 0) -> "Control":
|
| 86 |
+
"""Move cursor relative to current position.
|
| 87 |
+
|
| 88 |
+
Args:
|
| 89 |
+
x (int): X offset.
|
| 90 |
+
y (int): Y offset.
|
| 91 |
+
|
| 92 |
+
Returns:
|
| 93 |
+
~Control: Control object.
|
| 94 |
+
|
| 95 |
+
"""
|
| 96 |
+
|
| 97 |
+
def get_codes() -> Iterable[ControlCode]:
|
| 98 |
+
control = ControlType
|
| 99 |
+
if x:
|
| 100 |
+
yield (
|
| 101 |
+
control.CURSOR_FORWARD if x > 0 else control.CURSOR_BACKWARD,
|
| 102 |
+
abs(x),
|
| 103 |
+
)
|
| 104 |
+
if y:
|
| 105 |
+
yield (
|
| 106 |
+
control.CURSOR_DOWN if y > 0 else control.CURSOR_UP,
|
| 107 |
+
abs(y),
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
control = cls(*get_codes())
|
| 111 |
+
return control
|
| 112 |
+
|
| 113 |
+
@classmethod
|
| 114 |
+
def move_to_column(cls, x: int, y: int = 0) -> "Control":
|
| 115 |
+
"""Move to the given column, optionally add offset to row.
|
| 116 |
+
|
| 117 |
+
Returns:
|
| 118 |
+
x (int): absolute x (column)
|
| 119 |
+
y (int): optional y offset (row)
|
| 120 |
+
|
| 121 |
+
Returns:
|
| 122 |
+
~Control: Control object.
|
| 123 |
+
"""
|
| 124 |
+
|
| 125 |
+
return (
|
| 126 |
+
cls(
|
| 127 |
+
(ControlType.CURSOR_MOVE_TO_COLUMN, x),
|
| 128 |
+
(
|
| 129 |
+
ControlType.CURSOR_DOWN if y > 0 else ControlType.CURSOR_UP,
|
| 130 |
+
abs(y),
|
| 131 |
+
),
|
| 132 |
+
)
|
| 133 |
+
if y
|
| 134 |
+
else cls((ControlType.CURSOR_MOVE_TO_COLUMN, x))
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
@classmethod
|
| 138 |
+
def move_to(cls, x: int, y: int) -> "Control":
|
| 139 |
+
"""Move cursor to absolute position.
|
| 140 |
+
|
| 141 |
+
Args:
|
| 142 |
+
x (int): x offset (column)
|
| 143 |
+
y (int): y offset (row)
|
| 144 |
+
|
| 145 |
+
Returns:
|
| 146 |
+
~Control: Control object.
|
| 147 |
+
"""
|
| 148 |
+
return cls((ControlType.CURSOR_MOVE_TO, x, y))
|
| 149 |
+
|
| 150 |
+
@classmethod
|
| 151 |
+
def clear(cls) -> "Control":
|
| 152 |
+
"""Clear the screen."""
|
| 153 |
+
return cls(ControlType.CLEAR)
|
| 154 |
+
|
| 155 |
+
@classmethod
|
| 156 |
+
def show_cursor(cls, show: bool) -> "Control":
|
| 157 |
+
"""Show or hide the cursor."""
|
| 158 |
+
return cls(ControlType.SHOW_CURSOR if show else ControlType.HIDE_CURSOR)
|
| 159 |
+
|
| 160 |
+
@classmethod
|
| 161 |
+
def alt_screen(cls, enable: bool) -> "Control":
|
| 162 |
+
"""Enable or disable alt screen."""
|
| 163 |
+
if enable:
|
| 164 |
+
return cls(ControlType.ENABLE_ALT_SCREEN, ControlType.HOME)
|
| 165 |
+
else:
|
| 166 |
+
return cls(ControlType.DISABLE_ALT_SCREEN)
|
| 167 |
+
|
| 168 |
+
@classmethod
|
| 169 |
+
def title(cls, title: str) -> "Control":
|
| 170 |
+
"""Set the terminal window title
|
| 171 |
+
|
| 172 |
+
Args:
|
| 173 |
+
title (str): The new terminal window title
|
| 174 |
+
"""
|
| 175 |
+
return cls((ControlType.SET_WINDOW_TITLE, title))
|
| 176 |
+
|
| 177 |
+
def __str__(self) -> str:
|
| 178 |
+
return self.segment.text
|
| 179 |
+
|
| 180 |
+
def __rich_console__(
|
| 181 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 182 |
+
) -> "RenderResult":
|
| 183 |
+
if self.segment.text:
|
| 184 |
+
yield self.segment
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def strip_control_codes(
|
| 188 |
+
text: str, _translate_table: Dict[int, None] = _CONTROL_STRIP_TRANSLATE
|
| 189 |
+
) -> str:
|
| 190 |
+
"""Remove control codes from text.
|
| 191 |
+
|
| 192 |
+
Args:
|
| 193 |
+
text (str): A string possibly contain control codes.
|
| 194 |
+
|
| 195 |
+
Returns:
|
| 196 |
+
str: String with control codes removed.
|
| 197 |
+
"""
|
| 198 |
+
return text.translate(_translate_table)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def escape_control_codes(
|
| 202 |
+
text: str,
|
| 203 |
+
_translate_table: Dict[int, str] = CONTROL_ESCAPE,
|
| 204 |
+
) -> str:
|
| 205 |
+
"""Replace control codes with their "escaped" equivalent in the given text.
|
| 206 |
+
(e.g. "\b" becomes "\\b")
|
| 207 |
+
|
| 208 |
+
Args:
|
| 209 |
+
text (str): A string possibly containing control codes.
|
| 210 |
+
|
| 211 |
+
Returns:
|
| 212 |
+
str: String with control codes replaced with their escaped version.
|
| 213 |
+
"""
|
| 214 |
+
return text.translate(_translate_table)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
if __name__ == "__main__": # pragma: no cover
|
| 218 |
+
from pip._vendor.rich.console import Console
|
| 219 |
+
|
| 220 |
+
console = Console()
|
| 221 |
+
console.print("Look at the title of your terminal window ^")
|
| 222 |
+
# console.print(Control((ControlType.SET_WINDOW_TITLE, "Hello, world!")))
|
| 223 |
+
for i in range(10):
|
| 224 |
+
console.set_window_title("🚀 Loading" + "." * i)
|
| 225 |
+
time.sleep(0.5)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/diagnose.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import platform
|
| 3 |
+
|
| 4 |
+
from pip._vendor.rich import inspect
|
| 5 |
+
from pip._vendor.rich.console import Console, get_windows_console_features
|
| 6 |
+
from pip._vendor.rich.panel import Panel
|
| 7 |
+
from pip._vendor.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 |
+
"TERM",
|
| 19 |
+
"COLORTERM",
|
| 20 |
+
"CLICOLOR",
|
| 21 |
+
"NO_COLOR",
|
| 22 |
+
"TERM_PROGRAM",
|
| 23 |
+
"COLUMNS",
|
| 24 |
+
"LINES",
|
| 25 |
+
"JUPYTER_COLUMNS",
|
| 26 |
+
"JUPYTER_LINES",
|
| 27 |
+
"JPY_PARENT_PID",
|
| 28 |
+
"VSCODE_VERBOSE_LOGGING",
|
| 29 |
+
)
|
| 30 |
+
env = {name: os.getenv(name) for name in env_names}
|
| 31 |
+
console.print(Panel.fit((Pretty(env)), title="[b]Environment Variables"))
|
| 32 |
+
|
| 33 |
+
console.print(f'platform="{platform.system()}"')
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
if __name__ == "__main__": # pragma: no cover
|
| 37 |
+
report()
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35/lib/python3.12/site-packages/pip/_vendor/rich/emoji.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from typing import TYPE_CHECKING, Optional, Union
|
| 3 |
+
|
| 4 |
+
from .jupyter import JupyterMixin
|
| 5 |
+
from .segment import Segment
|
| 6 |
+
from .style import Style
|
| 7 |
+
from ._emoji_codes import EMOJI
|
| 8 |
+
from ._emoji_replace import _emoji_replace
|
| 9 |
+
|
| 10 |
+
if sys.version_info >= (3, 8):
|
| 11 |
+
from typing import Literal
|
| 12 |
+
else:
|
| 13 |
+
from pip._vendor.typing_extensions import Literal # pragma: no cover
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
if TYPE_CHECKING:
|
| 17 |
+
from .console import Console, ConsoleOptions, RenderResult
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
EmojiVariant = Literal["emoji", "text"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class NoEmoji(Exception):
|
| 24 |
+
"""No emoji by that name."""
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class Emoji(JupyterMixin):
|
| 28 |
+
__slots__ = ["name", "style", "_char", "variant"]
|
| 29 |
+
|
| 30 |
+
VARIANTS = {"text": "\uFE0E", "emoji": "\uFE0F"}
|
| 31 |
+
|
| 32 |
+
def __init__(
|
| 33 |
+
self,
|
| 34 |
+
name: str,
|
| 35 |
+
style: Union[str, Style] = "none",
|
| 36 |
+
variant: Optional[EmojiVariant] = None,
|
| 37 |
+
) -> None:
|
| 38 |
+
"""A single emoji character.
|
| 39 |
+
|
| 40 |
+
Args:
|
| 41 |
+
name (str): Name of emoji.
|
| 42 |
+
style (Union[str, Style], optional): Optional style. Defaults to None.
|
| 43 |
+
|
| 44 |
+
Raises:
|
| 45 |
+
NoEmoji: If the emoji doesn't exist.
|
| 46 |
+
"""
|
| 47 |
+
self.name = name
|
| 48 |
+
self.style = style
|
| 49 |
+
self.variant = variant
|
| 50 |
+
try:
|
| 51 |
+
self._char = EMOJI[name]
|
| 52 |
+
except KeyError:
|
| 53 |
+
raise NoEmoji(f"No emoji called {name!r}")
|
| 54 |
+
if variant is not None:
|
| 55 |
+
self._char += self.VARIANTS.get(variant, "")
|
| 56 |
+
|
| 57 |
+
@classmethod
|
| 58 |
+
def replace(cls, text: str) -> str:
|
| 59 |
+
"""Replace emoji markup with corresponding unicode characters.
|
| 60 |
+
|
| 61 |
+
Args:
|
| 62 |
+
text (str): A string with emojis codes, e.g. "Hello :smiley:!"
|
| 63 |
+
|
| 64 |
+
Returns:
|
| 65 |
+
str: A string with emoji codes replaces with actual emoji.
|
| 66 |
+
"""
|
| 67 |
+
return _emoji_replace(text)
|
| 68 |
+
|
| 69 |
+
def __repr__(self) -> str:
|
| 70 |
+
return f"<emoji {self.name!r}>"
|
| 71 |
+
|
| 72 |
+
def __str__(self) -> str:
|
| 73 |
+
return self._char
|
| 74 |
+
|
| 75 |
+
def __rich_console__(
|
| 76 |
+
self, console: "Console", options: "ConsoleOptions"
|
| 77 |
+
) -> "RenderResult":
|
| 78 |
+
yield Segment(self._char, console.get_style(self.style))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__ == "__main__": # pragma: no cover
|
| 82 |
+
import sys
|
| 83 |
+
|
| 84 |
+
from pip._vendor.rich.columns import Columns
|
| 85 |
+
from pip._vendor.rich.console import Console
|
| 86 |
+
|
| 87 |
+
console = Console(record=True)
|
| 88 |
+
|
| 89 |
+
columns = Columns(
|
| 90 |
+
(f":{name}: {name}" for name in sorted(EMOJI.keys()) if "\u200D" not in name),
|
| 91 |
+
column_first=True,
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
console.print(columns)
|
| 95 |
+
if len(sys.argv) > 1:
|
| 96 |
+
console.save_html(sys.argv[1])
|