Add files using upload-large-folder tool
Browse files- LTA_openwebtext_dualt/logs/lta_lm1b_classic_dirichlet_len1024_gbs512_8gpu_20k_save1k_20260523.log +0 -0
- LTA_openwebtext_dualt/logs/lta_owt_fullycoupled_gpt2cached_mask1_rollin_p50_s4_i32_gbs512_8gpu_1m_20260517_205504.log +0 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/__init__.py +126 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/decorators.py +551 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/globals.py +67 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/shell_completion.py +680 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/testing.py +736 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/packaging/licenses/__init__.py +186 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/_mapping.py +54 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/arduino.py +100 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/coffee.py +80 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/dracula.py +90 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/gh_dark.py +113 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/lightbulb.py +110 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/nord.py +156 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/paraiso_light.py +124 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/stata_dark.py +42 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/stata_light.py +42 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/zenburn.py +83 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/cache/qwen36_35b_owt_worst20_rewrite/accepted.jsonl +20 -0
LTA_openwebtext_dualt/logs/lta_lm1b_classic_dirichlet_len1024_gbs512_8gpu_20k_save1k_20260523.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/logs/lta_owt_fullycoupled_gpt2cached_mask1_rollin_p50_s4_i32_gbs512_8gpu_1m_20260517_205504.log
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/__init__.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Click is a simple Python module inspired by the stdlib optparse to make
|
| 3 |
+
writing command line scripts fun. Unlike other modules, it's based
|
| 4 |
+
around a simple API that does not come with too much magic and is
|
| 5 |
+
composable.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
from .core import Argument as Argument
|
| 11 |
+
from .core import Command as Command
|
| 12 |
+
from .core import CommandCollection as CommandCollection
|
| 13 |
+
from .core import Context as Context
|
| 14 |
+
from .core import Group as Group
|
| 15 |
+
from .core import Option as Option
|
| 16 |
+
from .core import Parameter as Parameter
|
| 17 |
+
from .core import ParameterSource as ParameterSource
|
| 18 |
+
from .decorators import argument as argument
|
| 19 |
+
from .decorators import command as command
|
| 20 |
+
from .decorators import confirmation_option as confirmation_option
|
| 21 |
+
from .decorators import group as group
|
| 22 |
+
from .decorators import help_option as help_option
|
| 23 |
+
from .decorators import make_pass_decorator as make_pass_decorator
|
| 24 |
+
from .decorators import option as option
|
| 25 |
+
from .decorators import pass_context as pass_context
|
| 26 |
+
from .decorators import pass_obj as pass_obj
|
| 27 |
+
from .decorators import password_option as password_option
|
| 28 |
+
from .decorators import version_option as version_option
|
| 29 |
+
from .exceptions import Abort as Abort
|
| 30 |
+
from .exceptions import BadArgumentUsage as BadArgumentUsage
|
| 31 |
+
from .exceptions import BadOptionUsage as BadOptionUsage
|
| 32 |
+
from .exceptions import BadParameter as BadParameter
|
| 33 |
+
from .exceptions import ClickException as ClickException
|
| 34 |
+
from .exceptions import FileError as FileError
|
| 35 |
+
from .exceptions import MissingParameter as MissingParameter
|
| 36 |
+
from .exceptions import NoSuchCommand as NoSuchCommand
|
| 37 |
+
from .exceptions import NoSuchOption as NoSuchOption
|
| 38 |
+
from .exceptions import UsageError as UsageError
|
| 39 |
+
from .formatting import HelpFormatter as HelpFormatter
|
| 40 |
+
from .formatting import wrap_text as wrap_text
|
| 41 |
+
from .globals import get_current_context as get_current_context
|
| 42 |
+
from .termui import clear as clear
|
| 43 |
+
from .termui import confirm as confirm
|
| 44 |
+
from .termui import echo_via_pager as echo_via_pager
|
| 45 |
+
from .termui import edit as edit
|
| 46 |
+
from .termui import get_pager_file as get_pager_file
|
| 47 |
+
from .termui import getchar as getchar
|
| 48 |
+
from .termui import launch as launch
|
| 49 |
+
from .termui import pause as pause
|
| 50 |
+
from .termui import progressbar as progressbar
|
| 51 |
+
from .termui import prompt as prompt
|
| 52 |
+
from .termui import secho as secho
|
| 53 |
+
from .termui import style as style
|
| 54 |
+
from .termui import unstyle as unstyle
|
| 55 |
+
from .types import BOOL as BOOL
|
| 56 |
+
from .types import Choice as Choice
|
| 57 |
+
from .types import DateTime as DateTime
|
| 58 |
+
from .types import File as File
|
| 59 |
+
from .types import FLOAT as FLOAT
|
| 60 |
+
from .types import FloatRange as FloatRange
|
| 61 |
+
from .types import INT as INT
|
| 62 |
+
from .types import IntRange as IntRange
|
| 63 |
+
from .types import ParamType as ParamType
|
| 64 |
+
from .types import Path as Path
|
| 65 |
+
from .types import STRING as STRING
|
| 66 |
+
from .types import Tuple as Tuple
|
| 67 |
+
from .types import UNPROCESSED as UNPROCESSED
|
| 68 |
+
from .types import UUID as UUID
|
| 69 |
+
from .utils import echo as echo
|
| 70 |
+
from .utils import format_filename as format_filename
|
| 71 |
+
from .utils import get_app_dir as get_app_dir
|
| 72 |
+
from .utils import get_binary_stream as get_binary_stream
|
| 73 |
+
from .utils import get_text_stream as get_text_stream
|
| 74 |
+
from .utils import open_file as open_file
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def __getattr__(name: str) -> object:
|
| 78 |
+
import warnings
|
| 79 |
+
|
| 80 |
+
if name == "BaseCommand":
|
| 81 |
+
from .core import _BaseCommand
|
| 82 |
+
|
| 83 |
+
warnings.warn(
|
| 84 |
+
"'BaseCommand' is deprecated and will be removed in Click 9.0. Use"
|
| 85 |
+
" 'Command' instead.",
|
| 86 |
+
DeprecationWarning,
|
| 87 |
+
stacklevel=2,
|
| 88 |
+
)
|
| 89 |
+
return _BaseCommand
|
| 90 |
+
|
| 91 |
+
if name == "MultiCommand":
|
| 92 |
+
from .core import _MultiCommand
|
| 93 |
+
|
| 94 |
+
warnings.warn(
|
| 95 |
+
"'MultiCommand' is deprecated and will be removed in Click 9.0. Use"
|
| 96 |
+
" 'Group' instead.",
|
| 97 |
+
DeprecationWarning,
|
| 98 |
+
stacklevel=2,
|
| 99 |
+
)
|
| 100 |
+
return _MultiCommand
|
| 101 |
+
|
| 102 |
+
if name == "OptionParser":
|
| 103 |
+
from .parser import _OptionParser
|
| 104 |
+
|
| 105 |
+
warnings.warn(
|
| 106 |
+
"'OptionParser' is deprecated and will be removed in Click 9.0. The"
|
| 107 |
+
" old parser is available in 'optparse'.",
|
| 108 |
+
DeprecationWarning,
|
| 109 |
+
stacklevel=2,
|
| 110 |
+
)
|
| 111 |
+
return _OptionParser
|
| 112 |
+
|
| 113 |
+
if name == "__version__":
|
| 114 |
+
import importlib.metadata
|
| 115 |
+
import warnings
|
| 116 |
+
|
| 117 |
+
warnings.warn(
|
| 118 |
+
"The '__version__' attribute is deprecated and will be removed in"
|
| 119 |
+
" Click 9.1. Use feature detection or"
|
| 120 |
+
" 'importlib.metadata.version(\"click\")' instead.",
|
| 121 |
+
DeprecationWarning,
|
| 122 |
+
stacklevel=2,
|
| 123 |
+
)
|
| 124 |
+
return importlib.metadata.version("click")
|
| 125 |
+
|
| 126 |
+
raise AttributeError(name)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/decorators.py
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import inspect
|
| 4 |
+
import typing as t
|
| 5 |
+
from functools import update_wrapper
|
| 6 |
+
from gettext import gettext as _
|
| 7 |
+
|
| 8 |
+
from .core import Argument
|
| 9 |
+
from .core import Command
|
| 10 |
+
from .core import Context
|
| 11 |
+
from .core import Group
|
| 12 |
+
from .core import Option
|
| 13 |
+
from .core import Parameter
|
| 14 |
+
from .globals import get_current_context
|
| 15 |
+
from .utils import echo
|
| 16 |
+
|
| 17 |
+
if t.TYPE_CHECKING:
|
| 18 |
+
import typing_extensions as te
|
| 19 |
+
|
| 20 |
+
P = te.ParamSpec("P")
|
| 21 |
+
|
| 22 |
+
R = t.TypeVar("R")
|
| 23 |
+
T = t.TypeVar("T")
|
| 24 |
+
_AnyCallable = t.Callable[..., t.Any]
|
| 25 |
+
FC = t.TypeVar("FC", bound="_AnyCallable | Command")
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def pass_context(f: t.Callable[te.Concatenate[Context, P], R]) -> t.Callable[P, R]:
|
| 29 |
+
"""Marks a callback as wanting to receive the current context
|
| 30 |
+
object as first argument.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
|
| 34 |
+
return f(get_current_context(), *args, **kwargs)
|
| 35 |
+
|
| 36 |
+
return update_wrapper(new_func, f)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def pass_obj(f: t.Callable[te.Concatenate[T, P], R]) -> t.Callable[P, R]:
|
| 40 |
+
"""Similar to :func:`pass_context`, but only pass the object on the
|
| 41 |
+
context onwards (:attr:`Context.obj`). This is useful if that object
|
| 42 |
+
represents the state of a nested system.
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
|
| 46 |
+
return f(get_current_context().obj, *args, **kwargs)
|
| 47 |
+
|
| 48 |
+
return update_wrapper(new_func, f)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def make_pass_decorator(
|
| 52 |
+
object_type: type[T], ensure: bool = False
|
| 53 |
+
) -> t.Callable[[t.Callable[te.Concatenate[T, P], R]], t.Callable[P, R]]:
|
| 54 |
+
"""Given an object type this creates a decorator that will work
|
| 55 |
+
similar to :func:`pass_obj` but instead of passing the object of the
|
| 56 |
+
current context, it will find the innermost context of type
|
| 57 |
+
:func:`object_type`.
|
| 58 |
+
|
| 59 |
+
This generates a decorator that works roughly like this::
|
| 60 |
+
|
| 61 |
+
from functools import update_wrapper
|
| 62 |
+
|
| 63 |
+
def decorator(f):
|
| 64 |
+
@pass_context
|
| 65 |
+
def new_func(ctx, *args, **kwargs):
|
| 66 |
+
obj = ctx.find_object(object_type)
|
| 67 |
+
return ctx.invoke(f, obj, *args, **kwargs)
|
| 68 |
+
return update_wrapper(new_func, f)
|
| 69 |
+
return decorator
|
| 70 |
+
|
| 71 |
+
:param object_type: the type of the object to pass.
|
| 72 |
+
:param ensure: if set to `True`, a new object will be created and
|
| 73 |
+
remembered on the context if it's not there yet.
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
def decorator(f: t.Callable[te.Concatenate[T, P], R]) -> t.Callable[P, R]:
|
| 77 |
+
def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
|
| 78 |
+
ctx = get_current_context()
|
| 79 |
+
|
| 80 |
+
obj: T | None
|
| 81 |
+
if ensure:
|
| 82 |
+
obj = ctx.ensure_object(object_type)
|
| 83 |
+
else:
|
| 84 |
+
obj = ctx.find_object(object_type)
|
| 85 |
+
|
| 86 |
+
if obj is None:
|
| 87 |
+
raise RuntimeError(
|
| 88 |
+
"Managed to invoke callback without a context"
|
| 89 |
+
f" object of type {object_type.__name__!r}"
|
| 90 |
+
" existing."
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
return ctx.invoke(f, obj, *args, **kwargs)
|
| 94 |
+
|
| 95 |
+
return update_wrapper(new_func, f)
|
| 96 |
+
|
| 97 |
+
return decorator
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def pass_meta_key(
|
| 101 |
+
key: str, *, doc_description: str | None = None
|
| 102 |
+
) -> t.Callable[[t.Callable[te.Concatenate[T, P], R]], t.Callable[P, R]]:
|
| 103 |
+
"""Create a decorator that passes a key from
|
| 104 |
+
:attr:`click.Context.meta` as the first argument to the decorated
|
| 105 |
+
function.
|
| 106 |
+
|
| 107 |
+
:param key: Key in ``Context.meta`` to pass.
|
| 108 |
+
:param doc_description: Description of the object being passed,
|
| 109 |
+
inserted into the decorator's docstring. Defaults to "the 'key'
|
| 110 |
+
key from Context.meta".
|
| 111 |
+
|
| 112 |
+
.. versionadded:: 8.0
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
def decorator(f: t.Callable[te.Concatenate[T, P], R]) -> t.Callable[P, R]:
|
| 116 |
+
def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
|
| 117 |
+
ctx = get_current_context()
|
| 118 |
+
obj = ctx.meta[key]
|
| 119 |
+
return ctx.invoke(f, obj, *args, **kwargs)
|
| 120 |
+
|
| 121 |
+
return update_wrapper(new_func, f)
|
| 122 |
+
|
| 123 |
+
if doc_description is None:
|
| 124 |
+
doc_description = f"the {key!r} key from :attr:`click.Context.meta`"
|
| 125 |
+
|
| 126 |
+
decorator.__doc__ = (
|
| 127 |
+
f"Decorator that passes {doc_description} as the first argument"
|
| 128 |
+
" to the decorated function."
|
| 129 |
+
)
|
| 130 |
+
return decorator
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
CmdType = t.TypeVar("CmdType", bound=Command)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
# variant: no call, directly as decorator for a function.
|
| 137 |
+
@t.overload
|
| 138 |
+
def command(name: _AnyCallable) -> Command: ...
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
# variant: with positional name and with positional or keyword cls argument:
|
| 142 |
+
# @command(namearg, CommandCls, ...) or @command(namearg, cls=CommandCls, ...)
|
| 143 |
+
@t.overload
|
| 144 |
+
def command(
|
| 145 |
+
name: str | None,
|
| 146 |
+
cls: type[CmdType],
|
| 147 |
+
**attrs: t.Any,
|
| 148 |
+
) -> t.Callable[[_AnyCallable], CmdType]: ...
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
# variant: name omitted, cls _must_ be a keyword argument, @command(cls=CommandCls, ...)
|
| 152 |
+
@t.overload
|
| 153 |
+
def command(
|
| 154 |
+
name: None = None,
|
| 155 |
+
*,
|
| 156 |
+
cls: type[CmdType],
|
| 157 |
+
**attrs: t.Any,
|
| 158 |
+
) -> t.Callable[[_AnyCallable], CmdType]: ...
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# variant: with optional string name, no cls argument provided.
|
| 162 |
+
@t.overload
|
| 163 |
+
def command(
|
| 164 |
+
name: str | None = ..., cls: None = None, **attrs: t.Any
|
| 165 |
+
) -> t.Callable[[_AnyCallable], Command]: ...
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def command(
|
| 169 |
+
name: str | _AnyCallable | None = None,
|
| 170 |
+
cls: type[CmdType] | None = None,
|
| 171 |
+
**attrs: t.Any,
|
| 172 |
+
) -> Command | t.Callable[[_AnyCallable], Command | CmdType]:
|
| 173 |
+
r"""Creates a new :class:`Command` and uses the decorated function as
|
| 174 |
+
callback. This will also automatically attach all decorated
|
| 175 |
+
:func:`option`\s and :func:`argument`\s as parameters to the command.
|
| 176 |
+
|
| 177 |
+
The name of the command defaults to the name of the function, converted to
|
| 178 |
+
lowercase, with underscores ``_`` replaced by dashes ``-``, and the suffixes
|
| 179 |
+
``_command``, ``_cmd``, ``_group``, and ``_grp`` are removed. For example,
|
| 180 |
+
``init_data_command`` becomes ``init-data``.
|
| 181 |
+
|
| 182 |
+
All keyword arguments are forwarded to the underlying command class.
|
| 183 |
+
For the ``params`` argument, any decorated params are appended to
|
| 184 |
+
the end of the list.
|
| 185 |
+
|
| 186 |
+
Once decorated the function turns into a :class:`Command` instance
|
| 187 |
+
that can be invoked as a command line utility or be attached to a
|
| 188 |
+
command :class:`Group`.
|
| 189 |
+
|
| 190 |
+
:param name: The name of the command. Defaults to modifying the function's
|
| 191 |
+
name as described above.
|
| 192 |
+
:param cls: The command class to create. Defaults to :class:`Command`.
|
| 193 |
+
|
| 194 |
+
.. versionchanged:: 8.2
|
| 195 |
+
The suffixes ``_command``, ``_cmd``, ``_group``, and ``_grp`` are
|
| 196 |
+
removed when generating the name.
|
| 197 |
+
|
| 198 |
+
.. versionchanged:: 8.1
|
| 199 |
+
This decorator can be applied without parentheses.
|
| 200 |
+
|
| 201 |
+
.. versionchanged:: 8.1
|
| 202 |
+
The ``params`` argument can be used. Decorated params are
|
| 203 |
+
appended to the end of the list.
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
func: t.Callable[[_AnyCallable], t.Any] | None = None
|
| 207 |
+
|
| 208 |
+
if callable(name):
|
| 209 |
+
func = name
|
| 210 |
+
name = None
|
| 211 |
+
assert cls is None, "Use 'command(cls=cls)(callable)' to specify a class."
|
| 212 |
+
assert not attrs, "Use 'command(**kwargs)(callable)' to provide arguments."
|
| 213 |
+
|
| 214 |
+
if cls is None:
|
| 215 |
+
cls = t.cast("type[CmdType]", Command)
|
| 216 |
+
|
| 217 |
+
def decorator(f: _AnyCallable) -> CmdType:
|
| 218 |
+
if isinstance(f, Command):
|
| 219 |
+
raise TypeError("Attempted to convert a callback into a command twice.")
|
| 220 |
+
|
| 221 |
+
attr_params = attrs.pop("params", None)
|
| 222 |
+
params = attr_params if attr_params is not None else []
|
| 223 |
+
|
| 224 |
+
try:
|
| 225 |
+
decorator_params = f.__click_params__ # type: ignore
|
| 226 |
+
except AttributeError:
|
| 227 |
+
pass
|
| 228 |
+
else:
|
| 229 |
+
del f.__click_params__ # type: ignore
|
| 230 |
+
params.extend(reversed(decorator_params))
|
| 231 |
+
|
| 232 |
+
if attrs.get("help") is None:
|
| 233 |
+
attrs["help"] = f.__doc__
|
| 234 |
+
|
| 235 |
+
if t.TYPE_CHECKING:
|
| 236 |
+
assert cls is not None
|
| 237 |
+
assert not callable(name)
|
| 238 |
+
|
| 239 |
+
if name is not None:
|
| 240 |
+
cmd_name = name
|
| 241 |
+
else:
|
| 242 |
+
cmd_name = f.__name__.lower().replace("_", "-")
|
| 243 |
+
cmd_left, sep, suffix = cmd_name.rpartition("-")
|
| 244 |
+
|
| 245 |
+
if sep and suffix in {"command", "cmd", "group", "grp"}:
|
| 246 |
+
cmd_name = cmd_left
|
| 247 |
+
|
| 248 |
+
cmd = cls(name=cmd_name, callback=f, params=params, **attrs)
|
| 249 |
+
cmd.__doc__ = f.__doc__
|
| 250 |
+
return cmd
|
| 251 |
+
|
| 252 |
+
if func is not None:
|
| 253 |
+
return decorator(func)
|
| 254 |
+
|
| 255 |
+
return decorator
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
GrpType = t.TypeVar("GrpType", bound=Group)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
# variant: no call, directly as decorator for a function.
|
| 262 |
+
@t.overload
|
| 263 |
+
def group(name: _AnyCallable) -> Group: ...
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
# variant: with positional name and with positional or keyword cls argument:
|
| 267 |
+
# @group(namearg, GroupCls, ...) or @group(namearg, cls=GroupCls, ...)
|
| 268 |
+
@t.overload
|
| 269 |
+
def group(
|
| 270 |
+
name: str | None,
|
| 271 |
+
cls: type[GrpType],
|
| 272 |
+
**attrs: t.Any,
|
| 273 |
+
) -> t.Callable[[_AnyCallable], GrpType]: ...
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# variant: name omitted, cls _must_ be a keyword argument, @group(cmd=GroupCls, ...)
|
| 277 |
+
@t.overload
|
| 278 |
+
def group(
|
| 279 |
+
name: None = None,
|
| 280 |
+
*,
|
| 281 |
+
cls: type[GrpType],
|
| 282 |
+
**attrs: t.Any,
|
| 283 |
+
) -> t.Callable[[_AnyCallable], GrpType]: ...
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# variant: with optional string name, no cls argument provided.
|
| 287 |
+
@t.overload
|
| 288 |
+
def group(
|
| 289 |
+
name: str | None = ..., cls: None = None, **attrs: t.Any
|
| 290 |
+
) -> t.Callable[[_AnyCallable], Group]: ...
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def group(
|
| 294 |
+
name: str | _AnyCallable | None = None,
|
| 295 |
+
cls: type[GrpType] | None = None,
|
| 296 |
+
**attrs: t.Any,
|
| 297 |
+
) -> Group | t.Callable[[_AnyCallable], Group | GrpType]:
|
| 298 |
+
"""Creates a new :class:`Group` with a function as callback. This
|
| 299 |
+
works otherwise the same as :func:`command` just that the `cls`
|
| 300 |
+
parameter is set to :class:`Group`.
|
| 301 |
+
|
| 302 |
+
.. versionchanged:: 8.1
|
| 303 |
+
This decorator can be applied without parentheses.
|
| 304 |
+
"""
|
| 305 |
+
if cls is None:
|
| 306 |
+
cls = t.cast("type[GrpType]", Group)
|
| 307 |
+
|
| 308 |
+
if callable(name):
|
| 309 |
+
return command(cls=cls, **attrs)(name)
|
| 310 |
+
|
| 311 |
+
return command(name, cls, **attrs)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def _param_memo(f: t.Callable[..., t.Any], param: Parameter) -> None:
|
| 315 |
+
if isinstance(f, Command):
|
| 316 |
+
f.params.append(param)
|
| 317 |
+
else:
|
| 318 |
+
if not hasattr(f, "__click_params__"):
|
| 319 |
+
f.__click_params__ = [] # type: ignore
|
| 320 |
+
|
| 321 |
+
f.__click_params__.append(param) # type: ignore
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
def argument(
|
| 325 |
+
*param_decls: str, cls: type[Argument] | None = None, **attrs: t.Any
|
| 326 |
+
) -> t.Callable[[FC], FC]:
|
| 327 |
+
"""Attaches an argument to the command. All positional arguments are
|
| 328 |
+
passed as parameter declarations to :class:`Argument`; all keyword
|
| 329 |
+
arguments are forwarded unchanged (except ``cls``).
|
| 330 |
+
This is equivalent to creating an :class:`Argument` instance manually
|
| 331 |
+
and attaching it to the :attr:`Command.params` list.
|
| 332 |
+
|
| 333 |
+
For the default argument class, refer to :class:`Argument` and
|
| 334 |
+
:class:`Parameter` for descriptions of parameters.
|
| 335 |
+
|
| 336 |
+
:param cls: the argument class to instantiate. This defaults to
|
| 337 |
+
:class:`Argument`.
|
| 338 |
+
:param param_decls: Passed as positional arguments to the constructor of
|
| 339 |
+
``cls``.
|
| 340 |
+
:param attrs: Passed as keyword arguments to the constructor of ``cls``.
|
| 341 |
+
"""
|
| 342 |
+
if cls is None:
|
| 343 |
+
cls = Argument
|
| 344 |
+
|
| 345 |
+
def decorator(f: FC) -> FC:
|
| 346 |
+
_param_memo(f, cls(param_decls, **attrs))
|
| 347 |
+
return f
|
| 348 |
+
|
| 349 |
+
return decorator
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
def option(
|
| 353 |
+
*param_decls: str, cls: type[Option] | None = None, **attrs: t.Any
|
| 354 |
+
) -> t.Callable[[FC], FC]:
|
| 355 |
+
"""Attaches an option to the command. All positional arguments are
|
| 356 |
+
passed as parameter declarations to :class:`Option`; all keyword
|
| 357 |
+
arguments are forwarded unchanged (except ``cls``).
|
| 358 |
+
This is equivalent to creating an :class:`Option` instance manually
|
| 359 |
+
and attaching it to the :attr:`Command.params` list.
|
| 360 |
+
|
| 361 |
+
For the default option class, refer to :class:`Option` and
|
| 362 |
+
:class:`Parameter` for descriptions of parameters.
|
| 363 |
+
|
| 364 |
+
:param cls: the option class to instantiate. This defaults to
|
| 365 |
+
:class:`Option`.
|
| 366 |
+
:param param_decls: Passed as positional arguments to the constructor of
|
| 367 |
+
``cls``.
|
| 368 |
+
:param attrs: Passed as keyword arguments to the constructor of ``cls``.
|
| 369 |
+
"""
|
| 370 |
+
if cls is None:
|
| 371 |
+
cls = Option
|
| 372 |
+
|
| 373 |
+
def decorator(f: FC) -> FC:
|
| 374 |
+
_param_memo(f, cls(param_decls, **attrs))
|
| 375 |
+
return f
|
| 376 |
+
|
| 377 |
+
return decorator
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def confirmation_option(*param_decls: str, **kwargs: t.Any) -> t.Callable[[FC], FC]:
|
| 381 |
+
"""Add a ``--yes`` option which shows a prompt before continuing if
|
| 382 |
+
not passed. If the prompt is declined, the program will exit.
|
| 383 |
+
|
| 384 |
+
:param param_decls: One or more option names. Defaults to the single
|
| 385 |
+
value ``"--yes"``.
|
| 386 |
+
:param kwargs: Extra arguments are passed to :func:`option`.
|
| 387 |
+
"""
|
| 388 |
+
|
| 389 |
+
def callback(ctx: Context, param: Parameter, value: bool) -> None:
|
| 390 |
+
if not value:
|
| 391 |
+
ctx.abort()
|
| 392 |
+
|
| 393 |
+
if not param_decls:
|
| 394 |
+
param_decls = ("--yes",)
|
| 395 |
+
|
| 396 |
+
kwargs.setdefault("is_flag", True)
|
| 397 |
+
kwargs.setdefault("callback", callback)
|
| 398 |
+
kwargs.setdefault("expose_value", False)
|
| 399 |
+
kwargs.setdefault("prompt", _("Do you want to continue?"))
|
| 400 |
+
kwargs.setdefault("help", _("Confirm the action without prompting."))
|
| 401 |
+
return option(*param_decls, **kwargs)
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
def password_option(*param_decls: str, **kwargs: t.Any) -> t.Callable[[FC], FC]:
|
| 405 |
+
"""Add a ``--password`` option which prompts for a password, hiding
|
| 406 |
+
input and asking to enter the value again for confirmation.
|
| 407 |
+
|
| 408 |
+
:param param_decls: One or more option names. Defaults to the single
|
| 409 |
+
value ``"--password"``.
|
| 410 |
+
:param kwargs: Extra arguments are passed to :func:`option`.
|
| 411 |
+
"""
|
| 412 |
+
if not param_decls:
|
| 413 |
+
param_decls = ("--password",)
|
| 414 |
+
|
| 415 |
+
kwargs.setdefault("prompt", True)
|
| 416 |
+
kwargs.setdefault("confirmation_prompt", True)
|
| 417 |
+
kwargs.setdefault("hide_input", True)
|
| 418 |
+
return option(*param_decls, **kwargs)
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
def version_option(
|
| 422 |
+
version: str | None = None,
|
| 423 |
+
*param_decls: str,
|
| 424 |
+
package_name: str | None = None,
|
| 425 |
+
prog_name: str | None = None,
|
| 426 |
+
message: str | None = None,
|
| 427 |
+
**kwargs: t.Any,
|
| 428 |
+
) -> t.Callable[[FC], FC]:
|
| 429 |
+
"""Add a ``--version`` option which immediately prints the version
|
| 430 |
+
number and exits the program.
|
| 431 |
+
|
| 432 |
+
If ``version`` is not provided, Click will try to detect it using
|
| 433 |
+
:func:`importlib.metadata.version` to get the version for the
|
| 434 |
+
``package_name``.
|
| 435 |
+
|
| 436 |
+
If ``package_name`` is not provided, Click will try to detect it by
|
| 437 |
+
inspecting the stack frames. This will be used to detect the
|
| 438 |
+
version, so it must match the name of the installed package.
|
| 439 |
+
|
| 440 |
+
:param version: The version number to show. If not provided, Click
|
| 441 |
+
will try to detect it.
|
| 442 |
+
:param param_decls: One or more option names. Defaults to the single
|
| 443 |
+
value ``"--version"``.
|
| 444 |
+
:param package_name: The package name to detect the version from. If
|
| 445 |
+
not provided, Click will try to detect it.
|
| 446 |
+
:param prog_name: The name of the CLI to show in the message. If not
|
| 447 |
+
provided, it will be detected from the command.
|
| 448 |
+
:param message: The message to show. The values ``%(prog)s``,
|
| 449 |
+
``%(package)s``, and ``%(version)s`` are available. Defaults to
|
| 450 |
+
``"%(prog)s, version %(version)s"``.
|
| 451 |
+
:param kwargs: Extra arguments are passed to :func:`option`.
|
| 452 |
+
:raise RuntimeError: ``version`` could not be detected.
|
| 453 |
+
|
| 454 |
+
.. versionchanged:: 8.0
|
| 455 |
+
Add the ``package_name`` parameter, and the ``%(package)s``
|
| 456 |
+
value for messages.
|
| 457 |
+
|
| 458 |
+
.. versionchanged:: 8.0
|
| 459 |
+
Use :mod:`importlib.metadata` instead of ``pkg_resources``. The
|
| 460 |
+
version is detected based on the package name, not the entry
|
| 461 |
+
point name. The Python package name must match the installed
|
| 462 |
+
package name, or be passed with ``package_name=``.
|
| 463 |
+
"""
|
| 464 |
+
if message is None:
|
| 465 |
+
message = _("%(prog)s, version %(version)s")
|
| 466 |
+
|
| 467 |
+
if version is None and package_name is None:
|
| 468 |
+
frame = inspect.currentframe()
|
| 469 |
+
f_back = frame.f_back if frame is not None else None
|
| 470 |
+
f_globals = f_back.f_globals if f_back is not None else None
|
| 471 |
+
# break reference cycle
|
| 472 |
+
# https://docs.python.org/3/library/inspect.html#the-interpreter-stack
|
| 473 |
+
del frame
|
| 474 |
+
|
| 475 |
+
if f_globals is not None:
|
| 476 |
+
package_name = f_globals.get("__name__")
|
| 477 |
+
|
| 478 |
+
if package_name == "__main__":
|
| 479 |
+
package_name = f_globals.get("__package__")
|
| 480 |
+
|
| 481 |
+
if package_name:
|
| 482 |
+
package_name = package_name.partition(".")[0]
|
| 483 |
+
|
| 484 |
+
def callback(ctx: Context, param: Parameter, value: bool) -> None:
|
| 485 |
+
if not value or ctx.resilient_parsing:
|
| 486 |
+
return
|
| 487 |
+
|
| 488 |
+
nonlocal prog_name
|
| 489 |
+
nonlocal version
|
| 490 |
+
|
| 491 |
+
if prog_name is None:
|
| 492 |
+
prog_name = ctx.find_root().info_name
|
| 493 |
+
|
| 494 |
+
if version is None and package_name is not None:
|
| 495 |
+
import importlib.metadata
|
| 496 |
+
|
| 497 |
+
try:
|
| 498 |
+
version = importlib.metadata.version(package_name)
|
| 499 |
+
except importlib.metadata.PackageNotFoundError:
|
| 500 |
+
raise RuntimeError(
|
| 501 |
+
f"{package_name!r} is not installed. Try passing"
|
| 502 |
+
" 'package_name' instead."
|
| 503 |
+
) from None
|
| 504 |
+
|
| 505 |
+
if version is None:
|
| 506 |
+
raise RuntimeError(
|
| 507 |
+
f"Could not determine the version for {package_name!r} automatically."
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
echo(
|
| 511 |
+
message % {"prog": prog_name, "package": package_name, "version": version},
|
| 512 |
+
color=ctx.color,
|
| 513 |
+
)
|
| 514 |
+
ctx.exit()
|
| 515 |
+
|
| 516 |
+
if not param_decls:
|
| 517 |
+
param_decls = ("--version",)
|
| 518 |
+
|
| 519 |
+
kwargs.setdefault("is_flag", True)
|
| 520 |
+
kwargs.setdefault("expose_value", False)
|
| 521 |
+
kwargs.setdefault("is_eager", True)
|
| 522 |
+
kwargs.setdefault("help", _("Show the version and exit."))
|
| 523 |
+
kwargs["callback"] = callback
|
| 524 |
+
return option(*param_decls, **kwargs)
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
def help_option(*param_decls: str, **kwargs: t.Any) -> t.Callable[[FC], FC]:
|
| 528 |
+
"""Pre-configured ``--help`` option which immediately prints the help page
|
| 529 |
+
and exits the program.
|
| 530 |
+
|
| 531 |
+
:param param_decls: One or more option names. Defaults to the single
|
| 532 |
+
value ``"--help"``.
|
| 533 |
+
:param kwargs: Extra arguments are passed to :func:`option`.
|
| 534 |
+
"""
|
| 535 |
+
|
| 536 |
+
def show_help(ctx: Context, param: Parameter, value: bool) -> None:
|
| 537 |
+
"""Callback that print the help page on ``<stdout>`` and exits."""
|
| 538 |
+
if value and not ctx.resilient_parsing:
|
| 539 |
+
echo(ctx.get_help(), color=ctx.color)
|
| 540 |
+
ctx.exit()
|
| 541 |
+
|
| 542 |
+
if not param_decls:
|
| 543 |
+
param_decls = ("--help",)
|
| 544 |
+
|
| 545 |
+
kwargs.setdefault("is_flag", True)
|
| 546 |
+
kwargs.setdefault("expose_value", False)
|
| 547 |
+
kwargs.setdefault("is_eager", True)
|
| 548 |
+
kwargs.setdefault("help", _("Show this message and exit."))
|
| 549 |
+
kwargs.setdefault("callback", show_help)
|
| 550 |
+
|
| 551 |
+
return option(*param_decls, **kwargs)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/globals.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import typing as t
|
| 4 |
+
from threading import local
|
| 5 |
+
|
| 6 |
+
if t.TYPE_CHECKING:
|
| 7 |
+
from .core import Context
|
| 8 |
+
|
| 9 |
+
_local = local()
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@t.overload
|
| 13 |
+
def get_current_context(silent: t.Literal[False] = False) -> Context: ...
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
@t.overload
|
| 17 |
+
def get_current_context(silent: bool = ...) -> Context | None: ...
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def get_current_context(silent: bool = False) -> Context | None:
|
| 21 |
+
"""Returns the current click context. This can be used as a way to
|
| 22 |
+
access the current context object from anywhere. This is a more implicit
|
| 23 |
+
alternative to the :func:`pass_context` decorator. This function is
|
| 24 |
+
primarily useful for helpers such as :func:`echo` which might be
|
| 25 |
+
interested in changing its behavior based on the current context.
|
| 26 |
+
|
| 27 |
+
To push the current context, :meth:`Context.scope` can be used.
|
| 28 |
+
|
| 29 |
+
.. versionadded:: 5.0
|
| 30 |
+
|
| 31 |
+
:param silent: if set to `True` the return value is `None` if no context
|
| 32 |
+
is available. The default behavior is to raise a
|
| 33 |
+
:exc:`RuntimeError`.
|
| 34 |
+
"""
|
| 35 |
+
try:
|
| 36 |
+
return t.cast("Context", _local.stack[-1])
|
| 37 |
+
except (AttributeError, IndexError) as e:
|
| 38 |
+
if not silent:
|
| 39 |
+
raise RuntimeError("There is no active click context.") from e
|
| 40 |
+
|
| 41 |
+
return None
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def push_context(ctx: Context) -> None:
|
| 45 |
+
"""Pushes a new context to the current stack."""
|
| 46 |
+
_local.__dict__.setdefault("stack", []).append(ctx)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def pop_context() -> None:
|
| 50 |
+
"""Removes the top level from the stack."""
|
| 51 |
+
_local.stack.pop()
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def resolve_color_default(color: bool | None = None) -> bool | None:
|
| 55 |
+
"""Internal helper to get the default value of the color flag. If a
|
| 56 |
+
value is passed it's returned unchanged, otherwise it's looked up from
|
| 57 |
+
the current context.
|
| 58 |
+
"""
|
| 59 |
+
if color is not None:
|
| 60 |
+
return color
|
| 61 |
+
|
| 62 |
+
ctx = get_current_context(silent=True)
|
| 63 |
+
|
| 64 |
+
if ctx is not None:
|
| 65 |
+
return ctx.color
|
| 66 |
+
|
| 67 |
+
return None
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/shell_completion.py
ADDED
|
@@ -0,0 +1,680 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import collections.abc as cabc
|
| 4 |
+
import os
|
| 5 |
+
import re
|
| 6 |
+
import typing as t
|
| 7 |
+
from gettext import gettext as _
|
| 8 |
+
|
| 9 |
+
from .core import Argument
|
| 10 |
+
from .core import Command
|
| 11 |
+
from .core import Context
|
| 12 |
+
from .core import Group
|
| 13 |
+
from .core import Option
|
| 14 |
+
from .core import Parameter
|
| 15 |
+
from .core import ParameterSource
|
| 16 |
+
from .utils import echo
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def shell_complete(
|
| 20 |
+
cli: Command,
|
| 21 |
+
ctx_args: cabc.MutableMapping[str, t.Any],
|
| 22 |
+
prog_name: str,
|
| 23 |
+
complete_var: str,
|
| 24 |
+
instruction: str,
|
| 25 |
+
) -> int:
|
| 26 |
+
"""Perform shell completion for the given CLI program.
|
| 27 |
+
|
| 28 |
+
:param cli: Command being called.
|
| 29 |
+
:param ctx_args: Extra arguments to pass to
|
| 30 |
+
``cli.make_context``.
|
| 31 |
+
:param prog_name: Name of the executable in the shell.
|
| 32 |
+
:param complete_var: Name of the environment variable that holds
|
| 33 |
+
the completion instruction.
|
| 34 |
+
:param instruction: Value of ``complete_var`` with the completion
|
| 35 |
+
instruction and shell, in the form ``instruction_shell``.
|
| 36 |
+
:return: Status code to exit with.
|
| 37 |
+
"""
|
| 38 |
+
shell, _, instruction = instruction.partition("_")
|
| 39 |
+
comp_cls = get_completion_class(shell)
|
| 40 |
+
|
| 41 |
+
if comp_cls is None:
|
| 42 |
+
return 1
|
| 43 |
+
|
| 44 |
+
comp = comp_cls(cli, ctx_args, prog_name, complete_var)
|
| 45 |
+
|
| 46 |
+
# Write bytes, otherwise Windows text stdout translates LF to CRLF and breaks.
|
| 47 |
+
if instruction == "source":
|
| 48 |
+
echo(comp.source().encode(), nl=False)
|
| 49 |
+
return 0
|
| 50 |
+
|
| 51 |
+
if instruction == "complete":
|
| 52 |
+
echo(comp.complete().encode())
|
| 53 |
+
return 0
|
| 54 |
+
|
| 55 |
+
return 1
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class CompletionItem:
|
| 59 |
+
"""Represents a completion value and metadata about the value. The
|
| 60 |
+
default metadata is ``type`` to indicate special shell handling,
|
| 61 |
+
and ``help`` if a shell supports showing a help string next to the
|
| 62 |
+
value.
|
| 63 |
+
|
| 64 |
+
Arbitrary parameters can be passed when creating the object, and
|
| 65 |
+
accessed using ``item.attr``. If an attribute wasn't passed,
|
| 66 |
+
accessing it returns ``None``.
|
| 67 |
+
|
| 68 |
+
:param value: The completion suggestion.
|
| 69 |
+
:param type: Tells the shell script to provide special completion
|
| 70 |
+
support for the type. Click uses ``"dir"`` and ``"file"``.
|
| 71 |
+
:param help: String shown next to the value if supported.
|
| 72 |
+
:param kwargs: Arbitrary metadata. The built-in implementations
|
| 73 |
+
don't use this, but custom type completions paired with custom
|
| 74 |
+
shell support could use it.
|
| 75 |
+
"""
|
| 76 |
+
|
| 77 |
+
__slots__ = ("value", "type", "help", "_info")
|
| 78 |
+
|
| 79 |
+
def __init__(
|
| 80 |
+
self,
|
| 81 |
+
value: t.Any,
|
| 82 |
+
type: str = "plain",
|
| 83 |
+
help: str | None = None,
|
| 84 |
+
**kwargs: t.Any,
|
| 85 |
+
) -> None:
|
| 86 |
+
self.value: t.Any = value
|
| 87 |
+
self.type: str = type
|
| 88 |
+
self.help: str | None = help
|
| 89 |
+
self._info = kwargs
|
| 90 |
+
|
| 91 |
+
def __getattr__(self, name: str) -> t.Any:
|
| 92 |
+
return self._info.get(name)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
# Only Bash >= 4.4 has the nosort option.
|
| 96 |
+
_SOURCE_BASH = """\
|
| 97 |
+
%(complete_func)s() {
|
| 98 |
+
local IFS=$'\\n'
|
| 99 |
+
local response
|
| 100 |
+
|
| 101 |
+
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD \
|
| 102 |
+
%(complete_var)s=bash_complete $1)
|
| 103 |
+
|
| 104 |
+
for completion in $response; do
|
| 105 |
+
IFS=',' read type value <<< "$completion"
|
| 106 |
+
|
| 107 |
+
if [[ $type == 'dir' ]]; then
|
| 108 |
+
COMPREPLY=()
|
| 109 |
+
compopt -o dirnames
|
| 110 |
+
elif [[ $type == 'file' ]]; then
|
| 111 |
+
COMPREPLY=()
|
| 112 |
+
compopt -o default
|
| 113 |
+
elif [[ $type == 'plain' ]]; then
|
| 114 |
+
COMPREPLY+=($value)
|
| 115 |
+
fi
|
| 116 |
+
done
|
| 117 |
+
|
| 118 |
+
return 0
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
%(complete_func)s_setup() {
|
| 122 |
+
complete -o nosort -F %(complete_func)s %(prog_name)s
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
%(complete_func)s_setup;
|
| 126 |
+
"""
|
| 127 |
+
|
| 128 |
+
# See ZshComplete.format_completion below, and issue #2703, before
|
| 129 |
+
# changing this script.
|
| 130 |
+
#
|
| 131 |
+
# (TL;DR: _describe is picky about the format, but this Zsh script snippet
|
| 132 |
+
# is already widely deployed. So freeze this script, and use clever-ish
|
| 133 |
+
# handling of colons in ZshComplet.format_completion.)
|
| 134 |
+
_SOURCE_ZSH = """\
|
| 135 |
+
#compdef %(prog_name)s
|
| 136 |
+
|
| 137 |
+
%(complete_func)s() {
|
| 138 |
+
local -a completions
|
| 139 |
+
local -a completions_with_descriptions
|
| 140 |
+
local -a response
|
| 141 |
+
(( ! $+commands[%(prog_name)s] )) && return 1
|
| 142 |
+
|
| 143 |
+
response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) \
|
| 144 |
+
%(complete_var)s=zsh_complete %(prog_name)s)}")
|
| 145 |
+
|
| 146 |
+
for type key descr in ${response}; do
|
| 147 |
+
if [[ "$type" == "plain" ]]; then
|
| 148 |
+
if [[ "$descr" == "_" ]]; then
|
| 149 |
+
completions+=("$key")
|
| 150 |
+
else
|
| 151 |
+
completions_with_descriptions+=("$key":"$descr")
|
| 152 |
+
fi
|
| 153 |
+
elif [[ "$type" == "dir" ]]; then
|
| 154 |
+
_path_files -/
|
| 155 |
+
elif [[ "$type" == "file" ]]; then
|
| 156 |
+
_path_files -f
|
| 157 |
+
fi
|
| 158 |
+
done
|
| 159 |
+
|
| 160 |
+
if [ -n "$completions_with_descriptions" ]; then
|
| 161 |
+
_describe -V unsorted completions_with_descriptions -U
|
| 162 |
+
fi
|
| 163 |
+
|
| 164 |
+
if [ -n "$completions" ]; then
|
| 165 |
+
compadd -U -V unsorted -a completions
|
| 166 |
+
fi
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
|
| 170 |
+
# autoload from fpath, call function directly
|
| 171 |
+
%(complete_func)s "$@"
|
| 172 |
+
else
|
| 173 |
+
# eval/source/. command, register function for later
|
| 174 |
+
compdef %(complete_func)s %(prog_name)s
|
| 175 |
+
fi
|
| 176 |
+
"""
|
| 177 |
+
|
| 178 |
+
_SOURCE_FISH = """\
|
| 179 |
+
function %(complete_func)s;
|
| 180 |
+
set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) \
|
| 181 |
+
COMP_CWORD=(commandline -t) %(prog_name)s);
|
| 182 |
+
|
| 183 |
+
for completion in $response;
|
| 184 |
+
set -l metadata (string split \n $completion);
|
| 185 |
+
|
| 186 |
+
if test $metadata[1] = "dir";
|
| 187 |
+
__fish_complete_directories $metadata[2];
|
| 188 |
+
else if test $metadata[1] = "file";
|
| 189 |
+
__fish_complete_path $metadata[2];
|
| 190 |
+
else if test $metadata[1] = "plain";
|
| 191 |
+
if test $metadata[3] != "_";
|
| 192 |
+
echo $metadata[2]\t$metadata[3];
|
| 193 |
+
else;
|
| 194 |
+
echo $metadata[2];
|
| 195 |
+
end;
|
| 196 |
+
end;
|
| 197 |
+
end;
|
| 198 |
+
end;
|
| 199 |
+
|
| 200 |
+
complete --no-files --command %(prog_name)s --arguments \
|
| 201 |
+
"(%(complete_func)s)";
|
| 202 |
+
"""
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class ShellComplete:
|
| 206 |
+
"""Base class for providing shell completion support. A subclass for
|
| 207 |
+
a given shell will override attributes and methods to implement the
|
| 208 |
+
completion instructions (``source`` and ``complete``).
|
| 209 |
+
|
| 210 |
+
:param cli: Command being called.
|
| 211 |
+
:param prog_name: Name of the executable in the shell.
|
| 212 |
+
:param complete_var: Name of the environment variable that holds
|
| 213 |
+
the completion instruction.
|
| 214 |
+
|
| 215 |
+
.. versionadded:: 8.0
|
| 216 |
+
"""
|
| 217 |
+
|
| 218 |
+
name: t.ClassVar[str]
|
| 219 |
+
"""Name to register the shell as with :func:`add_completion_class`.
|
| 220 |
+
This is used in completion instructions (``{name}_source`` and
|
| 221 |
+
``{name}_complete``).
|
| 222 |
+
"""
|
| 223 |
+
|
| 224 |
+
source_template: t.ClassVar[str]
|
| 225 |
+
"""Completion script template formatted by :meth:`source`. This must
|
| 226 |
+
be provided by subclasses.
|
| 227 |
+
"""
|
| 228 |
+
|
| 229 |
+
def __init__(
|
| 230 |
+
self,
|
| 231 |
+
cli: Command,
|
| 232 |
+
ctx_args: cabc.MutableMapping[str, t.Any],
|
| 233 |
+
prog_name: str,
|
| 234 |
+
complete_var: str,
|
| 235 |
+
) -> None:
|
| 236 |
+
self.cli = cli
|
| 237 |
+
self.ctx_args = ctx_args
|
| 238 |
+
self.prog_name = prog_name
|
| 239 |
+
self.complete_var = complete_var
|
| 240 |
+
|
| 241 |
+
@property
|
| 242 |
+
def func_name(self) -> str:
|
| 243 |
+
"""The name of the shell function defined by the completion
|
| 244 |
+
script.
|
| 245 |
+
"""
|
| 246 |
+
safe_name = re.sub(r"\W*", "", self.prog_name.replace("-", "_"), flags=re.ASCII)
|
| 247 |
+
return f"_{safe_name}_completion"
|
| 248 |
+
|
| 249 |
+
def source_vars(self) -> dict[str, t.Any]:
|
| 250 |
+
"""Vars for formatting :attr:`source_template`.
|
| 251 |
+
|
| 252 |
+
By default this provides ``complete_func``, ``complete_var``,
|
| 253 |
+
and ``prog_name``.
|
| 254 |
+
"""
|
| 255 |
+
return {
|
| 256 |
+
"complete_func": self.func_name,
|
| 257 |
+
"complete_var": self.complete_var,
|
| 258 |
+
"prog_name": self.prog_name,
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
def source(self) -> str:
|
| 262 |
+
"""Produce the shell script that defines the completion
|
| 263 |
+
function. By default this ``%``-style formats
|
| 264 |
+
:attr:`source_template` with the dict returned by
|
| 265 |
+
:meth:`source_vars`.
|
| 266 |
+
"""
|
| 267 |
+
return self.source_template % self.source_vars()
|
| 268 |
+
|
| 269 |
+
def get_completion_args(self) -> tuple[list[str], str]:
|
| 270 |
+
"""Use the env vars defined by the shell script to return a
|
| 271 |
+
tuple of ``args, incomplete``. This must be implemented by
|
| 272 |
+
subclasses.
|
| 273 |
+
"""
|
| 274 |
+
raise NotImplementedError
|
| 275 |
+
|
| 276 |
+
def get_completions(self, args: list[str], incomplete: str) -> list[CompletionItem]:
|
| 277 |
+
"""Determine the context and last complete command or parameter
|
| 278 |
+
from the complete args. Call that object's ``shell_complete``
|
| 279 |
+
method to get the completions for the incomplete value.
|
| 280 |
+
|
| 281 |
+
:param args: List of complete args before the incomplete value.
|
| 282 |
+
:param incomplete: Value being completed. May be empty.
|
| 283 |
+
"""
|
| 284 |
+
ctx = _resolve_context(self.cli, self.ctx_args, self.prog_name, args)
|
| 285 |
+
obj, incomplete = _resolve_incomplete(ctx, args, incomplete)
|
| 286 |
+
return obj.shell_complete(ctx, incomplete)
|
| 287 |
+
|
| 288 |
+
def format_completion(self, item: CompletionItem) -> str:
|
| 289 |
+
"""Format a completion item into the form recognized by the
|
| 290 |
+
shell script. This must be implemented by subclasses.
|
| 291 |
+
|
| 292 |
+
:param item: Completion item to format.
|
| 293 |
+
"""
|
| 294 |
+
raise NotImplementedError
|
| 295 |
+
|
| 296 |
+
def complete(self) -> str:
|
| 297 |
+
"""Produce the completion data to send back to the shell.
|
| 298 |
+
|
| 299 |
+
By default this calls :meth:`get_completion_args`, gets the
|
| 300 |
+
completions, then calls :meth:`format_completion` for each
|
| 301 |
+
completion.
|
| 302 |
+
"""
|
| 303 |
+
args, incomplete = self.get_completion_args()
|
| 304 |
+
completions = self.get_completions(args, incomplete)
|
| 305 |
+
out = [self.format_completion(item) for item in completions]
|
| 306 |
+
return "\n".join(out)
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
class BashComplete(ShellComplete):
|
| 310 |
+
"""Shell completion for Bash."""
|
| 311 |
+
|
| 312 |
+
name = "bash"
|
| 313 |
+
source_template = _SOURCE_BASH
|
| 314 |
+
|
| 315 |
+
@staticmethod
|
| 316 |
+
def _check_version() -> None:
|
| 317 |
+
import shutil
|
| 318 |
+
import subprocess
|
| 319 |
+
|
| 320 |
+
bash_exe = shutil.which("bash")
|
| 321 |
+
|
| 322 |
+
if bash_exe is None:
|
| 323 |
+
match = None
|
| 324 |
+
else:
|
| 325 |
+
output = subprocess.run(
|
| 326 |
+
[bash_exe, "--norc", "-c", 'echo "${BASH_VERSION}"'],
|
| 327 |
+
stdout=subprocess.PIPE,
|
| 328 |
+
)
|
| 329 |
+
match = re.search(r"^(\d+)\.(\d+)\.\d+", output.stdout.decode())
|
| 330 |
+
|
| 331 |
+
if match is not None:
|
| 332 |
+
major, minor = match.groups()
|
| 333 |
+
|
| 334 |
+
if major < "4" or major == "4" and minor < "4":
|
| 335 |
+
echo(
|
| 336 |
+
_(
|
| 337 |
+
"Shell completion is not supported for Bash"
|
| 338 |
+
" versions older than 4.4."
|
| 339 |
+
),
|
| 340 |
+
err=True,
|
| 341 |
+
)
|
| 342 |
+
else:
|
| 343 |
+
echo(
|
| 344 |
+
_("Couldn't detect Bash version, shell completion is not supported."),
|
| 345 |
+
err=True,
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
def source(self) -> str:
|
| 349 |
+
self._check_version()
|
| 350 |
+
return super().source()
|
| 351 |
+
|
| 352 |
+
def get_completion_args(self) -> tuple[list[str], str]:
|
| 353 |
+
cwords = split_arg_string(os.environ["COMP_WORDS"])
|
| 354 |
+
cword = int(os.environ["COMP_CWORD"])
|
| 355 |
+
args = cwords[1:cword]
|
| 356 |
+
|
| 357 |
+
try:
|
| 358 |
+
incomplete = cwords[cword]
|
| 359 |
+
except IndexError:
|
| 360 |
+
incomplete = ""
|
| 361 |
+
|
| 362 |
+
return args, incomplete
|
| 363 |
+
|
| 364 |
+
def format_completion(self, item: CompletionItem) -> str:
|
| 365 |
+
return f"{item.type},{item.value}"
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
class ZshComplete(ShellComplete):
|
| 369 |
+
"""Shell completion for Zsh."""
|
| 370 |
+
|
| 371 |
+
name = "zsh"
|
| 372 |
+
source_template = _SOURCE_ZSH
|
| 373 |
+
|
| 374 |
+
def get_completion_args(self) -> tuple[list[str], str]:
|
| 375 |
+
cwords = split_arg_string(os.environ["COMP_WORDS"])
|
| 376 |
+
cword = int(os.environ["COMP_CWORD"])
|
| 377 |
+
args = cwords[1:cword]
|
| 378 |
+
|
| 379 |
+
try:
|
| 380 |
+
incomplete = cwords[cword]
|
| 381 |
+
except IndexError:
|
| 382 |
+
incomplete = ""
|
| 383 |
+
|
| 384 |
+
return args, incomplete
|
| 385 |
+
|
| 386 |
+
def format_completion(self, item: CompletionItem) -> str:
|
| 387 |
+
help_ = item.help or "_"
|
| 388 |
+
# The zsh completion script uses `_describe` on items with help
|
| 389 |
+
# texts (which splits the item help from the item value at the
|
| 390 |
+
# first unescaped colon) and `compadd` on items without help
|
| 391 |
+
# text (which uses the item value as-is and does not support
|
| 392 |
+
# colon escaping). So escape colons in the item value if and
|
| 393 |
+
# only if the item help is not the sentinel "_" value, as used
|
| 394 |
+
# by the completion script.
|
| 395 |
+
#
|
| 396 |
+
# (The zsh completion script is potentially widely deployed, and
|
| 397 |
+
# thus harder to fix than this method.)
|
| 398 |
+
#
|
| 399 |
+
# See issue #1812 and issue #2703 for further context.
|
| 400 |
+
value = item.value.replace(":", r"\:") if help_ != "_" else item.value
|
| 401 |
+
return f"{item.type}\n{value}\n{help_}"
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
class FishComplete(ShellComplete):
|
| 405 |
+
"""Shell completion for Fish."""
|
| 406 |
+
|
| 407 |
+
name = "fish"
|
| 408 |
+
source_template = _SOURCE_FISH
|
| 409 |
+
|
| 410 |
+
def get_completion_args(self) -> tuple[list[str], str]:
|
| 411 |
+
cwords = split_arg_string(os.environ["COMP_WORDS"])
|
| 412 |
+
incomplete = os.environ["COMP_CWORD"]
|
| 413 |
+
if incomplete:
|
| 414 |
+
incomplete = split_arg_string(incomplete)[0]
|
| 415 |
+
args = cwords[1:]
|
| 416 |
+
|
| 417 |
+
# Fish stores the partial word in both COMP_WORDS and
|
| 418 |
+
# COMP_CWORD, remove it from complete args.
|
| 419 |
+
if incomplete and args and args[-1] == incomplete:
|
| 420 |
+
args.pop()
|
| 421 |
+
|
| 422 |
+
return args, incomplete
|
| 423 |
+
|
| 424 |
+
def format_completion(self, item: CompletionItem) -> str:
|
| 425 |
+
"""
|
| 426 |
+
.. versionchanged:: 8.4.0
|
| 427 |
+
Escape newlines in value and help to fix completion errors with
|
| 428 |
+
multi-line help strings.
|
| 429 |
+
"""
|
| 430 |
+
# The fish completion script splits each response line on literal
|
| 431 |
+
# newlines, so any newline in the value or help would corrupt the
|
| 432 |
+
# frame. Replace them with the two-character escape "\n" so the text
|
| 433 |
+
# round-trips through fish without breaking the format. The "_"
|
| 434 |
+
# sentinel for missing help mirrors :class:`ZshComplete`.
|
| 435 |
+
help_ = item.help or "_"
|
| 436 |
+
value = item.value.replace("\n", r"\n")
|
| 437 |
+
help_escaped = help_.replace("\n", r"\n")
|
| 438 |
+
return f"{item.type}\n{value}\n{help_escaped}"
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
ShellCompleteType = t.TypeVar("ShellCompleteType", bound="type[ShellComplete]")
|
| 442 |
+
|
| 443 |
+
|
| 444 |
+
_available_shells: dict[str, type[ShellComplete]] = {
|
| 445 |
+
"bash": BashComplete,
|
| 446 |
+
"fish": FishComplete,
|
| 447 |
+
"zsh": ZshComplete,
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
def add_completion_class(
|
| 452 |
+
cls: ShellCompleteType, name: str | None = None
|
| 453 |
+
) -> ShellCompleteType:
|
| 454 |
+
"""Register a :class:`ShellComplete` subclass under the given name.
|
| 455 |
+
The name will be provided by the completion instruction environment
|
| 456 |
+
variable during completion.
|
| 457 |
+
|
| 458 |
+
:param cls: The completion class that will handle completion for the
|
| 459 |
+
shell.
|
| 460 |
+
:param name: Name to register the class under. Defaults to the
|
| 461 |
+
class's ``name`` attribute.
|
| 462 |
+
"""
|
| 463 |
+
if name is None:
|
| 464 |
+
name = cls.name
|
| 465 |
+
|
| 466 |
+
_available_shells[name] = cls
|
| 467 |
+
|
| 468 |
+
return cls
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
def get_completion_class(shell: str) -> type[ShellComplete] | None:
|
| 472 |
+
"""Look up a registered :class:`ShellComplete` subclass by the name
|
| 473 |
+
provided by the completion instruction environment variable. If the
|
| 474 |
+
name isn't registered, returns ``None``.
|
| 475 |
+
|
| 476 |
+
:param shell: Name the class is registered under.
|
| 477 |
+
"""
|
| 478 |
+
return _available_shells.get(shell)
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
def split_arg_string(string: str) -> list[str]:
|
| 482 |
+
"""Split an argument string as with :func:`shlex.split`, but don't
|
| 483 |
+
fail if the string is incomplete. Ignores a missing closing quote or
|
| 484 |
+
incomplete escape sequence and uses the partial token as-is.
|
| 485 |
+
|
| 486 |
+
.. code-block:: python
|
| 487 |
+
|
| 488 |
+
split_arg_string("example 'my file")
|
| 489 |
+
["example", "my file"]
|
| 490 |
+
|
| 491 |
+
split_arg_string("example my\\")
|
| 492 |
+
["example", "my"]
|
| 493 |
+
|
| 494 |
+
:param string: String to split.
|
| 495 |
+
|
| 496 |
+
.. versionchanged:: 8.2
|
| 497 |
+
Moved to ``shell_completion`` from ``parser``.
|
| 498 |
+
"""
|
| 499 |
+
import shlex
|
| 500 |
+
|
| 501 |
+
lex = shlex.shlex(string, posix=True)
|
| 502 |
+
lex.whitespace_split = True
|
| 503 |
+
lex.commenters = ""
|
| 504 |
+
out = []
|
| 505 |
+
|
| 506 |
+
try:
|
| 507 |
+
for token in lex:
|
| 508 |
+
out.append(token)
|
| 509 |
+
except ValueError:
|
| 510 |
+
# Raised when end-of-string is reached in an invalid state. Use
|
| 511 |
+
# the partial token as-is. The quote or escape character is in
|
| 512 |
+
# lex.state, not lex.token.
|
| 513 |
+
out.append(lex.token)
|
| 514 |
+
|
| 515 |
+
return out
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
def _is_incomplete_argument(ctx: Context, param: Parameter) -> bool:
|
| 519 |
+
"""Determine if the given parameter is an argument that can still
|
| 520 |
+
accept values.
|
| 521 |
+
|
| 522 |
+
:param ctx: Invocation context for the command represented by the
|
| 523 |
+
parsed complete args.
|
| 524 |
+
:param param: Argument object being checked.
|
| 525 |
+
"""
|
| 526 |
+
if not isinstance(param, Argument):
|
| 527 |
+
return False
|
| 528 |
+
|
| 529 |
+
value = ctx.params.get(param.name)
|
| 530 |
+
return (
|
| 531 |
+
param.nargs == -1
|
| 532 |
+
or ctx.get_parameter_source(param.name) is not ParameterSource.COMMANDLINE
|
| 533 |
+
or (
|
| 534 |
+
param.nargs > 1
|
| 535 |
+
and isinstance(value, (tuple, list))
|
| 536 |
+
and len(value) < param.nargs
|
| 537 |
+
)
|
| 538 |
+
)
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
def _start_of_option(ctx: Context, value: str) -> bool:
|
| 542 |
+
"""Check if the value looks like the start of an option."""
|
| 543 |
+
if not value:
|
| 544 |
+
return False
|
| 545 |
+
|
| 546 |
+
c = value[0]
|
| 547 |
+
return c in ctx._opt_prefixes
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
def _is_incomplete_option(ctx: Context, args: list[str], param: Parameter) -> bool:
|
| 551 |
+
"""Determine if the given parameter is an option that needs a value.
|
| 552 |
+
|
| 553 |
+
:param args: List of complete args before the incomplete value.
|
| 554 |
+
:param param: Option object being checked.
|
| 555 |
+
"""
|
| 556 |
+
if not isinstance(param, Option):
|
| 557 |
+
return False
|
| 558 |
+
|
| 559 |
+
if param.is_flag or param.count:
|
| 560 |
+
return False
|
| 561 |
+
|
| 562 |
+
last_option = None
|
| 563 |
+
|
| 564 |
+
for index, arg in enumerate(reversed(args)):
|
| 565 |
+
if index + 1 > param.nargs:
|
| 566 |
+
break
|
| 567 |
+
|
| 568 |
+
if _start_of_option(ctx, arg):
|
| 569 |
+
last_option = arg
|
| 570 |
+
break
|
| 571 |
+
|
| 572 |
+
return last_option is not None and last_option in param.opts
|
| 573 |
+
|
| 574 |
+
|
| 575 |
+
def _resolve_context(
|
| 576 |
+
cli: Command,
|
| 577 |
+
ctx_args: cabc.MutableMapping[str, t.Any],
|
| 578 |
+
prog_name: str,
|
| 579 |
+
args: list[str],
|
| 580 |
+
) -> Context:
|
| 581 |
+
"""Produce the context hierarchy starting with the command and
|
| 582 |
+
traversing the complete arguments. This only follows the commands,
|
| 583 |
+
it doesn't trigger input prompts or callbacks.
|
| 584 |
+
|
| 585 |
+
:param cli: Command being called.
|
| 586 |
+
:param prog_name: Name of the executable in the shell.
|
| 587 |
+
:param args: List of complete args before the incomplete value.
|
| 588 |
+
"""
|
| 589 |
+
ctx_args["resilient_parsing"] = True
|
| 590 |
+
with cli.make_context(prog_name, args.copy(), **ctx_args) as ctx:
|
| 591 |
+
args = ctx._protected_args + ctx.args
|
| 592 |
+
|
| 593 |
+
while args:
|
| 594 |
+
command = ctx.command
|
| 595 |
+
|
| 596 |
+
if isinstance(command, Group):
|
| 597 |
+
if not command.chain:
|
| 598 |
+
name, cmd, args = command.resolve_command(ctx, args)
|
| 599 |
+
|
| 600 |
+
if cmd is None:
|
| 601 |
+
return ctx
|
| 602 |
+
|
| 603 |
+
with cmd.make_context(
|
| 604 |
+
name, args, parent=ctx, resilient_parsing=True
|
| 605 |
+
) as sub_ctx:
|
| 606 |
+
ctx = sub_ctx
|
| 607 |
+
args = ctx._protected_args + ctx.args
|
| 608 |
+
else:
|
| 609 |
+
sub_ctx = ctx
|
| 610 |
+
|
| 611 |
+
while args:
|
| 612 |
+
name, cmd, args = command.resolve_command(ctx, args)
|
| 613 |
+
|
| 614 |
+
if cmd is None:
|
| 615 |
+
return ctx
|
| 616 |
+
|
| 617 |
+
with cmd.make_context(
|
| 618 |
+
name,
|
| 619 |
+
args,
|
| 620 |
+
parent=ctx,
|
| 621 |
+
allow_extra_args=True,
|
| 622 |
+
allow_interspersed_args=False,
|
| 623 |
+
resilient_parsing=True,
|
| 624 |
+
) as sub_sub_ctx:
|
| 625 |
+
sub_ctx = sub_sub_ctx
|
| 626 |
+
args = sub_ctx.args
|
| 627 |
+
|
| 628 |
+
ctx = sub_ctx
|
| 629 |
+
args = [*sub_ctx._protected_args, *sub_ctx.args]
|
| 630 |
+
else:
|
| 631 |
+
break
|
| 632 |
+
|
| 633 |
+
return ctx
|
| 634 |
+
|
| 635 |
+
|
| 636 |
+
def _resolve_incomplete(
|
| 637 |
+
ctx: Context, args: list[str], incomplete: str
|
| 638 |
+
) -> tuple[Command | Parameter, str]:
|
| 639 |
+
"""Find the Click object that will handle the completion of the
|
| 640 |
+
incomplete value. Return the object and the incomplete value.
|
| 641 |
+
|
| 642 |
+
:param ctx: Invocation context for the command represented by
|
| 643 |
+
the parsed complete args.
|
| 644 |
+
:param args: List of complete args before the incomplete value.
|
| 645 |
+
:param incomplete: Value being completed. May be empty.
|
| 646 |
+
"""
|
| 647 |
+
# Different shells treat an "=" between a long option name and
|
| 648 |
+
# value differently. Might keep the value joined, return the "="
|
| 649 |
+
# as a separate item, or return the split name and value. Always
|
| 650 |
+
# split and discard the "=" to make completion easier.
|
| 651 |
+
if incomplete == "=":
|
| 652 |
+
incomplete = ""
|
| 653 |
+
elif "=" in incomplete and _start_of_option(ctx, incomplete):
|
| 654 |
+
name, _, incomplete = incomplete.partition("=")
|
| 655 |
+
args.append(name)
|
| 656 |
+
|
| 657 |
+
# The "--" marker tells Click to stop treating values as options
|
| 658 |
+
# even if they start with the option character. If it hasn't been
|
| 659 |
+
# given and the incomplete arg looks like an option, the current
|
| 660 |
+
# command will provide option name completions.
|
| 661 |
+
if "--" not in args and _start_of_option(ctx, incomplete):
|
| 662 |
+
return ctx.command, incomplete
|
| 663 |
+
|
| 664 |
+
params = ctx.command.get_params(ctx)
|
| 665 |
+
|
| 666 |
+
# If the last complete arg is an option name with an incomplete
|
| 667 |
+
# value, the option will provide value completions.
|
| 668 |
+
for param in params:
|
| 669 |
+
if _is_incomplete_option(ctx, args, param):
|
| 670 |
+
return param, incomplete
|
| 671 |
+
|
| 672 |
+
# It's not an option name or value. The first argument without a
|
| 673 |
+
# parsed value will provide value completions.
|
| 674 |
+
for param in params:
|
| 675 |
+
if _is_incomplete_argument(ctx, param):
|
| 676 |
+
return param, incomplete
|
| 677 |
+
|
| 678 |
+
# There were no unparsed arguments, the command may be a group that
|
| 679 |
+
# will provide command name completions.
|
| 680 |
+
return ctx.command, incomplete
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/click/testing.py
ADDED
|
@@ -0,0 +1,736 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import collections.abc as cabc
|
| 4 |
+
import contextlib
|
| 5 |
+
import io
|
| 6 |
+
import os
|
| 7 |
+
import pdb
|
| 8 |
+
import shlex
|
| 9 |
+
import sys
|
| 10 |
+
import tempfile
|
| 11 |
+
import typing as t
|
| 12 |
+
from types import TracebackType
|
| 13 |
+
|
| 14 |
+
from . import _compat
|
| 15 |
+
from . import formatting
|
| 16 |
+
from . import termui
|
| 17 |
+
from . import utils
|
| 18 |
+
from ._compat import _find_binary_reader
|
| 19 |
+
|
| 20 |
+
if t.TYPE_CHECKING:
|
| 21 |
+
from _typeshed import ReadableBuffer
|
| 22 |
+
|
| 23 |
+
from .core import Command
|
| 24 |
+
|
| 25 |
+
CaptureMode = t.Literal["sys", "fd"]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class EchoingStdin:
|
| 29 |
+
def __init__(self, input: t.BinaryIO, output: t.BinaryIO) -> None:
|
| 30 |
+
self._input = input
|
| 31 |
+
self._output = output
|
| 32 |
+
self._paused = False
|
| 33 |
+
|
| 34 |
+
def __getattr__(self, x: str) -> t.Any:
|
| 35 |
+
return getattr(self._input, x)
|
| 36 |
+
|
| 37 |
+
def _echo(self, rv: bytes) -> bytes:
|
| 38 |
+
if not self._paused:
|
| 39 |
+
self._output.write(rv)
|
| 40 |
+
|
| 41 |
+
return rv
|
| 42 |
+
|
| 43 |
+
def read(self, n: int = -1) -> bytes:
|
| 44 |
+
return self._echo(self._input.read(n))
|
| 45 |
+
|
| 46 |
+
def read1(self, n: int = -1) -> bytes:
|
| 47 |
+
return self._echo(self._input.read1(n)) # type: ignore
|
| 48 |
+
|
| 49 |
+
def readline(self, n: int = -1) -> bytes:
|
| 50 |
+
return self._echo(self._input.readline(n))
|
| 51 |
+
|
| 52 |
+
def readlines(self) -> list[bytes]:
|
| 53 |
+
return [self._echo(x) for x in self._input.readlines()]
|
| 54 |
+
|
| 55 |
+
def __iter__(self) -> cabc.Iterator[bytes]:
|
| 56 |
+
return iter(self._echo(x) for x in self._input)
|
| 57 |
+
|
| 58 |
+
def __repr__(self) -> str:
|
| 59 |
+
return repr(self._input)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
@contextlib.contextmanager
|
| 63 |
+
def _pause_echo(stream: EchoingStdin | None) -> cabc.Iterator[None]:
|
| 64 |
+
if stream is None:
|
| 65 |
+
yield
|
| 66 |
+
else:
|
| 67 |
+
stream._paused = True
|
| 68 |
+
yield
|
| 69 |
+
stream._paused = False
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class _FDCapture:
|
| 73 |
+
"""Redirect a file descriptor to a temporary file for capture.
|
| 74 |
+
|
| 75 |
+
Saves the current target of *targetfd* via :func:`os.dup`, then
|
| 76 |
+
redirects it to a temporary file via :func:`os.dup2`. On
|
| 77 |
+
:meth:`stop`, restores the original ``fd`` and returns the captured
|
| 78 |
+
bytes. Inspired by Pytest's ``FDCapture``.
|
| 79 |
+
|
| 80 |
+
.. versionadded:: 8.4.0
|
| 81 |
+
"""
|
| 82 |
+
|
| 83 |
+
def __init__(self, targetfd: int) -> None:
|
| 84 |
+
self._targetfd = targetfd
|
| 85 |
+
self.saved_fd: int = -1
|
| 86 |
+
self._tmpfile: t.BinaryIO | None = None
|
| 87 |
+
|
| 88 |
+
def start(self) -> None:
|
| 89 |
+
self.saved_fd = os.dup(self._targetfd)
|
| 90 |
+
self._tmpfile = tempfile.TemporaryFile(buffering=0)
|
| 91 |
+
os.dup2(self._tmpfile.fileno(), self._targetfd)
|
| 92 |
+
|
| 93 |
+
def stop(self) -> bytes:
|
| 94 |
+
assert self._tmpfile is not None, "_FDCapture.start() was not called"
|
| 95 |
+
os.dup2(self.saved_fd, self._targetfd)
|
| 96 |
+
os.close(self.saved_fd)
|
| 97 |
+
self.saved_fd = -1
|
| 98 |
+
self._tmpfile.seek(0)
|
| 99 |
+
data = self._tmpfile.read()
|
| 100 |
+
self._tmpfile.close()
|
| 101 |
+
self._tmpfile = None
|
| 102 |
+
return data
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
class BytesIOCopy(io.BytesIO):
|
| 106 |
+
"""Patch ``io.BytesIO`` to let the written stream be copied to another.
|
| 107 |
+
|
| 108 |
+
.. versionadded:: 8.2
|
| 109 |
+
"""
|
| 110 |
+
|
| 111 |
+
def __init__(self, copy_to: io.BytesIO) -> None:
|
| 112 |
+
super().__init__()
|
| 113 |
+
self.copy_to = copy_to
|
| 114 |
+
|
| 115 |
+
def flush(self) -> None:
|
| 116 |
+
super().flush()
|
| 117 |
+
self.copy_to.flush()
|
| 118 |
+
|
| 119 |
+
def write(self, b: ReadableBuffer) -> int:
|
| 120 |
+
self.copy_to.write(b)
|
| 121 |
+
return super().write(b)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class StreamMixer:
|
| 125 |
+
"""Mixes `<stdout>` and `<stderr>` streams.
|
| 126 |
+
|
| 127 |
+
The result is available in the ``output`` attribute.
|
| 128 |
+
|
| 129 |
+
.. versionadded:: 8.2
|
| 130 |
+
"""
|
| 131 |
+
|
| 132 |
+
def __init__(self) -> None:
|
| 133 |
+
self.output: io.BytesIO = io.BytesIO()
|
| 134 |
+
self.stdout: io.BytesIO = BytesIOCopy(copy_to=self.output)
|
| 135 |
+
self.stderr: io.BytesIO = BytesIOCopy(copy_to=self.output)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
class _NamedTextIOWrapper(io.TextIOWrapper):
|
| 139 |
+
"""A :class:`~io.TextIOWrapper` with custom ``name`` and ``mode``
|
| 140 |
+
that does not close its underlying buffer.
|
| 141 |
+
|
| 142 |
+
When ``CliRunner`` runs in ``fd`` mode, ``_original_fd`` is patched to
|
| 143 |
+
point at the saved (pre-redirection) ``fd``, so C-level consumers that call
|
| 144 |
+
:meth:`fileno` (like ``faulthandler`` or ``subprocess``) keep working. In
|
| 145 |
+
the default ``sys`` mode ``_original_fd`` stays at ``-1`` and
|
| 146 |
+
:meth:`fileno` raises :exc:`io.UnsupportedOperation`, matching the
|
| 147 |
+
pre-``8.3.3`` behavior.
|
| 148 |
+
"""
|
| 149 |
+
|
| 150 |
+
def __init__(
|
| 151 |
+
self,
|
| 152 |
+
buffer: t.BinaryIO,
|
| 153 |
+
name: str,
|
| 154 |
+
mode: str,
|
| 155 |
+
**kwargs: t.Any,
|
| 156 |
+
) -> None:
|
| 157 |
+
super().__init__(buffer, **kwargs)
|
| 158 |
+
self._name = name
|
| 159 |
+
self._mode = mode
|
| 160 |
+
self._original_fd: int = -1
|
| 161 |
+
|
| 162 |
+
def close(self) -> None:
|
| 163 |
+
"""The buffer this object contains belongs to some other object,
|
| 164 |
+
so prevent the default ``__del__`` implementation from closing
|
| 165 |
+
that buffer.
|
| 166 |
+
|
| 167 |
+
.. versionadded:: 8.3.2
|
| 168 |
+
"""
|
| 169 |
+
|
| 170 |
+
def fileno(self) -> int:
|
| 171 |
+
"""Return the file descriptor of the saved original stream when
|
| 172 |
+
``CliRunner`` runs in ``fd`` mode. Otherwise delegate to
|
| 173 |
+
:class:`~io.TextIOWrapper`, which raises
|
| 174 |
+
:exc:`io.UnsupportedOperation` for a ``BytesIO``-backed buffer.
|
| 175 |
+
"""
|
| 176 |
+
if self._original_fd >= 0:
|
| 177 |
+
return self._original_fd
|
| 178 |
+
return super().fileno()
|
| 179 |
+
|
| 180 |
+
@property
|
| 181 |
+
def name(self) -> str:
|
| 182 |
+
return self._name
|
| 183 |
+
|
| 184 |
+
@property
|
| 185 |
+
def mode(self) -> str:
|
| 186 |
+
return self._mode
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def make_input_stream(
|
| 190 |
+
input: str | bytes | t.IO[t.Any] | None, charset: str
|
| 191 |
+
) -> t.BinaryIO:
|
| 192 |
+
# Is already an input stream.
|
| 193 |
+
if hasattr(input, "read"):
|
| 194 |
+
rv = _find_binary_reader(t.cast("t.IO[t.Any]", input))
|
| 195 |
+
|
| 196 |
+
if rv is not None:
|
| 197 |
+
return rv
|
| 198 |
+
|
| 199 |
+
raise TypeError("Could not find binary reader for input stream.")
|
| 200 |
+
|
| 201 |
+
if input is None:
|
| 202 |
+
input = b""
|
| 203 |
+
elif isinstance(input, str):
|
| 204 |
+
input = input.encode(charset)
|
| 205 |
+
|
| 206 |
+
return io.BytesIO(input)
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
class Result:
|
| 210 |
+
"""Holds the captured result of an invoked CLI script.
|
| 211 |
+
|
| 212 |
+
:param runner: The runner that created the result
|
| 213 |
+
:param stdout_bytes: The standard output as bytes.
|
| 214 |
+
:param stderr_bytes: The standard error as bytes.
|
| 215 |
+
:param output_bytes: A mix of ``stdout_bytes`` and ``stderr_bytes``, as the
|
| 216 |
+
user would see it in its terminal.
|
| 217 |
+
:param return_value: The value returned from the invoked command.
|
| 218 |
+
:param exit_code: The exit code as integer.
|
| 219 |
+
:param exception: The exception that happened if one did.
|
| 220 |
+
:param exc_info: Exception information (exception type, exception instance,
|
| 221 |
+
traceback type).
|
| 222 |
+
|
| 223 |
+
.. versionchanged:: 8.2
|
| 224 |
+
``stderr_bytes`` no longer optional, ``output_bytes`` introduced and
|
| 225 |
+
``mix_stderr`` has been removed.
|
| 226 |
+
|
| 227 |
+
.. versionadded:: 8.0
|
| 228 |
+
Added ``return_value``.
|
| 229 |
+
"""
|
| 230 |
+
|
| 231 |
+
def __init__(
|
| 232 |
+
self,
|
| 233 |
+
runner: CliRunner,
|
| 234 |
+
stdout_bytes: bytes,
|
| 235 |
+
stderr_bytes: bytes,
|
| 236 |
+
output_bytes: bytes,
|
| 237 |
+
return_value: t.Any,
|
| 238 |
+
exit_code: int,
|
| 239 |
+
exception: BaseException | None,
|
| 240 |
+
exc_info: tuple[type[BaseException], BaseException, TracebackType]
|
| 241 |
+
| None = None,
|
| 242 |
+
):
|
| 243 |
+
self.runner = runner
|
| 244 |
+
self.stdout_bytes = stdout_bytes
|
| 245 |
+
self.stderr_bytes = stderr_bytes
|
| 246 |
+
self.output_bytes = output_bytes
|
| 247 |
+
self.return_value = return_value
|
| 248 |
+
self.exit_code = exit_code
|
| 249 |
+
self.exception = exception
|
| 250 |
+
self.exc_info = exc_info
|
| 251 |
+
|
| 252 |
+
@property
|
| 253 |
+
def output(self) -> str:
|
| 254 |
+
"""The terminal output as unicode string, as the user would see it.
|
| 255 |
+
|
| 256 |
+
.. versionchanged:: 8.2
|
| 257 |
+
No longer a proxy for ``self.stdout``. Now has its own independent stream
|
| 258 |
+
that is mixing `<stdout>` and `<stderr>`, in the order they were written.
|
| 259 |
+
"""
|
| 260 |
+
return self.output_bytes.decode(self.runner.charset, "replace").replace(
|
| 261 |
+
"\r\n", "\n"
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
@property
|
| 265 |
+
def stdout(self) -> str:
|
| 266 |
+
"""The standard output as unicode string."""
|
| 267 |
+
return self.stdout_bytes.decode(self.runner.charset, "replace").replace(
|
| 268 |
+
"\r\n", "\n"
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
@property
|
| 272 |
+
def stderr(self) -> str:
|
| 273 |
+
"""The standard error as unicode string.
|
| 274 |
+
|
| 275 |
+
.. versionchanged:: 8.2
|
| 276 |
+
No longer raise an exception, always returns the `<stderr>` string.
|
| 277 |
+
"""
|
| 278 |
+
return self.stderr_bytes.decode(self.runner.charset, "replace").replace(
|
| 279 |
+
"\r\n", "\n"
|
| 280 |
+
)
|
| 281 |
+
|
| 282 |
+
def __repr__(self) -> str:
|
| 283 |
+
exc_str = repr(self.exception) if self.exception else "okay"
|
| 284 |
+
return f"<{type(self).__name__} {exc_str}>"
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
class CliRunner:
|
| 288 |
+
"""The CLI runner provides functionality to invoke a Click command line
|
| 289 |
+
script for unittesting purposes in a isolated environment. This only
|
| 290 |
+
works in single-threaded systems without any concurrency as it changes the
|
| 291 |
+
global interpreter state.
|
| 292 |
+
|
| 293 |
+
:param charset: the character set for the input and output data.
|
| 294 |
+
:param env: a dictionary with environment variables for overriding.
|
| 295 |
+
:param echo_stdin: if this is set to `True`, then reading from `<stdin>` writes
|
| 296 |
+
to `<stdout>`. This is useful for showing examples in
|
| 297 |
+
some circumstances. Note that regular prompts
|
| 298 |
+
will automatically echo the input.
|
| 299 |
+
:param catch_exceptions: Whether to catch any exceptions other than
|
| 300 |
+
``SystemExit`` when running :meth:`~CliRunner.invoke`.
|
| 301 |
+
:param capture: Selects the output capture strategy. ``sys`` (default)
|
| 302 |
+
captures Python-level writes only and leaves
|
| 303 |
+
:meth:`sys.stdout.fileno` raising :exc:`io.UnsupportedOperation`, so
|
| 304 |
+
user code that calls :func:`os.dup2` on ``sys.stdout.fileno()`` cannot
|
| 305 |
+
clobber the host runner's stdout. ``fd`` redirects file descriptors
|
| 306 |
+
``1`` and ``2`` via :func:`os.dup2` to a temporary file, also catching
|
| 307 |
+
output from stale stream references, C extensions, and subprocesses.
|
| 308 |
+
``fd`` is not supported on Windows.
|
| 309 |
+
|
| 310 |
+
.. versionchanged:: 8.4.0
|
| 311 |
+
Added the ``capture`` parameter. The default ``sys`` mode no longer
|
| 312 |
+
exposes the original fd through :meth:`fileno`, reverting the change
|
| 313 |
+
introduced in ``8.3.3`` that broke Pytest's ``fd``-level capture
|
| 314 |
+
teardown. Use ``capture="fd"`` to restore that behavior with proper
|
| 315 |
+
isolation. :issue:`3384`
|
| 316 |
+
|
| 317 |
+
.. versionchanged:: 8.2
|
| 318 |
+
Added the ``catch_exceptions`` parameter.
|
| 319 |
+
|
| 320 |
+
.. versionchanged:: 8.2
|
| 321 |
+
``mix_stderr`` parameter has been removed.
|
| 322 |
+
"""
|
| 323 |
+
|
| 324 |
+
def __init__(
|
| 325 |
+
self,
|
| 326 |
+
charset: str = "utf-8",
|
| 327 |
+
env: cabc.Mapping[str, str | None] | None = None,
|
| 328 |
+
echo_stdin: bool = False,
|
| 329 |
+
catch_exceptions: bool = True,
|
| 330 |
+
capture: CaptureMode = "sys",
|
| 331 |
+
) -> None:
|
| 332 |
+
if capture not in {"sys", "fd"}:
|
| 333 |
+
raise ValueError(
|
| 334 |
+
f"capture={capture!r} is not valid. Choose from 'sys' or 'fd'."
|
| 335 |
+
)
|
| 336 |
+
if capture == "fd" and sys.platform == "win32":
|
| 337 |
+
raise ValueError(
|
| 338 |
+
f"capture={capture!r} is not supported on Windows. Use 'sys'."
|
| 339 |
+
)
|
| 340 |
+
self.charset = charset
|
| 341 |
+
self.env: cabc.Mapping[str, str | None] = env or {}
|
| 342 |
+
self.echo_stdin = echo_stdin
|
| 343 |
+
self.catch_exceptions = catch_exceptions
|
| 344 |
+
self.capture: CaptureMode = capture
|
| 345 |
+
|
| 346 |
+
def get_default_prog_name(self, cli: Command) -> str:
|
| 347 |
+
"""Given a command object it will return the default program name
|
| 348 |
+
for it. The default is the `name` attribute or ``"root"`` if not
|
| 349 |
+
set.
|
| 350 |
+
"""
|
| 351 |
+
return cli.name or "root"
|
| 352 |
+
|
| 353 |
+
def make_env(
|
| 354 |
+
self, overrides: cabc.Mapping[str, str | None] | None = None
|
| 355 |
+
) -> cabc.Mapping[str, str | None]:
|
| 356 |
+
"""Returns the environment overrides for invoking a script."""
|
| 357 |
+
rv = dict(self.env)
|
| 358 |
+
if overrides:
|
| 359 |
+
rv.update(overrides)
|
| 360 |
+
return rv
|
| 361 |
+
|
| 362 |
+
@contextlib.contextmanager
|
| 363 |
+
def isolation(
|
| 364 |
+
self,
|
| 365 |
+
input: str | bytes | t.IO[t.Any] | None = None,
|
| 366 |
+
env: cabc.Mapping[str, str | None] | None = None,
|
| 367 |
+
color: bool = False,
|
| 368 |
+
) -> cabc.Iterator[tuple[io.BytesIO, io.BytesIO, io.BytesIO]]:
|
| 369 |
+
"""A context manager that sets up the isolation for invoking of a
|
| 370 |
+
command line tool. This sets up `<stdin>` with the given input data
|
| 371 |
+
and `os.environ` with the overrides from the given dictionary.
|
| 372 |
+
This also rebinds some internals in Click to be mocked (like the
|
| 373 |
+
prompt functionality).
|
| 374 |
+
|
| 375 |
+
This is automatically done in the :meth:`invoke` method.
|
| 376 |
+
|
| 377 |
+
:param input: the input stream to put into `sys.stdin`.
|
| 378 |
+
:param env: the environment overrides as dictionary.
|
| 379 |
+
:param color: whether the output should contain color codes. The
|
| 380 |
+
application can still override this explicitly.
|
| 381 |
+
|
| 382 |
+
.. versionadded:: 8.2
|
| 383 |
+
An additional output stream is returned, which is a mix of
|
| 384 |
+
`<stdout>` and `<stderr>` streams.
|
| 385 |
+
|
| 386 |
+
.. versionchanged:: 8.2
|
| 387 |
+
Always returns the `<stderr>` stream.
|
| 388 |
+
|
| 389 |
+
.. versionchanged:: 8.0
|
| 390 |
+
`<stderr>` is opened with ``errors="backslashreplace"``
|
| 391 |
+
instead of the default ``"strict"``.
|
| 392 |
+
|
| 393 |
+
.. versionchanged:: 4.0
|
| 394 |
+
Added the ``color`` parameter.
|
| 395 |
+
"""
|
| 396 |
+
bytes_input = make_input_stream(input, self.charset)
|
| 397 |
+
echo_input = None
|
| 398 |
+
|
| 399 |
+
old_stdin = sys.stdin
|
| 400 |
+
old_stdout = sys.stdout
|
| 401 |
+
old_stderr = sys.stderr
|
| 402 |
+
old_forced_width = formatting.FORCED_WIDTH
|
| 403 |
+
formatting.FORCED_WIDTH = 80
|
| 404 |
+
|
| 405 |
+
env = self.make_env(env)
|
| 406 |
+
|
| 407 |
+
stream_mixer = StreamMixer()
|
| 408 |
+
|
| 409 |
+
if self.echo_stdin:
|
| 410 |
+
bytes_input = echo_input = t.cast(
|
| 411 |
+
t.BinaryIO, EchoingStdin(bytes_input, stream_mixer.stdout)
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
sys.stdin = text_input = _NamedTextIOWrapper(
|
| 415 |
+
bytes_input, encoding=self.charset, name="<stdin>", mode="r"
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
if self.echo_stdin:
|
| 419 |
+
# Force unbuffered reads, otherwise TextIOWrapper reads a
|
| 420 |
+
# large chunk which is echoed early.
|
| 421 |
+
text_input._CHUNK_SIZE = 1 # type: ignore
|
| 422 |
+
|
| 423 |
+
sys.stdout = _NamedTextIOWrapper(
|
| 424 |
+
stream_mixer.stdout,
|
| 425 |
+
encoding=self.charset,
|
| 426 |
+
name="<stdout>",
|
| 427 |
+
mode="w",
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
sys.stderr = _NamedTextIOWrapper(
|
| 431 |
+
stream_mixer.stderr,
|
| 432 |
+
encoding=self.charset,
|
| 433 |
+
name="<stderr>",
|
| 434 |
+
mode="w",
|
| 435 |
+
errors="backslashreplace",
|
| 436 |
+
)
|
| 437 |
+
|
| 438 |
+
@_pause_echo(echo_input) # type: ignore
|
| 439 |
+
def visible_input(prompt: str | None = None) -> str:
|
| 440 |
+
sys.stdout.write(prompt or "")
|
| 441 |
+
try:
|
| 442 |
+
val = next(text_input).rstrip("\r\n")
|
| 443 |
+
except StopIteration as e:
|
| 444 |
+
raise EOFError() from e
|
| 445 |
+
sys.stdout.write(f"{val}\n")
|
| 446 |
+
sys.stdout.flush()
|
| 447 |
+
return val
|
| 448 |
+
|
| 449 |
+
@_pause_echo(echo_input) # type: ignore
|
| 450 |
+
def hidden_input(prompt: str | None = None) -> str:
|
| 451 |
+
sys.stdout.write(f"{prompt or ''}\n")
|
| 452 |
+
sys.stdout.flush()
|
| 453 |
+
try:
|
| 454 |
+
return next(text_input).rstrip("\r\n")
|
| 455 |
+
except StopIteration as e:
|
| 456 |
+
raise EOFError() from e
|
| 457 |
+
|
| 458 |
+
@_pause_echo(echo_input) # type: ignore
|
| 459 |
+
def _getchar(echo: bool) -> str:
|
| 460 |
+
char = sys.stdin.read(1)
|
| 461 |
+
|
| 462 |
+
if echo:
|
| 463 |
+
sys.stdout.write(char)
|
| 464 |
+
|
| 465 |
+
sys.stdout.flush()
|
| 466 |
+
return char
|
| 467 |
+
|
| 468 |
+
default_color = color
|
| 469 |
+
|
| 470 |
+
def should_strip_ansi(
|
| 471 |
+
stream: t.IO[t.Any] | None = None, color: bool | None = None
|
| 472 |
+
) -> bool:
|
| 473 |
+
if color is None:
|
| 474 |
+
return not default_color
|
| 475 |
+
return not color
|
| 476 |
+
|
| 477 |
+
old_visible_prompt_func = termui.visible_prompt_func
|
| 478 |
+
old_hidden_prompt_func = termui.hidden_prompt_func
|
| 479 |
+
old__getchar_func = termui._getchar
|
| 480 |
+
old_should_strip_ansi = utils.should_strip_ansi # type: ignore
|
| 481 |
+
old__compat_should_strip_ansi = _compat.should_strip_ansi
|
| 482 |
+
old_pdb_init = pdb.Pdb.__init__
|
| 483 |
+
termui.visible_prompt_func = visible_input
|
| 484 |
+
termui.hidden_prompt_func = hidden_input
|
| 485 |
+
termui._getchar = _getchar
|
| 486 |
+
utils.should_strip_ansi = should_strip_ansi # type: ignore
|
| 487 |
+
_compat.should_strip_ansi = should_strip_ansi
|
| 488 |
+
|
| 489 |
+
def _patched_pdb_init(
|
| 490 |
+
self: pdb.Pdb,
|
| 491 |
+
completekey: str = "tab",
|
| 492 |
+
stdin: t.IO[str] | None = None,
|
| 493 |
+
stdout: t.IO[str] | None = None,
|
| 494 |
+
**kwargs: t.Any,
|
| 495 |
+
) -> None:
|
| 496 |
+
"""Default ``pdb.Pdb`` to real terminal streams during
|
| 497 |
+
``CliRunner`` isolation.
|
| 498 |
+
|
| 499 |
+
Without this patch, ``pdb.Pdb.__init__`` inherits from
|
| 500 |
+
``cmd.Cmd`` which falls back to ``sys.stdin``/``sys.stdout``
|
| 501 |
+
when no explicit streams are provided. During isolation
|
| 502 |
+
those are ``BytesIO``-backed wrappers, so the debugger
|
| 503 |
+
reads from an empty buffer and writes to captured output,
|
| 504 |
+
making interactive debugging impossible.
|
| 505 |
+
|
| 506 |
+
By defaulting to ``sys.__stdin__``/``sys.__stdout__`` (the
|
| 507 |
+
original terminal streams Python preserves regardless of
|
| 508 |
+
redirection), debuggers can interact with the user while
|
| 509 |
+
``click.echo`` output is still captured normally.
|
| 510 |
+
|
| 511 |
+
This covers ``pdb.set_trace()``, ``breakpoint()``,
|
| 512 |
+
``pdb.post_mortem()``, and debuggers that subclass
|
| 513 |
+
``pdb.Pdb`` (ipdb, pdbpp). Explicit ``stdin``/``stdout``
|
| 514 |
+
arguments are honored and not overridden. Debuggers that
|
| 515 |
+
do not subclass ``pdb.Pdb`` (pudb, debugpy) are not
|
| 516 |
+
covered.
|
| 517 |
+
"""
|
| 518 |
+
if stdin is None:
|
| 519 |
+
stdin = sys.__stdin__
|
| 520 |
+
if stdout is None:
|
| 521 |
+
stdout = sys.__stdout__
|
| 522 |
+
old_pdb_init(
|
| 523 |
+
self, completekey=completekey, stdin=stdin, stdout=stdout, **kwargs
|
| 524 |
+
)
|
| 525 |
+
|
| 526 |
+
pdb.Pdb.__init__ = _patched_pdb_init # type: ignore[assignment]
|
| 527 |
+
|
| 528 |
+
old_env = {}
|
| 529 |
+
try:
|
| 530 |
+
for key, value in env.items():
|
| 531 |
+
old_env[key] = os.environ.get(key)
|
| 532 |
+
if value is None:
|
| 533 |
+
try:
|
| 534 |
+
del os.environ[key]
|
| 535 |
+
except Exception:
|
| 536 |
+
pass
|
| 537 |
+
else:
|
| 538 |
+
os.environ[key] = value
|
| 539 |
+
yield (stream_mixer.stdout, stream_mixer.stderr, stream_mixer.output)
|
| 540 |
+
finally:
|
| 541 |
+
for key, value in old_env.items():
|
| 542 |
+
if value is None:
|
| 543 |
+
try:
|
| 544 |
+
del os.environ[key]
|
| 545 |
+
except Exception:
|
| 546 |
+
pass
|
| 547 |
+
else:
|
| 548 |
+
os.environ[key] = value
|
| 549 |
+
sys.stdout = old_stdout
|
| 550 |
+
sys.stderr = old_stderr
|
| 551 |
+
sys.stdin = old_stdin
|
| 552 |
+
termui.visible_prompt_func = old_visible_prompt_func
|
| 553 |
+
termui.hidden_prompt_func = old_hidden_prompt_func
|
| 554 |
+
termui._getchar = old__getchar_func
|
| 555 |
+
utils.should_strip_ansi = old_should_strip_ansi # type: ignore
|
| 556 |
+
_compat.should_strip_ansi = old__compat_should_strip_ansi
|
| 557 |
+
formatting.FORCED_WIDTH = old_forced_width
|
| 558 |
+
pdb.Pdb.__init__ = old_pdb_init # type: ignore[method-assign]
|
| 559 |
+
|
| 560 |
+
def invoke(
|
| 561 |
+
self,
|
| 562 |
+
cli: Command,
|
| 563 |
+
args: str | cabc.Sequence[str] | None = None,
|
| 564 |
+
input: str | bytes | t.IO[t.Any] | None = None,
|
| 565 |
+
env: cabc.Mapping[str, str | None] | None = None,
|
| 566 |
+
catch_exceptions: bool | None = None,
|
| 567 |
+
color: bool = False,
|
| 568 |
+
**extra: t.Any,
|
| 569 |
+
) -> Result:
|
| 570 |
+
"""Invokes a command in an isolated environment. The arguments are
|
| 571 |
+
forwarded directly to the command line script, the `extra` keyword
|
| 572 |
+
arguments are passed to the :meth:`~clickpkg.Command.main` function of
|
| 573 |
+
the command.
|
| 574 |
+
|
| 575 |
+
This returns a :class:`Result` object.
|
| 576 |
+
|
| 577 |
+
:param cli: the command to invoke
|
| 578 |
+
:param args: the arguments to invoke. It may be given as an iterable
|
| 579 |
+
or a string. When given as string it will be interpreted
|
| 580 |
+
as a Unix shell command. More details at
|
| 581 |
+
:func:`shlex.split`.
|
| 582 |
+
:param input: the input data for `sys.stdin`.
|
| 583 |
+
:param env: the environment overrides.
|
| 584 |
+
:param catch_exceptions: Whether to catch any other exceptions than
|
| 585 |
+
``SystemExit``. If :data:`None`, the value
|
| 586 |
+
from :class:`CliRunner` is used.
|
| 587 |
+
:param extra: the keyword arguments to pass to :meth:`main`.
|
| 588 |
+
:param color: whether the output should contain color codes. The
|
| 589 |
+
application can still override this explicitly.
|
| 590 |
+
|
| 591 |
+
.. versionadded:: 8.2
|
| 592 |
+
The result object has the ``output_bytes`` attribute with
|
| 593 |
+
the mix of ``stdout_bytes`` and ``stderr_bytes``, as the user would
|
| 594 |
+
see it in its terminal.
|
| 595 |
+
|
| 596 |
+
.. versionchanged:: 8.2
|
| 597 |
+
The result object always returns the ``stderr_bytes`` stream.
|
| 598 |
+
|
| 599 |
+
.. versionchanged:: 8.0
|
| 600 |
+
The result object has the ``return_value`` attribute with
|
| 601 |
+
the value returned from the invoked command.
|
| 602 |
+
|
| 603 |
+
.. versionchanged:: 4.0
|
| 604 |
+
Added the ``color`` parameter.
|
| 605 |
+
|
| 606 |
+
.. versionchanged:: 3.0
|
| 607 |
+
Added the ``catch_exceptions`` parameter.
|
| 608 |
+
|
| 609 |
+
.. versionchanged:: 3.0
|
| 610 |
+
The result object has the ``exc_info`` attribute with the
|
| 611 |
+
traceback if available.
|
| 612 |
+
"""
|
| 613 |
+
exc_info = None
|
| 614 |
+
if catch_exceptions is None:
|
| 615 |
+
catch_exceptions = self.catch_exceptions
|
| 616 |
+
|
| 617 |
+
# Set up fd capture before isolation replaces sys.stdout and sys.stderr.
|
| 618 |
+
cap_out: _FDCapture | None = None
|
| 619 |
+
cap_err: _FDCapture | None = None
|
| 620 |
+
|
| 621 |
+
if self.capture == "fd":
|
| 622 |
+
cap_out = _FDCapture(1)
|
| 623 |
+
cap_err = _FDCapture(2)
|
| 624 |
+
try:
|
| 625 |
+
cap_out.start()
|
| 626 |
+
cap_err.start()
|
| 627 |
+
except OSError:
|
| 628 |
+
cap_out = cap_err = None
|
| 629 |
+
|
| 630 |
+
with self.isolation(input=input, env=env, color=color) as outstreams:
|
| 631 |
+
# Point the captured streams' fileno() at the saved (original)
|
| 632 |
+
# fd so that C-level consumers like faulthandler keep working
|
| 633 |
+
# while fd 1/2 are redirected to the capture tmpfile.
|
| 634 |
+
if cap_out is not None and cap_err is not None:
|
| 635 |
+
sys.stdout._original_fd = cap_out.saved_fd # type: ignore[union-attr]
|
| 636 |
+
sys.stderr._original_fd = cap_err.saved_fd # type: ignore[union-attr]
|
| 637 |
+
|
| 638 |
+
return_value = None
|
| 639 |
+
exception: BaseException | None = None
|
| 640 |
+
exit_code = 0
|
| 641 |
+
|
| 642 |
+
if isinstance(args, str):
|
| 643 |
+
args = shlex.split(args)
|
| 644 |
+
|
| 645 |
+
try:
|
| 646 |
+
prog_name = extra.pop("prog_name")
|
| 647 |
+
except KeyError:
|
| 648 |
+
prog_name = self.get_default_prog_name(cli)
|
| 649 |
+
|
| 650 |
+
try:
|
| 651 |
+
return_value = cli.main(args=args or (), prog_name=prog_name, **extra)
|
| 652 |
+
except SystemExit as e:
|
| 653 |
+
exc_info = sys.exc_info()
|
| 654 |
+
e_code = t.cast("int | t.Any | None", e.code)
|
| 655 |
+
|
| 656 |
+
if e_code is None:
|
| 657 |
+
e_code = 0
|
| 658 |
+
|
| 659 |
+
if e_code != 0:
|
| 660 |
+
exception = e
|
| 661 |
+
|
| 662 |
+
if not isinstance(e_code, int):
|
| 663 |
+
sys.stdout.write(str(e_code))
|
| 664 |
+
sys.stdout.write("\n")
|
| 665 |
+
e_code = 1
|
| 666 |
+
|
| 667 |
+
exit_code = e_code
|
| 668 |
+
|
| 669 |
+
except Exception as e:
|
| 670 |
+
if not catch_exceptions:
|
| 671 |
+
raise
|
| 672 |
+
exception = e
|
| 673 |
+
exit_code = 1
|
| 674 |
+
exc_info = sys.exc_info()
|
| 675 |
+
finally:
|
| 676 |
+
sys.stdout.flush()
|
| 677 |
+
sys.stderr.flush()
|
| 678 |
+
|
| 679 |
+
# Stop fd capture and merge the captured bytes into
|
| 680 |
+
# the stdout/stderr BytesIO streams. BytesIOCopy mirrors
|
| 681 |
+
# those writes into outstreams[2] automatically.
|
| 682 |
+
if cap_out is not None and cap_err is not None:
|
| 683 |
+
fd_out = cap_out.stop()
|
| 684 |
+
fd_err = cap_err.stop()
|
| 685 |
+
if fd_out:
|
| 686 |
+
outstreams[0].write(fd_out)
|
| 687 |
+
if fd_err:
|
| 688 |
+
outstreams[1].write(fd_err)
|
| 689 |
+
|
| 690 |
+
stdout = outstreams[0].getvalue()
|
| 691 |
+
stderr = outstreams[1].getvalue()
|
| 692 |
+
output = outstreams[2].getvalue()
|
| 693 |
+
|
| 694 |
+
return Result(
|
| 695 |
+
runner=self,
|
| 696 |
+
stdout_bytes=stdout,
|
| 697 |
+
stderr_bytes=stderr,
|
| 698 |
+
output_bytes=output,
|
| 699 |
+
return_value=return_value,
|
| 700 |
+
exit_code=exit_code,
|
| 701 |
+
exception=exception,
|
| 702 |
+
exc_info=exc_info, # type: ignore
|
| 703 |
+
)
|
| 704 |
+
|
| 705 |
+
@contextlib.contextmanager
|
| 706 |
+
def isolated_filesystem(
|
| 707 |
+
self, temp_dir: str | os.PathLike[str] | None = None
|
| 708 |
+
) -> cabc.Iterator[str]:
|
| 709 |
+
"""A context manager that creates a temporary directory and
|
| 710 |
+
changes the current working directory to it. This isolates tests
|
| 711 |
+
that affect the contents of the CWD to prevent them from
|
| 712 |
+
interfering with each other.
|
| 713 |
+
|
| 714 |
+
:param temp_dir: Create the temporary directory under this
|
| 715 |
+
directory. If given, the created directory is not removed
|
| 716 |
+
when exiting.
|
| 717 |
+
|
| 718 |
+
.. versionchanged:: 8.0
|
| 719 |
+
Added the ``temp_dir`` parameter.
|
| 720 |
+
"""
|
| 721 |
+
cwd = os.getcwd()
|
| 722 |
+
dt = tempfile.mkdtemp(dir=temp_dir)
|
| 723 |
+
os.chdir(dt)
|
| 724 |
+
|
| 725 |
+
try:
|
| 726 |
+
yield dt
|
| 727 |
+
finally:
|
| 728 |
+
os.chdir(cwd)
|
| 729 |
+
|
| 730 |
+
if temp_dir is None:
|
| 731 |
+
import shutil
|
| 732 |
+
|
| 733 |
+
try:
|
| 734 |
+
shutil.rmtree(dt)
|
| 735 |
+
except OSError:
|
| 736 |
+
pass
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/packaging/licenses/__init__.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#######################################################################################
|
| 2 |
+
#
|
| 3 |
+
# Adapted from:
|
| 4 |
+
# https://github.com/pypa/hatch/blob/5352e44/backend/src/hatchling/licenses/parse.py
|
| 5 |
+
#
|
| 6 |
+
# MIT License
|
| 7 |
+
#
|
| 8 |
+
# Copyright (c) 2017-present Ofek Lev <oss@ofek.dev>
|
| 9 |
+
#
|
| 10 |
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
| 11 |
+
# software and associated documentation files (the "Software"), to deal in the Software
|
| 12 |
+
# without restriction, including without limitation the rights to use, copy, modify,
|
| 13 |
+
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
| 14 |
+
# permit persons to whom the Software is furnished to do so, subject to the following
|
| 15 |
+
# conditions:
|
| 16 |
+
#
|
| 17 |
+
# The above copyright notice and this permission notice shall be included in all copies
|
| 18 |
+
# or substantial portions of the Software.
|
| 19 |
+
#
|
| 20 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
| 21 |
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
| 22 |
+
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 23 |
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
| 24 |
+
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
| 25 |
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
#
|
| 27 |
+
#
|
| 28 |
+
# With additional allowance of arbitrary `LicenseRef-` identifiers, not just
|
| 29 |
+
# `LicenseRef-Public-Domain` and `LicenseRef-Proprietary`.
|
| 30 |
+
#
|
| 31 |
+
#######################################################################################
|
| 32 |
+
from __future__ import annotations
|
| 33 |
+
|
| 34 |
+
import re
|
| 35 |
+
from typing import NewType, cast
|
| 36 |
+
|
| 37 |
+
from ._spdx import EXCEPTIONS, LICENSES
|
| 38 |
+
|
| 39 |
+
__all__ = [
|
| 40 |
+
"InvalidLicenseExpression",
|
| 41 |
+
"NormalizedLicenseExpression",
|
| 42 |
+
"canonicalize_license_expression",
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# Simple __dir__ implementation since there are no public submodules
|
| 47 |
+
def __dir__() -> list[str]:
|
| 48 |
+
return __all__
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
license_ref_allowed = re.compile("^[A-Za-z0-9.-]*$")
|
| 52 |
+
|
| 53 |
+
NormalizedLicenseExpression = NewType("NormalizedLicenseExpression", str)
|
| 54 |
+
"""
|
| 55 |
+
A :class:`typing.NewType` of :class:`str`, representing a normalized
|
| 56 |
+
License-Expression.
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class InvalidLicenseExpression(ValueError):
|
| 61 |
+
"""Raised when a license-expression string is invalid
|
| 62 |
+
|
| 63 |
+
>>> from packaging.licenses import canonicalize_license_expression
|
| 64 |
+
>>> canonicalize_license_expression("invalid")
|
| 65 |
+
Traceback (most recent call last):
|
| 66 |
+
...
|
| 67 |
+
packaging.licenses.InvalidLicenseExpression: Invalid license expression: 'invalid'
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def canonicalize_license_expression(
|
| 72 |
+
raw_license_expression: str,
|
| 73 |
+
) -> NormalizedLicenseExpression:
|
| 74 |
+
"""
|
| 75 |
+
This function takes a valid License-Expression, and returns the normalized
|
| 76 |
+
form of it.
|
| 77 |
+
|
| 78 |
+
The return type is typed as :class:`NormalizedLicenseExpression`. This
|
| 79 |
+
allows type checkers to help require that a string has passed through this
|
| 80 |
+
function before use.
|
| 81 |
+
|
| 82 |
+
:param str raw_license_expression: The License-Expression to canonicalize.
|
| 83 |
+
:raises InvalidLicenseExpression: If the License-Expression is invalid due to an
|
| 84 |
+
invalid/unknown license identifier or invalid syntax.
|
| 85 |
+
|
| 86 |
+
.. doctest::
|
| 87 |
+
|
| 88 |
+
>>> from packaging.licenses import canonicalize_license_expression
|
| 89 |
+
>>> canonicalize_license_expression("mit")
|
| 90 |
+
'MIT'
|
| 91 |
+
>>> canonicalize_license_expression("mit and (apache-2.0 or bsd-2-clause)")
|
| 92 |
+
'MIT AND (Apache-2.0 OR BSD-2-Clause)'
|
| 93 |
+
>>> canonicalize_license_expression("(mit")
|
| 94 |
+
Traceback (most recent call last):
|
| 95 |
+
...
|
| 96 |
+
InvalidLicenseExpression: Invalid license expression: '(mit'
|
| 97 |
+
>>> canonicalize_license_expression("Use-it-after-midnight")
|
| 98 |
+
Traceback (most recent call last):
|
| 99 |
+
...
|
| 100 |
+
InvalidLicenseExpression: Unknown license: 'Use-it-after-midnight'
|
| 101 |
+
"""
|
| 102 |
+
if not raw_license_expression:
|
| 103 |
+
message = f"Invalid license expression: {raw_license_expression!r}"
|
| 104 |
+
raise InvalidLicenseExpression(message)
|
| 105 |
+
|
| 106 |
+
# Pad any parentheses so tokenization can be achieved by merely splitting on
|
| 107 |
+
# whitespace.
|
| 108 |
+
license_expression = raw_license_expression.replace("(", " ( ").replace(")", " ) ")
|
| 109 |
+
licenseref_prefix = "LicenseRef-"
|
| 110 |
+
license_refs = {
|
| 111 |
+
ref.lower(): "LicenseRef-" + ref[len(licenseref_prefix) :]
|
| 112 |
+
for ref in license_expression.split()
|
| 113 |
+
if ref.lower().startswith(licenseref_prefix.lower())
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
# Normalize to lower case so we can look up licenses/exceptions
|
| 117 |
+
# and so boolean operators are Python-compatible.
|
| 118 |
+
license_expression = license_expression.lower()
|
| 119 |
+
|
| 120 |
+
tokens = license_expression.split()
|
| 121 |
+
|
| 122 |
+
# Rather than implementing a parenthesis/boolean logic parser, create an
|
| 123 |
+
# expression that Python can parse. Everything that is not involved with the
|
| 124 |
+
# grammar itself is replaced with the placeholder `False` and the resultant
|
| 125 |
+
# expression should become a valid Python expression.
|
| 126 |
+
python_tokens = []
|
| 127 |
+
for token in tokens:
|
| 128 |
+
if token not in {"or", "and", "with", "(", ")"}:
|
| 129 |
+
python_tokens.append("False")
|
| 130 |
+
elif token == "with":
|
| 131 |
+
python_tokens.append("or")
|
| 132 |
+
elif (
|
| 133 |
+
token == "("
|
| 134 |
+
and python_tokens
|
| 135 |
+
and python_tokens[-1] not in {"or", "and", "("}
|
| 136 |
+
) or (token == ")" and python_tokens and python_tokens[-1] == "("):
|
| 137 |
+
message = f"Invalid license expression: {raw_license_expression!r}"
|
| 138 |
+
raise InvalidLicenseExpression(message)
|
| 139 |
+
else:
|
| 140 |
+
python_tokens.append(token)
|
| 141 |
+
|
| 142 |
+
python_expression = " ".join(python_tokens)
|
| 143 |
+
try:
|
| 144 |
+
compile(python_expression, "", "eval")
|
| 145 |
+
except SyntaxError:
|
| 146 |
+
message = f"Invalid license expression: {raw_license_expression!r}"
|
| 147 |
+
raise InvalidLicenseExpression(message) from None
|
| 148 |
+
|
| 149 |
+
# Take a final pass to check for unknown licenses/exceptions.
|
| 150 |
+
normalized_tokens = []
|
| 151 |
+
for token in tokens:
|
| 152 |
+
if token in {"or", "and", "with", "(", ")"}:
|
| 153 |
+
normalized_tokens.append(token.upper())
|
| 154 |
+
continue
|
| 155 |
+
|
| 156 |
+
if normalized_tokens and normalized_tokens[-1] == "WITH":
|
| 157 |
+
if token not in EXCEPTIONS:
|
| 158 |
+
message = f"Unknown license exception: {token!r}"
|
| 159 |
+
raise InvalidLicenseExpression(message)
|
| 160 |
+
|
| 161 |
+
normalized_tokens.append(EXCEPTIONS[token]["id"])
|
| 162 |
+
else:
|
| 163 |
+
if token.endswith("+"):
|
| 164 |
+
final_token = token[:-1]
|
| 165 |
+
suffix = "+"
|
| 166 |
+
else:
|
| 167 |
+
final_token = token
|
| 168 |
+
suffix = ""
|
| 169 |
+
|
| 170 |
+
if final_token.startswith("licenseref-"):
|
| 171 |
+
if not license_ref_allowed.match(final_token):
|
| 172 |
+
message = f"Invalid licenseref: {final_token!r}"
|
| 173 |
+
raise InvalidLicenseExpression(message)
|
| 174 |
+
normalized_tokens.append(license_refs[final_token] + suffix)
|
| 175 |
+
else:
|
| 176 |
+
if final_token not in LICENSES:
|
| 177 |
+
message = f"Unknown license: {final_token!r}"
|
| 178 |
+
raise InvalidLicenseExpression(message)
|
| 179 |
+
normalized_tokens.append(LICENSES[final_token]["id"] + suffix)
|
| 180 |
+
|
| 181 |
+
normalized_expression = " ".join(normalized_tokens)
|
| 182 |
+
|
| 183 |
+
return cast(
|
| 184 |
+
"NormalizedLicenseExpression",
|
| 185 |
+
normalized_expression.replace("( ", "(").replace(" )", ")"),
|
| 186 |
+
)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/_mapping.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Automatically generated by scripts/gen_mapfiles.py.
|
| 2 |
+
# DO NOT EDIT BY HAND; run `tox -e mapfiles` instead.
|
| 3 |
+
|
| 4 |
+
STYLES = {
|
| 5 |
+
'AbapStyle': ('pygments.styles.abap', 'abap', ()),
|
| 6 |
+
'AlgolStyle': ('pygments.styles.algol', 'algol', ()),
|
| 7 |
+
'Algol_NuStyle': ('pygments.styles.algol_nu', 'algol_nu', ()),
|
| 8 |
+
'ArduinoStyle': ('pygments.styles.arduino', 'arduino', ()),
|
| 9 |
+
'AutumnStyle': ('pygments.styles.autumn', 'autumn', ()),
|
| 10 |
+
'BlackWhiteStyle': ('pygments.styles.bw', 'bw', ()),
|
| 11 |
+
'BorlandStyle': ('pygments.styles.borland', 'borland', ()),
|
| 12 |
+
'CoffeeStyle': ('pygments.styles.coffee', 'coffee', ()),
|
| 13 |
+
'ColorfulStyle': ('pygments.styles.colorful', 'colorful', ()),
|
| 14 |
+
'DefaultStyle': ('pygments.styles.default', 'default', ()),
|
| 15 |
+
'DraculaStyle': ('pygments.styles.dracula', 'dracula', ()),
|
| 16 |
+
'EmacsStyle': ('pygments.styles.emacs', 'emacs', ()),
|
| 17 |
+
'FriendlyGrayscaleStyle': ('pygments.styles.friendly_grayscale', 'friendly_grayscale', ()),
|
| 18 |
+
'FriendlyStyle': ('pygments.styles.friendly', 'friendly', ()),
|
| 19 |
+
'FruityStyle': ('pygments.styles.fruity', 'fruity', ()),
|
| 20 |
+
'GhDarkStyle': ('pygments.styles.gh_dark', 'github-dark', ()),
|
| 21 |
+
'GruvboxDarkStyle': ('pygments.styles.gruvbox', 'gruvbox-dark', ()),
|
| 22 |
+
'GruvboxLightStyle': ('pygments.styles.gruvbox', 'gruvbox-light', ()),
|
| 23 |
+
'IgorStyle': ('pygments.styles.igor', 'igor', ()),
|
| 24 |
+
'InkPotStyle': ('pygments.styles.inkpot', 'inkpot', ()),
|
| 25 |
+
'LightbulbStyle': ('pygments.styles.lightbulb', 'lightbulb', ()),
|
| 26 |
+
'LilyPondStyle': ('pygments.styles.lilypond', 'lilypond', ()),
|
| 27 |
+
'LovelaceStyle': ('pygments.styles.lovelace', 'lovelace', ()),
|
| 28 |
+
'ManniStyle': ('pygments.styles.manni', 'manni', ()),
|
| 29 |
+
'MaterialStyle': ('pygments.styles.material', 'material', ()),
|
| 30 |
+
'MonokaiStyle': ('pygments.styles.monokai', 'monokai', ()),
|
| 31 |
+
'MurphyStyle': ('pygments.styles.murphy', 'murphy', ()),
|
| 32 |
+
'NativeStyle': ('pygments.styles.native', 'native', ()),
|
| 33 |
+
'NordDarkerStyle': ('pygments.styles.nord', 'nord-darker', ()),
|
| 34 |
+
'NordStyle': ('pygments.styles.nord', 'nord', ()),
|
| 35 |
+
'OneDarkStyle': ('pygments.styles.onedark', 'one-dark', ()),
|
| 36 |
+
'ParaisoDarkStyle': ('pygments.styles.paraiso_dark', 'paraiso-dark', ()),
|
| 37 |
+
'ParaisoLightStyle': ('pygments.styles.paraiso_light', 'paraiso-light', ()),
|
| 38 |
+
'PastieStyle': ('pygments.styles.pastie', 'pastie', ()),
|
| 39 |
+
'PerldocStyle': ('pygments.styles.perldoc', 'perldoc', ()),
|
| 40 |
+
'RainbowDashStyle': ('pygments.styles.rainbow_dash', 'rainbow_dash', ()),
|
| 41 |
+
'RrtStyle': ('pygments.styles.rrt', 'rrt', ()),
|
| 42 |
+
'SasStyle': ('pygments.styles.sas', 'sas', ()),
|
| 43 |
+
'SolarizedDarkStyle': ('pygments.styles.solarized', 'solarized-dark', ()),
|
| 44 |
+
'SolarizedLightStyle': ('pygments.styles.solarized', 'solarized-light', ()),
|
| 45 |
+
'StarofficeStyle': ('pygments.styles.staroffice', 'staroffice', ()),
|
| 46 |
+
'StataDarkStyle': ('pygments.styles.stata_dark', 'stata-dark', ()),
|
| 47 |
+
'StataLightStyle': ('pygments.styles.stata_light', 'stata-light', ()),
|
| 48 |
+
'TangoStyle': ('pygments.styles.tango', 'tango', ()),
|
| 49 |
+
'TracStyle': ('pygments.styles.trac', 'trac', ()),
|
| 50 |
+
'VimStyle': ('pygments.styles.vim', 'vim', ()),
|
| 51 |
+
'VisualStudioStyle': ('pygments.styles.vs', 'vs', ()),
|
| 52 |
+
'XcodeStyle': ('pygments.styles.xcode', 'xcode', ()),
|
| 53 |
+
'ZenburnStyle': ('pygments.styles.zenburn', 'zenburn', ()),
|
| 54 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/arduino.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.arduino
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Arduino® Syntax highlighting style.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.style import Style
|
| 12 |
+
from pygments.token import Keyword, Name, Comment, String, Error, \
|
| 13 |
+
Number, Operator, Generic, Whitespace
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
__all__ = ['ArduinoStyle']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class ArduinoStyle(Style):
|
| 20 |
+
"""
|
| 21 |
+
The Arduino® language style. This style is designed to highlight the
|
| 22 |
+
Arduino source code, so expect the best results with it.
|
| 23 |
+
"""
|
| 24 |
+
name = 'arduino'
|
| 25 |
+
|
| 26 |
+
background_color = "#ffffff"
|
| 27 |
+
|
| 28 |
+
styles = {
|
| 29 |
+
Whitespace: "", # class: 'w'
|
| 30 |
+
Error: "#a61717", # class: 'err'
|
| 31 |
+
|
| 32 |
+
Comment: "#95a5a6", # class: 'c'
|
| 33 |
+
Comment.Multiline: "", # class: 'cm'
|
| 34 |
+
Comment.Preproc: "#728E00", # class: 'cp'
|
| 35 |
+
Comment.Single: "", # class: 'c1'
|
| 36 |
+
Comment.Special: "", # class: 'cs'
|
| 37 |
+
|
| 38 |
+
Keyword: "#728E00", # class: 'k'
|
| 39 |
+
Keyword.Constant: "#00979D", # class: 'kc'
|
| 40 |
+
Keyword.Declaration: "", # class: 'kd'
|
| 41 |
+
Keyword.Namespace: "", # class: 'kn'
|
| 42 |
+
Keyword.Pseudo: "#00979D", # class: 'kp'
|
| 43 |
+
Keyword.Reserved: "#00979D", # class: 'kr'
|
| 44 |
+
Keyword.Type: "#00979D", # class: 'kt'
|
| 45 |
+
|
| 46 |
+
Operator: "#728E00", # class: 'o'
|
| 47 |
+
Operator.Word: "", # class: 'ow'
|
| 48 |
+
|
| 49 |
+
Name: "#434f54", # class: 'n'
|
| 50 |
+
Name.Attribute: "", # class: 'na'
|
| 51 |
+
Name.Builtin: "#728E00", # class: 'nb'
|
| 52 |
+
Name.Builtin.Pseudo: "", # class: 'bp'
|
| 53 |
+
Name.Class: "", # class: 'nc'
|
| 54 |
+
Name.Constant: "", # class: 'no'
|
| 55 |
+
Name.Decorator: "", # class: 'nd'
|
| 56 |
+
Name.Entity: "", # class: 'ni'
|
| 57 |
+
Name.Exception: "", # class: 'ne'
|
| 58 |
+
Name.Function: "#D35400", # class: 'nf'
|
| 59 |
+
Name.Property: "", # class: 'py'
|
| 60 |
+
Name.Label: "", # class: 'nl'
|
| 61 |
+
Name.Namespace: "", # class: 'nn'
|
| 62 |
+
Name.Other: "#728E00", # class: 'nx'
|
| 63 |
+
Name.Tag: "", # class: 'nt'
|
| 64 |
+
Name.Variable: "", # class: 'nv'
|
| 65 |
+
Name.Variable.Class: "", # class: 'vc'
|
| 66 |
+
Name.Variable.Global: "", # class: 'vg'
|
| 67 |
+
Name.Variable.Instance: "", # class: 'vi'
|
| 68 |
+
|
| 69 |
+
Number: "#8A7B52", # class: 'm'
|
| 70 |
+
Number.Float: "", # class: 'mf'
|
| 71 |
+
Number.Hex: "", # class: 'mh'
|
| 72 |
+
Number.Integer: "", # class: 'mi'
|
| 73 |
+
Number.Integer.Long: "", # class: 'il'
|
| 74 |
+
Number.Oct: "", # class: 'mo'
|
| 75 |
+
|
| 76 |
+
String: "#7F8C8D", # class: 's'
|
| 77 |
+
String.Backtick: "", # class: 'sb'
|
| 78 |
+
String.Char: "", # class: 'sc'
|
| 79 |
+
String.Doc: "", # class: 'sd'
|
| 80 |
+
String.Double: "", # class: 's2'
|
| 81 |
+
String.Escape: "", # class: 'se'
|
| 82 |
+
String.Heredoc: "", # class: 'sh'
|
| 83 |
+
String.Interpol: "", # class: 'si'
|
| 84 |
+
String.Other: "", # class: 'sx'
|
| 85 |
+
String.Regex: "", # class: 'sr'
|
| 86 |
+
String.Single: "", # class: 's1'
|
| 87 |
+
String.Symbol: "", # class: 'ss'
|
| 88 |
+
|
| 89 |
+
Generic: "", # class: 'g'
|
| 90 |
+
Generic.Deleted: "", # class: 'gd',
|
| 91 |
+
Generic.Emph: "", # class: 'ge'
|
| 92 |
+
Generic.Error: "", # class: 'gr'
|
| 93 |
+
Generic.Heading: "", # class: 'gh'
|
| 94 |
+
Generic.Inserted: "", # class: 'gi'
|
| 95 |
+
Generic.Output: "", # class: 'go'
|
| 96 |
+
Generic.Prompt: "", # class: 'gp'
|
| 97 |
+
Generic.Strong: "", # class: 'gs'
|
| 98 |
+
Generic.Subheading: "", # class: 'gu'
|
| 99 |
+
Generic.Traceback: "", # class: 'gt'
|
| 100 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/coffee.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.coffee
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
A warm and cozy theme based off gruvbox
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.style import Style
|
| 12 |
+
from pygments.token import (Comment, Error, Generic, Keyword, Literal, Name,
|
| 13 |
+
Number, Operator, Punctuation, String, Token)
|
| 14 |
+
|
| 15 |
+
__all__ = ["CoffeeStyle"]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class CoffeeStyle(Style):
|
| 19 |
+
"""
|
| 20 |
+
A warm and cozy theme based off gruvbox
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = "coffee"
|
| 24 |
+
|
| 25 |
+
background_color = "#262220"
|
| 26 |
+
highlight_color = "#ddd0c0"
|
| 27 |
+
|
| 28 |
+
line_number_color = "#4e4e4e"
|
| 29 |
+
line_number_special_color = "#8f9494"
|
| 30 |
+
|
| 31 |
+
styles = {
|
| 32 |
+
Comment: "#70757A",
|
| 33 |
+
Comment.Hashbang: "#8f9f9f",
|
| 34 |
+
Comment.Preproc: "#fdd0c0",
|
| 35 |
+
Comment.PreprocFile: "#c9b98f",
|
| 36 |
+
Comment.Special: "#af5f5f",
|
| 37 |
+
Error: "#af5f5f",
|
| 38 |
+
Generic.Deleted: "#bb6868",
|
| 39 |
+
Generic.Emph: "italic",
|
| 40 |
+
Generic.Error: "#af5f5f",
|
| 41 |
+
Generic.Inserted: "#849155",
|
| 42 |
+
Generic.Output: "#ddd0c0",
|
| 43 |
+
Generic.Strong: "bold",
|
| 44 |
+
Generic.Traceback: "#af5f5f",
|
| 45 |
+
Keyword: "#919191",
|
| 46 |
+
Keyword.Constant: "#875f5f",
|
| 47 |
+
Keyword.Declaration: "#875f5f",
|
| 48 |
+
Keyword.Namespace: "#875f5f",
|
| 49 |
+
Keyword.Reserved: "#b46276",
|
| 50 |
+
Keyword.Type: "#af875f",
|
| 51 |
+
Literal: "#af875f",
|
| 52 |
+
Name: "#ddd0c0",
|
| 53 |
+
Name.Attribute: "#ddd0c0",
|
| 54 |
+
Name.Builtin: "#ddd0c0",
|
| 55 |
+
Name.Builtin.Pseudo: "#87afaf",
|
| 56 |
+
Name.Class: "#875f5f",
|
| 57 |
+
Name.Constant: "#af8787",
|
| 58 |
+
Name.Decorator: "#fdd0c0",
|
| 59 |
+
Name.Entity: "#ddd0c0",
|
| 60 |
+
Name.Exception: "#877575",
|
| 61 |
+
Name.Function: "#fdd0c0",
|
| 62 |
+
Name.Function.Magic: "#fdd0c0",
|
| 63 |
+
Name.Other: "#ddd0c0",
|
| 64 |
+
Name.Property: "#dfaf87",
|
| 65 |
+
Name.Tag: "#87afaf",
|
| 66 |
+
Name.Variable: "#ddd0c0",
|
| 67 |
+
Number: "#87afaf",
|
| 68 |
+
Operator: "#878787",
|
| 69 |
+
Operator.Word: "#878787",
|
| 70 |
+
Punctuation: "#ddd0c0",
|
| 71 |
+
String: "#c9b98f",
|
| 72 |
+
String.Affix: "#dfaf87",
|
| 73 |
+
String.Doc: "#878787",
|
| 74 |
+
String.Escape: "#af5f5f",
|
| 75 |
+
String.Interpol: "#af5f5f",
|
| 76 |
+
String.Other: "#fdd0c0",
|
| 77 |
+
String.Regex: "#af5f5f",
|
| 78 |
+
String.Symbol: "#af5f5f",
|
| 79 |
+
Token: "#ddd0c0",
|
| 80 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/dracula.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.dracula
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments version of `Dracula` from https://github.com/dracula/dracula-theme.
|
| 6 |
+
|
| 7 |
+
Based on the Dracula Theme for pygments by Chris Bracco.
|
| 8 |
+
See https://github.com/dracula/pygments/tree/fee9ed5613d1086bc01b9d0a5a0e9867a009f571
|
| 9 |
+
|
| 10 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 11 |
+
:license: BSD, see LICENSE for details.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from pygments.style import Style
|
| 15 |
+
from pygments.token import Keyword, Name, Comment, String, Error, Literal, \
|
| 16 |
+
Number, Operator, Other, Punctuation, Text, Generic, Whitespace
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
__all__ = ['DraculaStyle']
|
| 20 |
+
|
| 21 |
+
background = "#282a36"
|
| 22 |
+
foreground = "#f8f8f2"
|
| 23 |
+
selection = "#44475a"
|
| 24 |
+
comment = "#6272a4"
|
| 25 |
+
cyan = "#8be9fd"
|
| 26 |
+
green = "#50fa7b"
|
| 27 |
+
orange = "#ffb86c"
|
| 28 |
+
pink = "#ff79c6"
|
| 29 |
+
purple = "#bd93f9"
|
| 30 |
+
red = "#ff5555"
|
| 31 |
+
yellow = "#f1fa8c"
|
| 32 |
+
|
| 33 |
+
deletion = "#8b080b"
|
| 34 |
+
|
| 35 |
+
class DraculaStyle(Style):
|
| 36 |
+
name = 'dracula'
|
| 37 |
+
|
| 38 |
+
background_color = background
|
| 39 |
+
highlight_color = selection
|
| 40 |
+
line_number_color = yellow
|
| 41 |
+
line_number_background_color = selection
|
| 42 |
+
line_number_special_color = green
|
| 43 |
+
line_number_special_background_color = comment
|
| 44 |
+
|
| 45 |
+
styles = {
|
| 46 |
+
Whitespace: foreground,
|
| 47 |
+
|
| 48 |
+
Comment: comment,
|
| 49 |
+
Comment.Preproc: pink,
|
| 50 |
+
|
| 51 |
+
Generic: foreground,
|
| 52 |
+
Generic.Deleted: deletion,
|
| 53 |
+
Generic.Emph: "underline",
|
| 54 |
+
Generic.Heading: "bold",
|
| 55 |
+
Generic.Inserted: "bold",
|
| 56 |
+
Generic.Output: selection,
|
| 57 |
+
Generic.EmphStrong: "underline",
|
| 58 |
+
Generic.Subheading: "bold",
|
| 59 |
+
|
| 60 |
+
Error: foreground,
|
| 61 |
+
|
| 62 |
+
Keyword: pink,
|
| 63 |
+
Keyword.Constant: pink,
|
| 64 |
+
Keyword.Declaration: cyan + " italic",
|
| 65 |
+
Keyword.Type: cyan,
|
| 66 |
+
|
| 67 |
+
Literal: foreground,
|
| 68 |
+
|
| 69 |
+
Name: foreground,
|
| 70 |
+
Name.Attribute: green,
|
| 71 |
+
Name.Builtin: cyan + " italic",
|
| 72 |
+
Name.Builtin.Pseudo: foreground,
|
| 73 |
+
Name.Class: green,
|
| 74 |
+
Name.Function: green,
|
| 75 |
+
Name.Label: cyan + " italic",
|
| 76 |
+
Name.Tag: pink,
|
| 77 |
+
Name.Variable: cyan + " italic",
|
| 78 |
+
|
| 79 |
+
Number: orange,
|
| 80 |
+
|
| 81 |
+
Operator: pink,
|
| 82 |
+
|
| 83 |
+
Other: foreground,
|
| 84 |
+
|
| 85 |
+
Punctuation: foreground,
|
| 86 |
+
|
| 87 |
+
String: purple,
|
| 88 |
+
|
| 89 |
+
Text: foreground,
|
| 90 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/gh_dark.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.gh_dark
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Github's Dark-Colorscheme based theme for Pygments
|
| 6 |
+
Colors extracted from https://github.com/primer/primitives
|
| 7 |
+
|
| 8 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 9 |
+
:license: BSD, see LICENSE for details.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
from pygments.style import Style
|
| 13 |
+
from pygments.token import Keyword, Name, Comment, Error, Number, Operator, \
|
| 14 |
+
Generic, Text, Literal, String, Token
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
__all__ = ['GhDarkStyle']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# vars are defined to match the defs in
|
| 21 |
+
# - [GitHub's VS Code theme](https://github.com/primer/github-vscode-theme) and
|
| 22 |
+
# - [Primer styles](https://github.com/primer/primitives)
|
| 23 |
+
RED_2 = "#ffa198"
|
| 24 |
+
RED_3 = "#ff7b72"
|
| 25 |
+
RED_9 = "#490202"
|
| 26 |
+
ORANGE_2 = "#ffa657"
|
| 27 |
+
ORANGE_3 = "#f0883e"
|
| 28 |
+
GREEN_1 = "#7ee787"
|
| 29 |
+
GREEN_2 = "#56d364"
|
| 30 |
+
GREEN_7 = "#0f5323"
|
| 31 |
+
BLUE_1 = "#a5d6ff"
|
| 32 |
+
BLUE_2 = "#79c0ff"
|
| 33 |
+
PURPLE_2 = "#d2a8ff"
|
| 34 |
+
GRAY_3 = "#8b949e"
|
| 35 |
+
GRAY_4 = "#6e7681"
|
| 36 |
+
FG_SUBTLE = "#6e7681"
|
| 37 |
+
FG_DEFAULT = "#e6edf3"
|
| 38 |
+
BG_DEFAULT = "#0d1117"
|
| 39 |
+
DANGER_FG = "#f85149"
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class GhDarkStyle(Style):
|
| 43 |
+
"""
|
| 44 |
+
Github's Dark-Colorscheme based theme for Pygments
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
name = 'github-dark'
|
| 48 |
+
|
| 49 |
+
background_color = BG_DEFAULT
|
| 50 |
+
|
| 51 |
+
# has transparency in VS Code theme as `colors.codemirror.activelineBg`
|
| 52 |
+
highlight_color = GRAY_4
|
| 53 |
+
|
| 54 |
+
line_number_special_color = FG_DEFAULT
|
| 55 |
+
line_number_special_background_color = FG_SUBTLE
|
| 56 |
+
|
| 57 |
+
line_number_color = GRAY_4
|
| 58 |
+
line_number_background_color = BG_DEFAULT
|
| 59 |
+
|
| 60 |
+
styles = {
|
| 61 |
+
Token: FG_DEFAULT,
|
| 62 |
+
|
| 63 |
+
Error: DANGER_FG,
|
| 64 |
+
|
| 65 |
+
Keyword: RED_3,
|
| 66 |
+
Keyword.Constant: BLUE_2,
|
| 67 |
+
Keyword.Pseudo: BLUE_2,
|
| 68 |
+
|
| 69 |
+
Name: FG_DEFAULT,
|
| 70 |
+
Name.Class: "bold "+ORANGE_3,
|
| 71 |
+
Name.Constant: "bold "+BLUE_2,
|
| 72 |
+
Name.Decorator: 'bold '+PURPLE_2,
|
| 73 |
+
Name.Entity: ORANGE_2,
|
| 74 |
+
Name.Exception: "bold "+ORANGE_3,
|
| 75 |
+
Name.Function: 'bold '+PURPLE_2,
|
| 76 |
+
Name.Label: "bold "+BLUE_2,
|
| 77 |
+
Name.Namespace: RED_3,
|
| 78 |
+
Name.Property: BLUE_2,
|
| 79 |
+
Name.Tag: GREEN_1,
|
| 80 |
+
Name.Variable: BLUE_2,
|
| 81 |
+
|
| 82 |
+
Literal: BLUE_1,
|
| 83 |
+
Literal.Date: BLUE_2,
|
| 84 |
+
String: BLUE_1,
|
| 85 |
+
String.Affix: BLUE_2,
|
| 86 |
+
String.Delimiter: BLUE_2,
|
| 87 |
+
String.Escape: BLUE_2,
|
| 88 |
+
String.Heredoc: BLUE_2,
|
| 89 |
+
String.Regex: BLUE_2,
|
| 90 |
+
Number: BLUE_1,
|
| 91 |
+
|
| 92 |
+
Comment: 'italic '+GRAY_3,
|
| 93 |
+
Comment.Preproc: "bold " + GRAY_3,
|
| 94 |
+
Comment.Special: "bold italic " + GRAY_3,
|
| 95 |
+
|
| 96 |
+
Operator: 'bold ' + RED_3,
|
| 97 |
+
|
| 98 |
+
Generic: FG_DEFAULT,
|
| 99 |
+
Generic.Deleted: f"bg:{RED_9} {RED_2}",
|
| 100 |
+
Generic.Emph: "italic",
|
| 101 |
+
Generic.Error: RED_2,
|
| 102 |
+
Generic.Heading: "bold "+BLUE_2,
|
| 103 |
+
Generic.Inserted: f'bg:{GREEN_7} {GREEN_2}',
|
| 104 |
+
Generic.Output: GRAY_3,
|
| 105 |
+
Generic.Prompt: GRAY_3,
|
| 106 |
+
Generic.Strong: "bold",
|
| 107 |
+
Generic.EmphStrong: "bold italic",
|
| 108 |
+
Generic.Subheading: BLUE_2,
|
| 109 |
+
Generic.Traceback: RED_3,
|
| 110 |
+
Generic.Underline: "underline",
|
| 111 |
+
|
| 112 |
+
Text.Whitespace: FG_SUBTLE,
|
| 113 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/lightbulb.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.lightbulb
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
A minimal dark theme based on the Lightbulb theme for VSCode.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.style import Style
|
| 12 |
+
from pygments.token import (
|
| 13 |
+
Comment,
|
| 14 |
+
Error,
|
| 15 |
+
Generic,
|
| 16 |
+
Keyword,
|
| 17 |
+
Literal,
|
| 18 |
+
Name,
|
| 19 |
+
Number,
|
| 20 |
+
Operator,
|
| 21 |
+
Punctuation,
|
| 22 |
+
String,
|
| 23 |
+
Token,
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
__all__ = ['LightbulbStyle']
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
COLORS = {
|
| 31 |
+
"bg": "#1d2331",
|
| 32 |
+
"blue_1": "#73D0FF",
|
| 33 |
+
"gray_1": "#7e8aa1",
|
| 34 |
+
"gray_2": "#3c4354",
|
| 35 |
+
"gray_3": "#6e7681",
|
| 36 |
+
"red_1": "#f88f7f",
|
| 37 |
+
"red_2": "#3d1e20",
|
| 38 |
+
"orange_1": "#FFAD66",
|
| 39 |
+
"orange_2": "#F29E74",
|
| 40 |
+
"yellow_1": "#FFD173",
|
| 41 |
+
"white": "#d4d2c8",
|
| 42 |
+
"magenta_1": "#DFBFFF",
|
| 43 |
+
"green_1": "#D5FF80",
|
| 44 |
+
"green_2": "#19362c",
|
| 45 |
+
"cyan_1": "#95E6CB",
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class LightbulbStyle(Style):
|
| 50 |
+
"""
|
| 51 |
+
A minimal dark theme based on the Lightbulb theme for VSCode.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
name = 'lightbulb'
|
| 55 |
+
|
| 56 |
+
background_color = COLORS['bg']
|
| 57 |
+
highlight_color = COLORS['gray_3']
|
| 58 |
+
|
| 59 |
+
line_number_color = COLORS['gray_2']
|
| 60 |
+
line_number_special_color = COLORS['gray_2']
|
| 61 |
+
|
| 62 |
+
styles = {
|
| 63 |
+
Comment: COLORS["gray_1"],
|
| 64 |
+
Comment.Hashbang: "italic " + COLORS['red_1'],
|
| 65 |
+
Comment.Preproc: "bold " + COLORS['orange_1'],
|
| 66 |
+
Comment.Special: "italic " + COLORS['gray_1'],
|
| 67 |
+
Error: COLORS['red_1'],
|
| 68 |
+
Generic.Deleted: f"bg:{COLORS['red_2']} #f88f7f",
|
| 69 |
+
Generic.Emph: "italic",
|
| 70 |
+
Generic.Error: "#f88f7f",
|
| 71 |
+
Generic.Inserted: f"bg:{COLORS['green_2']} #6ad4af",
|
| 72 |
+
Generic.Output: COLORS['gray_1'],
|
| 73 |
+
Generic.Strong: "bold",
|
| 74 |
+
Generic.Traceback: COLORS['red_1'],
|
| 75 |
+
Keyword: COLORS['orange_1'],
|
| 76 |
+
Keyword.Constant: COLORS['orange_1'],
|
| 77 |
+
Keyword.Declaration: COLORS['orange_1'],
|
| 78 |
+
Keyword.Namespace: COLORS['orange_1'],
|
| 79 |
+
Keyword.Reserved: COLORS['orange_1'],
|
| 80 |
+
Keyword.Type: COLORS['blue_1'],
|
| 81 |
+
Literal: COLORS['green_1'],
|
| 82 |
+
Name: COLORS['white'],
|
| 83 |
+
Name.Attribute: COLORS['yellow_1'],
|
| 84 |
+
Name.Builtin: COLORS['yellow_1'],
|
| 85 |
+
Name.Builtin.Pseudo: "#5CCFE6",
|
| 86 |
+
Name.Class: COLORS['blue_1'],
|
| 87 |
+
Name.Constant: COLORS['yellow_1'],
|
| 88 |
+
Name.Decorator: "bold italic " + COLORS['gray_1'],
|
| 89 |
+
Name.Entity: COLORS['cyan_1'],
|
| 90 |
+
Name.Exception: COLORS['blue_1'],
|
| 91 |
+
Name.Function: COLORS['yellow_1'],
|
| 92 |
+
Name.Function.Magic: COLORS['yellow_1'],
|
| 93 |
+
Name.Other: COLORS['white'],
|
| 94 |
+
Name.Property: COLORS['yellow_1'],
|
| 95 |
+
Name.Tag: "#5CCFE6",
|
| 96 |
+
Name.Variable: COLORS['white'],
|
| 97 |
+
Number: COLORS['magenta_1'],
|
| 98 |
+
Operator: COLORS['orange_1'],
|
| 99 |
+
Operator.Word: COLORS['orange_1'],
|
| 100 |
+
Punctuation: COLORS['white'],
|
| 101 |
+
String: COLORS['green_1'],
|
| 102 |
+
String.Affix: COLORS['orange_2'],
|
| 103 |
+
String.Doc: COLORS['gray_1'],
|
| 104 |
+
String.Escape: COLORS['cyan_1'],
|
| 105 |
+
String.Interpol: COLORS['cyan_1'],
|
| 106 |
+
String.Other: COLORS['cyan_1'],
|
| 107 |
+
String.Regex: COLORS['cyan_1'],
|
| 108 |
+
String.Symbol: COLORS['magenta_1'],
|
| 109 |
+
Token: COLORS['white'],
|
| 110 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/nord.py
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.nord
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
pygments version of the "nord" theme by Arctic Ice Studio
|
| 6 |
+
https://www.nordtheme.com/
|
| 7 |
+
|
| 8 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 9 |
+
:license: BSD, see LICENSE for details.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
from pygments.style import Style
|
| 13 |
+
from pygments.token import Keyword, Name, Comment, String, Error, Number, \
|
| 14 |
+
Operator, Generic, Whitespace, Punctuation, Text, Token
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
__all__ = ['NordStyle', 'NordDarkerStyle']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class NordStyle(Style):
|
| 21 |
+
"""
|
| 22 |
+
Pygments version of the "nord" theme by Arctic Ice Studio.
|
| 23 |
+
"""
|
| 24 |
+
name = 'nord'
|
| 25 |
+
|
| 26 |
+
line_number_color = "#D8DEE9"
|
| 27 |
+
line_number_background_color = "#242933"
|
| 28 |
+
line_number_special_color = "#242933"
|
| 29 |
+
line_number_special_background_color = "#D8DEE9"
|
| 30 |
+
|
| 31 |
+
background_color = "#2E3440"
|
| 32 |
+
highlight_color = "#3B4252"
|
| 33 |
+
|
| 34 |
+
styles = {
|
| 35 |
+
Token: "#d8dee9",
|
| 36 |
+
|
| 37 |
+
Whitespace: '#d8dee9',
|
| 38 |
+
Punctuation: '#eceff4',
|
| 39 |
+
|
| 40 |
+
Comment: 'italic #616e87',
|
| 41 |
+
Comment.Preproc: '#5e81ac',
|
| 42 |
+
|
| 43 |
+
Keyword: 'bold #81a1c1',
|
| 44 |
+
Keyword.Pseudo: 'nobold #81a1c1',
|
| 45 |
+
Keyword.Type: 'nobold #81a1c1',
|
| 46 |
+
|
| 47 |
+
Operator: 'bold #81a1c1',
|
| 48 |
+
Operator.Word: 'bold #81a1c1',
|
| 49 |
+
|
| 50 |
+
Name: '#d8dee9',
|
| 51 |
+
Name.Builtin: '#81a1c1',
|
| 52 |
+
Name.Function: '#88c0d0',
|
| 53 |
+
Name.Class: '#8fbcbb',
|
| 54 |
+
Name.Namespace: '#8fbcbb',
|
| 55 |
+
Name.Exception: '#bf616a',
|
| 56 |
+
Name.Variable: '#d8dee9',
|
| 57 |
+
Name.Constant: '#8fbcbb',
|
| 58 |
+
Name.Entity: '#d08770',
|
| 59 |
+
Name.Attribute: '#8fbcbb',
|
| 60 |
+
Name.Tag: '#81a1c1',
|
| 61 |
+
Name.Decorator: '#d08770',
|
| 62 |
+
|
| 63 |
+
String: '#a3be8c',
|
| 64 |
+
String.Doc: '#616e87',
|
| 65 |
+
String.Interpol: '#a3be8c',
|
| 66 |
+
String.Escape: '#ebcb8b',
|
| 67 |
+
String.Regex: '#ebcb8b',
|
| 68 |
+
String.Symbol: '#a3be8c',
|
| 69 |
+
String.Other: '#a3be8c',
|
| 70 |
+
|
| 71 |
+
Number: '#b48ead',
|
| 72 |
+
|
| 73 |
+
Generic.Heading: 'bold #88c0d0',
|
| 74 |
+
Generic.Subheading: 'bold #88c0d0',
|
| 75 |
+
Generic.Deleted: '#bf616a',
|
| 76 |
+
Generic.Inserted: '#a3be8c',
|
| 77 |
+
Generic.Error: '#bf616a',
|
| 78 |
+
Generic.Emph: 'italic',
|
| 79 |
+
Generic.Strong: 'bold',
|
| 80 |
+
Generic.EmphStrong: 'bold italic',
|
| 81 |
+
Generic.Prompt: 'bold #616e88',
|
| 82 |
+
Generic.Output: '#d8dee9',
|
| 83 |
+
Generic.Traceback: '#bf616a',
|
| 84 |
+
|
| 85 |
+
Error: '#bf616a',
|
| 86 |
+
Text: '#d8dee9',
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class NordDarkerStyle(Style):
|
| 91 |
+
"""
|
| 92 |
+
Pygments version of a darker "nord" theme by Arctic Ice Studio
|
| 93 |
+
"""
|
| 94 |
+
name = 'nord-darker'
|
| 95 |
+
|
| 96 |
+
line_number_color = "#D8DEE9"
|
| 97 |
+
line_number_background_color = "#242933"
|
| 98 |
+
line_number_special_color = "#242933"
|
| 99 |
+
line_number_special_background_color = "#D8DEE9"
|
| 100 |
+
|
| 101 |
+
background_color = "#242933"
|
| 102 |
+
highlight_color = "#3B4252"
|
| 103 |
+
|
| 104 |
+
styles = {
|
| 105 |
+
Token: "#d8dee9",
|
| 106 |
+
|
| 107 |
+
Whitespace: '#d8dee9',
|
| 108 |
+
Punctuation: '#eceff4',
|
| 109 |
+
|
| 110 |
+
Comment: 'italic #616e87',
|
| 111 |
+
Comment.Preproc: '#5e81ac',
|
| 112 |
+
|
| 113 |
+
Keyword: 'bold #81a1c1',
|
| 114 |
+
Keyword.Pseudo: 'nobold #81a1c1',
|
| 115 |
+
Keyword.Type: 'nobold #81a1c1',
|
| 116 |
+
|
| 117 |
+
Operator: 'bold #81a1c1',
|
| 118 |
+
Operator.Word: 'bold #81a1c1',
|
| 119 |
+
|
| 120 |
+
Name: '#d8dee9',
|
| 121 |
+
Name.Builtin: '#81a1c1',
|
| 122 |
+
Name.Function: '#88c0d0',
|
| 123 |
+
Name.Class: '#8fbcbb',
|
| 124 |
+
Name.Namespace: '#8fbcbb',
|
| 125 |
+
Name.Exception: '#bf616a',
|
| 126 |
+
Name.Variable: '#d8dee9',
|
| 127 |
+
Name.Constant: '#8fbcbb',
|
| 128 |
+
Name.Entity: '#d08770',
|
| 129 |
+
Name.Attribute: '#8fbcbb',
|
| 130 |
+
Name.Tag: '#81a1c1',
|
| 131 |
+
Name.Decorator: '#d08770',
|
| 132 |
+
|
| 133 |
+
String: '#a3be8c',
|
| 134 |
+
String.Doc: '#616e87',
|
| 135 |
+
String.Interpol: '#a3be8c',
|
| 136 |
+
String.Escape: '#ebcb8b',
|
| 137 |
+
String.Regex: '#ebcb8b',
|
| 138 |
+
String.Symbol: '#a3be8c',
|
| 139 |
+
String.Other: '#a3be8c',
|
| 140 |
+
|
| 141 |
+
Number: '#b48ead',
|
| 142 |
+
|
| 143 |
+
Generic.Heading: 'bold #88c0d0',
|
| 144 |
+
Generic.Subheading: 'bold #88c0d0',
|
| 145 |
+
Generic.Deleted: '#bf616a',
|
| 146 |
+
Generic.Inserted: '#a3be8c',
|
| 147 |
+
Generic.Error: '#bf616a',
|
| 148 |
+
Generic.Emph: 'italic',
|
| 149 |
+
Generic.Strong: 'bold',
|
| 150 |
+
Generic.Prompt: 'bold #616e88',
|
| 151 |
+
Generic.Output: '#d8dee9',
|
| 152 |
+
Generic.Traceback: '#bf616a',
|
| 153 |
+
|
| 154 |
+
Error: '#bf616a',
|
| 155 |
+
Text: '#d8dee9',
|
| 156 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/paraiso_light.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.paraiso_light
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Paraíso (Light) by Jan T. Sott
|
| 6 |
+
|
| 7 |
+
Pygments template by Jan T. Sott (https://github.com/idleberg)
|
| 8 |
+
Created with Base16 Builder by Chris Kempson
|
| 9 |
+
(https://github.com/chriskempson/base16-builder).
|
| 10 |
+
|
| 11 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 12 |
+
:license: BSD, see LICENSE for details.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
from pygments.style import Style
|
| 16 |
+
from pygments.token import Keyword, Name, Comment, String, Error, Text, \
|
| 17 |
+
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
__all__ = ['ParaisoLightStyle']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
BACKGROUND = "#e7e9db"
|
| 24 |
+
CURRENT_LINE = "#b9b6b0"
|
| 25 |
+
SELECTION = "#a39e9b"
|
| 26 |
+
FOREGROUND = "#2f1e2e"
|
| 27 |
+
COMMENT = "#8d8687"
|
| 28 |
+
RED = "#ef6155"
|
| 29 |
+
ORANGE = "#f99b15"
|
| 30 |
+
YELLOW = "#fec418"
|
| 31 |
+
GREEN = "#48b685"
|
| 32 |
+
AQUA = "#5bc4bf"
|
| 33 |
+
BLUE = "#06b6ef"
|
| 34 |
+
PURPLE = "#815ba4"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class ParaisoLightStyle(Style):
|
| 38 |
+
name = 'paraiso-light'
|
| 39 |
+
|
| 40 |
+
background_color = BACKGROUND
|
| 41 |
+
highlight_color = SELECTION
|
| 42 |
+
|
| 43 |
+
styles = {
|
| 44 |
+
# No corresponding class for the following:
|
| 45 |
+
Text: FOREGROUND, # class: ''
|
| 46 |
+
Whitespace: "", # class: 'w'
|
| 47 |
+
Error: RED, # class: 'err'
|
| 48 |
+
Other: "", # class 'x'
|
| 49 |
+
|
| 50 |
+
Comment: COMMENT, # class: 'c'
|
| 51 |
+
Comment.Multiline: "", # class: 'cm'
|
| 52 |
+
Comment.Preproc: "", # class: 'cp'
|
| 53 |
+
Comment.Single: "", # class: 'c1'
|
| 54 |
+
Comment.Special: "", # class: 'cs'
|
| 55 |
+
|
| 56 |
+
Keyword: PURPLE, # class: 'k'
|
| 57 |
+
Keyword.Constant: "", # class: 'kc'
|
| 58 |
+
Keyword.Declaration: "", # class: 'kd'
|
| 59 |
+
Keyword.Namespace: AQUA, # class: 'kn'
|
| 60 |
+
Keyword.Pseudo: "", # class: 'kp'
|
| 61 |
+
Keyword.Reserved: "", # class: 'kr'
|
| 62 |
+
Keyword.Type: YELLOW, # class: 'kt'
|
| 63 |
+
|
| 64 |
+
Operator: AQUA, # class: 'o'
|
| 65 |
+
Operator.Word: "", # class: 'ow' - like keywords
|
| 66 |
+
|
| 67 |
+
Punctuation: FOREGROUND, # class: 'p'
|
| 68 |
+
|
| 69 |
+
Name: FOREGROUND, # class: 'n'
|
| 70 |
+
Name.Attribute: BLUE, # class: 'na' - to be revised
|
| 71 |
+
Name.Builtin: "", # class: 'nb'
|
| 72 |
+
Name.Builtin.Pseudo: "", # class: 'bp'
|
| 73 |
+
Name.Class: YELLOW, # class: 'nc' - to be revised
|
| 74 |
+
Name.Constant: RED, # class: 'no' - to be revised
|
| 75 |
+
Name.Decorator: AQUA, # class: 'nd' - to be revised
|
| 76 |
+
Name.Entity: "", # class: 'ni'
|
| 77 |
+
Name.Exception: RED, # class: 'ne'
|
| 78 |
+
Name.Function: BLUE, # class: 'nf'
|
| 79 |
+
Name.Property: "", # class: 'py'
|
| 80 |
+
Name.Label: "", # class: 'nl'
|
| 81 |
+
Name.Namespace: YELLOW, # class: 'nn' - to be revised
|
| 82 |
+
Name.Other: BLUE, # class: 'nx'
|
| 83 |
+
Name.Tag: AQUA, # class: 'nt' - like a keyword
|
| 84 |
+
Name.Variable: RED, # class: 'nv' - to be revised
|
| 85 |
+
Name.Variable.Class: "", # class: 'vc' - to be revised
|
| 86 |
+
Name.Variable.Global: "", # class: 'vg' - to be revised
|
| 87 |
+
Name.Variable.Instance: "", # class: 'vi' - to be revised
|
| 88 |
+
|
| 89 |
+
Number: ORANGE, # class: 'm'
|
| 90 |
+
Number.Float: "", # class: 'mf'
|
| 91 |
+
Number.Hex: "", # class: 'mh'
|
| 92 |
+
Number.Integer: "", # class: 'mi'
|
| 93 |
+
Number.Integer.Long: "", # class: 'il'
|
| 94 |
+
Number.Oct: "", # class: 'mo'
|
| 95 |
+
|
| 96 |
+
Literal: ORANGE, # class: 'l'
|
| 97 |
+
Literal.Date: GREEN, # class: 'ld'
|
| 98 |
+
|
| 99 |
+
String: GREEN, # class: 's'
|
| 100 |
+
String.Backtick: "", # class: 'sb'
|
| 101 |
+
String.Char: FOREGROUND, # class: 'sc'
|
| 102 |
+
String.Doc: COMMENT, # class: 'sd' - like a comment
|
| 103 |
+
String.Double: "", # class: 's2'
|
| 104 |
+
String.Escape: ORANGE, # class: 'se'
|
| 105 |
+
String.Heredoc: "", # class: 'sh'
|
| 106 |
+
String.Interpol: ORANGE, # class: 'si'
|
| 107 |
+
String.Other: "", # class: 'sx'
|
| 108 |
+
String.Regex: "", # class: 'sr'
|
| 109 |
+
String.Single: "", # class: 's1'
|
| 110 |
+
String.Symbol: "", # class: 'ss'
|
| 111 |
+
|
| 112 |
+
Generic: "", # class: 'g'
|
| 113 |
+
Generic.Deleted: RED, # class: 'gd',
|
| 114 |
+
Generic.Emph: "italic", # class: 'ge'
|
| 115 |
+
Generic.Error: "", # class: 'gr'
|
| 116 |
+
Generic.Heading: "bold " + FOREGROUND, # class: 'gh'
|
| 117 |
+
Generic.Inserted: GREEN, # class: 'gi'
|
| 118 |
+
Generic.Output: "", # class: 'go'
|
| 119 |
+
Generic.Prompt: "bold " + COMMENT, # class: 'gp'
|
| 120 |
+
Generic.Strong: "bold", # class: 'gs'
|
| 121 |
+
Generic.EmphStrong: "bold italic", # class: 'ges'
|
| 122 |
+
Generic.Subheading: "bold " + AQUA, # class: 'gu'
|
| 123 |
+
Generic.Traceback: "", # class: 'gt'
|
| 124 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/stata_dark.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.stata_dark
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Dark style inspired by Stata's do-file editor. Note this is not
|
| 6 |
+
meant to be a complete style, just for Stata's file formats.
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pygments.style import Style
|
| 14 |
+
from pygments.token import Token, Keyword, Name, Comment, String, Error, \
|
| 15 |
+
Number, Operator, Whitespace, Generic
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
__all__ = ['StataDarkStyle']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class StataDarkStyle(Style):
|
| 22 |
+
name = 'stata-dark'
|
| 23 |
+
|
| 24 |
+
background_color = "#232629"
|
| 25 |
+
highlight_color = "#49483e"
|
| 26 |
+
|
| 27 |
+
styles = {
|
| 28 |
+
Token: '#cccccc',
|
| 29 |
+
Whitespace: '#bbbbbb',
|
| 30 |
+
Error: 'bg:#e3d2d2 #a61717',
|
| 31 |
+
String: '#51cc99',
|
| 32 |
+
Number: '#4FB8CC',
|
| 33 |
+
Operator: '',
|
| 34 |
+
Name.Function: '#6a6aff',
|
| 35 |
+
Name.Other: '#e2828e',
|
| 36 |
+
Keyword: 'bold #7686bb',
|
| 37 |
+
Keyword.Constant: '',
|
| 38 |
+
Comment: 'italic #777777',
|
| 39 |
+
Name.Variable: 'bold #7AB4DB',
|
| 40 |
+
Name.Variable.Global: 'bold #BE646C',
|
| 41 |
+
Generic.Prompt: '#ffffff',
|
| 42 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/stata_light.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.stata_light
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Light Style inspired by Stata's do-file editor. Note this is not
|
| 6 |
+
meant to be a complete style, just for Stata's file formats.
|
| 7 |
+
|
| 8 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 9 |
+
:license: BSD, see LICENSE for details.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
from pygments.style import Style
|
| 13 |
+
from pygments.token import Keyword, Name, Comment, String, Error, \
|
| 14 |
+
Number, Operator, Whitespace, Text
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
__all__ = ['StataLightStyle']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class StataLightStyle(Style):
|
| 21 |
+
"""
|
| 22 |
+
Light mode style inspired by Stata's do-file editor. This is not
|
| 23 |
+
meant to be a complete style, just for use with Stata.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'stata-light'
|
| 27 |
+
|
| 28 |
+
styles = {
|
| 29 |
+
Text: '#111111',
|
| 30 |
+
Whitespace: '#bbbbbb',
|
| 31 |
+
Error: 'bg:#e3d2d2 #a61717',
|
| 32 |
+
String: '#7a2424',
|
| 33 |
+
Number: '#2c2cff',
|
| 34 |
+
Operator: '',
|
| 35 |
+
Name.Function: '#2c2cff',
|
| 36 |
+
Name.Other: '#be646c',
|
| 37 |
+
Keyword: 'bold #353580',
|
| 38 |
+
Keyword.Constant: '',
|
| 39 |
+
Comment: 'italic #008800',
|
| 40 |
+
Name.Variable: 'bold #35baba',
|
| 41 |
+
Name.Variable.Global: 'bold #b5565e',
|
| 42 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/pygments/styles/zenburn.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles.zenburn
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Low contrast color scheme Zenburn.
|
| 6 |
+
|
| 7 |
+
See: https://kippura.org/zenburnpage/
|
| 8 |
+
https://github.com/jnurmine/Zenburn
|
| 9 |
+
|
| 10 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 11 |
+
:license: BSD, see LICENSE for details.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from pygments.style import Style
|
| 15 |
+
from pygments.token import Token, Name, Operator, Keyword, Generic, Comment, \
|
| 16 |
+
Number, String, Literal, Punctuation, Error
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
__all__ = ['ZenburnStyle']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class ZenburnStyle(Style):
|
| 23 |
+
"""
|
| 24 |
+
Low contrast Zenburn style.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'zenburn'
|
| 28 |
+
|
| 29 |
+
background_color = '#3f3f3f'
|
| 30 |
+
highlight_color = '#484848'
|
| 31 |
+
line_number_color = '#5d6262'
|
| 32 |
+
line_number_background_color = '#353535'
|
| 33 |
+
line_number_special_color = '#7a8080'
|
| 34 |
+
line_number_special_background_color = '#353535'
|
| 35 |
+
|
| 36 |
+
styles = {
|
| 37 |
+
Token: '#dcdccc',
|
| 38 |
+
Error: '#e37170 bold',
|
| 39 |
+
|
| 40 |
+
Keyword: '#efdcbc',
|
| 41 |
+
Keyword.Type: '#dfdfbf bold',
|
| 42 |
+
Keyword.Constant: '#dca3a3',
|
| 43 |
+
Keyword.Declaration: '#f0dfaf',
|
| 44 |
+
Keyword.Namespace: '#f0dfaf',
|
| 45 |
+
|
| 46 |
+
Name: '#dcdccc',
|
| 47 |
+
Name.Tag: '#e89393 bold',
|
| 48 |
+
Name.Entity: '#cfbfaf',
|
| 49 |
+
Name.Constant: '#dca3a3',
|
| 50 |
+
Name.Class: '#efef8f',
|
| 51 |
+
Name.Function: '#efef8f',
|
| 52 |
+
Name.Builtin: '#efef8f',
|
| 53 |
+
Name.Builtin.Pseudo: '#dcdccc',
|
| 54 |
+
Name.Attribute: '#efef8f',
|
| 55 |
+
Name.Exception: '#c3bf9f bold',
|
| 56 |
+
|
| 57 |
+
Literal: '#9fafaf',
|
| 58 |
+
|
| 59 |
+
String: '#cc9393',
|
| 60 |
+
String.Doc: '#7f9f7f',
|
| 61 |
+
String.Interpol: '#dca3a3 bold',
|
| 62 |
+
|
| 63 |
+
Number: '#8cd0d3',
|
| 64 |
+
Number.Float: '#c0bed1',
|
| 65 |
+
|
| 66 |
+
Operator: '#f0efd0',
|
| 67 |
+
|
| 68 |
+
Punctuation: '#f0efd0',
|
| 69 |
+
|
| 70 |
+
Comment: '#7f9f7f italic',
|
| 71 |
+
Comment.Preproc: '#dfaf8f bold',
|
| 72 |
+
Comment.PreprocFile: '#cc9393',
|
| 73 |
+
Comment.Special: '#dfdfdf bold',
|
| 74 |
+
|
| 75 |
+
Generic: '#ecbcbc bold',
|
| 76 |
+
Generic.Emph: '#ffffff bold',
|
| 77 |
+
Generic.Output: '#5b605e bold',
|
| 78 |
+
Generic.Heading: '#efefef bold',
|
| 79 |
+
Generic.Deleted: '#c3bf9f bg:#313c36',
|
| 80 |
+
Generic.Inserted: '#709080 bg:#313c36 bold',
|
| 81 |
+
Generic.Traceback: '#80d4aa bg:#2f2f2f bold',
|
| 82 |
+
Generic.Subheading: '#efefef bold',
|
| 83 |
+
}
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/cache/qwen36_35b_owt_worst20_rewrite/accepted.jsonl
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"doc_idx": 8304, "chunk_idx": 2, "raw_sha1": "f14ddb3c95a1e35ca40f7b0755c199850a100bb6", "raw_chars": 14, "clean_chars": 10, "edit_ratio": 0.1667, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "For me, it", "reject_reason": ""}
|
| 2 |
+
{"doc_idx": 9444, "chunk_idx": 1, "raw_sha1": "1f1134f0b3981e612424d545bad1fa9382b90178", "raw_chars": 1627, "clean_chars": 1640, "edit_ratio": 0.0077, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "We are shocked, please give us some time – Yadav on forming a new party. These tendencies have now taken an ugly turn - Bhushan. I have been telling Arvind Kejriwal he has dictatorial tendencies and he needs to curb those - Bhushan. I have 40 years of experience behind me. I know what democracy is, I know the values - Dharamvir Gandhi. Volunteers have to think: is it the party, the movement they had worked for - Bhushan. Admiral Ramdas sent a text back saying he was surprised to know that he could cause confrontation - Bhushan. Lokpal Admiral Ramdas was told, 'Your term has expired' - Bhushan. Also Read: AAP draws flak, ridicule over infighting. We had told them it must be ensured that the meeting be video-graphed, and voting to take place through a secret ballot - Bhushan. Each MLA was asked to bring along some 50 MLAs with them for today's meet - Bhushan. Through this entire rift, Dr Dharamvir Gandhi did not side with anyone, but what happened today wasn't acceptable to him as well - Yadav. I request people not to judge us, our party by what happened today - Yadav. Arvind bhai ended his speech in a dramatic matter and left by saying he had to attend an important meeting - Yadav. I went to Arvind ji and Manish ji and said look NC members are being beaten up; Arvind ji just stood there - Yadav. Ramzan Chaudhry had only said “please listen to the duo as well” and he was then beaten up and dragged by two bouncers - Yadav. Arvind said in his speech, “I can't work with these people, you decide who you want to work with” - Yadav. It was an orchestrated performance at the NC meet - Yadav. MLAs were shouting “gaddaron k", "reject_reason": ""}
|
| 3 |
+
{"doc_idx": 9444, "chunk_idx": 0, "raw_sha1": "3b1e771eeb5d5ffbd96c0d0e4f82901c1acb3b00", "raw_chars": 1888, "clean_chars": 2022, "edit_ratio": 0.1918, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Prashant Bhushan.\n\n\"They were treated unfairly,\" she said.\n\nArvind Kejriwal has, meanwhile, returned to the National Council meeting venue in Kapashera, say reports.\n\n\"Arvind and his gang are a bunch of uncouth goons,\" said Shazia Ilmi. \"They (Yogendra Yadav and Prashant Bhushan) have been thrown out unceremoniously, it's disgusting.\"\n\n\"This is political 'goondaism' at its worst,\" said Shazia Ilmi. \"Arvind will leave no stone unturned to show the way out to people who raise their voice of dissent.\"\n\n\"He wants power by hook or crook, and he can do anything to get there,\" said Shazia Ilmi. \"This has not come as a shock to me.\"\n\n\"I know exactly what kind of political 'goondaism' they can resort to,\" said BJP's Shazia Ilmi. \"This is AAP's internal matter, why would I get into it?\"\n\n\"It's beyond my understanding,\" said Anna Hazare. Also Read: Anna Hazare refuses to get involved in AAP's internal dissent, says it's beyond his understanding.\n\n\"This is nothing new. Anyone who raises a voice against the supremo of AAP, they are shown the way out,\" said Satish Upadhyay (BJP).\n\n\"I was also inside (the venue of the meeting), nothing of that sort (violence) happened,\" said Satyendra Jain.\n\n\"There were allegations against us that we were planning to float a separate party. If someone else talks about forming a new party, then it's a crime, but if Arvind bhai talks about the same then it is not,\" said Yadav.\n\n\"I got to know last night that Kejriwal himself is planning to float a new party,\" said Yadav.\n\n\"It is true that the meeting was unconstitutional and unlawful,\" said Bhushan.\n\n\"Now, what we will do to challenge it is yet to be decided,\" said Bhushan.\n\n\"Volunteers have sacrificed a lot for this party,\" said Yadav.\n\n\"I repeat, please don't judge AAP by what happened at National Council,\" said Yadav.\n\n\"National Council has 400 members, but they could manage signatures of only 167 members on the resolution. This hints at something,\" said Yadav.\n\n\"We didn't have any script, they had prepared a script.\"", "reject_reason": ""}
|
| 4 |
+
{"doc_idx": 8304, "chunk_idx": 0, "raw_sha1": "654cfa9ea0e5200e9e3d8c23bb2f8301b0a73b79", "raw_chars": 1983, "clean_chars": 1985, "edit_ratio": 0.0005, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "It's been fun.\n\nESPN.com: As a basketball player, how important are your socks?\n\nRobinson: Oh, man, it's big-time.\n\nTrust me.\n\nI've been around where you have uncomfortable socks, and they just don't feel right.\n\nIt's like, 'Ugh,' it's like a drag.\n\nThis is a game-changer.\n\nSay you're in the hotel and you don't want to run out of the room with your wallet.\n\nYou can put your hotel room key in your sock or your money and run downstairs right quick.\n\nIt's not deactivating because you put your key by your phone.\n\nThere are different perks to the whole pocket sock.\n\nI think it's pretty cool.\n\nWe're dropping it on April 23, and it's kind of a big deal for us.\n\nESPN.com: So fans can get involved by supporting the Kickstarter?\n\nRobinson: Yeah, pretty much.\n\nTrying to push that and get that going and get fans excited.\n\nWe'll get the socks to you early.\n\nIt's going to be pretty fun to see how it turns out.\n\nPlaying ball in Israel ESPN.com: What made you decide to go play in Israel?\n\nRobinson: Just to stay in shape, to play alongside my guy Tre Simmons, who went to college with me at UW.\n\nI get to play on his team.\n\nTo get away from home a little bit and just play, have fun and stay in shape.\n\nYou never know when your name is going to be called.\n\nESPN.com: We saw video of fans celebrating your arrival at the airport.\n\nHow has their support been?\n\nRobinson: It's pretty crazy.\n\nThe fans are big-time fans, man.\n\nI love how excited they are about the players.\n\nThey love it here.\n\nThey love the American players, what you bring to the table.\n\nMe being the player that I am, those fans are just the same.\n\nThey're just like me.\n\nESPN.com: Hapoel has gone 4-2 since your arrival to move into a playoff spot.\n\nDo you think you've helped?\n\nRobinson: I think I have.\n\nJust bringing a different culture of basketball to them.\n\nThe coach, he loves how intense I am in practice because it pushes the guys.\n\nA little bit of trash-talking can get guys excited about playing in practice.", "reject_reason": ""}
|
| 5 |
+
{"doc_idx": 8304, "chunk_idx": 1, "raw_sha1": "543a620d995b38e0ac6a817edd9afd8dd2405297", "raw_chars": 1991, "clean_chars": 1991, "edit_ratio": 0.0, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "He's letting me bring new plays in, what I think can help the team.\n\nIt's been pretty fun.\n\nESPN.com: How does the game on the court compare to your NBA experience?\n\nRobinson: The level of play's high.\n\nIt's high-level.\n\nThey don't call the touch fouls like when James Harden gets touched and he gets an and-one every time.\n\nYou've got to get fouled over here.\n\nESPN.com: Had you been to Israel?\n\nRobinson: No, this is my first time.\n\nESPN.com: What's the adjustment been like off the court?\n\nRobinson: Off the court ...\n\nnot really too much of an adjustment.\n\nThe weather is nice.\n\nThe food is great.\n\nIt's Americanized.\n\nThey've got great food, great culture here.\n\nThe people here are cool.\n\nThe food is awesome, though.\n\nI love the food.\n\nEating has been my favorite thing to do out here.\n\nESPN.com: What do you miss most being overseas?\n\nRobinson: My family.\n\nI miss my family the most, being home.\n\nI miss the Seattle rain.\n\nI miss the time difference.\n\nRight now it's nighttime [here], and it's daytime where you guys are at.\n\nTime to wind down now to get some rest, but I haven't been getting that much sleep.\n\nThe NBA games are on late at night for us -- 3, 4 in the morning.\n\n[I'm] trying to stay up and watch them.\n\nI fell asleep watching a couple of games.\n\nESPN.com: How serious are you about pursuing the NFL?\n\nRobinson: Serious as a heart attack.\n\nTotally serious.\n\nAs soon as I get the opportunity, if it comes my way, I'll take full advantage of it.\n\n\"The biggest challenge is probably all the haters, everybody counting me out, somebody not really giving me the opportunity.\" Nate Robinson, on hopes of joining NFL ESPN.com: Is playing in the NFL a dream of yours?\n\nRobinson: It's a big-time dream.\n\nSomething I've always wanted to do, play both sports at the highest level.\n\nWe'll see if I can be the first one to really do it.\n\nESPN.com: Was it difficult to give up football after your freshman year at University of Washington?\n\nRobinson: Kind of.\n\nIt was kind of tough.", "reject_reason": ""}
|
| 6 |
+
{"doc_idx": 2840, "chunk_idx": 0, "raw_sha1": "71d0f12edd4263fe04dba65f5065f739fee11de6", "raw_chars": 1862, "clean_chars": 1825, "edit_ratio": 0.169, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Sleep is not allowed. The crowd will be encouraged to chant \"SHAME. SHAME. SHAME. SHAME\" for the entire round. Admission would be free and open, allowing fresh hecklers to fill in and yell throughout the 41-hour process. In hour five, a limping, bedraggled Bonds would want to give up this foolish quest, to sign away the rights to the millions he was promised, to forget about the Hall of Fame. He would declare himself the winner after 278 home runs, begging for mercy. The crowd would chant \"SHAME. SHAME. SHAME. SHAME\" behind him, impervious to his pleas, acting like the bloodthirsty rabble behind Q during Picard's trial, shaking fists and half-eaten legs of mutton, possibly throwing the bones on the field when they're done. \"SHAME. SHAME. SHAME. SHAME,\" they would cry. And after a rest, Bonds would use his bat as support while he stood up, and then he would hit more dingers. After each home run, the crowd would roar a bloodthirsty, guttural roar and then start chanting again. \"SHAME. SHAME. SHAME. SHAME.\" Mark McGwire, hands blistered, lips cracked from the merciless sun, slowly walking up to take his five swings. \"SHAME. SHAME. SHAME. SHAME.\" Barry Bonds, eyes closed, hoping to find a reserve of strength he didn't know existed, a secret wellspring of power, now, when he needs it most. \"SHAME. SHAME. SHAME. SHAME.\" Someone would win. Someone would have to. Round Three format: After the participant reaches 1000 homers, he will collapse on the field, bloody, exhausted, and openly weeping. He will think he's victorious, that his nightmare is over. That's when they would play Jose Canseco's music. /K-Pop beat and vocals \"It's Jose Canseeeeeeco Jose, can you see? Can you see Jose? I can see Jose Jose Canseeeeeeco\" Okay, Jose Canseco doesn't have music yet, but the exact song can be figured out later.", "reject_reason": ""}
|
| 7 |
+
{"doc_idx": 4393, "chunk_idx": 1, "raw_sha1": "c225b7b34939acb7e9aa59f8a98a59af049d59cb", "raw_chars": 1794, "clean_chars": 1785, "edit_ratio": 0.7664, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "The Communist Party on the one hand continued to represent the general public, the farmers, and the workers, as its basis. On the other hand, the Communist Party began to represent the rich people—the new business community in mainland China. So, on the one hand, the Communist Party continued to represent the poor, the workers, and the farmers, and on the other hand, it represented the rich. That is a big change in Communist Party theory and also in Chinese constitutional law. I think in Hong Kong it is the same. In your history, the business community was the enemy of the Communist Party, always against the rich. But now the Communist Party is the ruling party; the Communist Party must take into account all classes, the rich and the poor. So that is why, in implementing universal suffrage in Hong Kong, on the one hand, we must consider the interests of the general public, the ordinary middle class in Hong Kong, and the ordinary people in Hong Kong. That is no problem. That is why China permits Hong Kong to implement universal suffrage. But on the other hand, the business community is a reality. Even if it is a small group of people, a very small group of people, they control the destiny of the economy in Hong Kong. If we just ignore their interests, Hong Kong capitalism will stop. So that is why, on the one hand, we realize universal suffrage in Hong Kong, and on the other hand, we must guarantee the continued development of capitalism in Hong Kong. During an interview before his speech, Mr. Wang was asked about a controversial white paper on electoral issues released in June by the Hong Kong and Macau Affairs Office in Beijing. Mr. Wang was one of the experts whose suggestions were solicited, although he was not one of the authors of the final document.", "reject_reason": ""}
|
| 8 |
+
{"doc_idx": 4393, "chunk_idx": 0, "raw_sha1": "7153242af1bf45b87ba0b69b92985e7cdb886abf", "raw_chars": 1900, "clean_chars": 1898, "edit_ratio": 0.0016, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "by the National People’s Congress Standing Committee on the broad outlines of policy changes envisioned for the 2017 election of the next chief executive of Hong Kong.\n\nIn his speech, he said giving people in Hong Kong an unfettered choice in who they could vote for would impinge on the interests of the city’s richest residents, who, he said, “control the destiny of the economy in Hong Kong.” Here is an excerpt from Mr. Wang’s prepared remarks, which he delivered in English: Democracy is a political matter, it is also an economic matter.\n\nA political system by its nature reflects and embodies the economic structure of said particular place.\n\nUniversal suffrage means the redistribution of economic interests among society’s members.\n\nWe have to take care of every class.\n\nEvery group of people.\n\nEvery person.\n\nRich or poor.\n\nNo one should be ignored.\n\nNo one should be left behind.\n\nEspecially those whose slice of pie will be shared by others upon the implementation of universal suffrage.\n\n[He added that he was referring to the business community’s share of the economy.] Their slice of pie will be shared by others through universal suffrage.\n\nSo we have to take full consideration of their concerns.\n\nThat’s why we require balanced participation.\n\nWe require nominating committees and functional constituencies.\n\nLater, in a question and answer session, Mr. Wang explained how this fit in with Communist Party theory.\n\nHe referred to the so-called Three Represents promoted during the term of President Jiang Zemin, which allowed capitalists to enter the Communist Party, which previously had been focused on peasants and workers: As you know the Communist Party initially, originally, only represents the people, not representing the billionaires, the businesspeople, in history.\n\nHowever, in 2002, the Communist Party changed its charter and later on China changed its Constitution.", "reject_reason": ""}
|
| 9 |
+
{"doc_idx": 2840, "chunk_idx": 1, "raw_sha1": "0076f511733d94e7f5a54a378c64b651d2e43342", "raw_chars": 1949, "clean_chars": 1943, "edit_ratio": 0.0098, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Flames would start shooting from behind the center field fence, and from the smoke and mists, Jose Canseco would emerge, bat in hand, dressed in full uniform.\n\nThe winner of Round Two, now a twitching mass of pure despair and regret, would matchup with Canseco, head-to-head, under the basic rules of the first round.\n\nFirst to five homers wins, but this time against a pitching machine.\n\nIf the winner of Round Two needs to be wheeled or carried into the box, that would be allowed.\n\nStanding would not be required.\n\nCanseco would win, of course.\n\nThe entire thing would be a sham, rigged for this purpose.\n\nWhat’s the point of the Home Run Derby?\n\nIt’s an abstraction of real baseball, a perversion of what the sport is all about.\n\nIn this, it becomes theater, it becomes something with a meaning and a purpose, something people can enjoy.\n\nSomething that makes you feel.\n\nAward presentation: With Canseco victorious, Commissioner Manfred would carry a beautiful red rose to home plate and ask the crowd to be quiet for the award presentation.\n\nWith the raucous crowd now murmuring in anticipation, Manfred would speak.\n\n\"We would like to announce that Jose Canseco will now be allowed in the Hall of Fame...\"\n\nThe crowd would hiss, boo, and cheer, all at once.\n\n\"...so long as he returns to Major League Baseball and has about three or four more excellent seasons, because these numbers aren’t quite good enough, as is.\"\n\nThe crowd would go crazy again, jeering Canseco, who would realize that he was used, the butt of a very elaborate joke.\n\nManfred would laaaaaugh and laaaaaaaaugh.\n\nCanseco would look around desperately, pleading his case.\n\nThe winner of Round Two would still be rolling around somewhere, moaning uncomfortably.\n\nAnd the chants of \"SHAME. SHAME. SHAME. SHAME\" would start up again.\n\nA couple days later, they would let Barry Bonds in the Hall of Fame because, c’mon, you jerks, just let Barry Bonds in the Hall of Fame.", "reject_reason": ""}
|
| 10 |
+
{"doc_idx": 4393, "chunk_idx": 2, "raw_sha1": "cf43489d7fa229150089389a960df1bd671c14d5", "raw_chars": 1093, "clean_chars": 1089, "edit_ratio": 0.0037, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Democracy advocates in Hong Kong have heavily criticized the white paper, contending that many of its passages represent a significant erosion in the high degree of autonomy that Beijing promised Hong Kong prior to its return by Britain to Chinese sovereignty in 1997.\n\nSome of the heaviest criticism has been directed at suggestions that judges need to be “patriotic” and should help in the administration of Hong Kong.\n\nThese passages raised concerns that the rule of law might be undermined, and that judges would rule for whichever side in a dispute had better ties to the Communist Party.\n\nMr. Wang was asked whether judges in Hong Kong should indeed be “patriotic,” keeping in mind that because judges in the United States did not see themselves as patriotic, but rather as upholding the Constitution, they helped stop the excesses of McCarthyism.\n\nHe replied: Yes, judges should be patriotic automatically.\n\nIt’s a natural requirement.\n\nEven if it may not be written in the law, in many countries, I think it’s a common practice.\n\nBut judicial patriotism does not mean the judiciary", "reject_reason": ""}
|
| 11 |
+
{"doc_idx": 4831, "chunk_idx": 2, "raw_sha1": "3216e8822f97aa31f388a145eb246ed1ff67cae3", "raw_chars": 535, "clean_chars": 531, "edit_ratio": 0.0094, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Trump voters have been called foolish, disgusting, frustrated, misguided, crazy, stupid, idiotic, dummies, willfully ignorant, defying common sense, driven by emotion, alienated, irrational and unthinking, an incompetent mob, thugs, hideous, hateful, xenophobic, violent, fanatics, Nazis, and on and on.\n\nAnother writer, in an apparent effort to appear even-handed, wrote, \"Trump supporters are not stupid; they just haven't been taught how to think.\" Others have gone to the extremes of telling Trump supporters they are all going", "reject_reason": ""}
|
| 12 |
+
{"doc_idx": 4831, "chunk_idx": 1, "raw_sha1": "a000036b795b37b85c0366fc0f3f9765cf60f415", "raw_chars": 1904, "clean_chars": 1903, "edit_ratio": 0.0034, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Since early March, Trump voters have endured some of the most insulting and malicious attacks ever in the print, online, and social media, except this time the charge is not being led by the left-wing media or the Democrats, but by other Republicans.\n\nThe attackers have been supporters of the #NeverTrump movement and of the remaining Republican challengers, most notably supporters of Senator Ted Cruz.\n\nTogether, they have waged a remarkably large and fairly effective smear campaign against Trump voters.\n\nAnd even though the worst may be over, especially now that Senator Cruz has suspended his campaign, it has not stopped yet.\n\nThe targets are primarily blue-collar whites, both Republican and Democrat, from small towns and rural areas of the country, who support Trump.\n\nMany of these people are factory workers, laborers, tradespeople, farmers, and small business owners.\n\nSome have college educations, but many who don't have high school diplomas.\n\nSome are unemployed.\n\nThese are the folks who used to be called the common people of America, the salt-of-the-Earth types, the ones who were depicted in the Norman Rockwell paintings.\n\nUnlike other established voting blocs and special interest groups, these people have no protectors in the media, beyond the established right-wing websites and talk radio, who, for their own reasons, have mostly abandoned them.\n\nSince blue-collar workers form the largest bloc of Trump supporters, they usually get slammed the hardest.\n\nThe simple fact that blue-collar workers, on average, have smaller incomes than white-collar workers invariably gets translated into economically disadvantaged, distressed, or poor.\n\nSince they are generally less well educated than people in the professions, they often get described as not well educated, poorly educated, or uneducated.\n\nIf it were nothing more than that, it would be bad enough, but it gets much worse.", "reject_reason": ""}
|
| 13 |
+
{"doc_idx": 4831, "chunk_idx": 0, "raw_sha1": "02eb20c1e8e083aed722fe188f192e4e7dc6d9e8", "raw_chars": 1906, "clean_chars": 1906, "edit_ratio": 0.0, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "k in the movie, All the King’s Men (based on the eponymous Pulitzer Prize-winning novel by Robert Penn Warren) is apropos the treatment of the supporters of Donald Trump by the reigning tastemakers of the conservative movement.\n\nAn updated version could be: Listen up Trump supporters!\n\nYou are all hicks!\n\nYeah, you heard me right.\n\nYou are all hicks and worse!\n\nYou are hicks because you want decent good paying jobs, and you are sick of American companies moving overseas.\n\nYou are hicks because you want a wall on the border and illegal immigration stopped.\n\nYou are all hicks because you like your doctor and you want to keep your doctor.\n\nYou are hicks because you want your kids to learn something in school besides which bathroom to use and why they should hate America.\n\nYou are hicks because you think military veterans are less likely to die in combat than they are standing in line at the VA.\n\nYou are hicks because you think the Bill of Rights actually means something.\n\nTruth is you hicks are in the way.\n\nYou are nothing but speed bumps on the road to socialism.\n\nYou are nothing but an inconvenience to the politicians who want lifetime employment offering their services to the highest bidders.\n\nYou are nothing but a campaign problem to the billionaires who want to fatten their wallets at your expense.\n\nWhy don’t you keep in your place and do what you are told?\n\nWho do you think runs this country?\n\nHow dare you threaten the powers that be?\n\nYeah, that’s right.\n\nYou are a problem.\n\nYou are a hick.\n\nYou are all hicks!\n\nAnd so am I.\n\nIt was not long ago we knew who our enemies were.\n\nThe leftist Democrats called us racists, narrow-minded bigots, mean-spirited bible-thumpers, homophobes, rich fat-cats who want to take your social security away, sexists, and more.\n\nIt was insulting, and for the large majority, untrue, but it was predictable.\n\nThat is definitely not the case today.", "reject_reason": ""}
|
| 14 |
+
{"doc_idx": 7195, "chunk_idx": 2, "raw_sha1": "d917ef497b0abbcaf21d5f31ed7a6edbf7b18a70", "raw_chars": 572, "clean_chars": 558, "edit_ratio": 0.7593, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "History says not really, but this year's Hawks could provide some precedent. He is one of the richest men in America, in the world for that matter, and if the Republicans get their way, Warren Buffett would be the perfect example of the rich in America who will directly benefit from their no-tax policies. But Mr. Buffett is operating in the realm of reality, and he knows that what the Republicans are trying to do – balance the budget on the backs of the poor – is simply not possible. Warren Buffett is speaking out, saying that the Republicans are \"play", "reject_reason": ""}
|
| 15 |
+
{"doc_idx": 7195, "chunk_idx": 0, "raw_sha1": "f57fafb98983fcdf0687ff90014a6dc8a0235ba1", "raw_chars": 1892, "clean_chars": 1887, "edit_ratio": 0.005, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "something we'd like to change.\n\nWe invite the rest of the political media to follow our lead and reject tired anti-Hillary narratives.\n\nStop rewarding conservative Clinton-bashers who constructed a toxic framework for Hillary coverage decades ago that remains operative to this day.\n\nWe know all media companies go through cycles, and we will face our own ups and downs, but let our current success be a model for how to cover Hillary and Donald in the coming five months.\n\n[Melissa McEwan contributed to this article.]\n\nAs the Miami Heat stumble forward toward the NBA playoffs, there has been some chatter as to what a playoff berth and early elimination is actually worth.\n\nEven if Miami makes it beyond the first 82 games, it's unlikely they would beat either the Atlanta Hawks or the Cleveland Cavaliers and make it beyond the first round.\n\nIn fact, no eight seed with a losing record has ever won its opening series, according to data published by the Boston Globe.\n\nSo, assuming the Heat make the playoffs (for the purpose of this post) and lose in the first round (as history tells us they will), what benefit does such an experience have for Miami's players?\n\nWell as an eighth seed, not so much.\n\nAccording to the same piece by the Boston Globe, after making the playoffs as a No. 8 seed with a losing record, 60.9 percent of teams miss the playoffs the next season, 8.7 percent of teams are eliminated in the first round and 26.1 percent of teams are eliminated in the second round.\n\nOnly one team has advanced to the NBA Finals and none have won a championship in the year immediately following.\n\nSince the difference between the seventh and eighth seed in the East is just half a game, I went ahead and pulled the data for No. 7 seeds as well.\n\nJust as only five eight seeds in NBA history have advanced beyond the first round of the playoffs, so have only five seven seeds.", "reject_reason": ""}
|
| 16 |
+
{"doc_idx": 7195, "chunk_idx": 1, "raw_sha1": "549c80dc07e8a57327914fb58103b4b8be022b08", "raw_chars": 1982, "clean_chars": 1982, "edit_ratio": 0.0202, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "Of those with losing records, only one team has ever won its first-round series (the 1986-87 Seattle Supersonics, who went to the Western Conference Finals).\n\nAs for how teams fare the year after making the playoffs as a seventh seed: [table id=13 /] There doesn't appear to be a correlation between making or missing the playoffs a year after being one of the bottom seeds, as 40 percent of teams that made the playoffs as a seventh seed missed the post-season the year after.\n\nTeams that made the playoffs as a seventh seed one year—regardless of record—have a 60 percent chance of making the playoffs the year after.\n\nWith a pretty even 60-40 split, that playoff experience doesn't seem to hold much weight when it comes to getting back to the post-season.\n\nHowever, once in the playoffs, nine of the 24 teams (37.5 percent) advanced to the next round.\n\nOnly one team with a losing record the year prior advanced beyond the first round—the 1984-85 Denver Nuggets, who advanced to the Western Conference Finals.\n\nTwo teams have made the NBA Finals a year after earning the seventh seed, but neither of them were No. 7 seeds with losing records.\n\nNo seventh seed has gone on to win a title the year after.\n\nIt's worth adding that three teams have won the championship after missing the playoffs altogether the season before (the 2007-08 Celtics, 1991-92 Rockets, and 1996-97 Spurs).\n\nHowever, a more comparable team for next season's Heat could be this season's Hawks.\n\nAtlanta made the playoffs as a No. 8 seed with a losing record last season and will be the top seed this season.\n\nLike this Heat team, the Hawks dealt with crippling injuries that stumped their season, with Al Horford playing just 29 games.\n\nChris Bosh, Dwyane Wade, Goran Dragic, and Hassan Whiteside are expected to start next season healthy.\n\nIt stands to reason the Heat will be better, but to what degree is the question.\n\nWill the playoff experience this team is gunning for make a difference next season?", "reject_reason": ""}
|
| 17 |
+
{"doc_idx": 8417, "chunk_idx": 2, "raw_sha1": "f5bc1c9142ca9cb89deecae1df06bdcad214b06b", "raw_chars": 873, "clean_chars": 865, "edit_ratio": 0.0092, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "We now know there has been a deliberate cover-up,” Wong said. “The prime minister’s office, the attorney general and the foreign minister’s office were aware for a full parliamentary week that Ms Bishop and the Attorney-General’s Department had misled the parliament and chose to do nothing. “Wilfully misleading the parliament is a serious offence – the prime minister must explain the actions of his ministers and staff.” Abbott’s spokesman defended the government’s handling of the issue. “As soon as it became clear that there was a possible problem with the testimony of the officer from the Attorney General’s Department, a thorough review was undertaken by that department,” he said. “As soon as that review was completed, the record was corrected by the attorney general and by the foreign minister.” Abbott’s spokesman pointed to comments by the Asio chief", "reject_reason": ""}
|
| 18 |
+
{"doc_idx": 8417, "chunk_idx": 0, "raw_sha1": "9bf789b4047dccef00dc72f7a89288f138388741", "raw_chars": 1891, "clean_chars": 1898, "edit_ratio": 0.0668, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "The error was corrected three days before the parliamentary record, on 4 June.\n\nLabor has been highly critical of the government for waiting until the final day of a parliamentary sitting fortnight to retract the previous claims, arguing that the new documents are evidence of \"a deliberate cover-up\".\n\nThe issue relates to a letter the siege gunman wrote to the attorney general, George Brandis, in October, two months before the deadly attack in the Lindt cafe, asking whether it was legal to contact the leader of Islamic State.\n\nBrandis and the foreign affairs minister, Julie Bishop, said on 28 May that Monis's letter had been given to the joint review conducted by the federal and New South Wales governments, which was completed in January.\n\nThey were relying on comments made a day earlier by Katherine Jones, the deputy secretary of the Attorney General's Department.\n\nThe documents, provided by the Attorney General's Department to a Senate committee, provide an insight into the talks that occurred between departments and ministerial offices before the formal correction was made on 4 June.\n\nOn Monday, 1 June, the Department of the Prime Minister and Cabinet provided a briefing note to the Attorney General's Department (AGD) that asserted: \"AGD never provided the Monis/Brandis letter to the Martin Place review team. The team was never aware of the existence of the letter.\" In an accompanying email at 12:15 pm, the deputy secretary of the Department of Prime Minister and Cabinet, Allan McKinnon, mentioned the Prime Minister's Office: \"PMO says that AG can answer any questions on this issue now that they know the review team didn't receive it.\" The Attorney General's Department asked the attorney general's office at 12:39 pm the same day \"whether any updates are required\" to the question time brief about the Monis correspondence \"in light of any discussions this morning\".", "reject_reason": ""}
|
| 19 |
+
{"doc_idx": 8417, "chunk_idx": 1, "raw_sha1": "cf90f17cbf70c010db3e7b67cc10818a770e6797", "raw_chars": 1950, "clean_chars": 1948, "edit_ratio": 0.0662, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "The department was told: \"Update not necessary, we're just leaving it how it is.\" The following day, Tuesday, 2 June, the Attorney General's Department distributed an updated question time brief.\n\nQuestion time briefs are prepared for ministers to draw upon in answering questions in parliament.\n\n\"The document has been amended to reflect – but not highlight – that not ALL documents held by AGD were provided to the siege review. Happy to discuss,\" the department said in the email to Brandis's office on 2 June.\n\nBrandis has previously defended the delay in correcting the record.\n\nHe said he was advised on 1 June \"that it appeared\" that the department's advice about the correspondence was wrong, prompting him to ask his top bureaucrat, Chris Moraitis, to \"establish the facts\".\n\nBrandis's office received Moraitis's report by email at 1.09pm on 4 June.\n\nBrandis and Bishop corrected the record later that afternoon.\n\nIn the report, Moraitis said the Attorney General's Department had handed documents to the siege review in January.\n\nHe revealed that \"officers in the department\" had become aware on 2 February that Monis's letter and the department's reply \"had been inadvertently omitted from the correspondence provided to the review\".\n\n\"The officers became aware of this omission following the Australian federal police notifying the department that it had come into possession of the letter and the reply while making inquiries,\" Moraitis wrote.\n\nHe said a departmental officer contacted an officer in the review team at the Department of the Prime Minister and Cabinet on 2 February to advise them of the omission.\n\n\"The review team member advised that the text of the review had already been finalised and the department therefore did not provide the two documents,\" Moraitis said.\n\nLabor's Senate leader, Penny Wong, said the new evidence was damning.\n\n\"We already knew that government ministers had misled the Australian parliament.\"", "reject_reason": ""}
|
| 20 |
+
{"doc_idx": 6276, "chunk_idx": 0, "raw_sha1": "ecdbc8441e0271ccf0e3932a2176ed14ae6d4ab5", "raw_chars": 1792, "clean_chars": 1781, "edit_ratio": 0.0087, "needs_rewrite": true, "decision": "keep", "reason": "rewritten", "edit_level": "rewrite", "domain": "", "prose_score": null, "junk_score": null, "removed_spans": [], "text": "and defining prohibited political activity to include all \"activity directed toward the success or failure of a political party, candidate for partisan political office, or partisan political group.\" Did Director Comey's letter to Congress violate the Hatch Act?\n\nThe Hatch Act provision most commonly invoked in discussions of Comey's letter is 5 U.S.C. § 7323(a)(1), which prohibits a government employee from \"us[ing] his official authority or influence for the purpose of interfering with or affecting the result of an election.\" The key text is the emphasized phrase -- which conditions a violation of the statute on whether the employee's purpose was to interfere with or affect the result of an election.\n\nThus, the Hatch Act does not focus on the effect of the employee's conduct, but the intent.\n\nTo that end, if Comey did not intend to interfere with or affect the upcoming election through his letter to Congress, then he did not violate the letter of the Hatch Act.\n\nOf course, only Comey knows what his intent was.\n\nBut Richard W. Painter, the chief White House ethics lawyer from 2005-07 (during the George W. Bush Administration), argued in a New York Times op-ed on Sunday that Comey's intent can be inferred from the absence of a good reason for sending the letter.\n\n\"Absent extraordinary circumstances that might justify it, a public communication about a pending F.B.I. investigation involving a candidate that is made on the eve of an election is . . . very likely to be a violation of the Hatch Act and a misuse of an official position,\" Painter wrote.\n\nAnd Senate Minority Leader Harry Reid invoked the Hatch Act in a letter to Sunday night.\n\n\"I am writing to inform you that my office has determined that these actions may violate the Hatch Act,\" Reid wrote.", "reject_reason": ""}
|