Datasets:
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +8 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908276/1908276.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908314/1908315.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908318/1908318.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908278/1908278.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908302/1908303.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908314/1908315.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Images/SEM/1908254.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Images/TSEM/1908265.tif +3 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__init__.py +4 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/main.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/status_codes.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py +171 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py +220 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/main.py +70 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py +87 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/progress_bars.py +321 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/spinners.py +157 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/status_codes.py +6 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/metadata.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/metadata_editable.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/wheel.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/wheel_legacy.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__init__.py +18 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.py +137 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/cache.py +43 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/compat.py +32 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/controller.py +415 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/heuristics.py +139 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/serialize.py +186 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/wrapper.py +33 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/progress/spinner.py +45 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__main__.py +17 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/__main__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/console.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/filter.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/formatter.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/lexer.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/modeline.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/plugin.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/regexopt.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/scanner.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/token.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/util.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/cmdline.py +663 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/filters/__init__.py +937 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/filters/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/formatters/__init__.py +153 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/formatters/__pycache__/__init__.cpython-310.pyc +0 -0
.gitattributes
CHANGED
|
@@ -313,3 +313,11 @@ material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:
|
|
| 313 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Images/SEM/1908258.tif filter=lfs diff=lfs merge=lfs -text
|
| 314 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908284/1908284.tif filter=lfs diff=lfs merge=lfs -text
|
| 315 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908290/1908290.tif filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Images/SEM/1908258.tif filter=lfs diff=lfs merge=lfs -text
|
| 314 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908284/1908284.tif filter=lfs diff=lfs merge=lfs -text
|
| 315 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908290/1908290.tif filter=lfs diff=lfs merge=lfs -text
|
| 316 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908318/1908318.tif filter=lfs diff=lfs merge=lfs -text
|
| 317 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908276/1908276.tif filter=lfs diff=lfs merge=lfs -text
|
| 318 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908302/1908303.tif filter=lfs diff=lfs merge=lfs -text
|
| 319 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Images/TSEM/1908265.tif filter=lfs diff=lfs merge=lfs -text
|
| 320 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908314/1908315.tif filter=lfs diff=lfs merge=lfs -text
|
| 321 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908314/1908315.tif filter=lfs diff=lfs merge=lfs -text
|
| 322 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Images/SEM/1908254.tif filter=lfs diff=lfs merge=lfs -text
|
| 323 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908278/1908278.tif filter=lfs diff=lfs merge=lfs -text
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908276/1908276.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908314/1908315.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908318/1908318.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908278/1908278.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908302/1908303.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908314/1908315.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Images/SEM/1908254.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Images/TSEM/1908265.tif
ADDED
|
|
Git LFS Details
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Subpackage containing all of pip's command line interface related code
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
# This file intentionally does not import submodules
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/main.cpython-310.pyc
ADDED
|
Binary file (1.42 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/status_codes.cpython-310.pyc
ADDED
|
Binary file (402 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Logic that powers autocompletion installed by ``pip completion``.
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
import optparse
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
from itertools import chain
|
| 8 |
+
from typing import Any, Iterable, List, Optional
|
| 9 |
+
|
| 10 |
+
from pip._internal.cli.main_parser import create_main_parser
|
| 11 |
+
from pip._internal.commands import commands_dict, create_command
|
| 12 |
+
from pip._internal.metadata import get_default_environment
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def autocomplete() -> None:
|
| 16 |
+
"""Entry Point for completion of main and subcommand options."""
|
| 17 |
+
# Don't complete if user hasn't sourced bash_completion file.
|
| 18 |
+
if "PIP_AUTO_COMPLETE" not in os.environ:
|
| 19 |
+
return
|
| 20 |
+
cwords = os.environ["COMP_WORDS"].split()[1:]
|
| 21 |
+
cword = int(os.environ["COMP_CWORD"])
|
| 22 |
+
try:
|
| 23 |
+
current = cwords[cword - 1]
|
| 24 |
+
except IndexError:
|
| 25 |
+
current = ""
|
| 26 |
+
|
| 27 |
+
parser = create_main_parser()
|
| 28 |
+
subcommands = list(commands_dict)
|
| 29 |
+
options = []
|
| 30 |
+
|
| 31 |
+
# subcommand
|
| 32 |
+
subcommand_name: Optional[str] = None
|
| 33 |
+
for word in cwords:
|
| 34 |
+
if word in subcommands:
|
| 35 |
+
subcommand_name = word
|
| 36 |
+
break
|
| 37 |
+
# subcommand options
|
| 38 |
+
if subcommand_name is not None:
|
| 39 |
+
# special case: 'help' subcommand has no options
|
| 40 |
+
if subcommand_name == "help":
|
| 41 |
+
sys.exit(1)
|
| 42 |
+
# special case: list locally installed dists for show and uninstall
|
| 43 |
+
should_list_installed = not current.startswith("-") and subcommand_name in [
|
| 44 |
+
"show",
|
| 45 |
+
"uninstall",
|
| 46 |
+
]
|
| 47 |
+
if should_list_installed:
|
| 48 |
+
env = get_default_environment()
|
| 49 |
+
lc = current.lower()
|
| 50 |
+
installed = [
|
| 51 |
+
dist.canonical_name
|
| 52 |
+
for dist in env.iter_installed_distributions(local_only=True)
|
| 53 |
+
if dist.canonical_name.startswith(lc)
|
| 54 |
+
and dist.canonical_name not in cwords[1:]
|
| 55 |
+
]
|
| 56 |
+
# if there are no dists installed, fall back to option completion
|
| 57 |
+
if installed:
|
| 58 |
+
for dist in installed:
|
| 59 |
+
print(dist)
|
| 60 |
+
sys.exit(1)
|
| 61 |
+
|
| 62 |
+
should_list_installables = (
|
| 63 |
+
not current.startswith("-") and subcommand_name == "install"
|
| 64 |
+
)
|
| 65 |
+
if should_list_installables:
|
| 66 |
+
for path in auto_complete_paths(current, "path"):
|
| 67 |
+
print(path)
|
| 68 |
+
sys.exit(1)
|
| 69 |
+
|
| 70 |
+
subcommand = create_command(subcommand_name)
|
| 71 |
+
|
| 72 |
+
for opt in subcommand.parser.option_list_all:
|
| 73 |
+
if opt.help != optparse.SUPPRESS_HELP:
|
| 74 |
+
for opt_str in opt._long_opts + opt._short_opts:
|
| 75 |
+
options.append((opt_str, opt.nargs))
|
| 76 |
+
|
| 77 |
+
# filter out previously specified options from available options
|
| 78 |
+
prev_opts = [x.split("=")[0] for x in cwords[1 : cword - 1]]
|
| 79 |
+
options = [(x, v) for (x, v) in options if x not in prev_opts]
|
| 80 |
+
# filter options by current input
|
| 81 |
+
options = [(k, v) for k, v in options if k.startswith(current)]
|
| 82 |
+
# get completion type given cwords and available subcommand options
|
| 83 |
+
completion_type = get_path_completion_type(
|
| 84 |
+
cwords,
|
| 85 |
+
cword,
|
| 86 |
+
subcommand.parser.option_list_all,
|
| 87 |
+
)
|
| 88 |
+
# get completion files and directories if ``completion_type`` is
|
| 89 |
+
# ``<file>``, ``<dir>`` or ``<path>``
|
| 90 |
+
if completion_type:
|
| 91 |
+
paths = auto_complete_paths(current, completion_type)
|
| 92 |
+
options = [(path, 0) for path in paths]
|
| 93 |
+
for option in options:
|
| 94 |
+
opt_label = option[0]
|
| 95 |
+
# append '=' to options which require args
|
| 96 |
+
if option[1] and option[0][:2] == "--":
|
| 97 |
+
opt_label += "="
|
| 98 |
+
print(opt_label)
|
| 99 |
+
else:
|
| 100 |
+
# show main parser options only when necessary
|
| 101 |
+
|
| 102 |
+
opts = [i.option_list for i in parser.option_groups]
|
| 103 |
+
opts.append(parser.option_list)
|
| 104 |
+
flattened_opts = chain.from_iterable(opts)
|
| 105 |
+
if current.startswith("-"):
|
| 106 |
+
for opt in flattened_opts:
|
| 107 |
+
if opt.help != optparse.SUPPRESS_HELP:
|
| 108 |
+
subcommands += opt._long_opts + opt._short_opts
|
| 109 |
+
else:
|
| 110 |
+
# get completion type given cwords and all available options
|
| 111 |
+
completion_type = get_path_completion_type(cwords, cword, flattened_opts)
|
| 112 |
+
if completion_type:
|
| 113 |
+
subcommands = list(auto_complete_paths(current, completion_type))
|
| 114 |
+
|
| 115 |
+
print(" ".join([x for x in subcommands if x.startswith(current)]))
|
| 116 |
+
sys.exit(1)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def get_path_completion_type(
|
| 120 |
+
cwords: List[str], cword: int, opts: Iterable[Any]
|
| 121 |
+
) -> Optional[str]:
|
| 122 |
+
"""Get the type of path completion (``file``, ``dir``, ``path`` or None)
|
| 123 |
+
|
| 124 |
+
:param cwords: same as the environmental variable ``COMP_WORDS``
|
| 125 |
+
:param cword: same as the environmental variable ``COMP_CWORD``
|
| 126 |
+
:param opts: The available options to check
|
| 127 |
+
:return: path completion type (``file``, ``dir``, ``path`` or None)
|
| 128 |
+
"""
|
| 129 |
+
if cword < 2 or not cwords[cword - 2].startswith("-"):
|
| 130 |
+
return None
|
| 131 |
+
for opt in opts:
|
| 132 |
+
if opt.help == optparse.SUPPRESS_HELP:
|
| 133 |
+
continue
|
| 134 |
+
for o in str(opt).split("/"):
|
| 135 |
+
if cwords[cword - 2].split("=")[0] == o:
|
| 136 |
+
if not opt.metavar or any(
|
| 137 |
+
x in ("path", "file", "dir") for x in opt.metavar.split("/")
|
| 138 |
+
):
|
| 139 |
+
return opt.metavar
|
| 140 |
+
return None
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def auto_complete_paths(current: str, completion_type: str) -> Iterable[str]:
|
| 144 |
+
"""If ``completion_type`` is ``file`` or ``path``, list all regular files
|
| 145 |
+
and directories starting with ``current``; otherwise only list directories
|
| 146 |
+
starting with ``current``.
|
| 147 |
+
|
| 148 |
+
:param current: The word to be completed
|
| 149 |
+
:param completion_type: path completion type(``file``, ``path`` or ``dir``)
|
| 150 |
+
:return: A generator of regular files and/or directories
|
| 151 |
+
"""
|
| 152 |
+
directory, filename = os.path.split(current)
|
| 153 |
+
current_path = os.path.abspath(directory)
|
| 154 |
+
# Don't complete paths if they can't be accessed
|
| 155 |
+
if not os.access(current_path, os.R_OK):
|
| 156 |
+
return
|
| 157 |
+
filename = os.path.normcase(filename)
|
| 158 |
+
# list all files that start with ``filename``
|
| 159 |
+
file_list = (
|
| 160 |
+
x for x in os.listdir(current_path) if os.path.normcase(x).startswith(filename)
|
| 161 |
+
)
|
| 162 |
+
for f in file_list:
|
| 163 |
+
opt = os.path.join(current_path, f)
|
| 164 |
+
comp_file = os.path.normcase(os.path.join(directory, f))
|
| 165 |
+
# complete regular files when there is not ``<dir>`` after option
|
| 166 |
+
# complete directories when there is ``<file>``, ``<path>`` or
|
| 167 |
+
# ``<dir>``after option
|
| 168 |
+
if completion_type != "dir" and os.path.isfile(opt):
|
| 169 |
+
yield comp_file
|
| 170 |
+
elif os.path.isdir(opt):
|
| 171 |
+
yield os.path.join(comp_file, "")
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Base Command class, and related routines"""
|
| 2 |
+
|
| 3 |
+
import functools
|
| 4 |
+
import logging
|
| 5 |
+
import logging.config
|
| 6 |
+
import optparse
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
import traceback
|
| 10 |
+
from optparse import Values
|
| 11 |
+
from typing import Any, Callable, List, Optional, Tuple
|
| 12 |
+
|
| 13 |
+
from pip._internal.cli import cmdoptions
|
| 14 |
+
from pip._internal.cli.command_context import CommandContextMixIn
|
| 15 |
+
from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
|
| 16 |
+
from pip._internal.cli.status_codes import (
|
| 17 |
+
ERROR,
|
| 18 |
+
PREVIOUS_BUILD_DIR_ERROR,
|
| 19 |
+
UNKNOWN_ERROR,
|
| 20 |
+
VIRTUALENV_NOT_FOUND,
|
| 21 |
+
)
|
| 22 |
+
from pip._internal.exceptions import (
|
| 23 |
+
BadCommand,
|
| 24 |
+
CommandError,
|
| 25 |
+
DiagnosticPipError,
|
| 26 |
+
InstallationError,
|
| 27 |
+
NetworkConnectionError,
|
| 28 |
+
PreviousBuildDirError,
|
| 29 |
+
UninstallationError,
|
| 30 |
+
)
|
| 31 |
+
from pip._internal.utils.filesystem import check_path_owner
|
| 32 |
+
from pip._internal.utils.logging import BrokenStdoutLoggingError, setup_logging
|
| 33 |
+
from pip._internal.utils.misc import get_prog, normalize_path
|
| 34 |
+
from pip._internal.utils.temp_dir import TempDirectoryTypeRegistry as TempDirRegistry
|
| 35 |
+
from pip._internal.utils.temp_dir import global_tempdir_manager, tempdir_registry
|
| 36 |
+
from pip._internal.utils.virtualenv import running_under_virtualenv
|
| 37 |
+
|
| 38 |
+
__all__ = ["Command"]
|
| 39 |
+
|
| 40 |
+
logger = logging.getLogger(__name__)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class Command(CommandContextMixIn):
|
| 44 |
+
usage: str = ""
|
| 45 |
+
ignore_require_venv: bool = False
|
| 46 |
+
|
| 47 |
+
def __init__(self, name: str, summary: str, isolated: bool = False) -> None:
|
| 48 |
+
super().__init__()
|
| 49 |
+
|
| 50 |
+
self.name = name
|
| 51 |
+
self.summary = summary
|
| 52 |
+
self.parser = ConfigOptionParser(
|
| 53 |
+
usage=self.usage,
|
| 54 |
+
prog=f"{get_prog()} {name}",
|
| 55 |
+
formatter=UpdatingDefaultsHelpFormatter(),
|
| 56 |
+
add_help_option=False,
|
| 57 |
+
name=name,
|
| 58 |
+
description=self.__doc__,
|
| 59 |
+
isolated=isolated,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
self.tempdir_registry: Optional[TempDirRegistry] = None
|
| 63 |
+
|
| 64 |
+
# Commands should add options to this option group
|
| 65 |
+
optgroup_name = f"{self.name.capitalize()} Options"
|
| 66 |
+
self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name)
|
| 67 |
+
|
| 68 |
+
# Add the general options
|
| 69 |
+
gen_opts = cmdoptions.make_option_group(
|
| 70 |
+
cmdoptions.general_group,
|
| 71 |
+
self.parser,
|
| 72 |
+
)
|
| 73 |
+
self.parser.add_option_group(gen_opts)
|
| 74 |
+
|
| 75 |
+
self.add_options()
|
| 76 |
+
|
| 77 |
+
def add_options(self) -> None:
|
| 78 |
+
pass
|
| 79 |
+
|
| 80 |
+
def handle_pip_version_check(self, options: Values) -> None:
|
| 81 |
+
"""
|
| 82 |
+
This is a no-op so that commands by default do not do the pip version
|
| 83 |
+
check.
|
| 84 |
+
"""
|
| 85 |
+
# Make sure we do the pip version check if the index_group options
|
| 86 |
+
# are present.
|
| 87 |
+
assert not hasattr(options, "no_index")
|
| 88 |
+
|
| 89 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 90 |
+
raise NotImplementedError
|
| 91 |
+
|
| 92 |
+
def parse_args(self, args: List[str]) -> Tuple[Values, List[str]]:
|
| 93 |
+
# factored out for testability
|
| 94 |
+
return self.parser.parse_args(args)
|
| 95 |
+
|
| 96 |
+
def main(self, args: List[str]) -> int:
|
| 97 |
+
try:
|
| 98 |
+
with self.main_context():
|
| 99 |
+
return self._main(args)
|
| 100 |
+
finally:
|
| 101 |
+
logging.shutdown()
|
| 102 |
+
|
| 103 |
+
def _main(self, args: List[str]) -> int:
|
| 104 |
+
# We must initialize this before the tempdir manager, otherwise the
|
| 105 |
+
# configuration would not be accessible by the time we clean up the
|
| 106 |
+
# tempdir manager.
|
| 107 |
+
self.tempdir_registry = self.enter_context(tempdir_registry())
|
| 108 |
+
# Intentionally set as early as possible so globally-managed temporary
|
| 109 |
+
# directories are available to the rest of the code.
|
| 110 |
+
self.enter_context(global_tempdir_manager())
|
| 111 |
+
|
| 112 |
+
options, args = self.parse_args(args)
|
| 113 |
+
|
| 114 |
+
# Set verbosity so that it can be used elsewhere.
|
| 115 |
+
self.verbosity = options.verbose - options.quiet
|
| 116 |
+
|
| 117 |
+
level_number = setup_logging(
|
| 118 |
+
verbosity=self.verbosity,
|
| 119 |
+
no_color=options.no_color,
|
| 120 |
+
user_log_file=options.log,
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
# TODO: Try to get these passing down from the command?
|
| 124 |
+
# without resorting to os.environ to hold these.
|
| 125 |
+
# This also affects isolated builds and it should.
|
| 126 |
+
|
| 127 |
+
if options.no_input:
|
| 128 |
+
os.environ["PIP_NO_INPUT"] = "1"
|
| 129 |
+
|
| 130 |
+
if options.exists_action:
|
| 131 |
+
os.environ["PIP_EXISTS_ACTION"] = " ".join(options.exists_action)
|
| 132 |
+
|
| 133 |
+
if options.require_venv and not self.ignore_require_venv:
|
| 134 |
+
# If a venv is required check if it can really be found
|
| 135 |
+
if not running_under_virtualenv():
|
| 136 |
+
logger.critical("Could not find an activated virtualenv (required).")
|
| 137 |
+
sys.exit(VIRTUALENV_NOT_FOUND)
|
| 138 |
+
|
| 139 |
+
if options.cache_dir:
|
| 140 |
+
options.cache_dir = normalize_path(options.cache_dir)
|
| 141 |
+
if not check_path_owner(options.cache_dir):
|
| 142 |
+
logger.warning(
|
| 143 |
+
"The directory '%s' or its parent directory is not owned "
|
| 144 |
+
"or is not writable by the current user. The cache "
|
| 145 |
+
"has been disabled. Check the permissions and owner of "
|
| 146 |
+
"that directory. If executing pip with sudo, you should "
|
| 147 |
+
"use sudo's -H flag.",
|
| 148 |
+
options.cache_dir,
|
| 149 |
+
)
|
| 150 |
+
options.cache_dir = None
|
| 151 |
+
|
| 152 |
+
if "2020-resolver" in options.features_enabled:
|
| 153 |
+
logger.warning(
|
| 154 |
+
"--use-feature=2020-resolver no longer has any effect, "
|
| 155 |
+
"since it is now the default dependency resolver in pip. "
|
| 156 |
+
"This will become an error in pip 21.0."
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
def intercepts_unhandled_exc(
|
| 160 |
+
run_func: Callable[..., int]
|
| 161 |
+
) -> Callable[..., int]:
|
| 162 |
+
@functools.wraps(run_func)
|
| 163 |
+
def exc_logging_wrapper(*args: Any) -> int:
|
| 164 |
+
try:
|
| 165 |
+
status = run_func(*args)
|
| 166 |
+
assert isinstance(status, int)
|
| 167 |
+
return status
|
| 168 |
+
except DiagnosticPipError as exc:
|
| 169 |
+
logger.error("[present-diagnostic] %s", exc)
|
| 170 |
+
logger.debug("Exception information:", exc_info=True)
|
| 171 |
+
|
| 172 |
+
return ERROR
|
| 173 |
+
except PreviousBuildDirError as exc:
|
| 174 |
+
logger.critical(str(exc))
|
| 175 |
+
logger.debug("Exception information:", exc_info=True)
|
| 176 |
+
|
| 177 |
+
return PREVIOUS_BUILD_DIR_ERROR
|
| 178 |
+
except (
|
| 179 |
+
InstallationError,
|
| 180 |
+
UninstallationError,
|
| 181 |
+
BadCommand,
|
| 182 |
+
NetworkConnectionError,
|
| 183 |
+
) as exc:
|
| 184 |
+
logger.critical(str(exc))
|
| 185 |
+
logger.debug("Exception information:", exc_info=True)
|
| 186 |
+
|
| 187 |
+
return ERROR
|
| 188 |
+
except CommandError as exc:
|
| 189 |
+
logger.critical("%s", exc)
|
| 190 |
+
logger.debug("Exception information:", exc_info=True)
|
| 191 |
+
|
| 192 |
+
return ERROR
|
| 193 |
+
except BrokenStdoutLoggingError:
|
| 194 |
+
# Bypass our logger and write any remaining messages to
|
| 195 |
+
# stderr because stdout no longer works.
|
| 196 |
+
print("ERROR: Pipe to stdout was broken", file=sys.stderr)
|
| 197 |
+
if level_number <= logging.DEBUG:
|
| 198 |
+
traceback.print_exc(file=sys.stderr)
|
| 199 |
+
|
| 200 |
+
return ERROR
|
| 201 |
+
except KeyboardInterrupt:
|
| 202 |
+
logger.critical("Operation cancelled by user")
|
| 203 |
+
logger.debug("Exception information:", exc_info=True)
|
| 204 |
+
|
| 205 |
+
return ERROR
|
| 206 |
+
except BaseException:
|
| 207 |
+
logger.critical("Exception:", exc_info=True)
|
| 208 |
+
|
| 209 |
+
return UNKNOWN_ERROR
|
| 210 |
+
|
| 211 |
+
return exc_logging_wrapper
|
| 212 |
+
|
| 213 |
+
try:
|
| 214 |
+
if not options.debug_mode:
|
| 215 |
+
run = intercepts_unhandled_exc(self.run)
|
| 216 |
+
else:
|
| 217 |
+
run = self.run
|
| 218 |
+
return run(options, args)
|
| 219 |
+
finally:
|
| 220 |
+
self.handle_pip_version_check(options)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/main.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Primary application entrypoint.
|
| 2 |
+
"""
|
| 3 |
+
import locale
|
| 4 |
+
import logging
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
from typing import List, Optional
|
| 8 |
+
|
| 9 |
+
from pip._internal.cli.autocompletion import autocomplete
|
| 10 |
+
from pip._internal.cli.main_parser import parse_command
|
| 11 |
+
from pip._internal.commands import create_command
|
| 12 |
+
from pip._internal.exceptions import PipError
|
| 13 |
+
from pip._internal.utils import deprecation
|
| 14 |
+
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# Do not import and use main() directly! Using it directly is actively
|
| 19 |
+
# discouraged by pip's maintainers. The name, location and behavior of
|
| 20 |
+
# this function is subject to change, so calling it directly is not
|
| 21 |
+
# portable across different pip versions.
|
| 22 |
+
|
| 23 |
+
# In addition, running pip in-process is unsupported and unsafe. This is
|
| 24 |
+
# elaborated in detail at
|
| 25 |
+
# https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program.
|
| 26 |
+
# That document also provides suggestions that should work for nearly
|
| 27 |
+
# all users that are considering importing and using main() directly.
|
| 28 |
+
|
| 29 |
+
# However, we know that certain users will still want to invoke pip
|
| 30 |
+
# in-process. If you understand and accept the implications of using pip
|
| 31 |
+
# in an unsupported manner, the best approach is to use runpy to avoid
|
| 32 |
+
# depending on the exact location of this entry point.
|
| 33 |
+
|
| 34 |
+
# The following example shows how to use runpy to invoke pip in that
|
| 35 |
+
# case:
|
| 36 |
+
#
|
| 37 |
+
# sys.argv = ["pip", your, args, here]
|
| 38 |
+
# runpy.run_module("pip", run_name="__main__")
|
| 39 |
+
#
|
| 40 |
+
# Note that this will exit the process after running, unlike a direct
|
| 41 |
+
# call to main. As it is not safe to do any processing after calling
|
| 42 |
+
# main, this should not be an issue in practice.
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def main(args: Optional[List[str]] = None) -> int:
|
| 46 |
+
if args is None:
|
| 47 |
+
args = sys.argv[1:]
|
| 48 |
+
|
| 49 |
+
# Configure our deprecation warnings to be sent through loggers
|
| 50 |
+
deprecation.install_warning_logger()
|
| 51 |
+
|
| 52 |
+
autocomplete()
|
| 53 |
+
|
| 54 |
+
try:
|
| 55 |
+
cmd_name, cmd_args = parse_command(args)
|
| 56 |
+
except PipError as exc:
|
| 57 |
+
sys.stderr.write(f"ERROR: {exc}")
|
| 58 |
+
sys.stderr.write(os.linesep)
|
| 59 |
+
sys.exit(1)
|
| 60 |
+
|
| 61 |
+
# Needed for locale.getpreferredencoding(False) to work
|
| 62 |
+
# in pip._internal.utils.encoding.auto_decode
|
| 63 |
+
try:
|
| 64 |
+
locale.setlocale(locale.LC_ALL, "")
|
| 65 |
+
except locale.Error as e:
|
| 66 |
+
# setlocale can apparently crash if locale are uninitialized
|
| 67 |
+
logger.debug("Ignoring error %s when setting locale", e)
|
| 68 |
+
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
|
| 69 |
+
|
| 70 |
+
return command.main(cmd_args)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""A single place for constructing and exposing the main parser
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
import os
|
| 5 |
+
import sys
|
| 6 |
+
from typing import List, Tuple
|
| 7 |
+
|
| 8 |
+
from pip._internal.cli import cmdoptions
|
| 9 |
+
from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
|
| 10 |
+
from pip._internal.commands import commands_dict, get_similar_commands
|
| 11 |
+
from pip._internal.exceptions import CommandError
|
| 12 |
+
from pip._internal.utils.misc import get_pip_version, get_prog
|
| 13 |
+
|
| 14 |
+
__all__ = ["create_main_parser", "parse_command"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def create_main_parser() -> ConfigOptionParser:
|
| 18 |
+
"""Creates and returns the main parser for pip's CLI"""
|
| 19 |
+
|
| 20 |
+
parser = ConfigOptionParser(
|
| 21 |
+
usage="\n%prog <command> [options]",
|
| 22 |
+
add_help_option=False,
|
| 23 |
+
formatter=UpdatingDefaultsHelpFormatter(),
|
| 24 |
+
name="global",
|
| 25 |
+
prog=get_prog(),
|
| 26 |
+
)
|
| 27 |
+
parser.disable_interspersed_args()
|
| 28 |
+
|
| 29 |
+
parser.version = get_pip_version()
|
| 30 |
+
|
| 31 |
+
# add the general options
|
| 32 |
+
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
|
| 33 |
+
parser.add_option_group(gen_opts)
|
| 34 |
+
|
| 35 |
+
# so the help formatter knows
|
| 36 |
+
parser.main = True # type: ignore
|
| 37 |
+
|
| 38 |
+
# create command listing for description
|
| 39 |
+
description = [""] + [
|
| 40 |
+
f"{name:27} {command_info.summary}"
|
| 41 |
+
for name, command_info in commands_dict.items()
|
| 42 |
+
]
|
| 43 |
+
parser.description = "\n".join(description)
|
| 44 |
+
|
| 45 |
+
return parser
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def parse_command(args: List[str]) -> Tuple[str, List[str]]:
|
| 49 |
+
parser = create_main_parser()
|
| 50 |
+
|
| 51 |
+
# Note: parser calls disable_interspersed_args(), so the result of this
|
| 52 |
+
# call is to split the initial args into the general options before the
|
| 53 |
+
# subcommand and everything else.
|
| 54 |
+
# For example:
|
| 55 |
+
# args: ['--timeout=5', 'install', '--user', 'INITools']
|
| 56 |
+
# general_options: ['--timeout==5']
|
| 57 |
+
# args_else: ['install', '--user', 'INITools']
|
| 58 |
+
general_options, args_else = parser.parse_args(args)
|
| 59 |
+
|
| 60 |
+
# --version
|
| 61 |
+
if general_options.version:
|
| 62 |
+
sys.stdout.write(parser.version)
|
| 63 |
+
sys.stdout.write(os.linesep)
|
| 64 |
+
sys.exit()
|
| 65 |
+
|
| 66 |
+
# pip || pip help -> print_help()
|
| 67 |
+
if not args_else or (args_else[0] == "help" and len(args_else) == 1):
|
| 68 |
+
parser.print_help()
|
| 69 |
+
sys.exit()
|
| 70 |
+
|
| 71 |
+
# the subcommand name
|
| 72 |
+
cmd_name = args_else[0]
|
| 73 |
+
|
| 74 |
+
if cmd_name not in commands_dict:
|
| 75 |
+
guess = get_similar_commands(cmd_name)
|
| 76 |
+
|
| 77 |
+
msg = [f'unknown command "{cmd_name}"']
|
| 78 |
+
if guess:
|
| 79 |
+
msg.append(f'maybe you meant "{guess}"')
|
| 80 |
+
|
| 81 |
+
raise CommandError(" - ".join(msg))
|
| 82 |
+
|
| 83 |
+
# all the args without the subcommand
|
| 84 |
+
cmd_args = args[:]
|
| 85 |
+
cmd_args.remove(cmd_name)
|
| 86 |
+
|
| 87 |
+
return cmd_name, cmd_args
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/progress_bars.py
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
import itertools
|
| 3 |
+
import sys
|
| 4 |
+
from signal import SIGINT, default_int_handler, signal
|
| 5 |
+
from typing import Any, Callable, Iterator, Optional, Tuple
|
| 6 |
+
|
| 7 |
+
from pip._vendor.progress.bar import Bar, FillingCirclesBar, IncrementalBar
|
| 8 |
+
from pip._vendor.progress.spinner import Spinner
|
| 9 |
+
from pip._vendor.rich.progress import (
|
| 10 |
+
BarColumn,
|
| 11 |
+
DownloadColumn,
|
| 12 |
+
FileSizeColumn,
|
| 13 |
+
Progress,
|
| 14 |
+
ProgressColumn,
|
| 15 |
+
SpinnerColumn,
|
| 16 |
+
TextColumn,
|
| 17 |
+
TimeElapsedColumn,
|
| 18 |
+
TimeRemainingColumn,
|
| 19 |
+
TransferSpeedColumn,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
from pip._internal.utils.compat import WINDOWS
|
| 23 |
+
from pip._internal.utils.logging import get_indentation
|
| 24 |
+
from pip._internal.utils.misc import format_size
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
from pip._vendor import colorama
|
| 28 |
+
# Lots of different errors can come from this, including SystemError and
|
| 29 |
+
# ImportError.
|
| 30 |
+
except Exception:
|
| 31 |
+
colorama = None
|
| 32 |
+
|
| 33 |
+
DownloadProgressRenderer = Callable[[Iterator[bytes]], Iterator[bytes]]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def _select_progress_class(preferred: Bar, fallback: Bar) -> Bar:
|
| 37 |
+
encoding = getattr(preferred.file, "encoding", None)
|
| 38 |
+
|
| 39 |
+
# If we don't know what encoding this file is in, then we'll just assume
|
| 40 |
+
# that it doesn't support unicode and use the ASCII bar.
|
| 41 |
+
if not encoding:
|
| 42 |
+
return fallback
|
| 43 |
+
|
| 44 |
+
# Collect all of the possible characters we want to use with the preferred
|
| 45 |
+
# bar.
|
| 46 |
+
characters = [
|
| 47 |
+
getattr(preferred, "empty_fill", ""),
|
| 48 |
+
getattr(preferred, "fill", ""),
|
| 49 |
+
]
|
| 50 |
+
characters += list(getattr(preferred, "phases", []))
|
| 51 |
+
|
| 52 |
+
# Try to decode the characters we're using for the bar using the encoding
|
| 53 |
+
# of the given file, if this works then we'll assume that we can use the
|
| 54 |
+
# fancier bar and if not we'll fall back to the plaintext bar.
|
| 55 |
+
try:
|
| 56 |
+
"".join(characters).encode(encoding)
|
| 57 |
+
except UnicodeEncodeError:
|
| 58 |
+
return fallback
|
| 59 |
+
else:
|
| 60 |
+
return preferred
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
_BaseBar: Any = _select_progress_class(IncrementalBar, Bar)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class InterruptibleMixin:
|
| 67 |
+
"""
|
| 68 |
+
Helper to ensure that self.finish() gets called on keyboard interrupt.
|
| 69 |
+
|
| 70 |
+
This allows downloads to be interrupted without leaving temporary state
|
| 71 |
+
(like hidden cursors) behind.
|
| 72 |
+
|
| 73 |
+
This class is similar to the progress library's existing SigIntMixin
|
| 74 |
+
helper, but as of version 1.2, that helper has the following problems:
|
| 75 |
+
|
| 76 |
+
1. It calls sys.exit().
|
| 77 |
+
2. It discards the existing SIGINT handler completely.
|
| 78 |
+
3. It leaves its own handler in place even after an uninterrupted finish,
|
| 79 |
+
which will have unexpected delayed effects if the user triggers an
|
| 80 |
+
unrelated keyboard interrupt some time after a progress-displaying
|
| 81 |
+
download has already completed, for example.
|
| 82 |
+
"""
|
| 83 |
+
|
| 84 |
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
| 85 |
+
"""
|
| 86 |
+
Save the original SIGINT handler for later.
|
| 87 |
+
"""
|
| 88 |
+
# https://github.com/python/mypy/issues/5887
|
| 89 |
+
super().__init__(*args, **kwargs) # type: ignore
|
| 90 |
+
|
| 91 |
+
self.original_handler = signal(SIGINT, self.handle_sigint)
|
| 92 |
+
|
| 93 |
+
# If signal() returns None, the previous handler was not installed from
|
| 94 |
+
# Python, and we cannot restore it. This probably should not happen,
|
| 95 |
+
# but if it does, we must restore something sensible instead, at least.
|
| 96 |
+
# The least bad option should be Python's default SIGINT handler, which
|
| 97 |
+
# just raises KeyboardInterrupt.
|
| 98 |
+
if self.original_handler is None:
|
| 99 |
+
self.original_handler = default_int_handler
|
| 100 |
+
|
| 101 |
+
def finish(self) -> None:
|
| 102 |
+
"""
|
| 103 |
+
Restore the original SIGINT handler after finishing.
|
| 104 |
+
|
| 105 |
+
This should happen regardless of whether the progress display finishes
|
| 106 |
+
normally, or gets interrupted.
|
| 107 |
+
"""
|
| 108 |
+
super().finish() # type: ignore
|
| 109 |
+
signal(SIGINT, self.original_handler)
|
| 110 |
+
|
| 111 |
+
def handle_sigint(self, signum, frame): # type: ignore
|
| 112 |
+
"""
|
| 113 |
+
Call self.finish() before delegating to the original SIGINT handler.
|
| 114 |
+
|
| 115 |
+
This handler should only be in place while the progress display is
|
| 116 |
+
active.
|
| 117 |
+
"""
|
| 118 |
+
self.finish()
|
| 119 |
+
self.original_handler(signum, frame)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class SilentBar(Bar):
|
| 123 |
+
def update(self) -> None:
|
| 124 |
+
pass
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
class BlueEmojiBar(IncrementalBar):
|
| 128 |
+
|
| 129 |
+
suffix = "%(percent)d%%"
|
| 130 |
+
bar_prefix = " "
|
| 131 |
+
bar_suffix = " "
|
| 132 |
+
phases = ("\U0001F539", "\U0001F537", "\U0001F535")
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class DownloadProgressMixin:
|
| 136 |
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
| 137 |
+
# https://github.com/python/mypy/issues/5887
|
| 138 |
+
super().__init__(*args, **kwargs) # type: ignore
|
| 139 |
+
self.message: str = (" " * (get_indentation() + 2)) + self.message
|
| 140 |
+
|
| 141 |
+
@property
|
| 142 |
+
def downloaded(self) -> str:
|
| 143 |
+
return format_size(self.index) # type: ignore
|
| 144 |
+
|
| 145 |
+
@property
|
| 146 |
+
def download_speed(self) -> str:
|
| 147 |
+
# Avoid zero division errors...
|
| 148 |
+
if self.avg == 0.0: # type: ignore
|
| 149 |
+
return "..."
|
| 150 |
+
return format_size(1 / self.avg) + "/s" # type: ignore
|
| 151 |
+
|
| 152 |
+
@property
|
| 153 |
+
def pretty_eta(self) -> str:
|
| 154 |
+
if self.eta: # type: ignore
|
| 155 |
+
return f"eta {self.eta_td}" # type: ignore
|
| 156 |
+
return ""
|
| 157 |
+
|
| 158 |
+
def iter(self, it): # type: ignore
|
| 159 |
+
for x in it:
|
| 160 |
+
yield x
|
| 161 |
+
# B305 is incorrectly raised here
|
| 162 |
+
# https://github.com/PyCQA/flake8-bugbear/issues/59
|
| 163 |
+
self.next(len(x)) # noqa: B305
|
| 164 |
+
self.finish()
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
class WindowsMixin:
|
| 168 |
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
| 169 |
+
# The Windows terminal does not support the hide/show cursor ANSI codes
|
| 170 |
+
# even with colorama. So we'll ensure that hide_cursor is False on
|
| 171 |
+
# Windows.
|
| 172 |
+
# This call needs to go before the super() call, so that hide_cursor
|
| 173 |
+
# is set in time. The base progress bar class writes the "hide cursor"
|
| 174 |
+
# code to the terminal in its init, so if we don't set this soon
|
| 175 |
+
# enough, we get a "hide" with no corresponding "show"...
|
| 176 |
+
if WINDOWS and self.hide_cursor: # type: ignore
|
| 177 |
+
self.hide_cursor = False
|
| 178 |
+
|
| 179 |
+
# https://github.com/python/mypy/issues/5887
|
| 180 |
+
super().__init__(*args, **kwargs) # type: ignore
|
| 181 |
+
|
| 182 |
+
# Check if we are running on Windows and we have the colorama module,
|
| 183 |
+
# if we do then wrap our file with it.
|
| 184 |
+
if WINDOWS and colorama:
|
| 185 |
+
self.file = colorama.AnsiToWin32(self.file) # type: ignore
|
| 186 |
+
# The progress code expects to be able to call self.file.isatty()
|
| 187 |
+
# but the colorama.AnsiToWin32() object doesn't have that, so we'll
|
| 188 |
+
# add it.
|
| 189 |
+
self.file.isatty = lambda: self.file.wrapped.isatty()
|
| 190 |
+
# The progress code expects to be able to call self.file.flush()
|
| 191 |
+
# but the colorama.AnsiToWin32() object doesn't have that, so we'll
|
| 192 |
+
# add it.
|
| 193 |
+
self.file.flush = lambda: self.file.wrapped.flush()
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
class BaseDownloadProgressBar(WindowsMixin, InterruptibleMixin, DownloadProgressMixin):
|
| 197 |
+
|
| 198 |
+
file = sys.stdout
|
| 199 |
+
message = "%(percent)d%%"
|
| 200 |
+
suffix = "%(downloaded)s %(download_speed)s %(pretty_eta)s"
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
class DefaultDownloadProgressBar(BaseDownloadProgressBar, _BaseBar):
|
| 204 |
+
pass
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
class DownloadSilentBar(BaseDownloadProgressBar, SilentBar):
|
| 208 |
+
pass
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
class DownloadBar(BaseDownloadProgressBar, Bar):
|
| 212 |
+
pass
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
class DownloadFillingCirclesBar(BaseDownloadProgressBar, FillingCirclesBar):
|
| 216 |
+
pass
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
class DownloadBlueEmojiProgressBar(BaseDownloadProgressBar, BlueEmojiBar):
|
| 220 |
+
pass
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
class DownloadProgressSpinner(
|
| 224 |
+
WindowsMixin, InterruptibleMixin, DownloadProgressMixin, Spinner
|
| 225 |
+
):
|
| 226 |
+
|
| 227 |
+
file = sys.stdout
|
| 228 |
+
suffix = "%(downloaded)s %(download_speed)s"
|
| 229 |
+
|
| 230 |
+
def next_phase(self) -> str:
|
| 231 |
+
if not hasattr(self, "_phaser"):
|
| 232 |
+
self._phaser = itertools.cycle(self.phases)
|
| 233 |
+
return next(self._phaser)
|
| 234 |
+
|
| 235 |
+
def update(self) -> None:
|
| 236 |
+
message = self.message % self
|
| 237 |
+
phase = self.next_phase()
|
| 238 |
+
suffix = self.suffix % self
|
| 239 |
+
line = "".join(
|
| 240 |
+
[
|
| 241 |
+
message,
|
| 242 |
+
" " if message else "",
|
| 243 |
+
phase,
|
| 244 |
+
" " if suffix else "",
|
| 245 |
+
suffix,
|
| 246 |
+
]
|
| 247 |
+
)
|
| 248 |
+
|
| 249 |
+
self.writeln(line)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
BAR_TYPES = {
|
| 253 |
+
"off": (DownloadSilentBar, DownloadSilentBar),
|
| 254 |
+
"on": (DefaultDownloadProgressBar, DownloadProgressSpinner),
|
| 255 |
+
"ascii": (DownloadBar, DownloadProgressSpinner),
|
| 256 |
+
"pretty": (DownloadFillingCirclesBar, DownloadProgressSpinner),
|
| 257 |
+
"emoji": (DownloadBlueEmojiProgressBar, DownloadProgressSpinner),
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
def _legacy_progress_bar(
|
| 262 |
+
progress_bar: str, max: Optional[int]
|
| 263 |
+
) -> DownloadProgressRenderer:
|
| 264 |
+
if max is None or max == 0:
|
| 265 |
+
return BAR_TYPES[progress_bar][1]().iter # type: ignore
|
| 266 |
+
else:
|
| 267 |
+
return BAR_TYPES[progress_bar][0](max=max).iter
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
#
|
| 271 |
+
# Modern replacement, for our legacy progress bars.
|
| 272 |
+
#
|
| 273 |
+
def _rich_progress_bar(
|
| 274 |
+
iterable: Iterator[bytes],
|
| 275 |
+
*,
|
| 276 |
+
bar_type: str,
|
| 277 |
+
size: int,
|
| 278 |
+
) -> Iterator[bytes]:
|
| 279 |
+
assert bar_type == "on", "This should only be used in the default mode."
|
| 280 |
+
|
| 281 |
+
if not size:
|
| 282 |
+
total = float("inf")
|
| 283 |
+
columns: Tuple[ProgressColumn, ...] = (
|
| 284 |
+
TextColumn("[progress.description]{task.description}"),
|
| 285 |
+
SpinnerColumn("line", speed=1.5),
|
| 286 |
+
FileSizeColumn(),
|
| 287 |
+
TransferSpeedColumn(),
|
| 288 |
+
TimeElapsedColumn(),
|
| 289 |
+
)
|
| 290 |
+
else:
|
| 291 |
+
total = size
|
| 292 |
+
columns = (
|
| 293 |
+
TextColumn("[progress.description]{task.description}"),
|
| 294 |
+
BarColumn(),
|
| 295 |
+
DownloadColumn(),
|
| 296 |
+
TransferSpeedColumn(),
|
| 297 |
+
TextColumn("eta"),
|
| 298 |
+
TimeRemainingColumn(),
|
| 299 |
+
)
|
| 300 |
+
|
| 301 |
+
progress = Progress(*columns, refresh_per_second=30)
|
| 302 |
+
task_id = progress.add_task(" " * (get_indentation() + 2), total=total)
|
| 303 |
+
with progress:
|
| 304 |
+
for chunk in iterable:
|
| 305 |
+
yield chunk
|
| 306 |
+
progress.update(task_id, advance=len(chunk))
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def get_download_progress_renderer(
|
| 310 |
+
*, bar_type: str, size: Optional[int] = None
|
| 311 |
+
) -> DownloadProgressRenderer:
|
| 312 |
+
"""Get an object that can be used to render the download progress.
|
| 313 |
+
|
| 314 |
+
Returns a callable, that takes an iterable to "wrap".
|
| 315 |
+
"""
|
| 316 |
+
if bar_type == "on":
|
| 317 |
+
return functools.partial(_rich_progress_bar, bar_type=bar_type, size=size)
|
| 318 |
+
elif bar_type == "off":
|
| 319 |
+
return iter # no-op, when passed an iterator
|
| 320 |
+
else:
|
| 321 |
+
return _legacy_progress_bar(bar_type, size)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/spinners.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import itertools
|
| 3 |
+
import logging
|
| 4 |
+
import sys
|
| 5 |
+
import time
|
| 6 |
+
from typing import IO, Iterator
|
| 7 |
+
|
| 8 |
+
from pip._vendor.progress import HIDE_CURSOR, SHOW_CURSOR
|
| 9 |
+
|
| 10 |
+
from pip._internal.utils.compat import WINDOWS
|
| 11 |
+
from pip._internal.utils.logging import get_indentation
|
| 12 |
+
|
| 13 |
+
logger = logging.getLogger(__name__)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class SpinnerInterface:
|
| 17 |
+
def spin(self) -> None:
|
| 18 |
+
raise NotImplementedError()
|
| 19 |
+
|
| 20 |
+
def finish(self, final_status: str) -> None:
|
| 21 |
+
raise NotImplementedError()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class InteractiveSpinner(SpinnerInterface):
|
| 25 |
+
def __init__(
|
| 26 |
+
self,
|
| 27 |
+
message: str,
|
| 28 |
+
file: IO[str] = None,
|
| 29 |
+
spin_chars: str = "-\\|/",
|
| 30 |
+
# Empirically, 8 updates/second looks nice
|
| 31 |
+
min_update_interval_seconds: float = 0.125,
|
| 32 |
+
):
|
| 33 |
+
self._message = message
|
| 34 |
+
if file is None:
|
| 35 |
+
file = sys.stdout
|
| 36 |
+
self._file = file
|
| 37 |
+
self._rate_limiter = RateLimiter(min_update_interval_seconds)
|
| 38 |
+
self._finished = False
|
| 39 |
+
|
| 40 |
+
self._spin_cycle = itertools.cycle(spin_chars)
|
| 41 |
+
|
| 42 |
+
self._file.write(" " * get_indentation() + self._message + " ... ")
|
| 43 |
+
self._width = 0
|
| 44 |
+
|
| 45 |
+
def _write(self, status: str) -> None:
|
| 46 |
+
assert not self._finished
|
| 47 |
+
# Erase what we wrote before by backspacing to the beginning, writing
|
| 48 |
+
# spaces to overwrite the old text, and then backspacing again
|
| 49 |
+
backup = "\b" * self._width
|
| 50 |
+
self._file.write(backup + " " * self._width + backup)
|
| 51 |
+
# Now we have a blank slate to add our status
|
| 52 |
+
self._file.write(status)
|
| 53 |
+
self._width = len(status)
|
| 54 |
+
self._file.flush()
|
| 55 |
+
self._rate_limiter.reset()
|
| 56 |
+
|
| 57 |
+
def spin(self) -> None:
|
| 58 |
+
if self._finished:
|
| 59 |
+
return
|
| 60 |
+
if not self._rate_limiter.ready():
|
| 61 |
+
return
|
| 62 |
+
self._write(next(self._spin_cycle))
|
| 63 |
+
|
| 64 |
+
def finish(self, final_status: str) -> None:
|
| 65 |
+
if self._finished:
|
| 66 |
+
return
|
| 67 |
+
self._write(final_status)
|
| 68 |
+
self._file.write("\n")
|
| 69 |
+
self._file.flush()
|
| 70 |
+
self._finished = True
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
# Used for dumb terminals, non-interactive installs (no tty), etc.
|
| 74 |
+
# We still print updates occasionally (once every 60 seconds by default) to
|
| 75 |
+
# act as a keep-alive for systems like Travis-CI that take lack-of-output as
|
| 76 |
+
# an indication that a task has frozen.
|
| 77 |
+
class NonInteractiveSpinner(SpinnerInterface):
|
| 78 |
+
def __init__(self, message: str, min_update_interval_seconds: float = 60.0) -> None:
|
| 79 |
+
self._message = message
|
| 80 |
+
self._finished = False
|
| 81 |
+
self._rate_limiter = RateLimiter(min_update_interval_seconds)
|
| 82 |
+
self._update("started")
|
| 83 |
+
|
| 84 |
+
def _update(self, status: str) -> None:
|
| 85 |
+
assert not self._finished
|
| 86 |
+
self._rate_limiter.reset()
|
| 87 |
+
logger.info("%s: %s", self._message, status)
|
| 88 |
+
|
| 89 |
+
def spin(self) -> None:
|
| 90 |
+
if self._finished:
|
| 91 |
+
return
|
| 92 |
+
if not self._rate_limiter.ready():
|
| 93 |
+
return
|
| 94 |
+
self._update("still running...")
|
| 95 |
+
|
| 96 |
+
def finish(self, final_status: str) -> None:
|
| 97 |
+
if self._finished:
|
| 98 |
+
return
|
| 99 |
+
self._update(f"finished with status '{final_status}'")
|
| 100 |
+
self._finished = True
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
class RateLimiter:
|
| 104 |
+
def __init__(self, min_update_interval_seconds: float) -> None:
|
| 105 |
+
self._min_update_interval_seconds = min_update_interval_seconds
|
| 106 |
+
self._last_update: float = 0
|
| 107 |
+
|
| 108 |
+
def ready(self) -> bool:
|
| 109 |
+
now = time.time()
|
| 110 |
+
delta = now - self._last_update
|
| 111 |
+
return delta >= self._min_update_interval_seconds
|
| 112 |
+
|
| 113 |
+
def reset(self) -> None:
|
| 114 |
+
self._last_update = time.time()
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
@contextlib.contextmanager
|
| 118 |
+
def open_spinner(message: str) -> Iterator[SpinnerInterface]:
|
| 119 |
+
# Interactive spinner goes directly to sys.stdout rather than being routed
|
| 120 |
+
# through the logging system, but it acts like it has level INFO,
|
| 121 |
+
# i.e. it's only displayed if we're at level INFO or better.
|
| 122 |
+
# Non-interactive spinner goes through the logging system, so it is always
|
| 123 |
+
# in sync with logging configuration.
|
| 124 |
+
if sys.stdout.isatty() and logger.getEffectiveLevel() <= logging.INFO:
|
| 125 |
+
spinner: SpinnerInterface = InteractiveSpinner(message)
|
| 126 |
+
else:
|
| 127 |
+
spinner = NonInteractiveSpinner(message)
|
| 128 |
+
try:
|
| 129 |
+
with hidden_cursor(sys.stdout):
|
| 130 |
+
yield spinner
|
| 131 |
+
except KeyboardInterrupt:
|
| 132 |
+
spinner.finish("canceled")
|
| 133 |
+
raise
|
| 134 |
+
except Exception:
|
| 135 |
+
spinner.finish("error")
|
| 136 |
+
raise
|
| 137 |
+
else:
|
| 138 |
+
spinner.finish("done")
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
@contextlib.contextmanager
|
| 142 |
+
def hidden_cursor(file: IO[str]) -> Iterator[None]:
|
| 143 |
+
# The Windows terminal does not support the hide/show cursor ANSI codes,
|
| 144 |
+
# even via colorama. So don't even try.
|
| 145 |
+
if WINDOWS:
|
| 146 |
+
yield
|
| 147 |
+
# We don't want to clutter the output with control characters if we're
|
| 148 |
+
# writing to a file, or if the user is running with --quiet.
|
| 149 |
+
# See https://github.com/pypa/pip/issues/3418
|
| 150 |
+
elif not file.isatty() or logger.getEffectiveLevel() > logging.INFO:
|
| 151 |
+
yield
|
| 152 |
+
else:
|
| 153 |
+
file.write(HIDE_CURSOR)
|
| 154 |
+
try:
|
| 155 |
+
yield
|
| 156 |
+
finally:
|
| 157 |
+
file.write(SHOW_CURSOR)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/status_codes.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SUCCESS = 0
|
| 2 |
+
ERROR = 1
|
| 3 |
+
UNKNOWN_ERROR = 2
|
| 4 |
+
VIRTUALENV_NOT_FOUND = 3
|
| 5 |
+
PREVIOUS_BUILD_DIR_ERROR = 4
|
| 6 |
+
NO_MATCHES_FOUND = 23
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/metadata.cpython-310.pyc
ADDED
|
Binary file (1.48 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/metadata_editable.cpython-310.pyc
ADDED
|
Binary file (1.51 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/wheel.cpython-310.pyc
ADDED
|
Binary file (1.27 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/wheel_legacy.cpython-310.pyc
ADDED
|
Binary file (2.81 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
"""CacheControl import Interface.
|
| 6 |
+
|
| 7 |
+
Make it easy to import from cachecontrol without long namespaces.
|
| 8 |
+
"""
|
| 9 |
+
__author__ = "Eric Larson"
|
| 10 |
+
__email__ = "eric@ionrock.org"
|
| 11 |
+
__version__ = "0.12.10"
|
| 12 |
+
|
| 13 |
+
from .wrapper import CacheControl
|
| 14 |
+
from .adapter import CacheControlAdapter
|
| 15 |
+
from .controller import CacheController
|
| 16 |
+
|
| 17 |
+
import logging
|
| 18 |
+
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
import types
|
| 6 |
+
import functools
|
| 7 |
+
import zlib
|
| 8 |
+
|
| 9 |
+
from pip._vendor.requests.adapters import HTTPAdapter
|
| 10 |
+
|
| 11 |
+
from .controller import CacheController, PERMANENT_REDIRECT_STATUSES
|
| 12 |
+
from .cache import DictCache
|
| 13 |
+
from .filewrapper import CallbackFileWrapper
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class CacheControlAdapter(HTTPAdapter):
|
| 17 |
+
invalidating_methods = {"PUT", "PATCH", "DELETE"}
|
| 18 |
+
|
| 19 |
+
def __init__(
|
| 20 |
+
self,
|
| 21 |
+
cache=None,
|
| 22 |
+
cache_etags=True,
|
| 23 |
+
controller_class=None,
|
| 24 |
+
serializer=None,
|
| 25 |
+
heuristic=None,
|
| 26 |
+
cacheable_methods=None,
|
| 27 |
+
*args,
|
| 28 |
+
**kw
|
| 29 |
+
):
|
| 30 |
+
super(CacheControlAdapter, self).__init__(*args, **kw)
|
| 31 |
+
self.cache = DictCache() if cache is None else cache
|
| 32 |
+
self.heuristic = heuristic
|
| 33 |
+
self.cacheable_methods = cacheable_methods or ("GET",)
|
| 34 |
+
|
| 35 |
+
controller_factory = controller_class or CacheController
|
| 36 |
+
self.controller = controller_factory(
|
| 37 |
+
self.cache, cache_etags=cache_etags, serializer=serializer
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
def send(self, request, cacheable_methods=None, **kw):
|
| 41 |
+
"""
|
| 42 |
+
Send a request. Use the request information to see if it
|
| 43 |
+
exists in the cache and cache the response if we need to and can.
|
| 44 |
+
"""
|
| 45 |
+
cacheable = cacheable_methods or self.cacheable_methods
|
| 46 |
+
if request.method in cacheable:
|
| 47 |
+
try:
|
| 48 |
+
cached_response = self.controller.cached_request(request)
|
| 49 |
+
except zlib.error:
|
| 50 |
+
cached_response = None
|
| 51 |
+
if cached_response:
|
| 52 |
+
return self.build_response(request, cached_response, from_cache=True)
|
| 53 |
+
|
| 54 |
+
# check for etags and add headers if appropriate
|
| 55 |
+
request.headers.update(self.controller.conditional_headers(request))
|
| 56 |
+
|
| 57 |
+
resp = super(CacheControlAdapter, self).send(request, **kw)
|
| 58 |
+
|
| 59 |
+
return resp
|
| 60 |
+
|
| 61 |
+
def build_response(
|
| 62 |
+
self, request, response, from_cache=False, cacheable_methods=None
|
| 63 |
+
):
|
| 64 |
+
"""
|
| 65 |
+
Build a response by making a request or using the cache.
|
| 66 |
+
|
| 67 |
+
This will end up calling send and returning a potentially
|
| 68 |
+
cached response
|
| 69 |
+
"""
|
| 70 |
+
cacheable = cacheable_methods or self.cacheable_methods
|
| 71 |
+
if not from_cache and request.method in cacheable:
|
| 72 |
+
# Check for any heuristics that might update headers
|
| 73 |
+
# before trying to cache.
|
| 74 |
+
if self.heuristic:
|
| 75 |
+
response = self.heuristic.apply(response)
|
| 76 |
+
|
| 77 |
+
# apply any expiration heuristics
|
| 78 |
+
if response.status == 304:
|
| 79 |
+
# We must have sent an ETag request. This could mean
|
| 80 |
+
# that we've been expired already or that we simply
|
| 81 |
+
# have an etag. In either case, we want to try and
|
| 82 |
+
# update the cache if that is the case.
|
| 83 |
+
cached_response = self.controller.update_cached_response(
|
| 84 |
+
request, response
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
if cached_response is not response:
|
| 88 |
+
from_cache = True
|
| 89 |
+
|
| 90 |
+
# We are done with the server response, read a
|
| 91 |
+
# possible response body (compliant servers will
|
| 92 |
+
# not return one, but we cannot be 100% sure) and
|
| 93 |
+
# release the connection back to the pool.
|
| 94 |
+
response.read(decode_content=False)
|
| 95 |
+
response.release_conn()
|
| 96 |
+
|
| 97 |
+
response = cached_response
|
| 98 |
+
|
| 99 |
+
# We always cache the 301 responses
|
| 100 |
+
elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
|
| 101 |
+
self.controller.cache_response(request, response)
|
| 102 |
+
else:
|
| 103 |
+
# Wrap the response file with a wrapper that will cache the
|
| 104 |
+
# response when the stream has been consumed.
|
| 105 |
+
response._fp = CallbackFileWrapper(
|
| 106 |
+
response._fp,
|
| 107 |
+
functools.partial(
|
| 108 |
+
self.controller.cache_response, request, response
|
| 109 |
+
),
|
| 110 |
+
)
|
| 111 |
+
if response.chunked:
|
| 112 |
+
super_update_chunk_length = response._update_chunk_length
|
| 113 |
+
|
| 114 |
+
def _update_chunk_length(self):
|
| 115 |
+
super_update_chunk_length()
|
| 116 |
+
if self.chunk_left == 0:
|
| 117 |
+
self._fp._close()
|
| 118 |
+
|
| 119 |
+
response._update_chunk_length = types.MethodType(
|
| 120 |
+
_update_chunk_length, response
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
resp = super(CacheControlAdapter, self).build_response(request, response)
|
| 124 |
+
|
| 125 |
+
# See if we should invalidate the cache.
|
| 126 |
+
if request.method in self.invalidating_methods and resp.ok:
|
| 127 |
+
cache_url = self.controller.cache_url(request.url)
|
| 128 |
+
self.cache.delete(cache_url)
|
| 129 |
+
|
| 130 |
+
# Give the request a from_cache attr to let people use it
|
| 131 |
+
resp.from_cache = from_cache
|
| 132 |
+
|
| 133 |
+
return resp
|
| 134 |
+
|
| 135 |
+
def close(self):
|
| 136 |
+
self.cache.close()
|
| 137 |
+
super(CacheControlAdapter, self).close()
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/cache.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
"""
|
| 6 |
+
The cache object API for implementing caches. The default is a thread
|
| 7 |
+
safe in-memory dictionary.
|
| 8 |
+
"""
|
| 9 |
+
from threading import Lock
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class BaseCache(object):
|
| 13 |
+
|
| 14 |
+
def get(self, key):
|
| 15 |
+
raise NotImplementedError()
|
| 16 |
+
|
| 17 |
+
def set(self, key, value, expires=None):
|
| 18 |
+
raise NotImplementedError()
|
| 19 |
+
|
| 20 |
+
def delete(self, key):
|
| 21 |
+
raise NotImplementedError()
|
| 22 |
+
|
| 23 |
+
def close(self):
|
| 24 |
+
pass
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class DictCache(BaseCache):
|
| 28 |
+
|
| 29 |
+
def __init__(self, init_dict=None):
|
| 30 |
+
self.lock = Lock()
|
| 31 |
+
self.data = init_dict or {}
|
| 32 |
+
|
| 33 |
+
def get(self, key):
|
| 34 |
+
return self.data.get(key, None)
|
| 35 |
+
|
| 36 |
+
def set(self, key, value, expires=None):
|
| 37 |
+
with self.lock:
|
| 38 |
+
self.data.update({key: value})
|
| 39 |
+
|
| 40 |
+
def delete(self, key):
|
| 41 |
+
with self.lock:
|
| 42 |
+
if key in self.data:
|
| 43 |
+
self.data.pop(key)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/compat.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
try:
|
| 6 |
+
from urllib.parse import urljoin
|
| 7 |
+
except ImportError:
|
| 8 |
+
from urlparse import urljoin
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
try:
|
| 12 |
+
import cPickle as pickle
|
| 13 |
+
except ImportError:
|
| 14 |
+
import pickle
|
| 15 |
+
|
| 16 |
+
# Handle the case where the requests module has been patched to not have
|
| 17 |
+
# urllib3 bundled as part of its source.
|
| 18 |
+
try:
|
| 19 |
+
from pip._vendor.requests.packages.urllib3.response import HTTPResponse
|
| 20 |
+
except ImportError:
|
| 21 |
+
from pip._vendor.urllib3.response import HTTPResponse
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
from pip._vendor.requests.packages.urllib3.util import is_fp_closed
|
| 25 |
+
except ImportError:
|
| 26 |
+
from pip._vendor.urllib3.util import is_fp_closed
|
| 27 |
+
|
| 28 |
+
# Replicate some six behaviour
|
| 29 |
+
try:
|
| 30 |
+
text_type = unicode
|
| 31 |
+
except NameError:
|
| 32 |
+
text_type = str
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/controller.py
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
"""
|
| 6 |
+
The httplib2 algorithms ported for use with requests.
|
| 7 |
+
"""
|
| 8 |
+
import logging
|
| 9 |
+
import re
|
| 10 |
+
import calendar
|
| 11 |
+
import time
|
| 12 |
+
from email.utils import parsedate_tz
|
| 13 |
+
|
| 14 |
+
from pip._vendor.requests.structures import CaseInsensitiveDict
|
| 15 |
+
|
| 16 |
+
from .cache import DictCache
|
| 17 |
+
from .serialize import Serializer
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
logger = logging.getLogger(__name__)
|
| 21 |
+
|
| 22 |
+
URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
|
| 23 |
+
|
| 24 |
+
PERMANENT_REDIRECT_STATUSES = (301, 308)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def parse_uri(uri):
|
| 28 |
+
"""Parses a URI using the regex given in Appendix B of RFC 3986.
|
| 29 |
+
|
| 30 |
+
(scheme, authority, path, query, fragment) = parse_uri(uri)
|
| 31 |
+
"""
|
| 32 |
+
groups = URI.match(uri).groups()
|
| 33 |
+
return (groups[1], groups[3], groups[4], groups[6], groups[8])
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class CacheController(object):
|
| 37 |
+
"""An interface to see if request should cached or not.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
def __init__(
|
| 41 |
+
self, cache=None, cache_etags=True, serializer=None, status_codes=None
|
| 42 |
+
):
|
| 43 |
+
self.cache = DictCache() if cache is None else cache
|
| 44 |
+
self.cache_etags = cache_etags
|
| 45 |
+
self.serializer = serializer or Serializer()
|
| 46 |
+
self.cacheable_status_codes = status_codes or (200, 203, 300, 301, 308)
|
| 47 |
+
|
| 48 |
+
@classmethod
|
| 49 |
+
def _urlnorm(cls, uri):
|
| 50 |
+
"""Normalize the URL to create a safe key for the cache"""
|
| 51 |
+
(scheme, authority, path, query, fragment) = parse_uri(uri)
|
| 52 |
+
if not scheme or not authority:
|
| 53 |
+
raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
|
| 54 |
+
|
| 55 |
+
scheme = scheme.lower()
|
| 56 |
+
authority = authority.lower()
|
| 57 |
+
|
| 58 |
+
if not path:
|
| 59 |
+
path = "/"
|
| 60 |
+
|
| 61 |
+
# Could do syntax based normalization of the URI before
|
| 62 |
+
# computing the digest. See Section 6.2.2 of Std 66.
|
| 63 |
+
request_uri = query and "?".join([path, query]) or path
|
| 64 |
+
defrag_uri = scheme + "://" + authority + request_uri
|
| 65 |
+
|
| 66 |
+
return defrag_uri
|
| 67 |
+
|
| 68 |
+
@classmethod
|
| 69 |
+
def cache_url(cls, uri):
|
| 70 |
+
return cls._urlnorm(uri)
|
| 71 |
+
|
| 72 |
+
def parse_cache_control(self, headers):
|
| 73 |
+
known_directives = {
|
| 74 |
+
# https://tools.ietf.org/html/rfc7234#section-5.2
|
| 75 |
+
"max-age": (int, True),
|
| 76 |
+
"max-stale": (int, False),
|
| 77 |
+
"min-fresh": (int, True),
|
| 78 |
+
"no-cache": (None, False),
|
| 79 |
+
"no-store": (None, False),
|
| 80 |
+
"no-transform": (None, False),
|
| 81 |
+
"only-if-cached": (None, False),
|
| 82 |
+
"must-revalidate": (None, False),
|
| 83 |
+
"public": (None, False),
|
| 84 |
+
"private": (None, False),
|
| 85 |
+
"proxy-revalidate": (None, False),
|
| 86 |
+
"s-maxage": (int, True),
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
cc_headers = headers.get("cache-control", headers.get("Cache-Control", ""))
|
| 90 |
+
|
| 91 |
+
retval = {}
|
| 92 |
+
|
| 93 |
+
for cc_directive in cc_headers.split(","):
|
| 94 |
+
if not cc_directive.strip():
|
| 95 |
+
continue
|
| 96 |
+
|
| 97 |
+
parts = cc_directive.split("=", 1)
|
| 98 |
+
directive = parts[0].strip()
|
| 99 |
+
|
| 100 |
+
try:
|
| 101 |
+
typ, required = known_directives[directive]
|
| 102 |
+
except KeyError:
|
| 103 |
+
logger.debug("Ignoring unknown cache-control directive: %s", directive)
|
| 104 |
+
continue
|
| 105 |
+
|
| 106 |
+
if not typ or not required:
|
| 107 |
+
retval[directive] = None
|
| 108 |
+
if typ:
|
| 109 |
+
try:
|
| 110 |
+
retval[directive] = typ(parts[1].strip())
|
| 111 |
+
except IndexError:
|
| 112 |
+
if required:
|
| 113 |
+
logger.debug(
|
| 114 |
+
"Missing value for cache-control " "directive: %s",
|
| 115 |
+
directive,
|
| 116 |
+
)
|
| 117 |
+
except ValueError:
|
| 118 |
+
logger.debug(
|
| 119 |
+
"Invalid value for cache-control directive " "%s, must be %s",
|
| 120 |
+
directive,
|
| 121 |
+
typ.__name__,
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
return retval
|
| 125 |
+
|
| 126 |
+
def cached_request(self, request):
|
| 127 |
+
"""
|
| 128 |
+
Return a cached response if it exists in the cache, otherwise
|
| 129 |
+
return False.
|
| 130 |
+
"""
|
| 131 |
+
cache_url = self.cache_url(request.url)
|
| 132 |
+
logger.debug('Looking up "%s" in the cache', cache_url)
|
| 133 |
+
cc = self.parse_cache_control(request.headers)
|
| 134 |
+
|
| 135 |
+
# Bail out if the request insists on fresh data
|
| 136 |
+
if "no-cache" in cc:
|
| 137 |
+
logger.debug('Request header has "no-cache", cache bypassed')
|
| 138 |
+
return False
|
| 139 |
+
|
| 140 |
+
if "max-age" in cc and cc["max-age"] == 0:
|
| 141 |
+
logger.debug('Request header has "max_age" as 0, cache bypassed')
|
| 142 |
+
return False
|
| 143 |
+
|
| 144 |
+
# Request allows serving from the cache, let's see if we find something
|
| 145 |
+
cache_data = self.cache.get(cache_url)
|
| 146 |
+
if cache_data is None:
|
| 147 |
+
logger.debug("No cache entry available")
|
| 148 |
+
return False
|
| 149 |
+
|
| 150 |
+
# Check whether it can be deserialized
|
| 151 |
+
resp = self.serializer.loads(request, cache_data)
|
| 152 |
+
if not resp:
|
| 153 |
+
logger.warning("Cache entry deserialization failed, entry ignored")
|
| 154 |
+
return False
|
| 155 |
+
|
| 156 |
+
# If we have a cached permanent redirect, return it immediately. We
|
| 157 |
+
# don't need to test our response for other headers b/c it is
|
| 158 |
+
# intrinsically "cacheable" as it is Permanent.
|
| 159 |
+
#
|
| 160 |
+
# See:
|
| 161 |
+
# https://tools.ietf.org/html/rfc7231#section-6.4.2
|
| 162 |
+
#
|
| 163 |
+
# Client can try to refresh the value by repeating the request
|
| 164 |
+
# with cache busting headers as usual (ie no-cache).
|
| 165 |
+
if int(resp.status) in PERMANENT_REDIRECT_STATUSES:
|
| 166 |
+
msg = (
|
| 167 |
+
"Returning cached permanent redirect response "
|
| 168 |
+
"(ignoring date and etag information)"
|
| 169 |
+
)
|
| 170 |
+
logger.debug(msg)
|
| 171 |
+
return resp
|
| 172 |
+
|
| 173 |
+
headers = CaseInsensitiveDict(resp.headers)
|
| 174 |
+
if not headers or "date" not in headers:
|
| 175 |
+
if "etag" not in headers:
|
| 176 |
+
# Without date or etag, the cached response can never be used
|
| 177 |
+
# and should be deleted.
|
| 178 |
+
logger.debug("Purging cached response: no date or etag")
|
| 179 |
+
self.cache.delete(cache_url)
|
| 180 |
+
logger.debug("Ignoring cached response: no date")
|
| 181 |
+
return False
|
| 182 |
+
|
| 183 |
+
now = time.time()
|
| 184 |
+
date = calendar.timegm(parsedate_tz(headers["date"]))
|
| 185 |
+
current_age = max(0, now - date)
|
| 186 |
+
logger.debug("Current age based on date: %i", current_age)
|
| 187 |
+
|
| 188 |
+
# TODO: There is an assumption that the result will be a
|
| 189 |
+
# urllib3 response object. This may not be best since we
|
| 190 |
+
# could probably avoid instantiating or constructing the
|
| 191 |
+
# response until we know we need it.
|
| 192 |
+
resp_cc = self.parse_cache_control(headers)
|
| 193 |
+
|
| 194 |
+
# determine freshness
|
| 195 |
+
freshness_lifetime = 0
|
| 196 |
+
|
| 197 |
+
# Check the max-age pragma in the cache control header
|
| 198 |
+
if "max-age" in resp_cc:
|
| 199 |
+
freshness_lifetime = resp_cc["max-age"]
|
| 200 |
+
logger.debug("Freshness lifetime from max-age: %i", freshness_lifetime)
|
| 201 |
+
|
| 202 |
+
# If there isn't a max-age, check for an expires header
|
| 203 |
+
elif "expires" in headers:
|
| 204 |
+
expires = parsedate_tz(headers["expires"])
|
| 205 |
+
if expires is not None:
|
| 206 |
+
expire_time = calendar.timegm(expires) - date
|
| 207 |
+
freshness_lifetime = max(0, expire_time)
|
| 208 |
+
logger.debug("Freshness lifetime from expires: %i", freshness_lifetime)
|
| 209 |
+
|
| 210 |
+
# Determine if we are setting freshness limit in the
|
| 211 |
+
# request. Note, this overrides what was in the response.
|
| 212 |
+
if "max-age" in cc:
|
| 213 |
+
freshness_lifetime = cc["max-age"]
|
| 214 |
+
logger.debug(
|
| 215 |
+
"Freshness lifetime from request max-age: %i", freshness_lifetime
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
if "min-fresh" in cc:
|
| 219 |
+
min_fresh = cc["min-fresh"]
|
| 220 |
+
# adjust our current age by our min fresh
|
| 221 |
+
current_age += min_fresh
|
| 222 |
+
logger.debug("Adjusted current age from min-fresh: %i", current_age)
|
| 223 |
+
|
| 224 |
+
# Return entry if it is fresh enough
|
| 225 |
+
if freshness_lifetime > current_age:
|
| 226 |
+
logger.debug('The response is "fresh", returning cached response')
|
| 227 |
+
logger.debug("%i > %i", freshness_lifetime, current_age)
|
| 228 |
+
return resp
|
| 229 |
+
|
| 230 |
+
# we're not fresh. If we don't have an Etag, clear it out
|
| 231 |
+
if "etag" not in headers:
|
| 232 |
+
logger.debug('The cached response is "stale" with no etag, purging')
|
| 233 |
+
self.cache.delete(cache_url)
|
| 234 |
+
|
| 235 |
+
# return the original handler
|
| 236 |
+
return False
|
| 237 |
+
|
| 238 |
+
def conditional_headers(self, request):
|
| 239 |
+
cache_url = self.cache_url(request.url)
|
| 240 |
+
resp = self.serializer.loads(request, self.cache.get(cache_url))
|
| 241 |
+
new_headers = {}
|
| 242 |
+
|
| 243 |
+
if resp:
|
| 244 |
+
headers = CaseInsensitiveDict(resp.headers)
|
| 245 |
+
|
| 246 |
+
if "etag" in headers:
|
| 247 |
+
new_headers["If-None-Match"] = headers["ETag"]
|
| 248 |
+
|
| 249 |
+
if "last-modified" in headers:
|
| 250 |
+
new_headers["If-Modified-Since"] = headers["Last-Modified"]
|
| 251 |
+
|
| 252 |
+
return new_headers
|
| 253 |
+
|
| 254 |
+
def cache_response(self, request, response, body=None, status_codes=None):
|
| 255 |
+
"""
|
| 256 |
+
Algorithm for caching requests.
|
| 257 |
+
|
| 258 |
+
This assumes a requests Response object.
|
| 259 |
+
"""
|
| 260 |
+
# From httplib2: Don't cache 206's since we aren't going to
|
| 261 |
+
# handle byte range requests
|
| 262 |
+
cacheable_status_codes = status_codes or self.cacheable_status_codes
|
| 263 |
+
if response.status not in cacheable_status_codes:
|
| 264 |
+
logger.debug(
|
| 265 |
+
"Status code %s not in %s", response.status, cacheable_status_codes
|
| 266 |
+
)
|
| 267 |
+
return
|
| 268 |
+
|
| 269 |
+
response_headers = CaseInsensitiveDict(response.headers)
|
| 270 |
+
|
| 271 |
+
if "date" in response_headers:
|
| 272 |
+
date = calendar.timegm(parsedate_tz(response_headers["date"]))
|
| 273 |
+
else:
|
| 274 |
+
date = 0
|
| 275 |
+
|
| 276 |
+
# If we've been given a body, our response has a Content-Length, that
|
| 277 |
+
# Content-Length is valid then we can check to see if the body we've
|
| 278 |
+
# been given matches the expected size, and if it doesn't we'll just
|
| 279 |
+
# skip trying to cache it.
|
| 280 |
+
if (
|
| 281 |
+
body is not None
|
| 282 |
+
and "content-length" in response_headers
|
| 283 |
+
and response_headers["content-length"].isdigit()
|
| 284 |
+
and int(response_headers["content-length"]) != len(body)
|
| 285 |
+
):
|
| 286 |
+
return
|
| 287 |
+
|
| 288 |
+
cc_req = self.parse_cache_control(request.headers)
|
| 289 |
+
cc = self.parse_cache_control(response_headers)
|
| 290 |
+
|
| 291 |
+
cache_url = self.cache_url(request.url)
|
| 292 |
+
logger.debug('Updating cache with response from "%s"', cache_url)
|
| 293 |
+
|
| 294 |
+
# Delete it from the cache if we happen to have it stored there
|
| 295 |
+
no_store = False
|
| 296 |
+
if "no-store" in cc:
|
| 297 |
+
no_store = True
|
| 298 |
+
logger.debug('Response header has "no-store"')
|
| 299 |
+
if "no-store" in cc_req:
|
| 300 |
+
no_store = True
|
| 301 |
+
logger.debug('Request header has "no-store"')
|
| 302 |
+
if no_store and self.cache.get(cache_url):
|
| 303 |
+
logger.debug('Purging existing cache entry to honor "no-store"')
|
| 304 |
+
self.cache.delete(cache_url)
|
| 305 |
+
if no_store:
|
| 306 |
+
return
|
| 307 |
+
|
| 308 |
+
# https://tools.ietf.org/html/rfc7234#section-4.1:
|
| 309 |
+
# A Vary header field-value of "*" always fails to match.
|
| 310 |
+
# Storing such a response leads to a deserialization warning
|
| 311 |
+
# during cache lookup and is not allowed to ever be served,
|
| 312 |
+
# so storing it can be avoided.
|
| 313 |
+
if "*" in response_headers.get("vary", ""):
|
| 314 |
+
logger.debug('Response header has "Vary: *"')
|
| 315 |
+
return
|
| 316 |
+
|
| 317 |
+
# If we've been given an etag, then keep the response
|
| 318 |
+
if self.cache_etags and "etag" in response_headers:
|
| 319 |
+
expires_time = 0
|
| 320 |
+
if response_headers.get("expires"):
|
| 321 |
+
expires = parsedate_tz(response_headers["expires"])
|
| 322 |
+
if expires is not None:
|
| 323 |
+
expires_time = calendar.timegm(expires) - date
|
| 324 |
+
|
| 325 |
+
expires_time = max(expires_time, 14 * 86400)
|
| 326 |
+
|
| 327 |
+
logger.debug("etag object cached for {0} seconds".format(expires_time))
|
| 328 |
+
logger.debug("Caching due to etag")
|
| 329 |
+
self.cache.set(
|
| 330 |
+
cache_url,
|
| 331 |
+
self.serializer.dumps(request, response, body),
|
| 332 |
+
expires=expires_time,
|
| 333 |
+
)
|
| 334 |
+
|
| 335 |
+
# Add to the cache any permanent redirects. We do this before looking
|
| 336 |
+
# that the Date headers.
|
| 337 |
+
elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
|
| 338 |
+
logger.debug("Caching permanent redirect")
|
| 339 |
+
self.cache.set(cache_url, self.serializer.dumps(request, response, b""))
|
| 340 |
+
|
| 341 |
+
# Add to the cache if the response headers demand it. If there
|
| 342 |
+
# is no date header then we can't do anything about expiring
|
| 343 |
+
# the cache.
|
| 344 |
+
elif "date" in response_headers:
|
| 345 |
+
date = calendar.timegm(parsedate_tz(response_headers["date"]))
|
| 346 |
+
# cache when there is a max-age > 0
|
| 347 |
+
if "max-age" in cc and cc["max-age"] > 0:
|
| 348 |
+
logger.debug("Caching b/c date exists and max-age > 0")
|
| 349 |
+
expires_time = cc["max-age"]
|
| 350 |
+
self.cache.set(
|
| 351 |
+
cache_url,
|
| 352 |
+
self.serializer.dumps(request, response, body),
|
| 353 |
+
expires=expires_time,
|
| 354 |
+
)
|
| 355 |
+
|
| 356 |
+
# If the request can expire, it means we should cache it
|
| 357 |
+
# in the meantime.
|
| 358 |
+
elif "expires" in response_headers:
|
| 359 |
+
if response_headers["expires"]:
|
| 360 |
+
expires = parsedate_tz(response_headers["expires"])
|
| 361 |
+
if expires is not None:
|
| 362 |
+
expires_time = calendar.timegm(expires) - date
|
| 363 |
+
else:
|
| 364 |
+
expires_time = None
|
| 365 |
+
|
| 366 |
+
logger.debug(
|
| 367 |
+
"Caching b/c of expires header. expires in {0} seconds".format(
|
| 368 |
+
expires_time
|
| 369 |
+
)
|
| 370 |
+
)
|
| 371 |
+
self.cache.set(
|
| 372 |
+
cache_url,
|
| 373 |
+
self.serializer.dumps(request, response, body=body),
|
| 374 |
+
expires=expires_time,
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
def update_cached_response(self, request, response):
|
| 378 |
+
"""On a 304 we will get a new set of headers that we want to
|
| 379 |
+
update our cached value with, assuming we have one.
|
| 380 |
+
|
| 381 |
+
This should only ever be called when we've sent an ETag and
|
| 382 |
+
gotten a 304 as the response.
|
| 383 |
+
"""
|
| 384 |
+
cache_url = self.cache_url(request.url)
|
| 385 |
+
|
| 386 |
+
cached_response = self.serializer.loads(request, self.cache.get(cache_url))
|
| 387 |
+
|
| 388 |
+
if not cached_response:
|
| 389 |
+
# we didn't have a cached response
|
| 390 |
+
return response
|
| 391 |
+
|
| 392 |
+
# Lets update our headers with the headers from the new request:
|
| 393 |
+
# http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-26#section-4.1
|
| 394 |
+
#
|
| 395 |
+
# The server isn't supposed to send headers that would make
|
| 396 |
+
# the cached body invalid. But... just in case, we'll be sure
|
| 397 |
+
# to strip out ones we know that might be problmatic due to
|
| 398 |
+
# typical assumptions.
|
| 399 |
+
excluded_headers = ["content-length"]
|
| 400 |
+
|
| 401 |
+
cached_response.headers.update(
|
| 402 |
+
dict(
|
| 403 |
+
(k, v)
|
| 404 |
+
for k, v in response.headers.items()
|
| 405 |
+
if k.lower() not in excluded_headers
|
| 406 |
+
)
|
| 407 |
+
)
|
| 408 |
+
|
| 409 |
+
# we want a 200 b/c we have content via the cache
|
| 410 |
+
cached_response.status = 200
|
| 411 |
+
|
| 412 |
+
# update our cache
|
| 413 |
+
self.cache.set(cache_url, self.serializer.dumps(request, cached_response))
|
| 414 |
+
|
| 415 |
+
return cached_response
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/heuristics.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
import calendar
|
| 6 |
+
import time
|
| 7 |
+
|
| 8 |
+
from email.utils import formatdate, parsedate, parsedate_tz
|
| 9 |
+
|
| 10 |
+
from datetime import datetime, timedelta
|
| 11 |
+
|
| 12 |
+
TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def expire_after(delta, date=None):
|
| 16 |
+
date = date or datetime.utcnow()
|
| 17 |
+
return date + delta
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def datetime_to_header(dt):
|
| 21 |
+
return formatdate(calendar.timegm(dt.timetuple()))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class BaseHeuristic(object):
|
| 25 |
+
|
| 26 |
+
def warning(self, response):
|
| 27 |
+
"""
|
| 28 |
+
Return a valid 1xx warning header value describing the cache
|
| 29 |
+
adjustments.
|
| 30 |
+
|
| 31 |
+
The response is provided too allow warnings like 113
|
| 32 |
+
http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need
|
| 33 |
+
to explicitly say response is over 24 hours old.
|
| 34 |
+
"""
|
| 35 |
+
return '110 - "Response is Stale"'
|
| 36 |
+
|
| 37 |
+
def update_headers(self, response):
|
| 38 |
+
"""Update the response headers with any new headers.
|
| 39 |
+
|
| 40 |
+
NOTE: This SHOULD always include some Warning header to
|
| 41 |
+
signify that the response was cached by the client, not
|
| 42 |
+
by way of the provided headers.
|
| 43 |
+
"""
|
| 44 |
+
return {}
|
| 45 |
+
|
| 46 |
+
def apply(self, response):
|
| 47 |
+
updated_headers = self.update_headers(response)
|
| 48 |
+
|
| 49 |
+
if updated_headers:
|
| 50 |
+
response.headers.update(updated_headers)
|
| 51 |
+
warning_header_value = self.warning(response)
|
| 52 |
+
if warning_header_value is not None:
|
| 53 |
+
response.headers.update({"Warning": warning_header_value})
|
| 54 |
+
|
| 55 |
+
return response
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class OneDayCache(BaseHeuristic):
|
| 59 |
+
"""
|
| 60 |
+
Cache the response by providing an expires 1 day in the
|
| 61 |
+
future.
|
| 62 |
+
"""
|
| 63 |
+
|
| 64 |
+
def update_headers(self, response):
|
| 65 |
+
headers = {}
|
| 66 |
+
|
| 67 |
+
if "expires" not in response.headers:
|
| 68 |
+
date = parsedate(response.headers["date"])
|
| 69 |
+
expires = expire_after(timedelta(days=1), date=datetime(*date[:6]))
|
| 70 |
+
headers["expires"] = datetime_to_header(expires)
|
| 71 |
+
headers["cache-control"] = "public"
|
| 72 |
+
return headers
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class ExpiresAfter(BaseHeuristic):
|
| 76 |
+
"""
|
| 77 |
+
Cache **all** requests for a defined time period.
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
def __init__(self, **kw):
|
| 81 |
+
self.delta = timedelta(**kw)
|
| 82 |
+
|
| 83 |
+
def update_headers(self, response):
|
| 84 |
+
expires = expire_after(self.delta)
|
| 85 |
+
return {"expires": datetime_to_header(expires), "cache-control": "public"}
|
| 86 |
+
|
| 87 |
+
def warning(self, response):
|
| 88 |
+
tmpl = "110 - Automatically cached for %s. Response might be stale"
|
| 89 |
+
return tmpl % self.delta
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
class LastModified(BaseHeuristic):
|
| 93 |
+
"""
|
| 94 |
+
If there is no Expires header already, fall back on Last-Modified
|
| 95 |
+
using the heuristic from
|
| 96 |
+
http://tools.ietf.org/html/rfc7234#section-4.2.2
|
| 97 |
+
to calculate a reasonable value.
|
| 98 |
+
|
| 99 |
+
Firefox also does something like this per
|
| 100 |
+
https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ
|
| 101 |
+
http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
|
| 102 |
+
Unlike mozilla we limit this to 24-hr.
|
| 103 |
+
"""
|
| 104 |
+
cacheable_by_default_statuses = {
|
| 105 |
+
200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
def update_headers(self, resp):
|
| 109 |
+
headers = resp.headers
|
| 110 |
+
|
| 111 |
+
if "expires" in headers:
|
| 112 |
+
return {}
|
| 113 |
+
|
| 114 |
+
if "cache-control" in headers and headers["cache-control"] != "public":
|
| 115 |
+
return {}
|
| 116 |
+
|
| 117 |
+
if resp.status not in self.cacheable_by_default_statuses:
|
| 118 |
+
return {}
|
| 119 |
+
|
| 120 |
+
if "date" not in headers or "last-modified" not in headers:
|
| 121 |
+
return {}
|
| 122 |
+
|
| 123 |
+
date = calendar.timegm(parsedate_tz(headers["date"]))
|
| 124 |
+
last_modified = parsedate(headers["last-modified"])
|
| 125 |
+
if date is None or last_modified is None:
|
| 126 |
+
return {}
|
| 127 |
+
|
| 128 |
+
now = time.time()
|
| 129 |
+
current_age = max(0, now - date)
|
| 130 |
+
delta = date - calendar.timegm(last_modified)
|
| 131 |
+
freshness_lifetime = max(0, min(delta / 10, 24 * 3600))
|
| 132 |
+
if freshness_lifetime <= current_age:
|
| 133 |
+
return {}
|
| 134 |
+
|
| 135 |
+
expires = date + freshness_lifetime
|
| 136 |
+
return {"expires": time.strftime(TIME_FMT, time.gmtime(expires))}
|
| 137 |
+
|
| 138 |
+
def warning(self, resp):
|
| 139 |
+
return None
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/serialize.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
import base64
|
| 6 |
+
import io
|
| 7 |
+
import json
|
| 8 |
+
import zlib
|
| 9 |
+
|
| 10 |
+
from pip._vendor import msgpack
|
| 11 |
+
from pip._vendor.requests.structures import CaseInsensitiveDict
|
| 12 |
+
|
| 13 |
+
from .compat import HTTPResponse, pickle, text_type
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def _b64_decode_bytes(b):
|
| 17 |
+
return base64.b64decode(b.encode("ascii"))
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _b64_decode_str(s):
|
| 21 |
+
return _b64_decode_bytes(s).decode("utf8")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
_default_body_read = object()
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class Serializer(object):
|
| 28 |
+
def dumps(self, request, response, body=None):
|
| 29 |
+
response_headers = CaseInsensitiveDict(response.headers)
|
| 30 |
+
|
| 31 |
+
if body is None:
|
| 32 |
+
# When a body isn't passed in, we'll read the response. We
|
| 33 |
+
# also update the response with a new file handler to be
|
| 34 |
+
# sure it acts as though it was never read.
|
| 35 |
+
body = response.read(decode_content=False)
|
| 36 |
+
response._fp = io.BytesIO(body)
|
| 37 |
+
|
| 38 |
+
# NOTE: This is all a bit weird, but it's really important that on
|
| 39 |
+
# Python 2.x these objects are unicode and not str, even when
|
| 40 |
+
# they contain only ascii. The problem here is that msgpack
|
| 41 |
+
# understands the difference between unicode and bytes and we
|
| 42 |
+
# have it set to differentiate between them, however Python 2
|
| 43 |
+
# doesn't know the difference. Forcing these to unicode will be
|
| 44 |
+
# enough to have msgpack know the difference.
|
| 45 |
+
data = {
|
| 46 |
+
u"response": {
|
| 47 |
+
u"body": body,
|
| 48 |
+
u"headers": dict(
|
| 49 |
+
(text_type(k), text_type(v)) for k, v in response.headers.items()
|
| 50 |
+
),
|
| 51 |
+
u"status": response.status,
|
| 52 |
+
u"version": response.version,
|
| 53 |
+
u"reason": text_type(response.reason),
|
| 54 |
+
u"strict": response.strict,
|
| 55 |
+
u"decode_content": response.decode_content,
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
# Construct our vary headers
|
| 60 |
+
data[u"vary"] = {}
|
| 61 |
+
if u"vary" in response_headers:
|
| 62 |
+
varied_headers = response_headers[u"vary"].split(",")
|
| 63 |
+
for header in varied_headers:
|
| 64 |
+
header = text_type(header).strip()
|
| 65 |
+
header_value = request.headers.get(header, None)
|
| 66 |
+
if header_value is not None:
|
| 67 |
+
header_value = text_type(header_value)
|
| 68 |
+
data[u"vary"][header] = header_value
|
| 69 |
+
|
| 70 |
+
return b",".join([b"cc=4", msgpack.dumps(data, use_bin_type=True)])
|
| 71 |
+
|
| 72 |
+
def loads(self, request, data):
|
| 73 |
+
# Short circuit if we've been given an empty set of data
|
| 74 |
+
if not data:
|
| 75 |
+
return
|
| 76 |
+
|
| 77 |
+
# Determine what version of the serializer the data was serialized
|
| 78 |
+
# with
|
| 79 |
+
try:
|
| 80 |
+
ver, data = data.split(b",", 1)
|
| 81 |
+
except ValueError:
|
| 82 |
+
ver = b"cc=0"
|
| 83 |
+
|
| 84 |
+
# Make sure that our "ver" is actually a version and isn't a false
|
| 85 |
+
# positive from a , being in the data stream.
|
| 86 |
+
if ver[:3] != b"cc=":
|
| 87 |
+
data = ver + data
|
| 88 |
+
ver = b"cc=0"
|
| 89 |
+
|
| 90 |
+
# Get the version number out of the cc=N
|
| 91 |
+
ver = ver.split(b"=", 1)[-1].decode("ascii")
|
| 92 |
+
|
| 93 |
+
# Dispatch to the actual load method for the given version
|
| 94 |
+
try:
|
| 95 |
+
return getattr(self, "_loads_v{}".format(ver))(request, data)
|
| 96 |
+
|
| 97 |
+
except AttributeError:
|
| 98 |
+
# This is a version we don't have a loads function for, so we'll
|
| 99 |
+
# just treat it as a miss and return None
|
| 100 |
+
return
|
| 101 |
+
|
| 102 |
+
def prepare_response(self, request, cached):
|
| 103 |
+
"""Verify our vary headers match and construct a real urllib3
|
| 104 |
+
HTTPResponse object.
|
| 105 |
+
"""
|
| 106 |
+
# Special case the '*' Vary value as it means we cannot actually
|
| 107 |
+
# determine if the cached response is suitable for this request.
|
| 108 |
+
# This case is also handled in the controller code when creating
|
| 109 |
+
# a cache entry, but is left here for backwards compatibility.
|
| 110 |
+
if "*" in cached.get("vary", {}):
|
| 111 |
+
return
|
| 112 |
+
|
| 113 |
+
# Ensure that the Vary headers for the cached response match our
|
| 114 |
+
# request
|
| 115 |
+
for header, value in cached.get("vary", {}).items():
|
| 116 |
+
if request.headers.get(header, None) != value:
|
| 117 |
+
return
|
| 118 |
+
|
| 119 |
+
body_raw = cached["response"].pop("body")
|
| 120 |
+
|
| 121 |
+
headers = CaseInsensitiveDict(data=cached["response"]["headers"])
|
| 122 |
+
if headers.get("transfer-encoding", "") == "chunked":
|
| 123 |
+
headers.pop("transfer-encoding")
|
| 124 |
+
|
| 125 |
+
cached["response"]["headers"] = headers
|
| 126 |
+
|
| 127 |
+
try:
|
| 128 |
+
body = io.BytesIO(body_raw)
|
| 129 |
+
except TypeError:
|
| 130 |
+
# This can happen if cachecontrol serialized to v1 format (pickle)
|
| 131 |
+
# using Python 2. A Python 2 str(byte string) will be unpickled as
|
| 132 |
+
# a Python 3 str (unicode string), which will cause the above to
|
| 133 |
+
# fail with:
|
| 134 |
+
#
|
| 135 |
+
# TypeError: 'str' does not support the buffer interface
|
| 136 |
+
body = io.BytesIO(body_raw.encode("utf8"))
|
| 137 |
+
|
| 138 |
+
return HTTPResponse(body=body, preload_content=False, **cached["response"])
|
| 139 |
+
|
| 140 |
+
def _loads_v0(self, request, data):
|
| 141 |
+
# The original legacy cache data. This doesn't contain enough
|
| 142 |
+
# information to construct everything we need, so we'll treat this as
|
| 143 |
+
# a miss.
|
| 144 |
+
return
|
| 145 |
+
|
| 146 |
+
def _loads_v1(self, request, data):
|
| 147 |
+
try:
|
| 148 |
+
cached = pickle.loads(data)
|
| 149 |
+
except ValueError:
|
| 150 |
+
return
|
| 151 |
+
|
| 152 |
+
return self.prepare_response(request, cached)
|
| 153 |
+
|
| 154 |
+
def _loads_v2(self, request, data):
|
| 155 |
+
try:
|
| 156 |
+
cached = json.loads(zlib.decompress(data).decode("utf8"))
|
| 157 |
+
except (ValueError, zlib.error):
|
| 158 |
+
return
|
| 159 |
+
|
| 160 |
+
# We need to decode the items that we've base64 encoded
|
| 161 |
+
cached["response"]["body"] = _b64_decode_bytes(cached["response"]["body"])
|
| 162 |
+
cached["response"]["headers"] = dict(
|
| 163 |
+
(_b64_decode_str(k), _b64_decode_str(v))
|
| 164 |
+
for k, v in cached["response"]["headers"].items()
|
| 165 |
+
)
|
| 166 |
+
cached["response"]["reason"] = _b64_decode_str(cached["response"]["reason"])
|
| 167 |
+
cached["vary"] = dict(
|
| 168 |
+
(_b64_decode_str(k), _b64_decode_str(v) if v is not None else v)
|
| 169 |
+
for k, v in cached["vary"].items()
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
return self.prepare_response(request, cached)
|
| 173 |
+
|
| 174 |
+
def _loads_v3(self, request, data):
|
| 175 |
+
# Due to Python 2 encoding issues, it's impossible to know for sure
|
| 176 |
+
# exactly how to load v3 entries, thus we'll treat these as a miss so
|
| 177 |
+
# that they get rewritten out as v4 entries.
|
| 178 |
+
return
|
| 179 |
+
|
| 180 |
+
def _loads_v4(self, request, data):
|
| 181 |
+
try:
|
| 182 |
+
cached = msgpack.loads(data, raw=False)
|
| 183 |
+
except ValueError:
|
| 184 |
+
return
|
| 185 |
+
|
| 186 |
+
return self.prepare_response(request, cached)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/wrapper.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: 2015 Eric Larson
|
| 2 |
+
#
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
from .adapter import CacheControlAdapter
|
| 6 |
+
from .cache import DictCache
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def CacheControl(
|
| 10 |
+
sess,
|
| 11 |
+
cache=None,
|
| 12 |
+
cache_etags=True,
|
| 13 |
+
serializer=None,
|
| 14 |
+
heuristic=None,
|
| 15 |
+
controller_class=None,
|
| 16 |
+
adapter_class=None,
|
| 17 |
+
cacheable_methods=None,
|
| 18 |
+
):
|
| 19 |
+
|
| 20 |
+
cache = DictCache() if cache is None else cache
|
| 21 |
+
adapter_class = adapter_class or CacheControlAdapter
|
| 22 |
+
adapter = adapter_class(
|
| 23 |
+
cache,
|
| 24 |
+
cache_etags=cache_etags,
|
| 25 |
+
serializer=serializer,
|
| 26 |
+
heuristic=heuristic,
|
| 27 |
+
controller_class=controller_class,
|
| 28 |
+
cacheable_methods=cacheable_methods,
|
| 29 |
+
)
|
| 30 |
+
sess.mount("http://", adapter)
|
| 31 |
+
sess.mount("https://", adapter)
|
| 32 |
+
|
| 33 |
+
return sess
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/progress/spinner.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
|
| 3 |
+
# Copyright (c) 2012 Georgios Verigakis <verigak@gmail.com>
|
| 4 |
+
#
|
| 5 |
+
# Permission to use, copy, modify, and distribute this software for any
|
| 6 |
+
# purpose with or without fee is hereby granted, provided that the above
|
| 7 |
+
# copyright notice and this permission notice appear in all copies.
|
| 8 |
+
#
|
| 9 |
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 10 |
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 11 |
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 12 |
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 13 |
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 14 |
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 15 |
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 16 |
+
|
| 17 |
+
from __future__ import unicode_literals
|
| 18 |
+
from . import Infinite
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class Spinner(Infinite):
|
| 22 |
+
phases = ('-', '\\', '|', '/')
|
| 23 |
+
hide_cursor = True
|
| 24 |
+
|
| 25 |
+
def update(self):
|
| 26 |
+
i = self.index % len(self.phases)
|
| 27 |
+
message = self.message % self
|
| 28 |
+
line = ''.join([message, self.phases[i]])
|
| 29 |
+
self.writeln(line)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class PieSpinner(Spinner):
|
| 33 |
+
phases = ['◷', '◶', '◵', '◴']
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class MoonSpinner(Spinner):
|
| 37 |
+
phases = ['◑', '◒', '◐', '◓']
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class LineSpinner(Spinner):
|
| 41 |
+
phases = ['⎺', '⎻', '⎼', '⎽', '⎼', '⎻']
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class PixelSpinner(Spinner):
|
| 45 |
+
phases = ['⣾', '⣷', '⣯', '⣟', '⡿', '⢿', '⣻', '⣽']
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__main__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.__main__
|
| 3 |
+
~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Main entry point for ``python -m pygments``.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import sys
|
| 12 |
+
from pip._vendor.pygments.cmdline import main
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
sys.exit(main(sys.argv))
|
| 16 |
+
except KeyboardInterrupt:
|
| 17 |
+
sys.exit(1)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (3.04 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/__main__.cpython-310.pyc
ADDED
|
Binary file (639 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/console.cpython-310.pyc
ADDED
|
Binary file (1.93 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/filter.cpython-310.pyc
ADDED
|
Binary file (2.71 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/formatter.cpython-310.pyc
ADDED
|
Binary file (3.06 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/lexer.cpython-310.pyc
ADDED
|
Binary file (24.4 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/modeline.cpython-310.pyc
ADDED
|
Binary file (1.24 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/plugin.cpython-310.pyc
ADDED
|
Binary file (2.1 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/regexopt.cpython-310.pyc
ADDED
|
Binary file (3.01 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/scanner.cpython-310.pyc
ADDED
|
Binary file (3.61 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/token.cpython-310.pyc
ADDED
|
Binary file (4.7 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/__pycache__/util.cpython-310.pyc
ADDED
|
Binary file (9.21 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/cmdline.py
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.cmdline
|
| 3 |
+
~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Command line interface.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import os
|
| 12 |
+
import sys
|
| 13 |
+
import shutil
|
| 14 |
+
import argparse
|
| 15 |
+
from textwrap import dedent
|
| 16 |
+
|
| 17 |
+
from pip._vendor.pygments import __version__, highlight
|
| 18 |
+
from pip._vendor.pygments.util import ClassNotFound, OptionError, docstring_headline, \
|
| 19 |
+
guess_decode, guess_decode_from_terminal, terminal_encoding, \
|
| 20 |
+
UnclosingTextIOWrapper
|
| 21 |
+
from pip._vendor.pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
|
| 22 |
+
load_lexer_from_file, get_lexer_for_filename, find_lexer_class_for_filename
|
| 23 |
+
from pip._vendor.pygments.lexers.special import TextLexer
|
| 24 |
+
from pip._vendor.pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
|
| 25 |
+
from pip._vendor.pygments.formatters import get_all_formatters, get_formatter_by_name, \
|
| 26 |
+
load_formatter_from_file, get_formatter_for_filename, find_formatter_class
|
| 27 |
+
from pip._vendor.pygments.formatters.terminal import TerminalFormatter
|
| 28 |
+
from pip._vendor.pygments.formatters.terminal256 import Terminal256Formatter
|
| 29 |
+
from pip._vendor.pygments.filters import get_all_filters, find_filter_class
|
| 30 |
+
from pip._vendor.pygments.styles import get_all_styles, get_style_by_name
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _parse_options(o_strs):
|
| 34 |
+
opts = {}
|
| 35 |
+
if not o_strs:
|
| 36 |
+
return opts
|
| 37 |
+
for o_str in o_strs:
|
| 38 |
+
if not o_str.strip():
|
| 39 |
+
continue
|
| 40 |
+
o_args = o_str.split(',')
|
| 41 |
+
for o_arg in o_args:
|
| 42 |
+
o_arg = o_arg.strip()
|
| 43 |
+
try:
|
| 44 |
+
o_key, o_val = o_arg.split('=', 1)
|
| 45 |
+
o_key = o_key.strip()
|
| 46 |
+
o_val = o_val.strip()
|
| 47 |
+
except ValueError:
|
| 48 |
+
opts[o_arg] = True
|
| 49 |
+
else:
|
| 50 |
+
opts[o_key] = o_val
|
| 51 |
+
return opts
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _parse_filters(f_strs):
|
| 55 |
+
filters = []
|
| 56 |
+
if not f_strs:
|
| 57 |
+
return filters
|
| 58 |
+
for f_str in f_strs:
|
| 59 |
+
if ':' in f_str:
|
| 60 |
+
fname, fopts = f_str.split(':', 1)
|
| 61 |
+
filters.append((fname, _parse_options([fopts])))
|
| 62 |
+
else:
|
| 63 |
+
filters.append((f_str, {}))
|
| 64 |
+
return filters
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def _print_help(what, name):
|
| 68 |
+
try:
|
| 69 |
+
if what == 'lexer':
|
| 70 |
+
cls = get_lexer_by_name(name)
|
| 71 |
+
print("Help on the %s lexer:" % cls.name)
|
| 72 |
+
print(dedent(cls.__doc__))
|
| 73 |
+
elif what == 'formatter':
|
| 74 |
+
cls = find_formatter_class(name)
|
| 75 |
+
print("Help on the %s formatter:" % cls.name)
|
| 76 |
+
print(dedent(cls.__doc__))
|
| 77 |
+
elif what == 'filter':
|
| 78 |
+
cls = find_filter_class(name)
|
| 79 |
+
print("Help on the %s filter:" % name)
|
| 80 |
+
print(dedent(cls.__doc__))
|
| 81 |
+
return 0
|
| 82 |
+
except (AttributeError, ValueError):
|
| 83 |
+
print("%s not found!" % what, file=sys.stderr)
|
| 84 |
+
return 1
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _print_list(what):
|
| 88 |
+
if what == 'lexer':
|
| 89 |
+
print()
|
| 90 |
+
print("Lexers:")
|
| 91 |
+
print("~~~~~~~")
|
| 92 |
+
|
| 93 |
+
info = []
|
| 94 |
+
for fullname, names, exts, _ in get_all_lexers():
|
| 95 |
+
tup = (', '.join(names)+':', fullname,
|
| 96 |
+
exts and '(filenames ' + ', '.join(exts) + ')' or '')
|
| 97 |
+
info.append(tup)
|
| 98 |
+
info.sort()
|
| 99 |
+
for i in info:
|
| 100 |
+
print(('* %s\n %s %s') % i)
|
| 101 |
+
|
| 102 |
+
elif what == 'formatter':
|
| 103 |
+
print()
|
| 104 |
+
print("Formatters:")
|
| 105 |
+
print("~~~~~~~~~~~")
|
| 106 |
+
|
| 107 |
+
info = []
|
| 108 |
+
for cls in get_all_formatters():
|
| 109 |
+
doc = docstring_headline(cls)
|
| 110 |
+
tup = (', '.join(cls.aliases) + ':', doc, cls.filenames and
|
| 111 |
+
'(filenames ' + ', '.join(cls.filenames) + ')' or '')
|
| 112 |
+
info.append(tup)
|
| 113 |
+
info.sort()
|
| 114 |
+
for i in info:
|
| 115 |
+
print(('* %s\n %s %s') % i)
|
| 116 |
+
|
| 117 |
+
elif what == 'filter':
|
| 118 |
+
print()
|
| 119 |
+
print("Filters:")
|
| 120 |
+
print("~~~~~~~~")
|
| 121 |
+
|
| 122 |
+
for name in get_all_filters():
|
| 123 |
+
cls = find_filter_class(name)
|
| 124 |
+
print("* " + name + ':')
|
| 125 |
+
print(" %s" % docstring_headline(cls))
|
| 126 |
+
|
| 127 |
+
elif what == 'style':
|
| 128 |
+
print()
|
| 129 |
+
print("Styles:")
|
| 130 |
+
print("~~~~~~~")
|
| 131 |
+
|
| 132 |
+
for name in get_all_styles():
|
| 133 |
+
cls = get_style_by_name(name)
|
| 134 |
+
print("* " + name + ':')
|
| 135 |
+
print(" %s" % docstring_headline(cls))
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def _print_list_as_json(requested_items):
|
| 139 |
+
import json
|
| 140 |
+
result = {}
|
| 141 |
+
if 'lexer' in requested_items:
|
| 142 |
+
info = {}
|
| 143 |
+
for fullname, names, filenames, mimetypes in get_all_lexers():
|
| 144 |
+
info[fullname] = {
|
| 145 |
+
'aliases': names,
|
| 146 |
+
'filenames': filenames,
|
| 147 |
+
'mimetypes': mimetypes
|
| 148 |
+
}
|
| 149 |
+
result['lexers'] = info
|
| 150 |
+
|
| 151 |
+
if 'formatter' in requested_items:
|
| 152 |
+
info = {}
|
| 153 |
+
for cls in get_all_formatters():
|
| 154 |
+
doc = docstring_headline(cls)
|
| 155 |
+
info[cls.name] = {
|
| 156 |
+
'aliases': cls.aliases,
|
| 157 |
+
'filenames': cls.filenames,
|
| 158 |
+
'doc': doc
|
| 159 |
+
}
|
| 160 |
+
result['formatters'] = info
|
| 161 |
+
|
| 162 |
+
if 'filter' in requested_items:
|
| 163 |
+
info = {}
|
| 164 |
+
for name in get_all_filters():
|
| 165 |
+
cls = find_filter_class(name)
|
| 166 |
+
info[name] = {
|
| 167 |
+
'doc': docstring_headline(cls)
|
| 168 |
+
}
|
| 169 |
+
result['filters'] = info
|
| 170 |
+
|
| 171 |
+
if 'style' in requested_items:
|
| 172 |
+
info = {}
|
| 173 |
+
for name in get_all_styles():
|
| 174 |
+
cls = get_style_by_name(name)
|
| 175 |
+
info[name] = {
|
| 176 |
+
'doc': docstring_headline(cls)
|
| 177 |
+
}
|
| 178 |
+
result['styles'] = info
|
| 179 |
+
|
| 180 |
+
json.dump(result, sys.stdout)
|
| 181 |
+
|
| 182 |
+
def main_inner(parser, argns):
|
| 183 |
+
if argns.help:
|
| 184 |
+
parser.print_help()
|
| 185 |
+
return 0
|
| 186 |
+
|
| 187 |
+
if argns.V:
|
| 188 |
+
print('Pygments version %s, (c) 2006-2021 by Georg Brandl, Matthäus '
|
| 189 |
+
'Chajdas and contributors.' % __version__)
|
| 190 |
+
return 0
|
| 191 |
+
|
| 192 |
+
def is_only_option(opt):
|
| 193 |
+
return not any(v for (k, v) in vars(argns).items() if k != opt)
|
| 194 |
+
|
| 195 |
+
# handle ``pygmentize -L``
|
| 196 |
+
if argns.L is not None:
|
| 197 |
+
arg_set = set()
|
| 198 |
+
for k, v in vars(argns).items():
|
| 199 |
+
if v:
|
| 200 |
+
arg_set.add(k)
|
| 201 |
+
|
| 202 |
+
arg_set.discard('L')
|
| 203 |
+
arg_set.discard('json')
|
| 204 |
+
|
| 205 |
+
if arg_set:
|
| 206 |
+
parser.print_help(sys.stderr)
|
| 207 |
+
return 2
|
| 208 |
+
|
| 209 |
+
# print version
|
| 210 |
+
if not argns.json:
|
| 211 |
+
main(['', '-V'])
|
| 212 |
+
allowed_types = {'lexer', 'formatter', 'filter', 'style'}
|
| 213 |
+
largs = [arg.rstrip('s') for arg in argns.L]
|
| 214 |
+
if any(arg not in allowed_types for arg in largs):
|
| 215 |
+
parser.print_help(sys.stderr)
|
| 216 |
+
return 0
|
| 217 |
+
if not largs:
|
| 218 |
+
largs = allowed_types
|
| 219 |
+
if not argns.json:
|
| 220 |
+
for arg in largs:
|
| 221 |
+
_print_list(arg)
|
| 222 |
+
else:
|
| 223 |
+
_print_list_as_json(largs)
|
| 224 |
+
return 0
|
| 225 |
+
|
| 226 |
+
# handle ``pygmentize -H``
|
| 227 |
+
if argns.H:
|
| 228 |
+
if not is_only_option('H'):
|
| 229 |
+
parser.print_help(sys.stderr)
|
| 230 |
+
return 2
|
| 231 |
+
what, name = argns.H
|
| 232 |
+
if what not in ('lexer', 'formatter', 'filter'):
|
| 233 |
+
parser.print_help(sys.stderr)
|
| 234 |
+
return 2
|
| 235 |
+
return _print_help(what, name)
|
| 236 |
+
|
| 237 |
+
# parse -O options
|
| 238 |
+
parsed_opts = _parse_options(argns.O or [])
|
| 239 |
+
|
| 240 |
+
# parse -P options
|
| 241 |
+
for p_opt in argns.P or []:
|
| 242 |
+
try:
|
| 243 |
+
name, value = p_opt.split('=', 1)
|
| 244 |
+
except ValueError:
|
| 245 |
+
parsed_opts[p_opt] = True
|
| 246 |
+
else:
|
| 247 |
+
parsed_opts[name] = value
|
| 248 |
+
|
| 249 |
+
# encodings
|
| 250 |
+
inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
|
| 251 |
+
outencoding = parsed_opts.get('outencoding', parsed_opts.get('encoding'))
|
| 252 |
+
|
| 253 |
+
# handle ``pygmentize -N``
|
| 254 |
+
if argns.N:
|
| 255 |
+
lexer = find_lexer_class_for_filename(argns.N)
|
| 256 |
+
if lexer is None:
|
| 257 |
+
lexer = TextLexer
|
| 258 |
+
|
| 259 |
+
print(lexer.aliases[0])
|
| 260 |
+
return 0
|
| 261 |
+
|
| 262 |
+
# handle ``pygmentize -C``
|
| 263 |
+
if argns.C:
|
| 264 |
+
inp = sys.stdin.buffer.read()
|
| 265 |
+
try:
|
| 266 |
+
lexer = guess_lexer(inp, inencoding=inencoding)
|
| 267 |
+
except ClassNotFound:
|
| 268 |
+
lexer = TextLexer
|
| 269 |
+
|
| 270 |
+
print(lexer.aliases[0])
|
| 271 |
+
return 0
|
| 272 |
+
|
| 273 |
+
# handle ``pygmentize -S``
|
| 274 |
+
S_opt = argns.S
|
| 275 |
+
a_opt = argns.a
|
| 276 |
+
if S_opt is not None:
|
| 277 |
+
f_opt = argns.f
|
| 278 |
+
if not f_opt:
|
| 279 |
+
parser.print_help(sys.stderr)
|
| 280 |
+
return 2
|
| 281 |
+
if argns.l or argns.INPUTFILE:
|
| 282 |
+
parser.print_help(sys.stderr)
|
| 283 |
+
return 2
|
| 284 |
+
|
| 285 |
+
try:
|
| 286 |
+
parsed_opts['style'] = S_opt
|
| 287 |
+
fmter = get_formatter_by_name(f_opt, **parsed_opts)
|
| 288 |
+
except ClassNotFound as err:
|
| 289 |
+
print(err, file=sys.stderr)
|
| 290 |
+
return 1
|
| 291 |
+
|
| 292 |
+
print(fmter.get_style_defs(a_opt or ''))
|
| 293 |
+
return 0
|
| 294 |
+
|
| 295 |
+
# if no -S is given, -a is not allowed
|
| 296 |
+
if argns.a is not None:
|
| 297 |
+
parser.print_help(sys.stderr)
|
| 298 |
+
return 2
|
| 299 |
+
|
| 300 |
+
# parse -F options
|
| 301 |
+
F_opts = _parse_filters(argns.F or [])
|
| 302 |
+
|
| 303 |
+
# -x: allow custom (eXternal) lexers and formatters
|
| 304 |
+
allow_custom_lexer_formatter = bool(argns.x)
|
| 305 |
+
|
| 306 |
+
# select lexer
|
| 307 |
+
lexer = None
|
| 308 |
+
|
| 309 |
+
# given by name?
|
| 310 |
+
lexername = argns.l
|
| 311 |
+
if lexername:
|
| 312 |
+
# custom lexer, located relative to user's cwd
|
| 313 |
+
if allow_custom_lexer_formatter and '.py' in lexername:
|
| 314 |
+
try:
|
| 315 |
+
filename = None
|
| 316 |
+
name = None
|
| 317 |
+
if ':' in lexername:
|
| 318 |
+
filename, name = lexername.rsplit(':', 1)
|
| 319 |
+
|
| 320 |
+
if '.py' in name:
|
| 321 |
+
# This can happen on Windows: If the lexername is
|
| 322 |
+
# C:\lexer.py -- return to normal load path in that case
|
| 323 |
+
name = None
|
| 324 |
+
|
| 325 |
+
if filename and name:
|
| 326 |
+
lexer = load_lexer_from_file(filename, name,
|
| 327 |
+
**parsed_opts)
|
| 328 |
+
else:
|
| 329 |
+
lexer = load_lexer_from_file(lexername, **parsed_opts)
|
| 330 |
+
except ClassNotFound as err:
|
| 331 |
+
print('Error:', err, file=sys.stderr)
|
| 332 |
+
return 1
|
| 333 |
+
else:
|
| 334 |
+
try:
|
| 335 |
+
lexer = get_lexer_by_name(lexername, **parsed_opts)
|
| 336 |
+
except (OptionError, ClassNotFound) as err:
|
| 337 |
+
print('Error:', err, file=sys.stderr)
|
| 338 |
+
return 1
|
| 339 |
+
|
| 340 |
+
# read input code
|
| 341 |
+
code = None
|
| 342 |
+
|
| 343 |
+
if argns.INPUTFILE:
|
| 344 |
+
if argns.s:
|
| 345 |
+
print('Error: -s option not usable when input file specified',
|
| 346 |
+
file=sys.stderr)
|
| 347 |
+
return 2
|
| 348 |
+
|
| 349 |
+
infn = argns.INPUTFILE
|
| 350 |
+
try:
|
| 351 |
+
with open(infn, 'rb') as infp:
|
| 352 |
+
code = infp.read()
|
| 353 |
+
except Exception as err:
|
| 354 |
+
print('Error: cannot read infile:', err, file=sys.stderr)
|
| 355 |
+
return 1
|
| 356 |
+
if not inencoding:
|
| 357 |
+
code, inencoding = guess_decode(code)
|
| 358 |
+
|
| 359 |
+
# do we have to guess the lexer?
|
| 360 |
+
if not lexer:
|
| 361 |
+
try:
|
| 362 |
+
lexer = get_lexer_for_filename(infn, code, **parsed_opts)
|
| 363 |
+
except ClassNotFound as err:
|
| 364 |
+
if argns.g:
|
| 365 |
+
try:
|
| 366 |
+
lexer = guess_lexer(code, **parsed_opts)
|
| 367 |
+
except ClassNotFound:
|
| 368 |
+
lexer = TextLexer(**parsed_opts)
|
| 369 |
+
else:
|
| 370 |
+
print('Error:', err, file=sys.stderr)
|
| 371 |
+
return 1
|
| 372 |
+
except OptionError as err:
|
| 373 |
+
print('Error:', err, file=sys.stderr)
|
| 374 |
+
return 1
|
| 375 |
+
|
| 376 |
+
elif not argns.s: # treat stdin as full file (-s support is later)
|
| 377 |
+
# read code from terminal, always in binary mode since we want to
|
| 378 |
+
# decode ourselves and be tolerant with it
|
| 379 |
+
code = sys.stdin.buffer.read() # use .buffer to get a binary stream
|
| 380 |
+
if not inencoding:
|
| 381 |
+
code, inencoding = guess_decode_from_terminal(code, sys.stdin)
|
| 382 |
+
# else the lexer will do the decoding
|
| 383 |
+
if not lexer:
|
| 384 |
+
try:
|
| 385 |
+
lexer = guess_lexer(code, **parsed_opts)
|
| 386 |
+
except ClassNotFound:
|
| 387 |
+
lexer = TextLexer(**parsed_opts)
|
| 388 |
+
|
| 389 |
+
else: # -s option needs a lexer with -l
|
| 390 |
+
if not lexer:
|
| 391 |
+
print('Error: when using -s a lexer has to be selected with -l',
|
| 392 |
+
file=sys.stderr)
|
| 393 |
+
return 2
|
| 394 |
+
|
| 395 |
+
# process filters
|
| 396 |
+
for fname, fopts in F_opts:
|
| 397 |
+
try:
|
| 398 |
+
lexer.add_filter(fname, **fopts)
|
| 399 |
+
except ClassNotFound as err:
|
| 400 |
+
print('Error:', err, file=sys.stderr)
|
| 401 |
+
return 1
|
| 402 |
+
|
| 403 |
+
# select formatter
|
| 404 |
+
outfn = argns.o
|
| 405 |
+
fmter = argns.f
|
| 406 |
+
if fmter:
|
| 407 |
+
# custom formatter, located relative to user's cwd
|
| 408 |
+
if allow_custom_lexer_formatter and '.py' in fmter:
|
| 409 |
+
try:
|
| 410 |
+
filename = None
|
| 411 |
+
name = None
|
| 412 |
+
if ':' in fmter:
|
| 413 |
+
# Same logic as above for custom lexer
|
| 414 |
+
filename, name = fmter.rsplit(':', 1)
|
| 415 |
+
|
| 416 |
+
if '.py' in name:
|
| 417 |
+
name = None
|
| 418 |
+
|
| 419 |
+
if filename and name:
|
| 420 |
+
fmter = load_formatter_from_file(filename, name,
|
| 421 |
+
**parsed_opts)
|
| 422 |
+
else:
|
| 423 |
+
fmter = load_formatter_from_file(fmter, **parsed_opts)
|
| 424 |
+
except ClassNotFound as err:
|
| 425 |
+
print('Error:', err, file=sys.stderr)
|
| 426 |
+
return 1
|
| 427 |
+
else:
|
| 428 |
+
try:
|
| 429 |
+
fmter = get_formatter_by_name(fmter, **parsed_opts)
|
| 430 |
+
except (OptionError, ClassNotFound) as err:
|
| 431 |
+
print('Error:', err, file=sys.stderr)
|
| 432 |
+
return 1
|
| 433 |
+
|
| 434 |
+
if outfn:
|
| 435 |
+
if not fmter:
|
| 436 |
+
try:
|
| 437 |
+
fmter = get_formatter_for_filename(outfn, **parsed_opts)
|
| 438 |
+
except (OptionError, ClassNotFound) as err:
|
| 439 |
+
print('Error:', err, file=sys.stderr)
|
| 440 |
+
return 1
|
| 441 |
+
try:
|
| 442 |
+
outfile = open(outfn, 'wb')
|
| 443 |
+
except Exception as err:
|
| 444 |
+
print('Error: cannot open outfile:', err, file=sys.stderr)
|
| 445 |
+
return 1
|
| 446 |
+
else:
|
| 447 |
+
if not fmter:
|
| 448 |
+
if '256' in os.environ.get('TERM', ''):
|
| 449 |
+
fmter = Terminal256Formatter(**parsed_opts)
|
| 450 |
+
else:
|
| 451 |
+
fmter = TerminalFormatter(**parsed_opts)
|
| 452 |
+
outfile = sys.stdout.buffer
|
| 453 |
+
|
| 454 |
+
# determine output encoding if not explicitly selected
|
| 455 |
+
if not outencoding:
|
| 456 |
+
if outfn:
|
| 457 |
+
# output file? use lexer encoding for now (can still be None)
|
| 458 |
+
fmter.encoding = inencoding
|
| 459 |
+
else:
|
| 460 |
+
# else use terminal encoding
|
| 461 |
+
fmter.encoding = terminal_encoding(sys.stdout)
|
| 462 |
+
|
| 463 |
+
# provide coloring under Windows, if possible
|
| 464 |
+
if not outfn and sys.platform in ('win32', 'cygwin') and \
|
| 465 |
+
fmter.name in ('Terminal', 'Terminal256'): # pragma: no cover
|
| 466 |
+
# unfortunately colorama doesn't support binary streams on Py3
|
| 467 |
+
outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
|
| 468 |
+
fmter.encoding = None
|
| 469 |
+
try:
|
| 470 |
+
import pip._vendor.colorama.initialise as colorama_initialise
|
| 471 |
+
except ImportError:
|
| 472 |
+
pass
|
| 473 |
+
else:
|
| 474 |
+
outfile = colorama_initialise.wrap_stream(
|
| 475 |
+
outfile, convert=None, strip=None, autoreset=False, wrap=True)
|
| 476 |
+
|
| 477 |
+
# When using the LaTeX formatter and the option `escapeinside` is
|
| 478 |
+
# specified, we need a special lexer which collects escaped text
|
| 479 |
+
# before running the chosen language lexer.
|
| 480 |
+
escapeinside = parsed_opts.get('escapeinside', '')
|
| 481 |
+
if len(escapeinside) == 2 and isinstance(fmter, LatexFormatter):
|
| 482 |
+
left = escapeinside[0]
|
| 483 |
+
right = escapeinside[1]
|
| 484 |
+
lexer = LatexEmbeddedLexer(left, right, lexer)
|
| 485 |
+
|
| 486 |
+
# ... and do it!
|
| 487 |
+
if not argns.s:
|
| 488 |
+
# process whole input as per normal...
|
| 489 |
+
try:
|
| 490 |
+
highlight(code, lexer, fmter, outfile)
|
| 491 |
+
finally:
|
| 492 |
+
if outfn:
|
| 493 |
+
outfile.close()
|
| 494 |
+
return 0
|
| 495 |
+
else:
|
| 496 |
+
# line by line processing of stdin (eg: for 'tail -f')...
|
| 497 |
+
try:
|
| 498 |
+
while 1:
|
| 499 |
+
line = sys.stdin.buffer.readline()
|
| 500 |
+
if not line:
|
| 501 |
+
break
|
| 502 |
+
if not inencoding:
|
| 503 |
+
line = guess_decode_from_terminal(line, sys.stdin)[0]
|
| 504 |
+
highlight(line, lexer, fmter, outfile)
|
| 505 |
+
if hasattr(outfile, 'flush'):
|
| 506 |
+
outfile.flush()
|
| 507 |
+
return 0
|
| 508 |
+
except KeyboardInterrupt: # pragma: no cover
|
| 509 |
+
return 0
|
| 510 |
+
finally:
|
| 511 |
+
if outfn:
|
| 512 |
+
outfile.close()
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
class HelpFormatter(argparse.HelpFormatter):
|
| 516 |
+
def __init__(self, prog, indent_increment=2, max_help_position=16, width=None):
|
| 517 |
+
if width is None:
|
| 518 |
+
try:
|
| 519 |
+
width = shutil.get_terminal_size().columns - 2
|
| 520 |
+
except Exception:
|
| 521 |
+
pass
|
| 522 |
+
argparse.HelpFormatter.__init__(self, prog, indent_increment,
|
| 523 |
+
max_help_position, width)
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
def main(args=sys.argv):
|
| 527 |
+
"""
|
| 528 |
+
Main command line entry point.
|
| 529 |
+
"""
|
| 530 |
+
desc = "Highlight an input file and write the result to an output file."
|
| 531 |
+
parser = argparse.ArgumentParser(description=desc, add_help=False,
|
| 532 |
+
formatter_class=HelpFormatter)
|
| 533 |
+
|
| 534 |
+
operation = parser.add_argument_group('Main operation')
|
| 535 |
+
lexersel = operation.add_mutually_exclusive_group()
|
| 536 |
+
lexersel.add_argument(
|
| 537 |
+
'-l', metavar='LEXER',
|
| 538 |
+
help='Specify the lexer to use. (Query names with -L.) If not '
|
| 539 |
+
'given and -g is not present, the lexer is guessed from the filename.')
|
| 540 |
+
lexersel.add_argument(
|
| 541 |
+
'-g', action='store_true',
|
| 542 |
+
help='Guess the lexer from the file contents, or pass through '
|
| 543 |
+
'as plain text if nothing can be guessed.')
|
| 544 |
+
operation.add_argument(
|
| 545 |
+
'-F', metavar='FILTER[:options]', action='append',
|
| 546 |
+
help='Add a filter to the token stream. (Query names with -L.) '
|
| 547 |
+
'Filter options are given after a colon if necessary.')
|
| 548 |
+
operation.add_argument(
|
| 549 |
+
'-f', metavar='FORMATTER',
|
| 550 |
+
help='Specify the formatter to use. (Query names with -L.) '
|
| 551 |
+
'If not given, the formatter is guessed from the output filename, '
|
| 552 |
+
'and defaults to the terminal formatter if the output is to the '
|
| 553 |
+
'terminal or an unknown file extension.')
|
| 554 |
+
operation.add_argument(
|
| 555 |
+
'-O', metavar='OPTION=value[,OPTION=value,...]', action='append',
|
| 556 |
+
help='Give options to the lexer and formatter as a comma-separated '
|
| 557 |
+
'list of key-value pairs. '
|
| 558 |
+
'Example: `-O bg=light,python=cool`.')
|
| 559 |
+
operation.add_argument(
|
| 560 |
+
'-P', metavar='OPTION=value', action='append',
|
| 561 |
+
help='Give a single option to the lexer and formatter - with this '
|
| 562 |
+
'you can pass options whose value contains commas and equal signs. '
|
| 563 |
+
'Example: `-P "heading=Pygments, the Python highlighter"`.')
|
| 564 |
+
operation.add_argument(
|
| 565 |
+
'-o', metavar='OUTPUTFILE',
|
| 566 |
+
help='Where to write the output. Defaults to standard output.')
|
| 567 |
+
|
| 568 |
+
operation.add_argument(
|
| 569 |
+
'INPUTFILE', nargs='?',
|
| 570 |
+
help='Where to read the input. Defaults to standard input.')
|
| 571 |
+
|
| 572 |
+
flags = parser.add_argument_group('Operation flags')
|
| 573 |
+
flags.add_argument(
|
| 574 |
+
'-v', action='store_true',
|
| 575 |
+
help='Print a detailed traceback on unhandled exceptions, which '
|
| 576 |
+
'is useful for debugging and bug reports.')
|
| 577 |
+
flags.add_argument(
|
| 578 |
+
'-s', action='store_true',
|
| 579 |
+
help='Process lines one at a time until EOF, rather than waiting to '
|
| 580 |
+
'process the entire file. This only works for stdin, only for lexers '
|
| 581 |
+
'with no line-spanning constructs, and is intended for streaming '
|
| 582 |
+
'input such as you get from `tail -f`. '
|
| 583 |
+
'Example usage: `tail -f sql.log | pygmentize -s -l sql`.')
|
| 584 |
+
flags.add_argument(
|
| 585 |
+
'-x', action='store_true',
|
| 586 |
+
help='Allow custom lexers and formatters to be loaded from a .py file '
|
| 587 |
+
'relative to the current working directory. For example, '
|
| 588 |
+
'`-l ./customlexer.py -x`. By default, this option expects a file '
|
| 589 |
+
'with a class named CustomLexer or CustomFormatter; you can also '
|
| 590 |
+
'specify your own class name with a colon (`-l ./lexer.py:MyLexer`). '
|
| 591 |
+
'Users should be very careful not to use this option with untrusted '
|
| 592 |
+
'files, because it will import and run them.')
|
| 593 |
+
flags.add_argument('--json', help='Output as JSON. This can '
|
| 594 |
+
'be only used in conjunction with -L.',
|
| 595 |
+
default=False,
|
| 596 |
+
action='store_true')
|
| 597 |
+
|
| 598 |
+
special_modes_group = parser.add_argument_group(
|
| 599 |
+
'Special modes - do not do any highlighting')
|
| 600 |
+
special_modes = special_modes_group.add_mutually_exclusive_group()
|
| 601 |
+
special_modes.add_argument(
|
| 602 |
+
'-S', metavar='STYLE -f formatter',
|
| 603 |
+
help='Print style definitions for STYLE for a formatter '
|
| 604 |
+
'given with -f. The argument given by -a is formatter '
|
| 605 |
+
'dependent.')
|
| 606 |
+
special_modes.add_argument(
|
| 607 |
+
'-L', nargs='*', metavar='WHAT',
|
| 608 |
+
help='List lexers, formatters, styles or filters -- '
|
| 609 |
+
'give additional arguments for the thing(s) you want to list '
|
| 610 |
+
'(e.g. "styles"), or omit them to list everything.')
|
| 611 |
+
special_modes.add_argument(
|
| 612 |
+
'-N', metavar='FILENAME',
|
| 613 |
+
help='Guess and print out a lexer name based solely on the given '
|
| 614 |
+
'filename. Does not take input or highlight anything. If no specific '
|
| 615 |
+
'lexer can be determined, "text" is printed.')
|
| 616 |
+
special_modes.add_argument(
|
| 617 |
+
'-C', action='store_true',
|
| 618 |
+
help='Like -N, but print out a lexer name based solely on '
|
| 619 |
+
'a given content from standard input.')
|
| 620 |
+
special_modes.add_argument(
|
| 621 |
+
'-H', action='store', nargs=2, metavar=('NAME', 'TYPE'),
|
| 622 |
+
help='Print detailed help for the object <name> of type <type>, '
|
| 623 |
+
'where <type> is one of "lexer", "formatter" or "filter".')
|
| 624 |
+
special_modes.add_argument(
|
| 625 |
+
'-V', action='store_true',
|
| 626 |
+
help='Print the package version.')
|
| 627 |
+
special_modes.add_argument(
|
| 628 |
+
'-h', '--help', action='store_true',
|
| 629 |
+
help='Print this help.')
|
| 630 |
+
special_modes_group.add_argument(
|
| 631 |
+
'-a', metavar='ARG',
|
| 632 |
+
help='Formatter-specific additional argument for the -S (print '
|
| 633 |
+
'style sheet) mode.')
|
| 634 |
+
|
| 635 |
+
argns = parser.parse_args(args[1:])
|
| 636 |
+
|
| 637 |
+
try:
|
| 638 |
+
return main_inner(parser, argns)
|
| 639 |
+
except Exception:
|
| 640 |
+
if argns.v:
|
| 641 |
+
print(file=sys.stderr)
|
| 642 |
+
print('*' * 65, file=sys.stderr)
|
| 643 |
+
print('An unhandled exception occurred while highlighting.',
|
| 644 |
+
file=sys.stderr)
|
| 645 |
+
print('Please report the whole traceback to the issue tracker at',
|
| 646 |
+
file=sys.stderr)
|
| 647 |
+
print('<https://github.com/pygments/pygments/issues>.',
|
| 648 |
+
file=sys.stderr)
|
| 649 |
+
print('*' * 65, file=sys.stderr)
|
| 650 |
+
print(file=sys.stderr)
|
| 651 |
+
raise
|
| 652 |
+
import traceback
|
| 653 |
+
info = traceback.format_exception(*sys.exc_info())
|
| 654 |
+
msg = info[-1].strip()
|
| 655 |
+
if len(info) >= 3:
|
| 656 |
+
# extract relevant file and position info
|
| 657 |
+
msg += '\n (f%s)' % info[-2].split('\n')[0].strip()[1:]
|
| 658 |
+
print(file=sys.stderr)
|
| 659 |
+
print('*** Error while highlighting:', file=sys.stderr)
|
| 660 |
+
print(msg, file=sys.stderr)
|
| 661 |
+
print('*** If this is a bug you want to report, please rerun with -v.',
|
| 662 |
+
file=sys.stderr)
|
| 663 |
+
return 1
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/filters/__init__.py
ADDED
|
@@ -0,0 +1,937 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.filters
|
| 3 |
+
~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Module containing filter lookup functions and default
|
| 6 |
+
filters.
|
| 7 |
+
|
| 8 |
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
| 9 |
+
:license: BSD, see LICENSE for details.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import re
|
| 13 |
+
|
| 14 |
+
from pip._vendor.pygments.token import String, Comment, Keyword, Name, Error, Whitespace, \
|
| 15 |
+
string_to_tokentype
|
| 16 |
+
from pip._vendor.pygments.filter import Filter
|
| 17 |
+
from pip._vendor.pygments.util import get_list_opt, get_int_opt, get_bool_opt, \
|
| 18 |
+
get_choice_opt, ClassNotFound, OptionError
|
| 19 |
+
from pip._vendor.pygments.plugin import find_plugin_filters
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def find_filter_class(filtername):
|
| 23 |
+
"""Lookup a filter by name. Return None if not found."""
|
| 24 |
+
if filtername in FILTERS:
|
| 25 |
+
return FILTERS[filtername]
|
| 26 |
+
for name, cls in find_plugin_filters():
|
| 27 |
+
if name == filtername:
|
| 28 |
+
return cls
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def get_filter_by_name(filtername, **options):
|
| 33 |
+
"""Return an instantiated filter.
|
| 34 |
+
|
| 35 |
+
Options are passed to the filter initializer if wanted.
|
| 36 |
+
Raise a ClassNotFound if not found.
|
| 37 |
+
"""
|
| 38 |
+
cls = find_filter_class(filtername)
|
| 39 |
+
if cls:
|
| 40 |
+
return cls(**options)
|
| 41 |
+
else:
|
| 42 |
+
raise ClassNotFound('filter %r not found' % filtername)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def get_all_filters():
|
| 46 |
+
"""Return a generator of all filter names."""
|
| 47 |
+
yield from FILTERS
|
| 48 |
+
for name, _ in find_plugin_filters():
|
| 49 |
+
yield name
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _replace_special(ttype, value, regex, specialttype,
|
| 53 |
+
replacefunc=lambda x: x):
|
| 54 |
+
last = 0
|
| 55 |
+
for match in regex.finditer(value):
|
| 56 |
+
start, end = match.start(), match.end()
|
| 57 |
+
if start != last:
|
| 58 |
+
yield ttype, value[last:start]
|
| 59 |
+
yield specialttype, replacefunc(value[start:end])
|
| 60 |
+
last = end
|
| 61 |
+
if last != len(value):
|
| 62 |
+
yield ttype, value[last:]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class CodeTagFilter(Filter):
|
| 66 |
+
"""Highlight special code tags in comments and docstrings.
|
| 67 |
+
|
| 68 |
+
Options accepted:
|
| 69 |
+
|
| 70 |
+
`codetags` : list of strings
|
| 71 |
+
A list of strings that are flagged as code tags. The default is to
|
| 72 |
+
highlight ``XXX``, ``TODO``, ``BUG`` and ``NOTE``.
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
def __init__(self, **options):
|
| 76 |
+
Filter.__init__(self, **options)
|
| 77 |
+
tags = get_list_opt(options, 'codetags',
|
| 78 |
+
['XXX', 'TODO', 'BUG', 'NOTE'])
|
| 79 |
+
self.tag_re = re.compile(r'\b(%s)\b' % '|'.join([
|
| 80 |
+
re.escape(tag) for tag in tags if tag
|
| 81 |
+
]))
|
| 82 |
+
|
| 83 |
+
def filter(self, lexer, stream):
|
| 84 |
+
regex = self.tag_re
|
| 85 |
+
for ttype, value in stream:
|
| 86 |
+
if ttype in String.Doc or \
|
| 87 |
+
ttype in Comment and \
|
| 88 |
+
ttype not in Comment.Preproc:
|
| 89 |
+
yield from _replace_special(ttype, value, regex, Comment.Special)
|
| 90 |
+
else:
|
| 91 |
+
yield ttype, value
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class SymbolFilter(Filter):
|
| 95 |
+
"""Convert mathematical symbols such as \\<longrightarrow> in Isabelle
|
| 96 |
+
or \\longrightarrow in LaTeX into Unicode characters.
|
| 97 |
+
|
| 98 |
+
This is mostly useful for HTML or console output when you want to
|
| 99 |
+
approximate the source rendering you'd see in an IDE.
|
| 100 |
+
|
| 101 |
+
Options accepted:
|
| 102 |
+
|
| 103 |
+
`lang` : string
|
| 104 |
+
The symbol language. Must be one of ``'isabelle'`` or
|
| 105 |
+
``'latex'``. The default is ``'isabelle'``.
|
| 106 |
+
"""
|
| 107 |
+
|
| 108 |
+
latex_symbols = {
|
| 109 |
+
'\\alpha' : '\U000003b1',
|
| 110 |
+
'\\beta' : '\U000003b2',
|
| 111 |
+
'\\gamma' : '\U000003b3',
|
| 112 |
+
'\\delta' : '\U000003b4',
|
| 113 |
+
'\\varepsilon' : '\U000003b5',
|
| 114 |
+
'\\zeta' : '\U000003b6',
|
| 115 |
+
'\\eta' : '\U000003b7',
|
| 116 |
+
'\\vartheta' : '\U000003b8',
|
| 117 |
+
'\\iota' : '\U000003b9',
|
| 118 |
+
'\\kappa' : '\U000003ba',
|
| 119 |
+
'\\lambda' : '\U000003bb',
|
| 120 |
+
'\\mu' : '\U000003bc',
|
| 121 |
+
'\\nu' : '\U000003bd',
|
| 122 |
+
'\\xi' : '\U000003be',
|
| 123 |
+
'\\pi' : '\U000003c0',
|
| 124 |
+
'\\varrho' : '\U000003c1',
|
| 125 |
+
'\\sigma' : '\U000003c3',
|
| 126 |
+
'\\tau' : '\U000003c4',
|
| 127 |
+
'\\upsilon' : '\U000003c5',
|
| 128 |
+
'\\varphi' : '\U000003c6',
|
| 129 |
+
'\\chi' : '\U000003c7',
|
| 130 |
+
'\\psi' : '\U000003c8',
|
| 131 |
+
'\\omega' : '\U000003c9',
|
| 132 |
+
'\\Gamma' : '\U00000393',
|
| 133 |
+
'\\Delta' : '\U00000394',
|
| 134 |
+
'\\Theta' : '\U00000398',
|
| 135 |
+
'\\Lambda' : '\U0000039b',
|
| 136 |
+
'\\Xi' : '\U0000039e',
|
| 137 |
+
'\\Pi' : '\U000003a0',
|
| 138 |
+
'\\Sigma' : '\U000003a3',
|
| 139 |
+
'\\Upsilon' : '\U000003a5',
|
| 140 |
+
'\\Phi' : '\U000003a6',
|
| 141 |
+
'\\Psi' : '\U000003a8',
|
| 142 |
+
'\\Omega' : '\U000003a9',
|
| 143 |
+
'\\leftarrow' : '\U00002190',
|
| 144 |
+
'\\longleftarrow' : '\U000027f5',
|
| 145 |
+
'\\rightarrow' : '\U00002192',
|
| 146 |
+
'\\longrightarrow' : '\U000027f6',
|
| 147 |
+
'\\Leftarrow' : '\U000021d0',
|
| 148 |
+
'\\Longleftarrow' : '\U000027f8',
|
| 149 |
+
'\\Rightarrow' : '\U000021d2',
|
| 150 |
+
'\\Longrightarrow' : '\U000027f9',
|
| 151 |
+
'\\leftrightarrow' : '\U00002194',
|
| 152 |
+
'\\longleftrightarrow' : '\U000027f7',
|
| 153 |
+
'\\Leftrightarrow' : '\U000021d4',
|
| 154 |
+
'\\Longleftrightarrow' : '\U000027fa',
|
| 155 |
+
'\\mapsto' : '\U000021a6',
|
| 156 |
+
'\\longmapsto' : '\U000027fc',
|
| 157 |
+
'\\relbar' : '\U00002500',
|
| 158 |
+
'\\Relbar' : '\U00002550',
|
| 159 |
+
'\\hookleftarrow' : '\U000021a9',
|
| 160 |
+
'\\hookrightarrow' : '\U000021aa',
|
| 161 |
+
'\\leftharpoondown' : '\U000021bd',
|
| 162 |
+
'\\rightharpoondown' : '\U000021c1',
|
| 163 |
+
'\\leftharpoonup' : '\U000021bc',
|
| 164 |
+
'\\rightharpoonup' : '\U000021c0',
|
| 165 |
+
'\\rightleftharpoons' : '\U000021cc',
|
| 166 |
+
'\\leadsto' : '\U0000219d',
|
| 167 |
+
'\\downharpoonleft' : '\U000021c3',
|
| 168 |
+
'\\downharpoonright' : '\U000021c2',
|
| 169 |
+
'\\upharpoonleft' : '\U000021bf',
|
| 170 |
+
'\\upharpoonright' : '\U000021be',
|
| 171 |
+
'\\restriction' : '\U000021be',
|
| 172 |
+
'\\uparrow' : '\U00002191',
|
| 173 |
+
'\\Uparrow' : '\U000021d1',
|
| 174 |
+
'\\downarrow' : '\U00002193',
|
| 175 |
+
'\\Downarrow' : '\U000021d3',
|
| 176 |
+
'\\updownarrow' : '\U00002195',
|
| 177 |
+
'\\Updownarrow' : '\U000021d5',
|
| 178 |
+
'\\langle' : '\U000027e8',
|
| 179 |
+
'\\rangle' : '\U000027e9',
|
| 180 |
+
'\\lceil' : '\U00002308',
|
| 181 |
+
'\\rceil' : '\U00002309',
|
| 182 |
+
'\\lfloor' : '\U0000230a',
|
| 183 |
+
'\\rfloor' : '\U0000230b',
|
| 184 |
+
'\\flqq' : '\U000000ab',
|
| 185 |
+
'\\frqq' : '\U000000bb',
|
| 186 |
+
'\\bot' : '\U000022a5',
|
| 187 |
+
'\\top' : '\U000022a4',
|
| 188 |
+
'\\wedge' : '\U00002227',
|
| 189 |
+
'\\bigwedge' : '\U000022c0',
|
| 190 |
+
'\\vee' : '\U00002228',
|
| 191 |
+
'\\bigvee' : '\U000022c1',
|
| 192 |
+
'\\forall' : '\U00002200',
|
| 193 |
+
'\\exists' : '\U00002203',
|
| 194 |
+
'\\nexists' : '\U00002204',
|
| 195 |
+
'\\neg' : '\U000000ac',
|
| 196 |
+
'\\Box' : '\U000025a1',
|
| 197 |
+
'\\Diamond' : '\U000025c7',
|
| 198 |
+
'\\vdash' : '\U000022a2',
|
| 199 |
+
'\\models' : '\U000022a8',
|
| 200 |
+
'\\dashv' : '\U000022a3',
|
| 201 |
+
'\\surd' : '\U0000221a',
|
| 202 |
+
'\\le' : '\U00002264',
|
| 203 |
+
'\\ge' : '\U00002265',
|
| 204 |
+
'\\ll' : '\U0000226a',
|
| 205 |
+
'\\gg' : '\U0000226b',
|
| 206 |
+
'\\lesssim' : '\U00002272',
|
| 207 |
+
'\\gtrsim' : '\U00002273',
|
| 208 |
+
'\\lessapprox' : '\U00002a85',
|
| 209 |
+
'\\gtrapprox' : '\U00002a86',
|
| 210 |
+
'\\in' : '\U00002208',
|
| 211 |
+
'\\notin' : '\U00002209',
|
| 212 |
+
'\\subset' : '\U00002282',
|
| 213 |
+
'\\supset' : '\U00002283',
|
| 214 |
+
'\\subseteq' : '\U00002286',
|
| 215 |
+
'\\supseteq' : '\U00002287',
|
| 216 |
+
'\\sqsubset' : '\U0000228f',
|
| 217 |
+
'\\sqsupset' : '\U00002290',
|
| 218 |
+
'\\sqsubseteq' : '\U00002291',
|
| 219 |
+
'\\sqsupseteq' : '\U00002292',
|
| 220 |
+
'\\cap' : '\U00002229',
|
| 221 |
+
'\\bigcap' : '\U000022c2',
|
| 222 |
+
'\\cup' : '\U0000222a',
|
| 223 |
+
'\\bigcup' : '\U000022c3',
|
| 224 |
+
'\\sqcup' : '\U00002294',
|
| 225 |
+
'\\bigsqcup' : '\U00002a06',
|
| 226 |
+
'\\sqcap' : '\U00002293',
|
| 227 |
+
'\\Bigsqcap' : '\U00002a05',
|
| 228 |
+
'\\setminus' : '\U00002216',
|
| 229 |
+
'\\propto' : '\U0000221d',
|
| 230 |
+
'\\uplus' : '\U0000228e',
|
| 231 |
+
'\\bigplus' : '\U00002a04',
|
| 232 |
+
'\\sim' : '\U0000223c',
|
| 233 |
+
'\\doteq' : '\U00002250',
|
| 234 |
+
'\\simeq' : '\U00002243',
|
| 235 |
+
'\\approx' : '\U00002248',
|
| 236 |
+
'\\asymp' : '\U0000224d',
|
| 237 |
+
'\\cong' : '\U00002245',
|
| 238 |
+
'\\equiv' : '\U00002261',
|
| 239 |
+
'\\Join' : '\U000022c8',
|
| 240 |
+
'\\bowtie' : '\U00002a1d',
|
| 241 |
+
'\\prec' : '\U0000227a',
|
| 242 |
+
'\\succ' : '\U0000227b',
|
| 243 |
+
'\\preceq' : '\U0000227c',
|
| 244 |
+
'\\succeq' : '\U0000227d',
|
| 245 |
+
'\\parallel' : '\U00002225',
|
| 246 |
+
'\\mid' : '\U000000a6',
|
| 247 |
+
'\\pm' : '\U000000b1',
|
| 248 |
+
'\\mp' : '\U00002213',
|
| 249 |
+
'\\times' : '\U000000d7',
|
| 250 |
+
'\\div' : '\U000000f7',
|
| 251 |
+
'\\cdot' : '\U000022c5',
|
| 252 |
+
'\\star' : '\U000022c6',
|
| 253 |
+
'\\circ' : '\U00002218',
|
| 254 |
+
'\\dagger' : '\U00002020',
|
| 255 |
+
'\\ddagger' : '\U00002021',
|
| 256 |
+
'\\lhd' : '\U000022b2',
|
| 257 |
+
'\\rhd' : '\U000022b3',
|
| 258 |
+
'\\unlhd' : '\U000022b4',
|
| 259 |
+
'\\unrhd' : '\U000022b5',
|
| 260 |
+
'\\triangleleft' : '\U000025c3',
|
| 261 |
+
'\\triangleright' : '\U000025b9',
|
| 262 |
+
'\\triangle' : '\U000025b3',
|
| 263 |
+
'\\triangleq' : '\U0000225c',
|
| 264 |
+
'\\oplus' : '\U00002295',
|
| 265 |
+
'\\bigoplus' : '\U00002a01',
|
| 266 |
+
'\\otimes' : '\U00002297',
|
| 267 |
+
'\\bigotimes' : '\U00002a02',
|
| 268 |
+
'\\odot' : '\U00002299',
|
| 269 |
+
'\\bigodot' : '\U00002a00',
|
| 270 |
+
'\\ominus' : '\U00002296',
|
| 271 |
+
'\\oslash' : '\U00002298',
|
| 272 |
+
'\\dots' : '\U00002026',
|
| 273 |
+
'\\cdots' : '\U000022ef',
|
| 274 |
+
'\\sum' : '\U00002211',
|
| 275 |
+
'\\prod' : '\U0000220f',
|
| 276 |
+
'\\coprod' : '\U00002210',
|
| 277 |
+
'\\infty' : '\U0000221e',
|
| 278 |
+
'\\int' : '\U0000222b',
|
| 279 |
+
'\\oint' : '\U0000222e',
|
| 280 |
+
'\\clubsuit' : '\U00002663',
|
| 281 |
+
'\\diamondsuit' : '\U00002662',
|
| 282 |
+
'\\heartsuit' : '\U00002661',
|
| 283 |
+
'\\spadesuit' : '\U00002660',
|
| 284 |
+
'\\aleph' : '\U00002135',
|
| 285 |
+
'\\emptyset' : '\U00002205',
|
| 286 |
+
'\\nabla' : '\U00002207',
|
| 287 |
+
'\\partial' : '\U00002202',
|
| 288 |
+
'\\flat' : '\U0000266d',
|
| 289 |
+
'\\natural' : '\U0000266e',
|
| 290 |
+
'\\sharp' : '\U0000266f',
|
| 291 |
+
'\\angle' : '\U00002220',
|
| 292 |
+
'\\copyright' : '\U000000a9',
|
| 293 |
+
'\\textregistered' : '\U000000ae',
|
| 294 |
+
'\\textonequarter' : '\U000000bc',
|
| 295 |
+
'\\textonehalf' : '\U000000bd',
|
| 296 |
+
'\\textthreequarters' : '\U000000be',
|
| 297 |
+
'\\textordfeminine' : '\U000000aa',
|
| 298 |
+
'\\textordmasculine' : '\U000000ba',
|
| 299 |
+
'\\euro' : '\U000020ac',
|
| 300 |
+
'\\pounds' : '\U000000a3',
|
| 301 |
+
'\\yen' : '\U000000a5',
|
| 302 |
+
'\\textcent' : '\U000000a2',
|
| 303 |
+
'\\textcurrency' : '\U000000a4',
|
| 304 |
+
'\\textdegree' : '\U000000b0',
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
isabelle_symbols = {
|
| 308 |
+
'\\<zero>' : '\U0001d7ec',
|
| 309 |
+
'\\<one>' : '\U0001d7ed',
|
| 310 |
+
'\\<two>' : '\U0001d7ee',
|
| 311 |
+
'\\<three>' : '\U0001d7ef',
|
| 312 |
+
'\\<four>' : '\U0001d7f0',
|
| 313 |
+
'\\<five>' : '\U0001d7f1',
|
| 314 |
+
'\\<six>' : '\U0001d7f2',
|
| 315 |
+
'\\<seven>' : '\U0001d7f3',
|
| 316 |
+
'\\<eight>' : '\U0001d7f4',
|
| 317 |
+
'\\<nine>' : '\U0001d7f5',
|
| 318 |
+
'\\<A>' : '\U0001d49c',
|
| 319 |
+
'\\<B>' : '\U0000212c',
|
| 320 |
+
'\\<C>' : '\U0001d49e',
|
| 321 |
+
'\\<D>' : '\U0001d49f',
|
| 322 |
+
'\\<E>' : '\U00002130',
|
| 323 |
+
'\\<F>' : '\U00002131',
|
| 324 |
+
'\\<G>' : '\U0001d4a2',
|
| 325 |
+
'\\<H>' : '\U0000210b',
|
| 326 |
+
'\\<I>' : '\U00002110',
|
| 327 |
+
'\\<J>' : '\U0001d4a5',
|
| 328 |
+
'\\<K>' : '\U0001d4a6',
|
| 329 |
+
'\\<L>' : '\U00002112',
|
| 330 |
+
'\\<M>' : '\U00002133',
|
| 331 |
+
'\\<N>' : '\U0001d4a9',
|
| 332 |
+
'\\<O>' : '\U0001d4aa',
|
| 333 |
+
'\\<P>' : '\U0001d4ab',
|
| 334 |
+
'\\<Q>' : '\U0001d4ac',
|
| 335 |
+
'\\<R>' : '\U0000211b',
|
| 336 |
+
'\\<S>' : '\U0001d4ae',
|
| 337 |
+
'\\<T>' : '\U0001d4af',
|
| 338 |
+
'\\<U>' : '\U0001d4b0',
|
| 339 |
+
'\\<V>' : '\U0001d4b1',
|
| 340 |
+
'\\<W>' : '\U0001d4b2',
|
| 341 |
+
'\\<X>' : '\U0001d4b3',
|
| 342 |
+
'\\<Y>' : '\U0001d4b4',
|
| 343 |
+
'\\<Z>' : '\U0001d4b5',
|
| 344 |
+
'\\<a>' : '\U0001d5ba',
|
| 345 |
+
'\\<b>' : '\U0001d5bb',
|
| 346 |
+
'\\<c>' : '\U0001d5bc',
|
| 347 |
+
'\\<d>' : '\U0001d5bd',
|
| 348 |
+
'\\<e>' : '\U0001d5be',
|
| 349 |
+
'\\<f>' : '\U0001d5bf',
|
| 350 |
+
'\\<g>' : '\U0001d5c0',
|
| 351 |
+
'\\<h>' : '\U0001d5c1',
|
| 352 |
+
'\\<i>' : '\U0001d5c2',
|
| 353 |
+
'\\<j>' : '\U0001d5c3',
|
| 354 |
+
'\\<k>' : '\U0001d5c4',
|
| 355 |
+
'\\<l>' : '\U0001d5c5',
|
| 356 |
+
'\\<m>' : '\U0001d5c6',
|
| 357 |
+
'\\<n>' : '\U0001d5c7',
|
| 358 |
+
'\\<o>' : '\U0001d5c8',
|
| 359 |
+
'\\<p>' : '\U0001d5c9',
|
| 360 |
+
'\\<q>' : '\U0001d5ca',
|
| 361 |
+
'\\<r>' : '\U0001d5cb',
|
| 362 |
+
'\\<s>' : '\U0001d5cc',
|
| 363 |
+
'\\<t>' : '\U0001d5cd',
|
| 364 |
+
'\\<u>' : '\U0001d5ce',
|
| 365 |
+
'\\<v>' : '\U0001d5cf',
|
| 366 |
+
'\\<w>' : '\U0001d5d0',
|
| 367 |
+
'\\<x>' : '\U0001d5d1',
|
| 368 |
+
'\\<y>' : '\U0001d5d2',
|
| 369 |
+
'\\<z>' : '\U0001d5d3',
|
| 370 |
+
'\\<AA>' : '\U0001d504',
|
| 371 |
+
'\\<BB>' : '\U0001d505',
|
| 372 |
+
'\\<CC>' : '\U0000212d',
|
| 373 |
+
'\\<DD>' : '\U0001d507',
|
| 374 |
+
'\\<EE>' : '\U0001d508',
|
| 375 |
+
'\\<FF>' : '\U0001d509',
|
| 376 |
+
'\\<GG>' : '\U0001d50a',
|
| 377 |
+
'\\<HH>' : '\U0000210c',
|
| 378 |
+
'\\<II>' : '\U00002111',
|
| 379 |
+
'\\<JJ>' : '\U0001d50d',
|
| 380 |
+
'\\<KK>' : '\U0001d50e',
|
| 381 |
+
'\\<LL>' : '\U0001d50f',
|
| 382 |
+
'\\<MM>' : '\U0001d510',
|
| 383 |
+
'\\<NN>' : '\U0001d511',
|
| 384 |
+
'\\<OO>' : '\U0001d512',
|
| 385 |
+
'\\<PP>' : '\U0001d513',
|
| 386 |
+
'\\<QQ>' : '\U0001d514',
|
| 387 |
+
'\\<RR>' : '\U0000211c',
|
| 388 |
+
'\\<SS>' : '\U0001d516',
|
| 389 |
+
'\\<TT>' : '\U0001d517',
|
| 390 |
+
'\\<UU>' : '\U0001d518',
|
| 391 |
+
'\\<VV>' : '\U0001d519',
|
| 392 |
+
'\\<WW>' : '\U0001d51a',
|
| 393 |
+
'\\<XX>' : '\U0001d51b',
|
| 394 |
+
'\\<YY>' : '\U0001d51c',
|
| 395 |
+
'\\<ZZ>' : '\U00002128',
|
| 396 |
+
'\\<aa>' : '\U0001d51e',
|
| 397 |
+
'\\<bb>' : '\U0001d51f',
|
| 398 |
+
'\\<cc>' : '\U0001d520',
|
| 399 |
+
'\\<dd>' : '\U0001d521',
|
| 400 |
+
'\\<ee>' : '\U0001d522',
|
| 401 |
+
'\\<ff>' : '\U0001d523',
|
| 402 |
+
'\\<gg>' : '\U0001d524',
|
| 403 |
+
'\\<hh>' : '\U0001d525',
|
| 404 |
+
'\\<ii>' : '\U0001d526',
|
| 405 |
+
'\\<jj>' : '\U0001d527',
|
| 406 |
+
'\\<kk>' : '\U0001d528',
|
| 407 |
+
'\\<ll>' : '\U0001d529',
|
| 408 |
+
'\\<mm>' : '\U0001d52a',
|
| 409 |
+
'\\<nn>' : '\U0001d52b',
|
| 410 |
+
'\\<oo>' : '\U0001d52c',
|
| 411 |
+
'\\<pp>' : '\U0001d52d',
|
| 412 |
+
'\\<qq>' : '\U0001d52e',
|
| 413 |
+
'\\<rr>' : '\U0001d52f',
|
| 414 |
+
'\\<ss>' : '\U0001d530',
|
| 415 |
+
'\\<tt>' : '\U0001d531',
|
| 416 |
+
'\\<uu>' : '\U0001d532',
|
| 417 |
+
'\\<vv>' : '\U0001d533',
|
| 418 |
+
'\\<ww>' : '\U0001d534',
|
| 419 |
+
'\\<xx>' : '\U0001d535',
|
| 420 |
+
'\\<yy>' : '\U0001d536',
|
| 421 |
+
'\\<zz>' : '\U0001d537',
|
| 422 |
+
'\\<alpha>' : '\U000003b1',
|
| 423 |
+
'\\<beta>' : '\U000003b2',
|
| 424 |
+
'\\<gamma>' : '\U000003b3',
|
| 425 |
+
'\\<delta>' : '\U000003b4',
|
| 426 |
+
'\\<epsilon>' : '\U000003b5',
|
| 427 |
+
'\\<zeta>' : '\U000003b6',
|
| 428 |
+
'\\<eta>' : '\U000003b7',
|
| 429 |
+
'\\<theta>' : '\U000003b8',
|
| 430 |
+
'\\<iota>' : '\U000003b9',
|
| 431 |
+
'\\<kappa>' : '\U000003ba',
|
| 432 |
+
'\\<lambda>' : '\U000003bb',
|
| 433 |
+
'\\<mu>' : '\U000003bc',
|
| 434 |
+
'\\<nu>' : '\U000003bd',
|
| 435 |
+
'\\<xi>' : '\U000003be',
|
| 436 |
+
'\\<pi>' : '\U000003c0',
|
| 437 |
+
'\\<rho>' : '\U000003c1',
|
| 438 |
+
'\\<sigma>' : '\U000003c3',
|
| 439 |
+
'\\<tau>' : '\U000003c4',
|
| 440 |
+
'\\<upsilon>' : '\U000003c5',
|
| 441 |
+
'\\<phi>' : '\U000003c6',
|
| 442 |
+
'\\<chi>' : '\U000003c7',
|
| 443 |
+
'\\<psi>' : '\U000003c8',
|
| 444 |
+
'\\<omega>' : '\U000003c9',
|
| 445 |
+
'\\<Gamma>' : '\U00000393',
|
| 446 |
+
'\\<Delta>' : '\U00000394',
|
| 447 |
+
'\\<Theta>' : '\U00000398',
|
| 448 |
+
'\\<Lambda>' : '\U0000039b',
|
| 449 |
+
'\\<Xi>' : '\U0000039e',
|
| 450 |
+
'\\<Pi>' : '\U000003a0',
|
| 451 |
+
'\\<Sigma>' : '\U000003a3',
|
| 452 |
+
'\\<Upsilon>' : '\U000003a5',
|
| 453 |
+
'\\<Phi>' : '\U000003a6',
|
| 454 |
+
'\\<Psi>' : '\U000003a8',
|
| 455 |
+
'\\<Omega>' : '\U000003a9',
|
| 456 |
+
'\\<bool>' : '\U0001d539',
|
| 457 |
+
'\\<complex>' : '\U00002102',
|
| 458 |
+
'\\<nat>' : '\U00002115',
|
| 459 |
+
'\\<rat>' : '\U0000211a',
|
| 460 |
+
'\\<real>' : '\U0000211d',
|
| 461 |
+
'\\<int>' : '\U00002124',
|
| 462 |
+
'\\<leftarrow>' : '\U00002190',
|
| 463 |
+
'\\<longleftarrow>' : '\U000027f5',
|
| 464 |
+
'\\<rightarrow>' : '\U00002192',
|
| 465 |
+
'\\<longrightarrow>' : '\U000027f6',
|
| 466 |
+
'\\<Leftarrow>' : '\U000021d0',
|
| 467 |
+
'\\<Longleftarrow>' : '\U000027f8',
|
| 468 |
+
'\\<Rightarrow>' : '\U000021d2',
|
| 469 |
+
'\\<Longrightarrow>' : '\U000027f9',
|
| 470 |
+
'\\<leftrightarrow>' : '\U00002194',
|
| 471 |
+
'\\<longleftrightarrow>' : '\U000027f7',
|
| 472 |
+
'\\<Leftrightarrow>' : '\U000021d4',
|
| 473 |
+
'\\<Longleftrightarrow>' : '\U000027fa',
|
| 474 |
+
'\\<mapsto>' : '\U000021a6',
|
| 475 |
+
'\\<longmapsto>' : '\U000027fc',
|
| 476 |
+
'\\<midarrow>' : '\U00002500',
|
| 477 |
+
'\\<Midarrow>' : '\U00002550',
|
| 478 |
+
'\\<hookleftarrow>' : '\U000021a9',
|
| 479 |
+
'\\<hookrightarrow>' : '\U000021aa',
|
| 480 |
+
'\\<leftharpoondown>' : '\U000021bd',
|
| 481 |
+
'\\<rightharpoondown>' : '\U000021c1',
|
| 482 |
+
'\\<leftharpoonup>' : '\U000021bc',
|
| 483 |
+
'\\<rightharpoonup>' : '\U000021c0',
|
| 484 |
+
'\\<rightleftharpoons>' : '\U000021cc',
|
| 485 |
+
'\\<leadsto>' : '\U0000219d',
|
| 486 |
+
'\\<downharpoonleft>' : '\U000021c3',
|
| 487 |
+
'\\<downharpoonright>' : '\U000021c2',
|
| 488 |
+
'\\<upharpoonleft>' : '\U000021bf',
|
| 489 |
+
'\\<upharpoonright>' : '\U000021be',
|
| 490 |
+
'\\<restriction>' : '\U000021be',
|
| 491 |
+
'\\<Colon>' : '\U00002237',
|
| 492 |
+
'\\<up>' : '\U00002191',
|
| 493 |
+
'\\<Up>' : '\U000021d1',
|
| 494 |
+
'\\<down>' : '\U00002193',
|
| 495 |
+
'\\<Down>' : '\U000021d3',
|
| 496 |
+
'\\<updown>' : '\U00002195',
|
| 497 |
+
'\\<Updown>' : '\U000021d5',
|
| 498 |
+
'\\<langle>' : '\U000027e8',
|
| 499 |
+
'\\<rangle>' : '\U000027e9',
|
| 500 |
+
'\\<lceil>' : '\U00002308',
|
| 501 |
+
'\\<rceil>' : '\U00002309',
|
| 502 |
+
'\\<lfloor>' : '\U0000230a',
|
| 503 |
+
'\\<rfloor>' : '\U0000230b',
|
| 504 |
+
'\\<lparr>' : '\U00002987',
|
| 505 |
+
'\\<rparr>' : '\U00002988',
|
| 506 |
+
'\\<lbrakk>' : '\U000027e6',
|
| 507 |
+
'\\<rbrakk>' : '\U000027e7',
|
| 508 |
+
'\\<lbrace>' : '\U00002983',
|
| 509 |
+
'\\<rbrace>' : '\U00002984',
|
| 510 |
+
'\\<guillemotleft>' : '\U000000ab',
|
| 511 |
+
'\\<guillemotright>' : '\U000000bb',
|
| 512 |
+
'\\<bottom>' : '\U000022a5',
|
| 513 |
+
'\\<top>' : '\U000022a4',
|
| 514 |
+
'\\<and>' : '\U00002227',
|
| 515 |
+
'\\<And>' : '\U000022c0',
|
| 516 |
+
'\\<or>' : '\U00002228',
|
| 517 |
+
'\\<Or>' : '\U000022c1',
|
| 518 |
+
'\\<forall>' : '\U00002200',
|
| 519 |
+
'\\<exists>' : '\U00002203',
|
| 520 |
+
'\\<nexists>' : '\U00002204',
|
| 521 |
+
'\\<not>' : '\U000000ac',
|
| 522 |
+
'\\<box>' : '\U000025a1',
|
| 523 |
+
'\\<diamond>' : '\U000025c7',
|
| 524 |
+
'\\<turnstile>' : '\U000022a2',
|
| 525 |
+
'\\<Turnstile>' : '\U000022a8',
|
| 526 |
+
'\\<tturnstile>' : '\U000022a9',
|
| 527 |
+
'\\<TTurnstile>' : '\U000022ab',
|
| 528 |
+
'\\<stileturn>' : '\U000022a3',
|
| 529 |
+
'\\<surd>' : '\U0000221a',
|
| 530 |
+
'\\<le>' : '\U00002264',
|
| 531 |
+
'\\<ge>' : '\U00002265',
|
| 532 |
+
'\\<lless>' : '\U0000226a',
|
| 533 |
+
'\\<ggreater>' : '\U0000226b',
|
| 534 |
+
'\\<lesssim>' : '\U00002272',
|
| 535 |
+
'\\<greatersim>' : '\U00002273',
|
| 536 |
+
'\\<lessapprox>' : '\U00002a85',
|
| 537 |
+
'\\<greaterapprox>' : '\U00002a86',
|
| 538 |
+
'\\<in>' : '\U00002208',
|
| 539 |
+
'\\<notin>' : '\U00002209',
|
| 540 |
+
'\\<subset>' : '\U00002282',
|
| 541 |
+
'\\<supset>' : '\U00002283',
|
| 542 |
+
'\\<subseteq>' : '\U00002286',
|
| 543 |
+
'\\<supseteq>' : '\U00002287',
|
| 544 |
+
'\\<sqsubset>' : '\U0000228f',
|
| 545 |
+
'\\<sqsupset>' : '\U00002290',
|
| 546 |
+
'\\<sqsubseteq>' : '\U00002291',
|
| 547 |
+
'\\<sqsupseteq>' : '\U00002292',
|
| 548 |
+
'\\<inter>' : '\U00002229',
|
| 549 |
+
'\\<Inter>' : '\U000022c2',
|
| 550 |
+
'\\<union>' : '\U0000222a',
|
| 551 |
+
'\\<Union>' : '\U000022c3',
|
| 552 |
+
'\\<squnion>' : '\U00002294',
|
| 553 |
+
'\\<Squnion>' : '\U00002a06',
|
| 554 |
+
'\\<sqinter>' : '\U00002293',
|
| 555 |
+
'\\<Sqinter>' : '\U00002a05',
|
| 556 |
+
'\\<setminus>' : '\U00002216',
|
| 557 |
+
'\\<propto>' : '\U0000221d',
|
| 558 |
+
'\\<uplus>' : '\U0000228e',
|
| 559 |
+
'\\<Uplus>' : '\U00002a04',
|
| 560 |
+
'\\<noteq>' : '\U00002260',
|
| 561 |
+
'\\<sim>' : '\U0000223c',
|
| 562 |
+
'\\<doteq>' : '\U00002250',
|
| 563 |
+
'\\<simeq>' : '\U00002243',
|
| 564 |
+
'\\<approx>' : '\U00002248',
|
| 565 |
+
'\\<asymp>' : '\U0000224d',
|
| 566 |
+
'\\<cong>' : '\U00002245',
|
| 567 |
+
'\\<smile>' : '\U00002323',
|
| 568 |
+
'\\<equiv>' : '\U00002261',
|
| 569 |
+
'\\<frown>' : '\U00002322',
|
| 570 |
+
'\\<Join>' : '\U000022c8',
|
| 571 |
+
'\\<bowtie>' : '\U00002a1d',
|
| 572 |
+
'\\<prec>' : '\U0000227a',
|
| 573 |
+
'\\<succ>' : '\U0000227b',
|
| 574 |
+
'\\<preceq>' : '\U0000227c',
|
| 575 |
+
'\\<succeq>' : '\U0000227d',
|
| 576 |
+
'\\<parallel>' : '\U00002225',
|
| 577 |
+
'\\<bar>' : '\U000000a6',
|
| 578 |
+
'\\<plusminus>' : '\U000000b1',
|
| 579 |
+
'\\<minusplus>' : '\U00002213',
|
| 580 |
+
'\\<times>' : '\U000000d7',
|
| 581 |
+
'\\<div>' : '\U000000f7',
|
| 582 |
+
'\\<cdot>' : '\U000022c5',
|
| 583 |
+
'\\<star>' : '\U000022c6',
|
| 584 |
+
'\\<bullet>' : '\U00002219',
|
| 585 |
+
'\\<circ>' : '\U00002218',
|
| 586 |
+
'\\<dagger>' : '\U00002020',
|
| 587 |
+
'\\<ddagger>' : '\U00002021',
|
| 588 |
+
'\\<lhd>' : '\U000022b2',
|
| 589 |
+
'\\<rhd>' : '\U000022b3',
|
| 590 |
+
'\\<unlhd>' : '\U000022b4',
|
| 591 |
+
'\\<unrhd>' : '\U000022b5',
|
| 592 |
+
'\\<triangleleft>' : '\U000025c3',
|
| 593 |
+
'\\<triangleright>' : '\U000025b9',
|
| 594 |
+
'\\<triangle>' : '\U000025b3',
|
| 595 |
+
'\\<triangleq>' : '\U0000225c',
|
| 596 |
+
'\\<oplus>' : '\U00002295',
|
| 597 |
+
'\\<Oplus>' : '\U00002a01',
|
| 598 |
+
'\\<otimes>' : '\U00002297',
|
| 599 |
+
'\\<Otimes>' : '\U00002a02',
|
| 600 |
+
'\\<odot>' : '\U00002299',
|
| 601 |
+
'\\<Odot>' : '\U00002a00',
|
| 602 |
+
'\\<ominus>' : '\U00002296',
|
| 603 |
+
'\\<oslash>' : '\U00002298',
|
| 604 |
+
'\\<dots>' : '\U00002026',
|
| 605 |
+
'\\<cdots>' : '\U000022ef',
|
| 606 |
+
'\\<Sum>' : '\U00002211',
|
| 607 |
+
'\\<Prod>' : '\U0000220f',
|
| 608 |
+
'\\<Coprod>' : '\U00002210',
|
| 609 |
+
'\\<infinity>' : '\U0000221e',
|
| 610 |
+
'\\<integral>' : '\U0000222b',
|
| 611 |
+
'\\<ointegral>' : '\U0000222e',
|
| 612 |
+
'\\<clubsuit>' : '\U00002663',
|
| 613 |
+
'\\<diamondsuit>' : '\U00002662',
|
| 614 |
+
'\\<heartsuit>' : '\U00002661',
|
| 615 |
+
'\\<spadesuit>' : '\U00002660',
|
| 616 |
+
'\\<aleph>' : '\U00002135',
|
| 617 |
+
'\\<emptyset>' : '\U00002205',
|
| 618 |
+
'\\<nabla>' : '\U00002207',
|
| 619 |
+
'\\<partial>' : '\U00002202',
|
| 620 |
+
'\\<flat>' : '\U0000266d',
|
| 621 |
+
'\\<natural>' : '\U0000266e',
|
| 622 |
+
'\\<sharp>' : '\U0000266f',
|
| 623 |
+
'\\<angle>' : '\U00002220',
|
| 624 |
+
'\\<copyright>' : '\U000000a9',
|
| 625 |
+
'\\<registered>' : '\U000000ae',
|
| 626 |
+
'\\<hyphen>' : '\U000000ad',
|
| 627 |
+
'\\<inverse>' : '\U000000af',
|
| 628 |
+
'\\<onequarter>' : '\U000000bc',
|
| 629 |
+
'\\<onehalf>' : '\U000000bd',
|
| 630 |
+
'\\<threequarters>' : '\U000000be',
|
| 631 |
+
'\\<ordfeminine>' : '\U000000aa',
|
| 632 |
+
'\\<ordmasculine>' : '\U000000ba',
|
| 633 |
+
'\\<section>' : '\U000000a7',
|
| 634 |
+
'\\<paragraph>' : '\U000000b6',
|
| 635 |
+
'\\<exclamdown>' : '\U000000a1',
|
| 636 |
+
'\\<questiondown>' : '\U000000bf',
|
| 637 |
+
'\\<euro>' : '\U000020ac',
|
| 638 |
+
'\\<pounds>' : '\U000000a3',
|
| 639 |
+
'\\<yen>' : '\U000000a5',
|
| 640 |
+
'\\<cent>' : '\U000000a2',
|
| 641 |
+
'\\<currency>' : '\U000000a4',
|
| 642 |
+
'\\<degree>' : '\U000000b0',
|
| 643 |
+
'\\<amalg>' : '\U00002a3f',
|
| 644 |
+
'\\<mho>' : '\U00002127',
|
| 645 |
+
'\\<lozenge>' : '\U000025ca',
|
| 646 |
+
'\\<wp>' : '\U00002118',
|
| 647 |
+
'\\<wrong>' : '\U00002240',
|
| 648 |
+
'\\<struct>' : '\U000022c4',
|
| 649 |
+
'\\<acute>' : '\U000000b4',
|
| 650 |
+
'\\<index>' : '\U00000131',
|
| 651 |
+
'\\<dieresis>' : '\U000000a8',
|
| 652 |
+
'\\<cedilla>' : '\U000000b8',
|
| 653 |
+
'\\<hungarumlaut>' : '\U000002dd',
|
| 654 |
+
'\\<some>' : '\U000003f5',
|
| 655 |
+
'\\<newline>' : '\U000023ce',
|
| 656 |
+
'\\<open>' : '\U00002039',
|
| 657 |
+
'\\<close>' : '\U0000203a',
|
| 658 |
+
'\\<here>' : '\U00002302',
|
| 659 |
+
'\\<^sub>' : '\U000021e9',
|
| 660 |
+
'\\<^sup>' : '\U000021e7',
|
| 661 |
+
'\\<^bold>' : '\U00002759',
|
| 662 |
+
'\\<^bsub>' : '\U000021d8',
|
| 663 |
+
'\\<^esub>' : '\U000021d9',
|
| 664 |
+
'\\<^bsup>' : '\U000021d7',
|
| 665 |
+
'\\<^esup>' : '\U000021d6',
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
lang_map = {'isabelle' : isabelle_symbols, 'latex' : latex_symbols}
|
| 669 |
+
|
| 670 |
+
def __init__(self, **options):
|
| 671 |
+
Filter.__init__(self, **options)
|
| 672 |
+
lang = get_choice_opt(options, 'lang',
|
| 673 |
+
['isabelle', 'latex'], 'isabelle')
|
| 674 |
+
self.symbols = self.lang_map[lang]
|
| 675 |
+
|
| 676 |
+
def filter(self, lexer, stream):
|
| 677 |
+
for ttype, value in stream:
|
| 678 |
+
if value in self.symbols:
|
| 679 |
+
yield ttype, self.symbols[value]
|
| 680 |
+
else:
|
| 681 |
+
yield ttype, value
|
| 682 |
+
|
| 683 |
+
|
| 684 |
+
class KeywordCaseFilter(Filter):
|
| 685 |
+
"""Convert keywords to lowercase or uppercase or capitalize them, which
|
| 686 |
+
means first letter uppercase, rest lowercase.
|
| 687 |
+
|
| 688 |
+
This can be useful e.g. if you highlight Pascal code and want to adapt the
|
| 689 |
+
code to your styleguide.
|
| 690 |
+
|
| 691 |
+
Options accepted:
|
| 692 |
+
|
| 693 |
+
`case` : string
|
| 694 |
+
The casing to convert keywords to. Must be one of ``'lower'``,
|
| 695 |
+
``'upper'`` or ``'capitalize'``. The default is ``'lower'``.
|
| 696 |
+
"""
|
| 697 |
+
|
| 698 |
+
def __init__(self, **options):
|
| 699 |
+
Filter.__init__(self, **options)
|
| 700 |
+
case = get_choice_opt(options, 'case',
|
| 701 |
+
['lower', 'upper', 'capitalize'], 'lower')
|
| 702 |
+
self.convert = getattr(str, case)
|
| 703 |
+
|
| 704 |
+
def filter(self, lexer, stream):
|
| 705 |
+
for ttype, value in stream:
|
| 706 |
+
if ttype in Keyword:
|
| 707 |
+
yield ttype, self.convert(value)
|
| 708 |
+
else:
|
| 709 |
+
yield ttype, value
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
class NameHighlightFilter(Filter):
|
| 713 |
+
"""Highlight a normal Name (and Name.*) token with a different token type.
|
| 714 |
+
|
| 715 |
+
Example::
|
| 716 |
+
|
| 717 |
+
filter = NameHighlightFilter(
|
| 718 |
+
names=['foo', 'bar', 'baz'],
|
| 719 |
+
tokentype=Name.Function,
|
| 720 |
+
)
|
| 721 |
+
|
| 722 |
+
This would highlight the names "foo", "bar" and "baz"
|
| 723 |
+
as functions. `Name.Function` is the default token type.
|
| 724 |
+
|
| 725 |
+
Options accepted:
|
| 726 |
+
|
| 727 |
+
`names` : list of strings
|
| 728 |
+
A list of names that should be given the different token type.
|
| 729 |
+
There is no default.
|
| 730 |
+
`tokentype` : TokenType or string
|
| 731 |
+
A token type or a string containing a token type name that is
|
| 732 |
+
used for highlighting the strings in `names`. The default is
|
| 733 |
+
`Name.Function`.
|
| 734 |
+
"""
|
| 735 |
+
|
| 736 |
+
def __init__(self, **options):
|
| 737 |
+
Filter.__init__(self, **options)
|
| 738 |
+
self.names = set(get_list_opt(options, 'names', []))
|
| 739 |
+
tokentype = options.get('tokentype')
|
| 740 |
+
if tokentype:
|
| 741 |
+
self.tokentype = string_to_tokentype(tokentype)
|
| 742 |
+
else:
|
| 743 |
+
self.tokentype = Name.Function
|
| 744 |
+
|
| 745 |
+
def filter(self, lexer, stream):
|
| 746 |
+
for ttype, value in stream:
|
| 747 |
+
if ttype in Name and value in self.names:
|
| 748 |
+
yield self.tokentype, value
|
| 749 |
+
else:
|
| 750 |
+
yield ttype, value
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
class ErrorToken(Exception):
|
| 754 |
+
pass
|
| 755 |
+
|
| 756 |
+
|
| 757 |
+
class RaiseOnErrorTokenFilter(Filter):
|
| 758 |
+
"""Raise an exception when the lexer generates an error token.
|
| 759 |
+
|
| 760 |
+
Options accepted:
|
| 761 |
+
|
| 762 |
+
`excclass` : Exception class
|
| 763 |
+
The exception class to raise.
|
| 764 |
+
The default is `pygments.filters.ErrorToken`.
|
| 765 |
+
|
| 766 |
+
.. versionadded:: 0.8
|
| 767 |
+
"""
|
| 768 |
+
|
| 769 |
+
def __init__(self, **options):
|
| 770 |
+
Filter.__init__(self, **options)
|
| 771 |
+
self.exception = options.get('excclass', ErrorToken)
|
| 772 |
+
try:
|
| 773 |
+
# issubclass() will raise TypeError if first argument is not a class
|
| 774 |
+
if not issubclass(self.exception, Exception):
|
| 775 |
+
raise TypeError
|
| 776 |
+
except TypeError:
|
| 777 |
+
raise OptionError('excclass option is not an exception class')
|
| 778 |
+
|
| 779 |
+
def filter(self, lexer, stream):
|
| 780 |
+
for ttype, value in stream:
|
| 781 |
+
if ttype is Error:
|
| 782 |
+
raise self.exception(value)
|
| 783 |
+
yield ttype, value
|
| 784 |
+
|
| 785 |
+
|
| 786 |
+
class VisibleWhitespaceFilter(Filter):
|
| 787 |
+
"""Convert tabs, newlines and/or spaces to visible characters.
|
| 788 |
+
|
| 789 |
+
Options accepted:
|
| 790 |
+
|
| 791 |
+
`spaces` : string or bool
|
| 792 |
+
If this is a one-character string, spaces will be replaces by this string.
|
| 793 |
+
If it is another true value, spaces will be replaced by ``·`` (unicode
|
| 794 |
+
MIDDLE DOT). If it is a false value, spaces will not be replaced. The
|
| 795 |
+
default is ``False``.
|
| 796 |
+
`tabs` : string or bool
|
| 797 |
+
The same as for `spaces`, but the default replacement character is ``»``
|
| 798 |
+
(unicode RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK). The default value
|
| 799 |
+
is ``False``. Note: this will not work if the `tabsize` option for the
|
| 800 |
+
lexer is nonzero, as tabs will already have been expanded then.
|
| 801 |
+
`tabsize` : int
|
| 802 |
+
If tabs are to be replaced by this filter (see the `tabs` option), this
|
| 803 |
+
is the total number of characters that a tab should be expanded to.
|
| 804 |
+
The default is ``8``.
|
| 805 |
+
`newlines` : string or bool
|
| 806 |
+
The same as for `spaces`, but the default replacement character is ``¶``
|
| 807 |
+
(unicode PILCROW SIGN). The default value is ``False``.
|
| 808 |
+
`wstokentype` : bool
|
| 809 |
+
If true, give whitespace the special `Whitespace` token type. This allows
|
| 810 |
+
styling the visible whitespace differently (e.g. greyed out), but it can
|
| 811 |
+
disrupt background colors. The default is ``True``.
|
| 812 |
+
|
| 813 |
+
.. versionadded:: 0.8
|
| 814 |
+
"""
|
| 815 |
+
|
| 816 |
+
def __init__(self, **options):
|
| 817 |
+
Filter.__init__(self, **options)
|
| 818 |
+
for name, default in [('spaces', '·'),
|
| 819 |
+
('tabs', '»'),
|
| 820 |
+
('newlines', '¶')]:
|
| 821 |
+
opt = options.get(name, False)
|
| 822 |
+
if isinstance(opt, str) and len(opt) == 1:
|
| 823 |
+
setattr(self, name, opt)
|
| 824 |
+
else:
|
| 825 |
+
setattr(self, name, (opt and default or ''))
|
| 826 |
+
tabsize = get_int_opt(options, 'tabsize', 8)
|
| 827 |
+
if self.tabs:
|
| 828 |
+
self.tabs += ' ' * (tabsize - 1)
|
| 829 |
+
if self.newlines:
|
| 830 |
+
self.newlines += '\n'
|
| 831 |
+
self.wstt = get_bool_opt(options, 'wstokentype', True)
|
| 832 |
+
|
| 833 |
+
def filter(self, lexer, stream):
|
| 834 |
+
if self.wstt:
|
| 835 |
+
spaces = self.spaces or ' '
|
| 836 |
+
tabs = self.tabs or '\t'
|
| 837 |
+
newlines = self.newlines or '\n'
|
| 838 |
+
regex = re.compile(r'\s')
|
| 839 |
+
|
| 840 |
+
def replacefunc(wschar):
|
| 841 |
+
if wschar == ' ':
|
| 842 |
+
return spaces
|
| 843 |
+
elif wschar == '\t':
|
| 844 |
+
return tabs
|
| 845 |
+
elif wschar == '\n':
|
| 846 |
+
return newlines
|
| 847 |
+
return wschar
|
| 848 |
+
|
| 849 |
+
for ttype, value in stream:
|
| 850 |
+
yield from _replace_special(ttype, value, regex, Whitespace,
|
| 851 |
+
replacefunc)
|
| 852 |
+
else:
|
| 853 |
+
spaces, tabs, newlines = self.spaces, self.tabs, self.newlines
|
| 854 |
+
# simpler processing
|
| 855 |
+
for ttype, value in stream:
|
| 856 |
+
if spaces:
|
| 857 |
+
value = value.replace(' ', spaces)
|
| 858 |
+
if tabs:
|
| 859 |
+
value = value.replace('\t', tabs)
|
| 860 |
+
if newlines:
|
| 861 |
+
value = value.replace('\n', newlines)
|
| 862 |
+
yield ttype, value
|
| 863 |
+
|
| 864 |
+
|
| 865 |
+
class GobbleFilter(Filter):
|
| 866 |
+
"""Gobbles source code lines (eats initial characters).
|
| 867 |
+
|
| 868 |
+
This filter drops the first ``n`` characters off every line of code. This
|
| 869 |
+
may be useful when the source code fed to the lexer is indented by a fixed
|
| 870 |
+
amount of space that isn't desired in the output.
|
| 871 |
+
|
| 872 |
+
Options accepted:
|
| 873 |
+
|
| 874 |
+
`n` : int
|
| 875 |
+
The number of characters to gobble.
|
| 876 |
+
|
| 877 |
+
.. versionadded:: 1.2
|
| 878 |
+
"""
|
| 879 |
+
def __init__(self, **options):
|
| 880 |
+
Filter.__init__(self, **options)
|
| 881 |
+
self.n = get_int_opt(options, 'n', 0)
|
| 882 |
+
|
| 883 |
+
def gobble(self, value, left):
|
| 884 |
+
if left < len(value):
|
| 885 |
+
return value[left:], 0
|
| 886 |
+
else:
|
| 887 |
+
return '', left - len(value)
|
| 888 |
+
|
| 889 |
+
def filter(self, lexer, stream):
|
| 890 |
+
n = self.n
|
| 891 |
+
left = n # How many characters left to gobble.
|
| 892 |
+
for ttype, value in stream:
|
| 893 |
+
# Remove ``left`` tokens from first line, ``n`` from all others.
|
| 894 |
+
parts = value.split('\n')
|
| 895 |
+
(parts[0], left) = self.gobble(parts[0], left)
|
| 896 |
+
for i in range(1, len(parts)):
|
| 897 |
+
(parts[i], left) = self.gobble(parts[i], n)
|
| 898 |
+
value = '\n'.join(parts)
|
| 899 |
+
|
| 900 |
+
if value != '':
|
| 901 |
+
yield ttype, value
|
| 902 |
+
|
| 903 |
+
|
| 904 |
+
class TokenMergeFilter(Filter):
|
| 905 |
+
"""Merges consecutive tokens with the same token type in the output
|
| 906 |
+
stream of a lexer.
|
| 907 |
+
|
| 908 |
+
.. versionadded:: 1.2
|
| 909 |
+
"""
|
| 910 |
+
def __init__(self, **options):
|
| 911 |
+
Filter.__init__(self, **options)
|
| 912 |
+
|
| 913 |
+
def filter(self, lexer, stream):
|
| 914 |
+
current_type = None
|
| 915 |
+
current_value = None
|
| 916 |
+
for ttype, value in stream:
|
| 917 |
+
if ttype is current_type:
|
| 918 |
+
current_value += value
|
| 919 |
+
else:
|
| 920 |
+
if current_type is not None:
|
| 921 |
+
yield current_type, current_value
|
| 922 |
+
current_type = ttype
|
| 923 |
+
current_value = value
|
| 924 |
+
if current_type is not None:
|
| 925 |
+
yield current_type, current_value
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
FILTERS = {
|
| 929 |
+
'codetagify': CodeTagFilter,
|
| 930 |
+
'keywordcase': KeywordCaseFilter,
|
| 931 |
+
'highlight': NameHighlightFilter,
|
| 932 |
+
'raiseonerror': RaiseOnErrorTokenFilter,
|
| 933 |
+
'whitespace': VisibleWhitespaceFilter,
|
| 934 |
+
'gobble': GobbleFilter,
|
| 935 |
+
'tokenmerge': TokenMergeFilter,
|
| 936 |
+
'symbols': SymbolFilter,
|
| 937 |
+
}
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/filters/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (29.6 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/formatters/__init__.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.formatters
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments formatters.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
import sys
|
| 13 |
+
import types
|
| 14 |
+
import fnmatch
|
| 15 |
+
from os.path import basename
|
| 16 |
+
|
| 17 |
+
from pip._vendor.pygments.formatters._mapping import FORMATTERS
|
| 18 |
+
from pip._vendor.pygments.plugin import find_plugin_formatters
|
| 19 |
+
from pip._vendor.pygments.util import ClassNotFound
|
| 20 |
+
|
| 21 |
+
__all__ = ['get_formatter_by_name', 'get_formatter_for_filename',
|
| 22 |
+
'get_all_formatters', 'load_formatter_from_file'] + list(FORMATTERS)
|
| 23 |
+
|
| 24 |
+
_formatter_cache = {} # classes by name
|
| 25 |
+
_pattern_cache = {}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _fn_matches(fn, glob):
|
| 29 |
+
"""Return whether the supplied file name fn matches pattern filename."""
|
| 30 |
+
if glob not in _pattern_cache:
|
| 31 |
+
pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob))
|
| 32 |
+
return pattern.match(fn)
|
| 33 |
+
return _pattern_cache[glob].match(fn)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def _load_formatters(module_name):
|
| 37 |
+
"""Load a formatter (and all others in the module too)."""
|
| 38 |
+
mod = __import__(module_name, None, None, ['__all__'])
|
| 39 |
+
for formatter_name in mod.__all__:
|
| 40 |
+
cls = getattr(mod, formatter_name)
|
| 41 |
+
_formatter_cache[cls.name] = cls
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def get_all_formatters():
|
| 45 |
+
"""Return a generator for all formatter classes."""
|
| 46 |
+
# NB: this returns formatter classes, not info like get_all_lexers().
|
| 47 |
+
for info in FORMATTERS.values():
|
| 48 |
+
if info[1] not in _formatter_cache:
|
| 49 |
+
_load_formatters(info[0])
|
| 50 |
+
yield _formatter_cache[info[1]]
|
| 51 |
+
for _, formatter in find_plugin_formatters():
|
| 52 |
+
yield formatter
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def find_formatter_class(alias):
|
| 56 |
+
"""Lookup a formatter by alias.
|
| 57 |
+
|
| 58 |
+
Returns None if not found.
|
| 59 |
+
"""
|
| 60 |
+
for module_name, name, aliases, _, _ in FORMATTERS.values():
|
| 61 |
+
if alias in aliases:
|
| 62 |
+
if name not in _formatter_cache:
|
| 63 |
+
_load_formatters(module_name)
|
| 64 |
+
return _formatter_cache[name]
|
| 65 |
+
for _, cls in find_plugin_formatters():
|
| 66 |
+
if alias in cls.aliases:
|
| 67 |
+
return cls
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def get_formatter_by_name(_alias, **options):
|
| 71 |
+
"""Lookup and instantiate a formatter by alias.
|
| 72 |
+
|
| 73 |
+
Raises ClassNotFound if not found.
|
| 74 |
+
"""
|
| 75 |
+
cls = find_formatter_class(_alias)
|
| 76 |
+
if cls is None:
|
| 77 |
+
raise ClassNotFound("no formatter found for name %r" % _alias)
|
| 78 |
+
return cls(**options)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def load_formatter_from_file(filename, formattername="CustomFormatter",
|
| 82 |
+
**options):
|
| 83 |
+
"""Load a formatter from a file.
|
| 84 |
+
|
| 85 |
+
This method expects a file located relative to the current working
|
| 86 |
+
directory, which contains a class named CustomFormatter. By default,
|
| 87 |
+
it expects the Formatter to be named CustomFormatter; you can specify
|
| 88 |
+
your own class name as the second argument to this function.
|
| 89 |
+
|
| 90 |
+
Users should be very careful with the input, because this method
|
| 91 |
+
is equivalent to running eval on the input file.
|
| 92 |
+
|
| 93 |
+
Raises ClassNotFound if there are any problems importing the Formatter.
|
| 94 |
+
|
| 95 |
+
.. versionadded:: 2.2
|
| 96 |
+
"""
|
| 97 |
+
try:
|
| 98 |
+
# This empty dict will contain the namespace for the exec'd file
|
| 99 |
+
custom_namespace = {}
|
| 100 |
+
with open(filename, 'rb') as f:
|
| 101 |
+
exec(f.read(), custom_namespace)
|
| 102 |
+
# Retrieve the class `formattername` from that namespace
|
| 103 |
+
if formattername not in custom_namespace:
|
| 104 |
+
raise ClassNotFound('no valid %s class found in %s' %
|
| 105 |
+
(formattername, filename))
|
| 106 |
+
formatter_class = custom_namespace[formattername]
|
| 107 |
+
# And finally instantiate it with the options
|
| 108 |
+
return formatter_class(**options)
|
| 109 |
+
except OSError as err:
|
| 110 |
+
raise ClassNotFound('cannot read %s: %s' % (filename, err))
|
| 111 |
+
except ClassNotFound:
|
| 112 |
+
raise
|
| 113 |
+
except Exception as err:
|
| 114 |
+
raise ClassNotFound('error when loading custom formatter: %s' % err)
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def get_formatter_for_filename(fn, **options):
|
| 118 |
+
"""Lookup and instantiate a formatter by filename pattern.
|
| 119 |
+
|
| 120 |
+
Raises ClassNotFound if not found.
|
| 121 |
+
"""
|
| 122 |
+
fn = basename(fn)
|
| 123 |
+
for modname, name, _, filenames, _ in FORMATTERS.values():
|
| 124 |
+
for filename in filenames:
|
| 125 |
+
if _fn_matches(fn, filename):
|
| 126 |
+
if name not in _formatter_cache:
|
| 127 |
+
_load_formatters(modname)
|
| 128 |
+
return _formatter_cache[name](**options)
|
| 129 |
+
for cls in find_plugin_formatters():
|
| 130 |
+
for filename in cls.filenames:
|
| 131 |
+
if _fn_matches(fn, filename):
|
| 132 |
+
return cls(**options)
|
| 133 |
+
raise ClassNotFound("no formatter found for file name %r" % fn)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class _automodule(types.ModuleType):
|
| 137 |
+
"""Automatically import formatters."""
|
| 138 |
+
|
| 139 |
+
def __getattr__(self, name):
|
| 140 |
+
info = FORMATTERS.get(name)
|
| 141 |
+
if info:
|
| 142 |
+
_load_formatters(info[0])
|
| 143 |
+
cls = _formatter_cache[info[1]]
|
| 144 |
+
setattr(self, name, cls)
|
| 145 |
+
return cls
|
| 146 |
+
raise AttributeError(name)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
oldmod = sys.modules[__name__]
|
| 150 |
+
newmod = _automodule(__name__)
|
| 151 |
+
newmod.__dict__.update(oldmod.__dict__)
|
| 152 |
+
sys.modules[__name__] = newmod
|
| 153 |
+
del newmod.newmod, newmod.oldmod, newmod.sys, newmod.types
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_vendor/pygments/formatters/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (4.72 kB). View file
|
|
|