├── thirdparty
├── rich
│ ├── py.typed
│ ├── themes.py
│ ├── region.py
│ ├── _extension.py
│ ├── _stack.py
│ ├── _pick.py
│ ├── _timer.py
│ ├── errors.py
│ ├── pager.py
│ ├── abc.py
│ ├── diagnose.py
│ ├── _emoji_replace.py
│ ├── color_triplet.py
│ ├── styled.py
│ ├── _loop.py
│ ├── constrain.py
│ ├── protocol.py
│ ├── screen.py
│ ├── file_proxy.py
│ ├── _wrap.py
│ ├── _windows.py
│ └── _export_format.py
├── elftools
│ ├── common
│ │ ├── __init__.py
│ │ └── exceptions.py
│ ├── dwarf
│ │ └── __init__.py
│ ├── ehabi
│ │ ├── __init__.py
│ │ ├── constants.py
│ │ └── structs.py
│ ├── elf
│ │ └── __init__.py
│ ├── __init__.py
│ └── construct
│ │ └── lib
│ │ ├── __init__.py
│ │ ├── hex.py
│ │ ├── py3compat.py
│ │ └── bitstream.py
├── prompt_toolkit
│ ├── py.typed
│ ├── contrib
│ │ ├── __init__.py
│ │ ├── completers
│ │ │ ├── __init__.py
│ │ │ └── system.py
│ │ ├── telnet
│ │ │ ├── __init__.py
│ │ │ └── log.py
│ │ ├── ssh
│ │ │ └── __init__.py
│ │ └── regular_languages
│ │ │ └── validation.py
│ ├── key_binding
│ │ ├── bindings
│ │ │ ├── __init__.py
│ │ │ ├── focus.py
│ │ │ ├── cpr.py
│ │ │ ├── open_in_editor.py
│ │ │ └── auto_suggest.py
│ │ ├── __init__.py
│ │ ├── emacs_state.py
│ │ └── defaults.py
│ ├── token.py
│ ├── log.py
│ ├── data_structures.py
│ ├── input
│ │ ├── __init__.py
│ │ └── defaults.py
│ ├── output
│ │ ├── __init__.py
│ │ ├── color_depth.py
│ │ └── conemu.py
│ ├── enums.py
│ ├── lexers
│ │ └── __init__.py
│ ├── clipboard
│ │ ├── __init__.py
│ │ ├── in_memory.py
│ │ └── pyperclip.py
│ ├── shortcuts
│ │ ├── progress_bar
│ │ │ └── __init__.py
│ │ └── __init__.py
│ ├── application
│ │ ├── __init__.py
│ │ └── dummy.py
│ ├── eventloop
│ │ ├── __init__.py
│ │ ├── dummy_contextvars.py
│ │ └── async_generator.py
│ ├── formatted_text
│ │ ├── pygments.py
│ │ └── __init__.py
│ ├── filters
│ │ ├── utils.py
│ │ ├── cli.py
│ │ └── __init__.py
│ ├── __init__.py
│ ├── completion
│ │ ├── __init__.py
│ │ └── deduplicate.py
│ ├── layout
│ │ ├── dummy.py
│ │ └── mouse_handlers.py
│ ├── widgets
│ │ └── __init__.py
│ ├── selection.py
│ └── styles
│ │ ├── __init__.py
│ │ └── pygments.py
├── commonmark
│ ├── render
│ │ ├── __init__.py
│ │ └── renderer.py
│ ├── tests
│ │ └── __init__.py
│ ├── __init__.py
│ ├── main.py
│ └── cmark.py
├── wcwidth
│ ├── tests
│ │ └── __init__.py
│ ├── version.json
│ ├── unicode_versions.py
│ └── __init__.py
├── pefile
│ ├── __init__.py
│ └── ordlookup
│ │ └── __init__.py
├── __init__.py
└── pygments
│ ├── __main__.py
│ ├── lexers
│ ├── math.py
│ ├── functional.py
│ ├── agile.py
│ ├── gcodelexer.py
│ ├── web.py
│ ├── xorg.py
│ ├── text.py
│ ├── procfile.py
│ ├── rita.py
│ ├── compiled.py
│ ├── cplint.py
│ ├── trafficscript.py
│ ├── asc.py
│ ├── amdgpu.py
│ ├── bdd.py
│ ├── other.py
│ ├── srcinfo.py
│ ├── _ada_builtins.py
│ ├── iolang.py
│ ├── graphviz.py
│ ├── x10.py
│ ├── sgf.py
│ ├── rnc.py
│ ├── pointless.py
│ ├── _usd_builtins.py
│ ├── roboconf.py
│ ├── jmespath.py
│ └── capnproto.py
│ ├── styles
│ ├── igor.py
│ ├── abap.py
│ ├── staroffice.py
│ ├── rrt.py
│ ├── vs.py
│ ├── stata_dark.py
│ ├── stata_light.py
│ ├── fruity.py
│ ├── bw.py
│ ├── sas.py
│ ├── xcode.py
│ ├── borland.py
│ ├── onedark.py
│ ├── trac.py
│ ├── vim.py
│ ├── native.py
│ ├── lilypond.py
│ ├── autumn.py
│ ├── perldoc.py
│ ├── algol.py
│ ├── algol_nu.py
│ └── zenburn.py
│ ├── modeline.py
│ ├── console.py
│ └── filter.py
├── core
├── riposte_sf
│ ├── __init__.py
│ ├── README.md
│ ├── exceptions.py
│ ├── flag_parser.py
│ ├── guides.py
│ ├── input_streams.py
│ └── data_vars.py
├── __init__.py
├── utils
│ ├── __init__.py
│ ├── ByteTools.py
│ ├── TextParser.py
│ └── FileTools.py
└── config.py
├── samples_pass_infected.zip
├── auto_config
├── sf2.py
└── plugins
├── __init__.py
├── module_elf.py
├── command_fill.py
└── command_elf_info.py
/thirdparty/rich/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/elftools/common/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/elftools/dwarf/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/elftools/ehabi/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/elftools/elf/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/commonmark/render/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/commonmark/tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/contrib/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/key_binding/bindings/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/thirdparty/elftools/ehabi/constants.py:
--------------------------------------------------------------------------------
1 | EHABI_INDEX_ENTRY_SIZE = 8
2 |
--------------------------------------------------------------------------------
/thirdparty/wcwidth/tests/__init__.py:
--------------------------------------------------------------------------------
1 | """This file intentionally left blank."""
2 |
--------------------------------------------------------------------------------
/thirdparty/pefile/__init__.py:
--------------------------------------------------------------------------------
1 | #from pefile import *
2 | from . import pefile
3 |
4 |
5 |
--------------------------------------------------------------------------------
/core/riposte_sf/__init__.py:
--------------------------------------------------------------------------------
1 | from .riposte import RiposteSF
2 | from .command import Command
3 |
--------------------------------------------------------------------------------
/samples_pass_infected.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/d3ranged/sf2/HEAD/samples_pass_infected.zip
--------------------------------------------------------------------------------
/core/__init__.py:
--------------------------------------------------------------------------------
1 | from .config import *
2 | from .core import *
3 | from .plugin_manager import *
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/thirdparty/__init__.py:
--------------------------------------------------------------------------------
1 | # add current dir to import list
2 | import sys, pathlib
3 | sys.path.insert(0, str(pathlib.Path(__file__).parent))
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/contrib/completers/__init__.py:
--------------------------------------------------------------------------------
1 | from .system import SystemCompleter
2 |
3 | __all__ = ["SystemCompleter"]
4 |
--------------------------------------------------------------------------------
/core/utils/__init__.py:
--------------------------------------------------------------------------------
1 | from .ByteTools import *
2 | from .FileTools import *
3 | from .TextParser import *
4 | from .RangeTools import *
5 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/contrib/telnet/__init__.py:
--------------------------------------------------------------------------------
1 | from .server import TelnetServer
2 |
3 | __all__ = [
4 | "TelnetServer",
5 | ]
6 |
--------------------------------------------------------------------------------
/thirdparty/rich/themes.py:
--------------------------------------------------------------------------------
1 | from .default_styles import DEFAULT_STYLES
2 | from .theme import Theme
3 |
4 |
5 | DEFAULT = Theme(DEFAULT_STYLES)
6 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/token.py:
--------------------------------------------------------------------------------
1 | """
2 | """
3 |
4 | __all__ = [
5 | "ZeroWidthEscape",
6 | ]
7 |
8 | ZeroWidthEscape = "[ZeroWidthEscape]"
9 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/log.py:
--------------------------------------------------------------------------------
1 | """
2 | Logging configuration.
3 | """
4 | import logging
5 |
6 | __all__ = [
7 | "logger",
8 | ]
9 |
10 | logger = logging.getLogger(__package__)
11 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/contrib/ssh/__init__.py:
--------------------------------------------------------------------------------
1 | from .server import PromptToolkitSSHServer, PromptToolkitSSHSession
2 |
3 | __all__ = [
4 | "PromptToolkitSSHSession",
5 | "PromptToolkitSSHServer",
6 | ]
7 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/contrib/telnet/log.py:
--------------------------------------------------------------------------------
1 | """
2 | Python logger for the telnet server.
3 | """
4 | import logging
5 |
6 | logger = logging.getLogger(__package__)
7 |
8 | __all__ = [
9 | "logger",
10 | ]
11 |
--------------------------------------------------------------------------------
/thirdparty/wcwidth/version.json:
--------------------------------------------------------------------------------
1 | {"tables": ["4.1.0", "5.0.0", "5.1.0", "5.2.0", "6.0.0", "6.1.0", "6.2.0", "6.3.0", "7.0.0", "8.0.0", "9.0.0", "10.0.0", "11.0.0", "12.0.0", "12.1.0", "13.0.0"], "package": "0.2.4", "default": "8.0.0"}
2 |
--------------------------------------------------------------------------------
/auto_config:
--------------------------------------------------------------------------------
1 | alias h help
2 | alias c cls
3 | alias l 'load'
4 | alias q quit
5 | alias p files
6 | alias sf "run 'clamscan --remove=yes {}' -f $out ; echo ; files"
7 | alias scan "run 'clamscan --remove=yes {} --no-summary ' -f $out" -s
8 |
--------------------------------------------------------------------------------
/thirdparty/rich/region.py:
--------------------------------------------------------------------------------
1 | from typing import NamedTuple
2 |
3 |
4 | class Region(NamedTuple):
5 | """Defines a rectangular region of the screen."""
6 |
7 | x: int
8 | y: int
9 | width: int
10 | height: int
11 |
--------------------------------------------------------------------------------
/sf2.py:
--------------------------------------------------------------------------------
1 | # SignFinder2 by d3ranged
2 |
3 | import sys
4 |
5 | if sys.version_info < (3, 8):
6 | print('\n\tSF2 requires Python 3.8+\n')
7 | sys.exit()
8 |
9 | from core import *
10 |
11 | if __name__ == '__main__':
12 | core = SF_CORE(__file__)
13 | core.start_cli()
14 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/data_structures.py:
--------------------------------------------------------------------------------
1 | from typing import NamedTuple
2 |
3 | __all__ = [
4 | "Point",
5 | "Size",
6 | ]
7 |
8 |
9 | class Point(NamedTuple):
10 | x: int
11 | y: int
12 |
13 |
14 | class Size(NamedTuple):
15 | rows: int
16 | columns: int
17 |
--------------------------------------------------------------------------------
/thirdparty/rich/_extension.py:
--------------------------------------------------------------------------------
1 | from typing import Any
2 |
3 |
4 | def load_ipython_extension(ip: Any) -> None: # pragma: no cover
5 | # prevent circular import
6 | from rich.pretty import install
7 | from rich.traceback import install as tr_install
8 |
9 | install()
10 | tr_install()
11 |
--------------------------------------------------------------------------------
/thirdparty/elftools/__init__.py:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # elftools
3 | #
4 | # Eli Bendersky (eliben@gmail.com)
5 | # This code is in the public domain
6 | #-------------------------------------------------------------------------------
7 | __version__ = '0.28'
8 |
--------------------------------------------------------------------------------
/plugins/__init__.py:
--------------------------------------------------------------------------------
1 | # You can disable any plugin
2 |
3 | from .command_div import *
4 | from .command_pe_info import *
5 | from .command_fill import *
6 | from .command_half import *
7 | from .command_elf_info import *
8 | from .command_vd import *
9 |
10 | from .module_pe32 import *
11 | from .module_elf import *
12 |
13 |
--------------------------------------------------------------------------------
/thirdparty/elftools/construct/lib/__init__.py:
--------------------------------------------------------------------------------
1 | from .binary import (
2 | int_to_bin, bin_to_int, swap_bytes, encode_bin, decode_bin)
3 | from .bitstream import BitStreamReader, BitStreamWriter
4 | from .container import (Container, FlagsContainer, ListContainer,
5 | LazyContainer)
6 | from .hex import HexString, hexdump
7 |
8 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/input/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import DummyInput, Input, PipeInput
2 | from .defaults import create_input, create_pipe_input
3 |
4 | __all__ = [
5 | # Base.
6 | "Input",
7 | "PipeInput",
8 | "DummyInput",
9 | # Defaults.
10 | "create_input",
11 | "create_pipe_input",
12 | ]
13 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/output/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import DummyOutput, Output
2 | from .color_depth import ColorDepth
3 | from .defaults import create_output
4 |
5 | __all__ = [
6 | # Base.
7 | "Output",
8 | "DummyOutput",
9 | # Color depth.
10 | "ColorDepth",
11 | # Defaults.
12 | "create_output",
13 | ]
14 |
--------------------------------------------------------------------------------
/thirdparty/commonmark/__init__.py:
--------------------------------------------------------------------------------
1 | # flake8: noqa
2 | from __future__ import unicode_literals, absolute_import
3 |
4 | from commonmark.main import commonmark
5 | from commonmark.dump import dumpAST, dumpJSON
6 | from commonmark.blocks import Parser
7 | from commonmark.render.html import HtmlRenderer
8 | from commonmark.render.rst import ReStructuredTextRenderer
9 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/enums.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 |
4 | class EditingMode(Enum):
5 | # The set of key bindings that is active.
6 | VI = "VI"
7 | EMACS = "EMACS"
8 |
9 |
10 | #: Name of the search buffer.
11 | SEARCH_BUFFER = "SEARCH_BUFFER"
12 |
13 | #: Name of the default buffer.
14 | DEFAULT_BUFFER = "DEFAULT_BUFFER"
15 |
16 | #: Name of the system buffer.
17 | SYSTEM_BUFFER = "SYSTEM_BUFFER"
18 |
--------------------------------------------------------------------------------
/core/riposte_sf/README.md:
--------------------------------------------------------------------------------
1 | # what RiposteSF is?
2 |
3 | Huge modification of [riposte-0.4.1](https://github.com/fwkz/riposte)
4 |
5 | Special for SignFinder-2.0
6 |
7 | ## change list:
8 | - autoconf file that works like autoexec.bat
9 | - support of aliases and variables
10 | - flags as command's arguments
11 | - windows and linux support
12 | - ansi color repplaced by rich library
13 | - readline replaced by python-prompt-toolkit
--------------------------------------------------------------------------------
/thirdparty/rich/_stack.py:
--------------------------------------------------------------------------------
1 | from typing import List, TypeVar
2 |
3 | T = TypeVar("T")
4 |
5 |
6 | class Stack(List[T]):
7 | """A small shim over builtin list."""
8 |
9 | @property
10 | def top(self) -> T:
11 | """Get top of stack."""
12 | return self[-1]
13 |
14 | def push(self, item: T) -> None:
15 | """Push an item on to the stack (append in stack nomenclature)."""
16 | self.append(item)
17 |
--------------------------------------------------------------------------------
/thirdparty/pygments/__main__.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.__main__
3 | ~~~~~~~~~~~~~~~~~
4 |
5 | Main entry point for ``python -m pygments``.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | import sys
12 | import pygments.cmdline
13 |
14 | try:
15 | sys.exit(pygments.cmdline.main(sys.argv))
16 | except KeyboardInterrupt:
17 | sys.exit(1)
18 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/lexers/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | Lexer interface and implementations.
3 | Used for syntax highlighting.
4 | """
5 | from .base import DynamicLexer, Lexer, SimpleLexer
6 | from .pygments import PygmentsLexer, RegexSync, SyncFromStart, SyntaxSync
7 |
8 | __all__ = [
9 | # Base.
10 | "Lexer",
11 | "SimpleLexer",
12 | "DynamicLexer",
13 | # Pygments.
14 | "PygmentsLexer",
15 | "RegexSync",
16 | "SyncFromStart",
17 | "SyntaxSync",
18 | ]
19 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/clipboard/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import Clipboard, ClipboardData, DummyClipboard, DynamicClipboard
2 | from .in_memory import InMemoryClipboard
3 |
4 | # We are not importing `PyperclipClipboard` here, because it would require the
5 | # `pyperclip` module to be present.
6 |
7 | # from .pyperclip import PyperclipClipboard
8 |
9 | __all__ = [
10 | "Clipboard",
11 | "ClipboardData",
12 | "DummyClipboard",
13 | "DynamicClipboard",
14 | "InMemoryClipboard",
15 | ]
16 |
--------------------------------------------------------------------------------
/thirdparty/rich/_pick.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 |
4 | def pick_bool(*values: Optional[bool]) -> bool:
5 | """Pick the first non-none bool or return the last value.
6 |
7 | Args:
8 | *values (bool): Any number of boolean or None values.
9 |
10 | Returns:
11 | bool: First non-none boolean.
12 | """
13 | assert values, "1 or more values required"
14 | for value in values:
15 | if value is not None:
16 | return value
17 | return bool(value)
18 |
--------------------------------------------------------------------------------
/thirdparty/rich/_timer.py:
--------------------------------------------------------------------------------
1 | """
2 | Timer context manager, only used in debug.
3 |
4 | """
5 |
6 | from time import time
7 |
8 | import contextlib
9 | from typing import Generator
10 |
11 |
12 | @contextlib.contextmanager
13 | def timer(subject: str = "time") -> Generator[None, None, None]:
14 | """print the elapsed time. (only used in debugging)"""
15 | start = time()
16 | yield
17 | elapsed = time() - start
18 | elapsed_ms = elapsed * 1000
19 | print(f"{subject} elapsed {elapsed_ms:.1f}ms")
20 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/key_binding/__init__.py:
--------------------------------------------------------------------------------
1 | from .key_bindings import (
2 | ConditionalKeyBindings,
3 | DynamicKeyBindings,
4 | KeyBindings,
5 | KeyBindingsBase,
6 | merge_key_bindings,
7 | )
8 | from .key_processor import KeyPress, KeyPressEvent
9 |
10 | __all__ = [
11 | # key_bindings.
12 | "ConditionalKeyBindings",
13 | "DynamicKeyBindings",
14 | "KeyBindings",
15 | "KeyBindingsBase",
16 | "merge_key_bindings",
17 | # key_processor
18 | "KeyPress",
19 | "KeyPressEvent",
20 | ]
21 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/key_binding/bindings/focus.py:
--------------------------------------------------------------------------------
1 | from prompt_toolkit.key_binding.key_processor import KeyPressEvent
2 |
3 | __all__ = [
4 | "focus_next",
5 | "focus_previous",
6 | ]
7 |
8 | E = KeyPressEvent
9 |
10 |
11 | def focus_next(event: E) -> None:
12 | """
13 | Focus the next visible Window.
14 | (Often bound to the `Tab` key.)
15 | """
16 | event.app.layout.focus_next()
17 |
18 |
19 | def focus_previous(event: E) -> None:
20 | """
21 | Focus the previous visible Window.
22 | (Often bound to the `BackTab` key.)
23 | """
24 | event.app.layout.focus_previous()
25 |
--------------------------------------------------------------------------------
/core/riposte_sf/exceptions.py:
--------------------------------------------------------------------------------
1 | from typing import Callable
2 |
3 |
4 | class RiposteException(Exception):
5 | pass
6 |
7 |
8 | class StopRiposteException(Exception):
9 | pass
10 |
11 |
12 | class CommandError(RiposteException):
13 | pass
14 |
15 |
16 | class GuideError(RiposteException):
17 | def __init__(self, value: str, guide: Callable):
18 | self.value = value
19 | self.guide = guide
20 |
21 | def __str__(self):
22 | return (
23 | f"GuideError: Can't apply "
24 | f"{self.guide.__name__} guide "
25 | f"to value {self.value}"
26 | )
27 |
--------------------------------------------------------------------------------
/thirdparty/elftools/common/exceptions.py:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # elftools: common/exceptions.py
3 | #
4 | # Exception classes for elftools
5 | #
6 | # Eli Bendersky (eliben@gmail.com)
7 | # This code is in the public domain
8 | #-------------------------------------------------------------------------------
9 | class ELFError(Exception):
10 | pass
11 |
12 | class ELFRelocationError(ELFError):
13 | pass
14 |
15 | class ELFParseError(ELFError):
16 | pass
17 |
18 | class ELFCompressionError(ELFError):
19 | pass
20 |
21 | class DWARFError(Exception):
22 | pass
23 |
--------------------------------------------------------------------------------
/plugins/module_elf.py:
--------------------------------------------------------------------------------
1 | import io
2 |
3 | from core.plugin_aux import *
4 | from core.utils import *
5 | from thirdparty.elftools.elf.elffile import ELFFile
6 |
7 |
8 | class MODULE_ELF(MODULES_BASE):
9 |
10 | name = 'elf'
11 |
12 | def is_my_type(self):
13 | file_data = self.db.get_data()
14 | return file_data[0:4] == b'\x7fELF'
15 |
16 | def load(self):
17 | try:
18 |
19 | stream = io.BytesIO(self.db.get_bytes())
20 |
21 | readelf = ELFFile(stream)
22 |
23 | self.repl.success('ELF detected')
24 |
25 | return readelf
26 |
27 | except Exception as e:
28 | raise ValueError("Invalid ELF file")
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/shortcuts/progress_bar/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import ProgressBar, ProgressBarCounter
2 | from .formatters import (
3 | Bar,
4 | Formatter,
5 | IterationsPerSecond,
6 | Label,
7 | Percentage,
8 | Progress,
9 | Rainbow,
10 | SpinningWheel,
11 | Text,
12 | TimeElapsed,
13 | TimeLeft,
14 | )
15 |
16 | __all__ = [
17 | "ProgressBar",
18 | "ProgressBarCounter",
19 | # Formatters.
20 | "Formatter",
21 | "Text",
22 | "Label",
23 | "Percentage",
24 | "Bar",
25 | "Progress",
26 | "TimeElapsed",
27 | "TimeLeft",
28 | "IterationsPerSecond",
29 | "SpinningWheel",
30 | "Rainbow",
31 | ]
32 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/math.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.math
3 | ~~~~~~~~~~~~~~~~~~~~
4 |
5 | Just export lexers that were contained in this module.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexers.python import NumPyLexer
12 | from pygments.lexers.matlab import MatlabLexer, MatlabSessionLexer, \
13 | OctaveLexer, ScilabLexer
14 | from pygments.lexers.julia import JuliaLexer, JuliaConsoleLexer
15 | from pygments.lexers.r import RConsoleLexer, SLexer, RdLexer
16 | from pygments.lexers.modeling import BugsLexer, JagsLexer, StanLexer
17 | from pygments.lexers.idl import IDLLexer
18 | from pygments.lexers.algebra import MuPADLexer
19 |
20 | __all__ = []
21 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/functional.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.functional
3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 |
5 | Just export lexer classes previously contained in this module.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexers.lisp import SchemeLexer, CommonLispLexer, RacketLexer, \
12 | NewLispLexer, ShenLexer
13 | from pygments.lexers.haskell import HaskellLexer, LiterateHaskellLexer, \
14 | KokaLexer
15 | from pygments.lexers.theorem import CoqLexer
16 | from pygments.lexers.erlang import ErlangLexer, ErlangShellLexer, \
17 | ElixirConsoleLexer, ElixirLexer
18 | from pygments.lexers.ml import SMLLexer, OcamlLexer, OpaLexer
19 |
20 | __all__ = []
21 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/application/__init__.py:
--------------------------------------------------------------------------------
1 | from .application import Application
2 | from .current import (
3 | AppSession,
4 | create_app_session,
5 | create_app_session_from_tty,
6 | get_app,
7 | get_app_or_none,
8 | get_app_session,
9 | set_app,
10 | )
11 | from .dummy import DummyApplication
12 | from .run_in_terminal import in_terminal, run_in_terminal
13 |
14 | __all__ = [
15 | # Application.
16 | "Application",
17 | # Current.
18 | "AppSession",
19 | "get_app_session",
20 | "create_app_session",
21 | "create_app_session_from_tty",
22 | "get_app",
23 | "get_app_or_none",
24 | "set_app",
25 | # Dummy.
26 | "DummyApplication",
27 | # Run_in_terminal
28 | "in_terminal",
29 | "run_in_terminal",
30 | ]
31 |
--------------------------------------------------------------------------------
/thirdparty/rich/errors.py:
--------------------------------------------------------------------------------
1 | class ConsoleError(Exception):
2 | """An error in console operation."""
3 |
4 |
5 | class StyleError(Exception):
6 | """An error in styles."""
7 |
8 |
9 | class StyleSyntaxError(ConsoleError):
10 | """Style was badly formatted."""
11 |
12 |
13 | class MissingStyle(StyleError):
14 | """No such style."""
15 |
16 |
17 | class StyleStackError(ConsoleError):
18 | """Style stack is invalid."""
19 |
20 |
21 | class NotRenderableError(ConsoleError):
22 | """Object is not renderable."""
23 |
24 |
25 | class MarkupError(ConsoleError):
26 | """Markup was badly formatted."""
27 |
28 |
29 | class LiveError(ConsoleError):
30 | """Error related to Live display."""
31 |
32 |
33 | class NoAltScreen(ConsoleError):
34 | """Alt screen mode was required."""
35 |
--------------------------------------------------------------------------------
/thirdparty/pygments/styles/igor.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.styles.igor
3 | ~~~~~~~~~~~~~~~~~~~~
4 |
5 | Igor Pro default style.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.style import Style
12 | from pygments.token import Keyword, Name, Comment, String
13 |
14 |
15 | class IgorStyle(Style):
16 | """
17 | Pygments version of the official colors for Igor Pro procedures.
18 | """
19 |
20 | styles = {
21 | Comment: 'italic #FF0000',
22 | Keyword: '#0000FF',
23 | Name.Function: '#C34E00',
24 | Name.Decorator: '#CC00A3',
25 | Name.Class: '#007575',
26 | String: '#009C00'
27 | }
28 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/eventloop/__init__.py:
--------------------------------------------------------------------------------
1 | from .async_generator import generator_to_async_generator
2 | from .inputhook import (
3 | InputHookContext,
4 | InputHookSelector,
5 | new_eventloop_with_inputhook,
6 | set_eventloop_with_inputhook,
7 | )
8 | from .utils import (
9 | call_soon_threadsafe,
10 | get_event_loop,
11 | get_traceback_from_context,
12 | run_in_executor_with_context,
13 | )
14 |
15 | __all__ = [
16 | # Async generator
17 | "generator_to_async_generator",
18 | # Utils.
19 | "run_in_executor_with_context",
20 | "call_soon_threadsafe",
21 | "get_traceback_from_context",
22 | "get_event_loop",
23 | # Inputhooks.
24 | "new_eventloop_with_inputhook",
25 | "set_eventloop_with_inputhook",
26 | "InputHookSelector",
27 | "InputHookContext",
28 | ]
29 |
--------------------------------------------------------------------------------
/thirdparty/pygments/styles/abap.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.styles.abap
3 | ~~~~~~~~~~~~~~~~~~~~
4 |
5 | ABAP workbench like style.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.style import Style
12 | from pygments.token import Keyword, Name, Comment, String, Error, \
13 | Number, Operator
14 |
15 |
16 | class AbapStyle(Style):
17 |
18 | styles = {
19 | Comment: 'italic #888',
20 | Comment.Special: '#888',
21 | Keyword: '#00f',
22 | Operator.Word: '#00f',
23 | Name: '#000',
24 | Number: '#3af',
25 | String: '#5a2',
26 |
27 | Error: '#F00',
28 | }
29 |
--------------------------------------------------------------------------------
/thirdparty/pygments/styles/staroffice.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.styles.staroffice
3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 |
5 | Style similar to StarOffice style, also in OpenOffice and LibreOffice.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.style import Style
12 | from pygments.token import Comment, Error, Literal, Name, Token
13 |
14 |
15 | class StarofficeStyle(Style):
16 | """
17 | Style similar to StarOffice style, also in OpenOffice and LibreOffice.
18 | """
19 |
20 | styles = {
21 | Token: '#000080', # Blue
22 | Comment: '#696969', # DimGray
23 | Error: '#800000', # Maroon
24 | Literal: '#EE0000', # Red
25 | Name: '#008000', # Green
26 | }
27 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/key_binding/bindings/cpr.py:
--------------------------------------------------------------------------------
1 | from prompt_toolkit.key_binding.key_processor import KeyPressEvent
2 | from prompt_toolkit.keys import Keys
3 |
4 | from ..key_bindings import KeyBindings
5 |
6 | __all__ = [
7 | "load_cpr_bindings",
8 | ]
9 |
10 | E = KeyPressEvent
11 |
12 |
13 | def load_cpr_bindings() -> KeyBindings:
14 | key_bindings = KeyBindings()
15 |
16 | @key_bindings.add(Keys.CPRResponse, save_before=lambda e: False)
17 | def _(event: E) -> None:
18 | """
19 | Handle incoming Cursor-Position-Request response.
20 | """
21 | # The incoming data looks like u'\x1b[35;1R'
22 | # Parse row/col information.
23 | row, col = map(int, event.data[2:-1].split(";"))
24 |
25 | # Report absolute cursor position to the renderer.
26 | event.app.renderer.report_absolute_cursor_row(row)
27 |
28 | return key_bindings
29 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/formatted_text/pygments.py:
--------------------------------------------------------------------------------
1 | from typing import TYPE_CHECKING, List, Tuple
2 |
3 | from prompt_toolkit.styles.pygments import pygments_token_to_classname
4 |
5 | from .base import StyleAndTextTuples
6 |
7 | if TYPE_CHECKING:
8 | from pygments.token import Token
9 |
10 | __all__ = [
11 | "PygmentsTokens",
12 | ]
13 |
14 |
15 | class PygmentsTokens:
16 | """
17 | Turn a pygments token list into a list of prompt_toolkit text fragments
18 | (``(style_str, text)`` tuples).
19 | """
20 |
21 | def __init__(self, token_list: List[Tuple["Token", str]]) -> None:
22 | self.token_list = token_list
23 |
24 | def __pt_formatted_text__(self) -> StyleAndTextTuples:
25 | result: StyleAndTextTuples = []
26 |
27 | for token, text in self.token_list:
28 | result.append(("class:" + pygments_token_to_classname(token), text))
29 |
30 | return result
31 |
--------------------------------------------------------------------------------
/core/config.py:
--------------------------------------------------------------------------------
1 | """
2 | Global config
3 | """
4 |
5 | SF_SKIP_BANNER = 0
6 | SF_SKIP_GOODBYE = False
7 | SF_CLS_AFTER = 0
8 | SF_DOUBLE_MARGIN = True
9 |
10 | SF_URL = 'https://github.com/d3ranged/sf2'
11 | SF_BLOG = 'd3ranged.github.io'
12 |
13 | SF_VERSION = '2.0'
14 | SF_DATE = '31.12.22'
15 |
16 | SF_BANNER = fr'''
17 | [SignFinder {SF_VERSION} by d3ranged]
18 | '''
19 |
20 | SF_CLI_VER = f'''
21 | SignFinder {SF_VERSION}
22 |
23 | {SF_URL}
24 | '''
25 |
26 | SF_PROMPT = "sf2"
27 | SF_HIST_NAME = 'sf2.log'
28 | SF_HIST_LEN = 1000
29 | SF_AUTO_NAME = 'auto_config'
30 | SF_OUT_DIR= 'output'
31 |
32 |
33 | SF_BACKUP_DIR = 'backups'
34 | SF_BACKUP_INPUT = True
35 | SF_REMOVE_OUTPUT = True
36 | SF_DEBUG = 0
37 | SF_DEBUG_PM = 0
38 |
39 | MAX_INPUT_FILE_SIZE = 1024 * 1024 * 100 # 100MB
40 | MAX_CALC_ENTROPY_SIZE = 1024 * 1024 * 15 # 15MB
41 | SF_LINE_SIZE = 80
42 | SF_BAR_EMPTY = '░'
43 | SF_BAR_FULL = '█'
44 | SF_BAR_PART = '▒'
45 |
46 | # ░ ▒ ▓ █
47 |
48 |
--------------------------------------------------------------------------------
/thirdparty/wcwidth/unicode_versions.py:
--------------------------------------------------------------------------------
1 | """
2 | Exports function list_versions() for unicode version level support.
3 |
4 | This code generated by bin/update-tables.py on 2020-06-23 16:03:21.350604.
5 | """
6 |
7 |
8 | def list_versions():
9 | """
10 | Return Unicode version levels supported by this module release.
11 |
12 | Any of the version strings returned may be used as keyword argument
13 | ``unicode_version`` to the ``wcwidth()`` family of functions.
14 |
15 | :returns: Supported Unicode version numbers in ascending sorted order.
16 | :rtype: list[str]
17 | """
18 | return (
19 | "4.1.0",
20 | "5.0.0",
21 | "5.1.0",
22 | "5.2.0",
23 | "6.0.0",
24 | "6.1.0",
25 | "6.2.0",
26 | "6.3.0",
27 | "7.0.0",
28 | "8.0.0",
29 | "9.0.0",
30 | "10.0.0",
31 | "11.0.0",
32 | "12.0.0",
33 | "12.1.0",
34 | "13.0.0",
35 | )
36 |
--------------------------------------------------------------------------------
/thirdparty/rich/pager.py:
--------------------------------------------------------------------------------
1 | from abc import ABC, abstractmethod
2 | from typing import Any
3 |
4 |
5 | class Pager(ABC):
6 | """Base class for a pager."""
7 |
8 | @abstractmethod
9 | def show(self, content: str) -> None:
10 | """Show content in pager.
11 |
12 | Args:
13 | content (str): Content to be displayed.
14 | """
15 |
16 |
17 | class SystemPager(Pager):
18 | """Uses the pager installed on the system."""
19 |
20 | def _pager(self, content: str) -> Any: # pragma: no cover
21 | return __import__("pydoc").pager(content)
22 |
23 | def show(self, content: str) -> None:
24 | """Use the same pager used by pydoc."""
25 | self._pager(content)
26 |
27 |
28 | if __name__ == "__main__": # pragma: no cover
29 | from .__main__ import make_test_card
30 | from .console import Console
31 |
32 | console = Console()
33 | with console.pager(styles=True):
34 | console.print(make_test_card())
35 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/agile.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.agile
3 | ~~~~~~~~~~~~~~~~~~~~~
4 |
5 | Just export lexer classes previously contained in this module.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexers.lisp import SchemeLexer
12 | from pygments.lexers.jvm import IokeLexer, ClojureLexer
13 | from pygments.lexers.python import PythonLexer, PythonConsoleLexer, \
14 | PythonTracebackLexer, Python3Lexer, Python3TracebackLexer, DgLexer
15 | from pygments.lexers.ruby import RubyLexer, RubyConsoleLexer, FancyLexer
16 | from pygments.lexers.perl import PerlLexer, Perl6Lexer
17 | from pygments.lexers.d import CrocLexer, MiniDLexer
18 | from pygments.lexers.iolang import IoLexer
19 | from pygments.lexers.tcl import TclLexer
20 | from pygments.lexers.factor import FactorLexer
21 | from pygments.lexers.scripting import LuaLexer, MoonScriptLexer
22 |
23 | __all__ = []
24 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/gcodelexer.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.gcodelexer
3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 |
5 | Lexers for the G Code Language.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexer import RegexLexer, bygroups
12 | from pygments.token import Comment, Name, Text, Keyword, Number
13 |
14 | __all__ = ['GcodeLexer']
15 |
16 |
17 | class GcodeLexer(RegexLexer):
18 | """
19 | For gcode source code.
20 |
21 | .. versionadded:: 2.9
22 | """
23 | name = 'g-code'
24 | aliases = ['gcode']
25 | filenames = ['*.gcode']
26 |
27 | tokens = {
28 | 'root': [
29 | (r';.*\n', Comment),
30 | (r'^[gmGM]\d{1,4}\s', Name.Builtin), # M or G commands
31 | (r'([^gGmM])([+-]?\d*[.]?\d+)', bygroups(Keyword, Number)),
32 | (r'\s', Text.Whitespace),
33 | (r'.*\n', Text),
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/web.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.web
3 | ~~~~~~~~~~~~~~~~~~~
4 |
5 | Just export previously exported lexers.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexers.html import HtmlLexer, DtdLexer, XmlLexer, XsltLexer, \
12 | HamlLexer, ScamlLexer, JadeLexer
13 | from pygments.lexers.css import CssLexer, SassLexer, ScssLexer
14 | from pygments.lexers.javascript import JavascriptLexer, LiveScriptLexer, \
15 | DartLexer, TypeScriptLexer, LassoLexer, ObjectiveJLexer, CoffeeScriptLexer
16 | from pygments.lexers.actionscript import ActionScriptLexer, \
17 | ActionScript3Lexer, MxmlLexer
18 | from pygments.lexers.php import PhpLexer
19 | from pygments.lexers.webmisc import DuelLexer, XQueryLexer, SlimLexer, QmlLexer
20 | from pygments.lexers.data import JsonLexer
21 | JSONLexer = JsonLexer # for backwards compatibility with Pygments 1.5
22 |
23 | __all__ = []
24 |
--------------------------------------------------------------------------------
/thirdparty/rich/abc.py:
--------------------------------------------------------------------------------
1 | from abc import ABC
2 |
3 |
4 | class RichRenderable(ABC):
5 | """An abstract base class for Rich renderables.
6 |
7 | Note that there is no need to extend this class, the intended use is to check if an
8 | object supports the Rich renderable protocol. For example::
9 |
10 | if isinstance(my_object, RichRenderable):
11 | console.print(my_object)
12 |
13 | """
14 |
15 | @classmethod
16 | def __subclasshook__(cls, other: type) -> bool:
17 | """Check if this class supports the rich render protocol."""
18 | return hasattr(other, "__rich_console__") or hasattr(other, "__rich__")
19 |
20 |
21 | if __name__ == "__main__": # pragma: no cover
22 | from rich.text import Text
23 |
24 | t = Text()
25 | print(isinstance(Text, RichRenderable))
26 | print(isinstance(t, RichRenderable))
27 |
28 | class Foo:
29 | pass
30 |
31 | f = Foo()
32 | print(isinstance(f, RichRenderable))
33 | print(isinstance("", RichRenderable))
34 |
--------------------------------------------------------------------------------
/thirdparty/pygments/styles/rrt.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.styles.rrt
3 | ~~~~~~~~~~~~~~~~~~~
4 |
5 | pygments "rrt" theme, based on Zap and Emacs defaults.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.style import Style
12 | from pygments.token import Token, Comment, Name, Keyword, String
13 |
14 |
15 | class RrtStyle(Style):
16 | """
17 | Minimalistic "rrt" theme, based on Zap and Emacs defaults.
18 | """
19 |
20 | background_color = '#000000'
21 | highlight_color = '#0000ff'
22 |
23 | styles = {
24 | Token: '#dddddd',
25 | Comment: '#00ff00',
26 | Name.Function: '#ffff00',
27 | Name.Variable: '#eedd82',
28 | Name.Constant: '#7fffd4',
29 | Keyword: '#ff0000',
30 | Comment.Preproc: '#e5e5e5',
31 | String: '#87ceeb',
32 | Keyword.Type: '#ee82ee',
33 | }
34 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/filters/utils.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from .base import Always, Filter, FilterOrBool, Never
4 |
5 | __all__ = [
6 | "to_filter",
7 | "is_true",
8 | ]
9 |
10 |
11 | _always = Always()
12 | _never = Never()
13 |
14 |
15 | _bool_to_filter: Dict[bool, Filter] = {
16 | True: _always,
17 | False: _never,
18 | }
19 |
20 |
21 | def to_filter(bool_or_filter: FilterOrBool) -> Filter:
22 | """
23 | Accept both booleans and Filters as input and
24 | turn it into a Filter.
25 | """
26 | if isinstance(bool_or_filter, bool):
27 | return _bool_to_filter[bool_or_filter]
28 |
29 | if isinstance(bool_or_filter, Filter):
30 | return bool_or_filter
31 |
32 | raise TypeError("Expecting a bool or a Filter instance. Got %r" % bool_or_filter)
33 |
34 |
35 | def is_true(value: FilterOrBool) -> bool:
36 | """
37 | Test whether `value` is True. In case of a Filter, call it.
38 |
39 | :param value: Boolean or `Filter` instance.
40 | """
41 | return to_filter(value)()
42 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/key_binding/emacs_state.py:
--------------------------------------------------------------------------------
1 | from typing import List, Optional
2 |
3 | from .key_processor import KeyPress
4 |
5 | __all__ = [
6 | "EmacsState",
7 | ]
8 |
9 |
10 | class EmacsState:
11 | """
12 | Mutable class to hold Emacs specific state.
13 | """
14 |
15 | def __init__(self) -> None:
16 | # Simple macro recording. (Like Readline does.)
17 | # (For Emacs mode.)
18 | self.macro: Optional[List[KeyPress]] = []
19 | self.current_recording: Optional[List[KeyPress]] = None
20 |
21 | def reset(self) -> None:
22 | self.current_recording = None
23 |
24 | @property
25 | def is_recording(self) -> bool:
26 | "Tell whether we are recording a macro."
27 | return self.current_recording is not None
28 |
29 | def start_macro(self) -> None:
30 | "Start recording macro."
31 | self.current_recording = []
32 |
33 | def end_macro(self) -> None:
34 | "End recording macro."
35 | self.macro = self.current_recording
36 | self.current_recording = None
37 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/xorg.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.xorg
3 | ~~~~~~~~~~~~~~~~~~~~
4 |
5 | Lexers for Xorg configs.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexer import RegexLexer, bygroups
12 | from pygments.token import Comment, String, Name, Text
13 |
14 | __all__ = ['XorgLexer']
15 |
16 |
17 | class XorgLexer(RegexLexer):
18 | """Lexer for xorg.conf file."""
19 | name = 'Xorg'
20 | url = 'https://www.x.org/wiki/'
21 | aliases = ['xorg.conf']
22 | filenames = ['xorg.conf']
23 | mimetypes = []
24 |
25 | tokens = {
26 | 'root': [
27 | (r'\s+', Text),
28 | (r'#.*$', Comment),
29 |
30 | (r'((?:Sub)?Section)(\s+)("\w+")',
31 | bygroups(String.Escape, Text, String.Escape)),
32 | (r'(End(?:Sub)?Section)', String.Escape),
33 |
34 | (r'(\w+)(\s+)([^\n#]+)',
35 | bygroups(Name.Builtin, Text, Name.Constant)),
36 | ],
37 | }
38 |
--------------------------------------------------------------------------------
/thirdparty/rich/diagnose.py:
--------------------------------------------------------------------------------
1 | import os
2 | import platform
3 |
4 | from rich import inspect
5 | from rich.console import Console, get_windows_console_features
6 | from rich.panel import Panel
7 | from rich.pretty import Pretty
8 |
9 |
10 | def report() -> None: # pragma: no cover
11 | """Print a report to the terminal with debugging information"""
12 | console = Console()
13 | inspect(console)
14 | features = get_windows_console_features()
15 | inspect(features)
16 |
17 | env_names = (
18 | "TERM",
19 | "COLORTERM",
20 | "CLICOLOR",
21 | "NO_COLOR",
22 | "TERM_PROGRAM",
23 | "COLUMNS",
24 | "LINES",
25 | "JUPYTER_COLUMNS",
26 | "JUPYTER_LINES",
27 | "JPY_PARENT_PID",
28 | "VSCODE_VERBOSE_LOGGING",
29 | )
30 | env = {name: os.getenv(name) for name in env_names}
31 | console.print(Panel.fit((Pretty(env)), title="[b]Environment Variables"))
32 |
33 | console.print(f'platform="{platform.system()}"')
34 |
35 |
36 | if __name__ == "__main__": # pragma: no cover
37 | report()
38 |
--------------------------------------------------------------------------------
/core/riposte_sf/flag_parser.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | class FlagParser:
4 |
5 | '''
6 | "command arg1 arg2 -1 666 12 -2 3 -aaa"
7 | =>
8 | ('arg1', 'arg2', '-1', '666', '12', '-2', '3', '-aaaa')
9 | =>
10 | [aaaa(()), 2(('3',)), 1(('666', '12'))]
11 | '''
12 |
13 | def _get_flag_idx(self, inp):
14 | return [idx for idx, i in enumerate(inp) if i.startswith('-')]
15 |
16 | def _get_flag_data(self, inp):
17 | for idx in reversed(self._get_flag_idx(inp)):
18 | yield inp[idx:]
19 | inp = inp[:idx]
20 |
21 | def _parse_flags(self, inp):
22 | flag_lst = self._get_flag_data(inp)
23 | for item in flag_lst:
24 | cmd = item[0].replace('-','')
25 | args = item[1:]
26 | yield cmd, args
27 |
28 | def remove_flags(self, inp):
29 | idx = list(self._get_flag_idx(inp))
30 | if not idx: return inp
31 | return inp[:idx[0]]
32 |
33 | def parse(self, inp):
34 | return dict(self._parse_flags(inp))
35 |
36 |
37 | def get_format_arg_count(mask):
38 |
39 | for i in range(150):
40 |
41 | try:
42 | out_str = mask.format(*list(range(i)))
43 | return i
44 | except IndexError:
45 | pass
46 |
47 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | prompt_toolkit
3 | ==============
4 |
5 | Author: Jonathan Slenders
6 |
7 | Description: prompt_toolkit is a Library for building powerful interactive
8 | command lines in Python. It can be a replacement for GNU
9 | Readline, but it can be much more than that.
10 |
11 | See the examples directory to learn about the usage.
12 |
13 | Probably, to get started, you might also want to have a look at
14 | `prompt_toolkit.shortcuts.prompt`.
15 | """
16 | from .application import Application
17 | from .formatted_text import ANSI, HTML
18 | from .shortcuts import PromptSession, print_formatted_text, prompt
19 |
20 | # Don't forget to update in `docs/conf.py`!
21 | __version__ = "3.0.31"
22 |
23 | # Version tuple.
24 | VERSION = tuple(__version__.split("."))
25 |
26 |
27 | __all__ = [
28 | # Application.
29 | "Application",
30 | # Shortcuts.
31 | "prompt",
32 | "PromptSession",
33 | "print_formatted_text",
34 | # Formatted text.
35 | "HTML",
36 | "ANSI",
37 | # Version info.
38 | "__version__",
39 | "VERSION",
40 | ]
41 |
--------------------------------------------------------------------------------
/core/riposte_sf/guides.py:
--------------------------------------------------------------------------------
1 | import ast
2 | from typing import Any, AnyStr, Callable, Dict, Text, Tuple
3 |
4 | from .exceptions import GuideError
5 |
6 |
7 | def literal(value: str) -> Any:
8 | try:
9 | return ast.literal_eval(value)
10 | except Exception:
11 | raise GuideError(value, literal)
12 |
13 |
14 | def encode(value: str) -> Any:
15 | try:
16 | return value.encode()
17 | except Exception:
18 | raise GuideError(value, encode)
19 |
20 |
21 | def get_guides(annotation) -> Tuple[Callable]:
22 | """ Based on given annotation get chain of guides. """
23 |
24 | if annotation in (str, AnyStr, Text):
25 | return ()
26 | elif annotation is bytes:
27 | return (encode,)
28 | elif annotation in (int,): # patch
29 | return (annotation,) # patch
30 | else:
31 | return (literal,)
32 |
33 |
34 | def extract_guides(func: Callable) -> Dict[str, Tuple[Callable]]:
35 | """ Extract guides out of type-annotations. """
36 | return {
37 | arg: get_guides(annotation)
38 | for arg, annotation in func.__annotations__.items()
39 | }
40 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/shortcuts/__init__.py:
--------------------------------------------------------------------------------
1 | from .dialogs import (
2 | button_dialog,
3 | checkboxlist_dialog,
4 | input_dialog,
5 | message_dialog,
6 | progress_dialog,
7 | radiolist_dialog,
8 | yes_no_dialog,
9 | )
10 | from .progress_bar import ProgressBar, ProgressBarCounter
11 | from .prompt import (
12 | CompleteStyle,
13 | PromptSession,
14 | confirm,
15 | create_confirm_session,
16 | prompt,
17 | )
18 | from .utils import clear, clear_title, print_container, print_formatted_text, set_title
19 |
20 | __all__ = [
21 | # Dialogs.
22 | "input_dialog",
23 | "message_dialog",
24 | "progress_dialog",
25 | "checkboxlist_dialog",
26 | "radiolist_dialog",
27 | "yes_no_dialog",
28 | "button_dialog",
29 | # Prompts.
30 | "PromptSession",
31 | "prompt",
32 | "confirm",
33 | "create_confirm_session",
34 | "CompleteStyle",
35 | # Progress bars.
36 | "ProgressBar",
37 | "ProgressBarCounter",
38 | # Utils.
39 | "clear",
40 | "clear_title",
41 | "print_container",
42 | "print_formatted_text",
43 | "set_title",
44 | ]
45 |
--------------------------------------------------------------------------------
/thirdparty/pygments/lexers/text.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.lexers.text
3 | ~~~~~~~~~~~~~~~~~~~~
4 |
5 | Lexers for non-source code file types.
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | from pygments.lexers.configs import ApacheConfLexer, NginxConfLexer, \
12 | SquidConfLexer, LighttpdConfLexer, IniLexer, RegeditLexer, PropertiesLexer, \
13 | UnixConfigLexer
14 | from pygments.lexers.console import PyPyLogLexer
15 | from pygments.lexers.textedit import VimLexer
16 | from pygments.lexers.markup import BBCodeLexer, MoinWikiLexer, RstLexer, \
17 | TexLexer, GroffLexer
18 | from pygments.lexers.installers import DebianControlLexer, SourcesListLexer
19 | from pygments.lexers.make import MakefileLexer, BaseMakefileLexer, CMakeLexer
20 | from pygments.lexers.haxe import HxmlLexer
21 | from pygments.lexers.sgf import SmartGameFormatLexer
22 | from pygments.lexers.diff import DiffLexer, DarcsPatchLexer
23 | from pygments.lexers.data import YamlLexer
24 | from pygments.lexers.textfmts import IrcLogsLexer, GettextLexer, HttpLexer
25 |
26 | __all__ = []
27 |
--------------------------------------------------------------------------------
/core/utils/ByteTools.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import math
3 | from collections import Counter
4 |
5 |
6 | class ByteTools:
7 |
8 | @staticmethod
9 | def str2bytes(new_bytes):
10 | if sys.version_info >= (3, 0):
11 | return bytes(new_bytes, 'utf-8')
12 | # python 2 have only 'str'
13 | return new_bytes
14 |
15 | @staticmethod
16 | def bytes2str(new_bytes):
17 | return new_bytes.decode("utf-8")
18 |
19 | @staticmethod
20 | def entropy(data):
21 | """Calculate the entropy of a chunk of data."""
22 |
23 | if not data:
24 | return 0.0
25 |
26 | occurences = Counter(bytearray(data))
27 |
28 | entropy = 0
29 | for x in occurences.values():
30 | p_x = float(x) / len(data)
31 | entropy -= p_x * math.log(p_x, 2)
32 |
33 | return entropy
34 |
35 | @staticmethod
36 | def bytes2int(raw_bytes):
37 | return int.from_bytes(raw_bytes, 'big', signed = False)
38 |
39 | @staticmethod
40 | def int2bytes(number, fill_size = 0):
41 | assert(number > 0)
42 | bytes_required = max(1, math.ceil(number.bit_length() / 8))
43 | if fill_size > 0: return number.to_bytes(fill_size, 'big')
44 | return number.to_bytes(bytes_required, 'big', signed = False)
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/completion/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import (
2 | CompleteEvent,
3 | Completer,
4 | Completion,
5 | ConditionalCompleter,
6 | DummyCompleter,
7 | DynamicCompleter,
8 | ThreadedCompleter,
9 | get_common_complete_suffix,
10 | merge_completers,
11 | )
12 | from .deduplicate import DeduplicateCompleter
13 | from .filesystem import ExecutableCompleter, PathCompleter
14 | from .fuzzy_completer import FuzzyCompleter, FuzzyWordCompleter
15 | from .nested import NestedCompleter
16 | from .word_completer import WordCompleter
17 |
18 | __all__ = [
19 | # Base.
20 | "Completion",
21 | "Completer",
22 | "ThreadedCompleter",
23 | "DummyCompleter",
24 | "DynamicCompleter",
25 | "CompleteEvent",
26 | "ConditionalCompleter",
27 | "merge_completers",
28 | "get_common_complete_suffix",
29 | # Filesystem.
30 | "PathCompleter",
31 | "ExecutableCompleter",
32 | # Fuzzy
33 | "FuzzyCompleter",
34 | "FuzzyWordCompleter",
35 | # Nested.
36 | "NestedCompleter",
37 | # Word completer.
38 | "WordCompleter",
39 | # Deduplicate
40 | "DeduplicateCompleter",
41 | ]
42 |
--------------------------------------------------------------------------------
/thirdparty/pefile/ordlookup/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | import sys
3 | from . import ws2_32
4 | from . import oleaut32
5 |
6 | """
7 | A small module for keeping a database of ordinal to symbol
8 | mappings for DLLs which frequently get linked without symbolic
9 | infoz.
10 | """
11 |
12 | ords = {
13 | b"ws2_32.dll": ws2_32.ord_names,
14 | b"wsock32.dll": ws2_32.ord_names,
15 | b"oleaut32.dll": oleaut32.ord_names,
16 | }
17 |
18 | PY3 = sys.version_info > (3,)
19 |
20 | if PY3:
21 |
22 | def formatOrdString(ord_val):
23 | return "ord{}".format(ord_val).encode()
24 |
25 |
26 | else:
27 |
28 | def formatOrdString(ord_val):
29 | return b"ord%d" % ord_val
30 |
31 |
32 | def ordLookup(libname, ord_val, make_name=False):
33 | """
34 | Lookup a name for the given ordinal if it's in our
35 | database.
36 | """
37 | names = ords.get(libname.lower())
38 | if names is None:
39 | if make_name is True:
40 | return formatOrdString(ord_val)
41 | return None
42 | name = names.get(ord_val)
43 | if name is None:
44 | return formatOrdString(ord_val)
45 | return name
46 |
--------------------------------------------------------------------------------
/thirdparty/pygments/modeline.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.modeline
3 | ~~~~~~~~~~~~~~~~~
4 |
5 | A simple modeline parser (based on pymodeline).
6 |
7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8 | :license: BSD, see LICENSE for details.
9 | """
10 |
11 | import re
12 |
13 | __all__ = ['get_filetype_from_buffer']
14 |
15 |
16 | modeline_re = re.compile(r'''
17 | (?: vi | vim | ex ) (?: [<=>]? \d* )? :
18 | .* (?: ft | filetype | syn | syntax ) = ( [^:\s]+ )
19 | ''', re.VERBOSE)
20 |
21 |
22 | def get_filetype_from_line(l):
23 | m = modeline_re.search(l)
24 | if m:
25 | return m.group(1)
26 |
27 |
28 | def get_filetype_from_buffer(buf, max_lines=5):
29 | """
30 | Scan the buffer for modelines and return filetype if one is found.
31 | """
32 | lines = buf.splitlines()
33 | for l in lines[-1:-max_lines-1:-1]:
34 | ret = get_filetype_from_line(l)
35 | if ret:
36 | return ret
37 | for i in range(max_lines, -1, -1):
38 | if i < len(lines):
39 | ret = get_filetype_from_line(lines[i])
40 | if ret:
41 | return ret
42 |
43 | return None
44 |
--------------------------------------------------------------------------------
/thirdparty/prompt_toolkit/layout/dummy.py:
--------------------------------------------------------------------------------
1 | """
2 | Dummy layout. Used when somebody creates an `Application` without specifying a
3 | `Layout`.
4 | """
5 | from prompt_toolkit.formatted_text import HTML
6 | from prompt_toolkit.key_binding import KeyBindings
7 | from prompt_toolkit.key_binding.key_processor import KeyPressEvent
8 |
9 | from .containers import Window
10 | from .controls import FormattedTextControl
11 | from .dimension import D
12 | from .layout import Layout
13 |
14 | __all__ = [
15 | "create_dummy_layout",
16 | ]
17 |
18 | E = KeyPressEvent
19 |
20 |
21 | def create_dummy_layout() -> Layout:
22 | """
23 | Create a dummy layout for use in an 'Application' that doesn't have a
24 | layout specified. When ENTER is pressed, the application quits.
25 | """
26 | kb = KeyBindings()
27 |
28 | @kb.add("enter")
29 | def enter(event: E) -> None:
30 | event.app.exit()
31 |
32 | control = FormattedTextControl(
33 | HTML("No layout specified. Press
hello
\\n' 27 | """ 28 | parser = Parser() 29 | ast = parser.parse(text) 30 | if format not in ["html", "json", "ast", "rst"]: 31 | raise ValueError("format must be 'html', 'json' or 'ast'") 32 | if format == "html": 33 | renderer = HtmlRenderer() 34 | return renderer.render(ast) 35 | if format == "json": 36 | return dumpJSON(ast) 37 | if format == "ast": 38 | return dumpAST(ast) 39 | if format == "rst": 40 | renderer = ReStructuredTextRenderer() 41 | return renderer.render(ast) 42 | -------------------------------------------------------------------------------- /thirdparty/rich/constrain.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, TYPE_CHECKING 2 | 3 | from .jupyter import JupyterMixin 4 | from .measure import Measurement 5 | 6 | if TYPE_CHECKING: 7 | from .console import Console, ConsoleOptions, RenderableType, RenderResult 8 | 9 | 10 | class Constrain(JupyterMixin): 11 | """Constrain the width of a renderable to a given number of characters. 12 | 13 | Args: 14 | renderable (RenderableType): A renderable object. 15 | width (int, optional): The maximum width (in characters) to render. Defaults to 80. 16 | """ 17 | 18 | def __init__(self, renderable: "RenderableType", width: Optional[int] = 80) -> None: 19 | self.renderable = renderable 20 | self.width = width 21 | 22 | def __rich_console__( 23 | self, console: "Console", options: "ConsoleOptions" 24 | ) -> "RenderResult": 25 | if self.width is None: 26 | yield self.renderable 27 | else: 28 | child_options = options.update_width(min(self.width, options.max_width)) 29 | yield from console.render(self.renderable, child_options) 30 | 31 | def __rich_measure__( 32 | self, console: "Console", options: "ConsoleOptions" 33 | ) -> "Measurement": 34 | if self.width is not None: 35 | options = options.update_width(self.width) 36 | measurement = Measurement.get(console, options, self.renderable) 37 | return measurement 38 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/fruity.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.fruity 3 | ~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | pygments version of my "fruity" vim theme. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Token, Comment, Name, Keyword, \ 13 | Generic, Number, String, Whitespace 14 | 15 | class FruityStyle(Style): 16 | """ 17 | Pygments version of the "native" vim theme. 18 | """ 19 | 20 | background_color = '#111111' 21 | highlight_color = '#333333' 22 | 23 | styles = { 24 | Whitespace: '#888888', 25 | Token: '#ffffff', 26 | Generic.Output: '#444444 bg:#222222', 27 | Keyword: '#fb660a bold', 28 | Keyword.Pseudo: 'nobold', 29 | Number: '#0086f7 bold', 30 | Name.Tag: '#fb660a bold', 31 | Name.Variable: '#fb660a', 32 | Comment: '#008800 bg:#0f140f italic', 33 | Name.Attribute: '#ff0086 bold', 34 | String: '#0086d2', 35 | Name.Function: '#ff0086 bold', 36 | Generic.Heading: '#ffffff bold', 37 | Keyword.Type: '#cdcaa9 bold', 38 | Generic.Subheading: '#ffffff bold', 39 | Name.Constant: '#0086d2', 40 | Comment.Preproc: '#ff0007 bold' 41 | } 42 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/widgets/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Collection of reusable components for building full screen applications. 3 | These are higher level abstractions on top of the `prompt_toolkit.layout` 4 | module. 5 | 6 | Most of these widgets implement the ``__pt_container__`` method, which makes it 7 | possible to embed these in the layout like any other container. 8 | """ 9 | from .base import ( 10 | Box, 11 | Button, 12 | Checkbox, 13 | CheckboxList, 14 | Frame, 15 | HorizontalLine, 16 | Label, 17 | ProgressBar, 18 | RadioList, 19 | Shadow, 20 | TextArea, 21 | VerticalLine, 22 | ) 23 | from .dialogs import Dialog 24 | from .menus import MenuContainer, MenuItem 25 | from .toolbars import ( 26 | ArgToolbar, 27 | CompletionsToolbar, 28 | FormattedTextToolbar, 29 | SearchToolbar, 30 | SystemToolbar, 31 | ValidationToolbar, 32 | ) 33 | 34 | __all__ = [ 35 | # Base. 36 | "TextArea", 37 | "Label", 38 | "Button", 39 | "Frame", 40 | "Shadow", 41 | "Box", 42 | "VerticalLine", 43 | "HorizontalLine", 44 | "CheckboxList", 45 | "RadioList", 46 | "Checkbox", 47 | "ProgressBar", 48 | # Toolbars. 49 | "ArgToolbar", 50 | "CompletionsToolbar", 51 | "FormattedTextToolbar", 52 | "SearchToolbar", 53 | "SystemToolbar", 54 | "ValidationToolbar", 55 | # Dialogs. 56 | "Dialog", 57 | # Menus. 58 | "MenuContainer", 59 | "MenuItem", 60 | ] 61 | -------------------------------------------------------------------------------- /plugins/command_fill.py: -------------------------------------------------------------------------------- 1 | from core.plugin_aux import * 2 | from core.utils import * 3 | 4 | 5 | class COMMAND_FILL(COMMANDS_BASE): 6 | 7 | ''' 8 | DESCRIPTION 9 | 10 | Replace data in specific ranges 11 | 12 | EXAMPLES 13 | 14 | fill 15 | no args, write a copy of current file 16 | 17 | fill 0+100 18 | replace first 100 bytes 19 | 20 | fill 0+10 300+10 400-500 21 | we can use as many ranges as we want 22 | ''' 23 | 24 | def __init__(self): 25 | self.name = 'fill' 26 | self.desc = 'cleaning; replacement by list' 27 | self.no_flags = False 28 | self.category = 'clean' 29 | 30 | 31 | def get_range_list(self, in_list): 32 | range_list = list() 33 | 34 | for item in in_list: 35 | 36 | in_range = self.inp.parse_range(item) 37 | 38 | if isinstance(in_range, RangeList): 39 | range_list += in_range 40 | 41 | if isinstance(in_range, Range): 42 | range_list.append(in_range) 43 | 44 | if in_range is None: 45 | raise ValueError(f'invalid arg - {item}') 46 | 47 | optimized = RangeTools.concat_list(range_list) 48 | self.repl.status(f'list: {optimized}') 49 | return optimized 50 | 51 | 52 | def execute(self, *range_str): 53 | 54 | range_list = self.get_range_list(range_str) 55 | 56 | new_data = self.db.copy() 57 | 58 | for offset, size in range_list: 59 | new_data.replace_standard(offset, size) 60 | 61 | self.fi.new_file(new_data, 'FILL') 62 | 63 | -------------------------------------------------------------------------------- /thirdparty/elftools/construct/lib/hex.py: -------------------------------------------------------------------------------- 1 | from .py3compat import byte2int, int2byte, bytes2str 2 | 3 | 4 | # Map an integer in the inclusive range 0-255 to its string byte representation 5 | _printable = dict((i, ".") for i in range(256)) 6 | _printable.update((i, bytes2str(int2byte(i))) for i in range(32, 128)) 7 | 8 | 9 | def hexdump(data, linesize): 10 | """ 11 | data is a bytes object. The returned result is a string. 12 | """ 13 | prettylines = [] 14 | if len(data) < 65536: 15 | fmt = "%%04X %%-%ds %%s" 16 | else: 17 | fmt = "%%08X %%-%ds %%s" 18 | fmt = fmt % (3 * linesize - 1,) 19 | for i in range(0, len(data), linesize): 20 | line = data[i : i + linesize] 21 | hextext = " ".join('%02x' % byte2int(b) for b in line) 22 | rawtext = "".join(_printable[byte2int(b)] for b in line) 23 | prettylines.append(fmt % (i, str(hextext), str(rawtext))) 24 | return prettylines 25 | 26 | 27 | class HexString(bytes): 28 | """ 29 | Represents bytes that will be hex-dumped to a string when its string 30 | representation is requested. 31 | """ 32 | def __init__(self, data, linesize = 16): 33 | self.linesize = linesize 34 | 35 | def __new__(cls, data, *args, **kwargs): 36 | return bytes.__new__(cls, data) 37 | 38 | def __str__(self): 39 | if not self: 40 | return "''" 41 | sep = "\n" 42 | return sep + sep.join( 43 | hexdump(self, self.linesize)) 44 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/bw.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.bw 3 | ~~~~~~~~~~~~~~~~~~ 4 | 5 | Simple black/white only style. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Keyword, Name, Comment, String, Error, \ 13 | Operator, Generic 14 | 15 | 16 | class BlackWhiteStyle(Style): 17 | 18 | background_color = "#ffffff" 19 | 20 | styles = { 21 | Comment: "italic", 22 | Comment.Preproc: "noitalic", 23 | 24 | Keyword: "bold", 25 | Keyword.Pseudo: "nobold", 26 | Keyword.Type: "nobold", 27 | 28 | Operator.Word: "bold", 29 | 30 | Name.Class: "bold", 31 | Name.Namespace: "bold", 32 | Name.Exception: "bold", 33 | Name.Entity: "bold", 34 | Name.Tag: "bold", 35 | 36 | String: "italic", 37 | String.Interpol: "bold", 38 | String.Escape: "bold", 39 | 40 | Generic.Heading: "bold", 41 | Generic.Subheading: "bold", 42 | Generic.Emph: "italic", 43 | Generic.Strong: "bold", 44 | Generic.Prompt: "bold", 45 | 46 | Error: "border:#FF0000" 47 | } 48 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/compiled.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.compiled 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Just export lexer classes previously contained in this module. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexers.jvm import JavaLexer, ScalaLexer 12 | from pygments.lexers.c_cpp import CLexer, CppLexer 13 | from pygments.lexers.d import DLexer 14 | from pygments.lexers.objective import ObjectiveCLexer, \ 15 | ObjectiveCppLexer, LogosLexer 16 | from pygments.lexers.go import GoLexer 17 | from pygments.lexers.rust import RustLexer 18 | from pygments.lexers.c_like import ECLexer, ValaLexer, CudaLexer 19 | from pygments.lexers.pascal import DelphiLexer, Modula2Lexer 20 | from pygments.lexers.ada import AdaLexer 21 | from pygments.lexers.business import CobolLexer, CobolFreeformatLexer 22 | from pygments.lexers.fortran import FortranLexer 23 | from pygments.lexers.prolog import PrologLexer 24 | from pygments.lexers.python import CythonLexer 25 | from pygments.lexers.graphics import GLShaderLexer 26 | from pygments.lexers.ml import OcamlLexer 27 | from pygments.lexers.basic import BlitzBasicLexer, BlitzMaxLexer, MonkeyLexer 28 | from pygments.lexers.dylan import DylanLexer, DylanLidLexer, DylanConsoleLexer 29 | from pygments.lexers.ooc import OocLexer 30 | from pygments.lexers.felix import FelixLexer 31 | from pygments.lexers.nimrod import NimrodLexer 32 | from pygments.lexers.crystal import CrystalLexer 33 | 34 | __all__ = [] 35 | -------------------------------------------------------------------------------- /thirdparty/rich/protocol.py: -------------------------------------------------------------------------------- 1 | from typing import Any, cast, Set, TYPE_CHECKING 2 | from inspect import isclass 3 | 4 | if TYPE_CHECKING: 5 | from rich.console import RenderableType 6 | 7 | _GIBBERISH = """aihwerij235234ljsdnp34ksodfipwoe234234jlskjdf""" 8 | 9 | 10 | def is_renderable(check_object: Any) -> bool: 11 | """Check if an object may be rendered by Rich.""" 12 | return ( 13 | isinstance(check_object, str) 14 | or hasattr(check_object, "__rich__") 15 | or hasattr(check_object, "__rich_console__") 16 | ) 17 | 18 | 19 | def rich_cast(renderable: object) -> "RenderableType": 20 | """Cast an object to a renderable by calling __rich__ if present. 21 | 22 | Args: 23 | renderable (object): A potentially renderable object 24 | 25 | Returns: 26 | object: The result of recursively calling __rich__. 27 | """ 28 | from rich.console import RenderableType 29 | 30 | rich_visited_set: Set[type] = set() # Prevent potential infinite loop 31 | while hasattr(renderable, "__rich__") and not isclass(renderable): 32 | # Detect object which claim to have all the attributes 33 | if hasattr(renderable, _GIBBERISH): 34 | return repr(renderable) 35 | cast_method = getattr(renderable, "__rich__") 36 | renderable = cast_method() 37 | renderable_type = type(renderable) 38 | if renderable_type in rich_visited_set: 39 | break 40 | rich_visited_set.add(renderable_type) 41 | 42 | return cast(RenderableType, renderable) 43 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/key_binding/bindings/open_in_editor.py: -------------------------------------------------------------------------------- 1 | """ 2 | Open in editor key bindings. 3 | """ 4 | from prompt_toolkit.filters import emacs_mode, has_selection, vi_navigation_mode 5 | 6 | from ..key_bindings import KeyBindings, KeyBindingsBase, merge_key_bindings 7 | from .named_commands import get_by_name 8 | 9 | __all__ = [ 10 | "load_open_in_editor_bindings", 11 | "load_emacs_open_in_editor_bindings", 12 | "load_vi_open_in_editor_bindings", 13 | ] 14 | 15 | 16 | def load_open_in_editor_bindings() -> KeyBindingsBase: 17 | """ 18 | Load both the Vi and emacs key bindings for handling edit-and-execute-command. 19 | """ 20 | return merge_key_bindings( 21 | [ 22 | load_emacs_open_in_editor_bindings(), 23 | load_vi_open_in_editor_bindings(), 24 | ] 25 | ) 26 | 27 | 28 | def load_emacs_open_in_editor_bindings() -> KeyBindings: 29 | """ 30 | Pressing C-X C-E will open the buffer in an external editor. 31 | """ 32 | key_bindings = KeyBindings() 33 | 34 | key_bindings.add("c-x", "c-e", filter=emacs_mode & ~has_selection)( 35 | get_by_name("edit-and-execute-command") 36 | ) 37 | 38 | return key_bindings 39 | 40 | 41 | def load_vi_open_in_editor_bindings() -> KeyBindings: 42 | """ 43 | Pressing 'v' in navigation mode will open the buffer in an external editor. 44 | """ 45 | key_bindings = KeyBindings() 46 | key_bindings.add("v", filter=vi_navigation_mode)( 47 | get_by_name("edit-and-execute-command") 48 | ) 49 | return key_bindings 50 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/sas.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.sas 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Style inspired by SAS' enhanced program editor. Note This is not 6 | meant to be a complete style. It's merely meant to mimic SAS' 7 | program editor syntax highlighting. 8 | 9 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 10 | :license: BSD, see LICENSE for details. 11 | """ 12 | 13 | from pygments.style import Style 14 | from pygments.token import Keyword, Name, Comment, String, Error, \ 15 | Number, Other, Whitespace, Generic 16 | 17 | 18 | class SasStyle(Style): 19 | """ 20 | Style inspired by SAS' enhanced program editor. Note This is not 21 | meant to be a complete style. It's merely meant to mimic SAS' 22 | program editor syntax highlighting. 23 | """ 24 | 25 | styles = { 26 | Whitespace: '#bbbbbb', 27 | Comment: 'italic #008800', 28 | String: '#800080', 29 | Number: 'bold #2c8553', 30 | Other: 'bg:#ffffe0', 31 | Keyword: '#2c2cff', 32 | Keyword.Reserved: 'bold #353580', 33 | Keyword.Constant: 'bold', 34 | Name.Builtin: '#2c2cff', 35 | Name.Function: 'bold italic', 36 | Name.Variable: 'bold #2c2cff', 37 | Generic: '#2c2cff', 38 | Generic.Emph: '#008800', 39 | Generic.Error: '#d30202', 40 | Error: 'bg:#e3d2d2 #a61717' 41 | } 42 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/selection.py: -------------------------------------------------------------------------------- 1 | """ 2 | Data structures for the selection. 3 | """ 4 | from enum import Enum 5 | 6 | __all__ = [ 7 | "SelectionType", 8 | "PasteMode", 9 | "SelectionState", 10 | ] 11 | 12 | 13 | class SelectionType(Enum): 14 | """ 15 | Type of selection. 16 | """ 17 | 18 | #: Characters. (Visual in Vi.) 19 | CHARACTERS = "CHARACTERS" 20 | 21 | #: Whole lines. (Visual-Line in Vi.) 22 | LINES = "LINES" 23 | 24 | #: A block selection. (Visual-Block in Vi.) 25 | BLOCK = "BLOCK" 26 | 27 | 28 | class PasteMode(Enum): 29 | EMACS = "EMACS" # Yank like emacs. 30 | VI_AFTER = "VI_AFTER" # When pressing 'p' in Vi. 31 | VI_BEFORE = "VI_BEFORE" # When pressing 'P' in Vi. 32 | 33 | 34 | class SelectionState: 35 | """ 36 | State of the current selection. 37 | 38 | :param original_cursor_position: int 39 | :param type: :class:`~.SelectionType` 40 | """ 41 | 42 | def __init__( 43 | self, 44 | original_cursor_position: int = 0, 45 | type: SelectionType = SelectionType.CHARACTERS, 46 | ) -> None: 47 | 48 | self.original_cursor_position = original_cursor_position 49 | self.type = type 50 | self.shift_mode = False 51 | 52 | def enter_shift_mode(self) -> None: 53 | self.shift_mode = True 54 | 55 | def __repr__(self) -> str: 56 | return "{}(original_cursor_position={!r}, type={!r})".format( 57 | self.__class__.__name__, 58 | self.original_cursor_position, 59 | self.type, 60 | ) 61 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/cplint.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.cplint 3 | ~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for the cplint language 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | import re 12 | 13 | from pygments.lexer import bygroups, inherit, words 14 | from pygments.lexers import PrologLexer 15 | from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 16 | Number, Punctuation 17 | 18 | __all__ = ['CplintLexer'] 19 | 20 | 21 | class CplintLexer(PrologLexer): 22 | """ 23 | Lexer for cplint files, including CP-logic, Logic Programs with Annotated Disjunctions, 24 | Distributional Clauses syntax, ProbLog, DTProbLog 25 | 26 | .. versionadded:: 2.12 27 | """ 28 | name = 'cplint' 29 | url = 'https://cplint.eu' 30 | aliases = ['cplint'] 31 | filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl'] 32 | mimetypes = ['text/x-cplint'] 33 | 34 | tokens = { 35 | 'root': [ 36 | (r'map_query',Keyword), 37 | (words(('gaussian','uniform_dens','dirichlet','gamma','beta','poisson','binomial','geometric', 38 | 'exponential','pascal','multinomial','user','val', 39 | 'uniform','discrete','finite')),Name.Builtin), 40 | (r'([a-z]+)(:)', bygroups(String.Atom, Punctuation)), # annotations of atoms 41 | (r':(-|=)|::?|~=?|=>', Operator), 42 | (r'\?', Name.Builtin), 43 | inherit, 44 | ], 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/eventloop/dummy_contextvars.py: -------------------------------------------------------------------------------- 1 | """ 2 | Dummy contextvars implementation, to make prompt_toolkit work on Python 3.6. 3 | 4 | As long as there is only one application running at a time, we don't need the 5 | real contextvars. So, stuff like the telnet-server and so on requires 3.7. 6 | """ 7 | from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, TypeVar 8 | 9 | if TYPE_CHECKING: 10 | from typing_extensions import ParamSpec 11 | 12 | 13 | def copy_context() -> "Context": 14 | return Context() 15 | 16 | 17 | if TYPE_CHECKING: 18 | _P = ParamSpec("_P") 19 | _T = TypeVar("_T") 20 | 21 | 22 | class Context: 23 | def run( 24 | self, callable: "Callable[_P, _T]", *args: "_P.args", **kwargs: "_P.kwargs" 25 | ) -> _T: 26 | return callable(*args, **kwargs) 27 | 28 | def copy(self) -> "Context": 29 | return self 30 | 31 | 32 | class Token(Generic[_T]): 33 | pass 34 | 35 | 36 | class ContextVar(Generic[_T]): 37 | def __init__(self, name: str, *, default: Optional[_T] = None) -> None: 38 | self._name = name 39 | self._value = default 40 | 41 | @property 42 | def name(self) -> str: 43 | return self._name 44 | 45 | def get(self, default: Optional[_T] = None) -> _T: 46 | result = self._value or default 47 | if result is None: 48 | raise LookupError 49 | return result 50 | 51 | def set(self, value: _T) -> Token[_T]: 52 | self._value = value 53 | return Token() 54 | 55 | def reset(self, token: Token[_T]) -> None: 56 | pass 57 | -------------------------------------------------------------------------------- /thirdparty/elftools/ehabi/structs.py: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------- 2 | # elftools: ehabi/structs.py 3 | # 4 | # Encapsulation of Construct structs for parsing an EHABI, adjusted for 5 | # correct endianness and word-size. 6 | # 7 | # LeadroyaL (leadroyal@qq.com) 8 | # This code is in the public domain 9 | # ------------------------------------------------------------------------------- 10 | 11 | from ..construct import UBInt32, ULInt32, Struct 12 | 13 | 14 | class EHABIStructs(object): 15 | """ Accessible attributes: 16 | 17 | EH_index_struct: 18 | Struct of item in section .ARM.exidx. 19 | 20 | EH_table_struct: 21 | Struct of item in section .ARM.extab. 22 | """ 23 | 24 | def __init__(self, little_endian): 25 | self._little_endian = little_endian 26 | self._create_structs() 27 | 28 | def _create_structs(self): 29 | if self._little_endian: 30 | self.EHABI_uint32 = ULInt32 31 | else: 32 | self.EHABI_uint32 = UBInt32 33 | self._create_exception_handler_index() 34 | self._create_exception_handler_table() 35 | 36 | def _create_exception_handler_index(self): 37 | self.EH_index_struct = Struct( 38 | 'EH_index', 39 | self.EHABI_uint32('word0'), 40 | self.EHABI_uint32('word1') 41 | ) 42 | 43 | def _create_exception_handler_table(self): 44 | self.EH_table_struct = Struct( 45 | 'EH_table', 46 | self.EHABI_uint32('word0'), 47 | ) 48 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/completion/deduplicate.py: -------------------------------------------------------------------------------- 1 | from typing import Iterable, Set 2 | 3 | from prompt_toolkit.document import Document 4 | 5 | from .base import CompleteEvent, Completer, Completion 6 | 7 | __all__ = ["DeduplicateCompleter"] 8 | 9 | 10 | class DeduplicateCompleter(Completer): 11 | """ 12 | Wrapper around a completer that removes duplicates. Only the first unique 13 | completions are kept. 14 | 15 | Completions are considered to be a duplicate if they result in the same 16 | document text when they would be applied. 17 | """ 18 | 19 | def __init__(self, completer: Completer) -> None: 20 | self.completer = completer 21 | 22 | def get_completions( 23 | self, document: Document, complete_event: CompleteEvent 24 | ) -> Iterable[Completion]: 25 | # Keep track of the document strings we'd get after applying any completion. 26 | found_so_far: Set[str] = set() 27 | 28 | for completion in self.completer.get_completions(document, complete_event): 29 | text_if_applied = ( 30 | document.text[: document.cursor_position + completion.start_position] 31 | + completion.text 32 | + document.text[document.cursor_position :] 33 | ) 34 | 35 | if text_if_applied == document.text: 36 | # Don't include completions that don't have any effect at all. 37 | continue 38 | 39 | if text_if_applied in found_so_far: 40 | continue 41 | 42 | found_so_far.add(text_if_applied) 43 | yield completion 44 | -------------------------------------------------------------------------------- /thirdparty/commonmark/cmark.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import unicode_literals 3 | import argparse 4 | import sys 5 | import commonmark 6 | 7 | 8 | def main(): 9 | parser = argparse.ArgumentParser( 10 | description="Process Markdown according to " 11 | "the CommonMark specification.") 12 | if sys.version_info < (3, 0): 13 | reload(sys) # noqa 14 | sys.setdefaultencoding('utf-8') 15 | parser.add_argument( 16 | 'infile', 17 | nargs="?", 18 | type=argparse.FileType('r'), 19 | default=sys.stdin, 20 | help="Input Markdown file to parse, defaults to STDIN") 21 | parser.add_argument( 22 | '-o', 23 | nargs="?", 24 | type=argparse.FileType('w'), 25 | default=sys.stdout, 26 | help="Output HTML/JSON file, defaults to STDOUT") 27 | parser.add_argument('-a', action="store_true", help="Print formatted AST") 28 | parser.add_argument('-aj', action="store_true", help="Output JSON AST") 29 | args = parser.parse_args() 30 | parser = commonmark.Parser() 31 | f = args.infile 32 | o = args.o 33 | lines = [] 34 | for line in f: 35 | lines.append(line) 36 | data = "".join(lines) 37 | ast = parser.parse(data) 38 | if not args.a and not args.aj: 39 | renderer = commonmark.HtmlRenderer() 40 | o.write(renderer.render(ast)) 41 | exit() 42 | if args.a: 43 | # print ast 44 | commonmark.dumpAST(ast) 45 | exit() 46 | 47 | # o.write(ast.to_JSON()) 48 | o.write(commonmark.dumpJSON(ast)) 49 | exit() 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/output/color_depth.py: -------------------------------------------------------------------------------- 1 | import os 2 | from enum import Enum 3 | from typing import Optional 4 | 5 | __all__ = [ 6 | "ColorDepth", 7 | ] 8 | 9 | 10 | class ColorDepth(str, Enum): 11 | """ 12 | Possible color depth values for the output. 13 | """ 14 | 15 | value: str 16 | 17 | #: One color only. 18 | DEPTH_1_BIT = "DEPTH_1_BIT" 19 | 20 | #: ANSI Colors. 21 | DEPTH_4_BIT = "DEPTH_4_BIT" 22 | 23 | #: The default. 24 | DEPTH_8_BIT = "DEPTH_8_BIT" 25 | 26 | #: 24 bit True color. 27 | DEPTH_24_BIT = "DEPTH_24_BIT" 28 | 29 | # Aliases. 30 | MONOCHROME = DEPTH_1_BIT 31 | ANSI_COLORS_ONLY = DEPTH_4_BIT 32 | DEFAULT = DEPTH_8_BIT 33 | TRUE_COLOR = DEPTH_24_BIT 34 | 35 | @classmethod 36 | def from_env(cls) -> Optional["ColorDepth"]: 37 | """ 38 | Return the color depth if the $PROMPT_TOOLKIT_COLOR_DEPTH environment 39 | variable has been set. 40 | 41 | This is a way to enforce a certain color depth in all prompt_toolkit 42 | applications. 43 | """ 44 | # Check the `PROMPT_TOOLKIT_COLOR_DEPTH` environment variable. 45 | all_values = [i.value for i in ColorDepth] 46 | if os.environ.get("PROMPT_TOOLKIT_COLOR_DEPTH") in all_values: 47 | return cls(os.environ["PROMPT_TOOLKIT_COLOR_DEPTH"]) 48 | 49 | return None 50 | 51 | @classmethod 52 | def default(cls) -> "ColorDepth": 53 | """ 54 | Return the default color depth for the default output. 55 | """ 56 | from .defaults import create_output 57 | 58 | return create_output().get_default_color_depth() 59 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/xcode.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.xcode 3 | ~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Style similar to the `Xcode` default theme. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Keyword, Name, Comment, String, Error, \ 13 | Number, Operator, Literal 14 | 15 | 16 | class XcodeStyle(Style): 17 | """ 18 | Style similar to the Xcode default colouring theme. 19 | """ 20 | 21 | styles = { 22 | Comment: '#177500', 23 | Comment.Preproc: '#633820', 24 | 25 | String: '#C41A16', 26 | String.Char: '#2300CE', 27 | 28 | Operator: '#000000', 29 | 30 | Keyword: '#A90D91', 31 | 32 | Name: '#000000', 33 | Name.Attribute: '#836C28', 34 | Name.Class: '#3F6E75', 35 | Name.Function: '#000000', 36 | Name.Builtin: '#A90D91', 37 | # In Obj-C code this token is used to colour Cocoa types 38 | Name.Builtin.Pseudo: '#5B269A', 39 | Name.Variable: '#000000', 40 | Name.Tag: '#000000', 41 | Name.Decorator: '#000000', 42 | # Workaround for a BUG here: lexer treats multiline method signatres as labels 43 | Name.Label: '#000000', 44 | 45 | Literal: '#1C01CE', 46 | Number: '#1C01CE', 47 | Error: '#000000', 48 | } 49 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/formatted_text/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Many places in prompt_toolkit can take either plain text, or formatted text. 3 | For instance the :func:`~prompt_toolkit.shortcuts.prompt` function takes either 4 | plain text or formatted text for the prompt. The 5 | :class:`~prompt_toolkit.layout.FormattedTextControl` can also take either plain 6 | text or formatted text. 7 | 8 | In any case, there is an input that can either be just plain text (a string), 9 | an :class:`.HTML` object, an :class:`.ANSI` object or a sequence of 10 | `(style_string, text)` tuples. The :func:`.to_formatted_text` conversion 11 | function takes any of these and turns all of them into such a tuple sequence. 12 | """ 13 | from .ansi import ANSI 14 | from .base import ( 15 | AnyFormattedText, 16 | FormattedText, 17 | StyleAndTextTuples, 18 | Template, 19 | is_formatted_text, 20 | merge_formatted_text, 21 | to_formatted_text, 22 | ) 23 | from .html import HTML 24 | from .pygments import PygmentsTokens 25 | from .utils import ( 26 | fragment_list_len, 27 | fragment_list_to_text, 28 | fragment_list_width, 29 | split_lines, 30 | to_plain_text, 31 | ) 32 | 33 | __all__ = [ 34 | # Base. 35 | "AnyFormattedText", 36 | "to_formatted_text", 37 | "is_formatted_text", 38 | "Template", 39 | "merge_formatted_text", 40 | "FormattedText", 41 | "StyleAndTextTuples", 42 | # HTML. 43 | "HTML", 44 | # ANSI. 45 | "ANSI", 46 | # Pygments. 47 | "PygmentsTokens", 48 | # Utils. 49 | "fragment_list_len", 50 | "fragment_list_width", 51 | "fragment_list_to_text", 52 | "split_lines", 53 | "to_plain_text", 54 | ] 55 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/trafficscript.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.trafficscript 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for RiverBed's TrafficScript (RTS) language. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer 12 | from pygments.token import String, Number, Name, Keyword, Operator, Text, Comment 13 | 14 | __all__ = ['RtsLexer'] 15 | 16 | 17 | class RtsLexer(RegexLexer): 18 | """ 19 | For Riverbed Stingray Traffic Manager 20 | 21 | .. versionadded:: 2.1 22 | """ 23 | name = 'TrafficScript' 24 | aliases = ['trafficscript', 'rts'] 25 | filenames = ['*.rts'] 26 | 27 | tokens = { 28 | 'root' : [ 29 | (r"'(\\\\|\\[^\\]|[^'\\])*'", String), 30 | (r'"', String, 'escapable-string'), 31 | (r'(0x[0-9a-fA-F]+|\d+)', Number), 32 | (r'\d+\.\d+', Number.Float), 33 | (r'\$[a-zA-Z](\w|_)*', Name.Variable), 34 | (r'(if|else|for(each)?|in|while|do|break|sub|return|import)', Keyword), 35 | (r'[a-zA-Z][\w.]*', Name.Function), 36 | (r'[-+*/%=,;(){}<>^.!~|&\[\]\?\:]', Operator), 37 | (r'(>=|<=|==|!=|' 38 | r'&&|\|\||' 39 | r'\+=|.=|-=|\*=|/=|%=|<<=|>>=|&=|\|=|\^=|' 40 | r'>>|<<|' 41 | r'\+\+|--|=>)', Operator), 42 | (r'[ \t\r]+', Text), 43 | (r'#[^\n]*', Comment), 44 | ], 45 | 'escapable-string' : [ 46 | (r'\\[tsn]', String.Escape), 47 | (r'[^"]', String), 48 | (r'"', String, '#pop'), 49 | ], 50 | 51 | } 52 | -------------------------------------------------------------------------------- /thirdparty/wcwidth/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | wcwidth module. 3 | 4 | https://github.com/jquast/wcwidth 5 | """ 6 | # re-export all functions & definitions, even private ones, from top-level 7 | # module path, to allow for 'from wcwidth import _private_func'. Of course, 8 | # user beware that any _private function may disappear or change signature at 9 | # any future version. 10 | 11 | # local 12 | from .wcwidth import ZERO_WIDTH # noqa 13 | from .wcwidth import (WIDE_EASTASIAN, 14 | wcwidth, 15 | wcswidth, 16 | _bisearch, 17 | list_versions, 18 | _wcmatch_version, 19 | _wcversion_value) 20 | 21 | # The __all__ attribute defines the items exported from statement, 22 | # 'from wcwidth import *', but also to say, "This is the public API". 23 | __all__ = ('wcwidth', 'wcswidth', 'list_versions') 24 | 25 | # I used to use a _get_package_version() function to use the `pkg_resources' 26 | # module to parse the package version from our version.json file, but this blew 27 | # some folks up, or more particularly, just the `xonsh' shell. 28 | # 29 | # Yikes! I always wanted to like xonsh and tried it many times but issues like 30 | # these always bit me, too, so I can sympathize -- this version is now manually 31 | # kept in sync with version.json to help them out. Shucks, this variable is just 32 | # for legacy, from the days before 'pip freeze' was a thing. 33 | # 34 | # We also used pkg_resources to load unicode version tables from version.json, 35 | # generated by bin/update-tables.py, but some environments are unable to 36 | # import pkg_resources for one reason or another, yikes! 37 | __version__ = '0.2.5' 38 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/borland.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.borland 3 | ~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Style similar to the style used in the Borland IDEs. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Keyword, Name, Comment, String, Error, \ 13 | Number, Operator, Generic, Whitespace 14 | 15 | 16 | class BorlandStyle(Style): 17 | """ 18 | Style similar to the style used in the borland IDEs. 19 | """ 20 | 21 | styles = { 22 | Whitespace: '#bbbbbb', 23 | 24 | Comment: 'italic #008800', 25 | Comment.Preproc: 'noitalic #008080', 26 | Comment.Special: 'noitalic bold', 27 | 28 | String: '#0000FF', 29 | String.Char: '#800080', 30 | Number: '#0000FF', 31 | Keyword: 'bold #000080', 32 | Operator.Word: 'bold', 33 | Name.Tag: 'bold #000080', 34 | Name.Attribute: '#FF0000', 35 | 36 | Generic.Heading: '#999999', 37 | Generic.Subheading: '#aaaaaa', 38 | Generic.Deleted: 'bg:#ffdddd #000000', 39 | Generic.Inserted: 'bg:#ddffdd #000000', 40 | Generic.Error: '#aa0000', 41 | Generic.Emph: 'italic', 42 | Generic.Strong: 'bold', 43 | Generic.Prompt: '#555555', 44 | Generic.Output: '#888888', 45 | Generic.Traceback: '#aa0000', 46 | 47 | Error: 'bg:#e3d2d2 #a61717' 48 | } 49 | -------------------------------------------------------------------------------- /core/riposte_sf/data_vars.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | class VarManager: 5 | 6 | def __init__(self): 7 | self.data = dict() 8 | 9 | def get_data(self): 10 | return self.data 11 | 12 | def names(self): 13 | return self.data.keys() 14 | 15 | def set(self, name : str, value : str): 16 | self.data[name] = str(value) 17 | 18 | def get(self, name : str): 19 | if name in self.data: 20 | return self.data[name] 21 | else: 22 | raise ValueError(f'Unknown variable - {name}') 23 | 24 | def delete(self, name): 25 | if name in self.data: 26 | del self.data[name] 27 | return True 28 | 29 | def del_by_prefix(self, prefix : str): 30 | for name in list(self.names()): 31 | if name.startswith(prefix): 32 | self.delete(name) 33 | 34 | 35 | 36 | class VarManager2(VarManager): 37 | 38 | def __init__(self): 39 | self.data = dict() 40 | self.pattern = re.compile(r'(%|\$)[A-Za-z0-9_]+') 41 | 42 | def validate(self, arg_name): 43 | match = self.pattern.fullmatch(arg_name) 44 | if match is None: 45 | raise ValueError(f'Invalid variable name - {arg_name}') 46 | 47 | def is_var(self, arg_name): 48 | return arg_name[0] in ['$', '%'] 49 | 50 | def replace_list(self, args_list): 51 | new_args = [] + args_list 52 | 53 | for idx, arg in enumerate(new_args): 54 | 55 | if self.is_var(arg): 56 | 57 | self.validate(arg) 58 | 59 | value = self.get(arg) 60 | new_args[idx] = value 61 | 62 | return new_args 63 | 64 | def set(self, name : str, value : str): 65 | self.validate(name) 66 | self.data[name] = str(value) 67 | 68 | def set_type_1(self, name : str, value : str): 69 | self.set(f'%{name}', value) 70 | 71 | def set_type_2(self, name : str, value : str): 72 | self.set(f'${name}', value) -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/application/dummy.py: -------------------------------------------------------------------------------- 1 | from typing import Callable, Optional 2 | 3 | from prompt_toolkit.formatted_text import AnyFormattedText 4 | from prompt_toolkit.input import DummyInput 5 | from prompt_toolkit.output import DummyOutput 6 | 7 | from .application import Application 8 | 9 | __all__ = [ 10 | "DummyApplication", 11 | ] 12 | 13 | 14 | class DummyApplication(Application[None]): 15 | """ 16 | When no :class:`.Application` is running, 17 | :func:`.get_app` will run an instance of this :class:`.DummyApplication` instead. 18 | """ 19 | 20 | def __init__(self) -> None: 21 | super().__init__(output=DummyOutput(), input=DummyInput()) 22 | 23 | def run( 24 | self, 25 | pre_run: Optional[Callable[[], None]] = None, 26 | set_exception_handler: bool = True, 27 | handle_sigint: bool = True, 28 | in_thread: bool = False, 29 | ) -> None: 30 | raise NotImplementedError("A DummyApplication is not supposed to run.") 31 | 32 | async def run_async( 33 | self, 34 | pre_run: Optional[Callable[[], None]] = None, 35 | set_exception_handler: bool = True, 36 | handle_sigint: bool = True, 37 | slow_callback_duration: float = 0.5, 38 | ) -> None: 39 | raise NotImplementedError("A DummyApplication is not supposed to run.") 40 | 41 | async def run_system_command( 42 | self, 43 | command: str, 44 | wait_for_enter: bool = True, 45 | display_before_text: AnyFormattedText = "", 46 | wait_text: str = "", 47 | ) -> None: 48 | raise NotImplementedError 49 | 50 | def suspend_to_background(self, suspend_group: bool = True) -> None: 51 | raise NotImplementedError 52 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/asc.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.asc 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for various ASCII armored files. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | import re 11 | 12 | from pygments.lexer import RegexLexer, bygroups 13 | from pygments.token import Comment, Generic, Name, Operator, String, Whitespace 14 | 15 | __all__ = ['AscLexer'] 16 | 17 | 18 | class AscLexer(RegexLexer): 19 | """ 20 | Lexer for ASCII armored files, containing `-----BEGIN/END ...-----` wrapped base64 data. 21 | 22 | .. versionadded:: 2.10 23 | """ 24 | name = 'ASCII armored' 25 | aliases = ['asc', 'pem'] 26 | filenames = [ 27 | '*.asc', # PGP; *.gpg, *.pgp, and *.sig too, but those can be binary 28 | '*.pem', # X.509; *.cer, *.crt, *.csr, and key etc too, but those can be binary 29 | 'id_dsa', 'id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk', 'id_rsa', # SSH private keys 30 | ] 31 | mimetypes = ['application/pgp-keys', 'application/pgp-encrypted', 'application/pgp-signature'] 32 | 33 | flags = re.MULTILINE 34 | 35 | tokens = { 36 | 'root': [ 37 | (r'\s+', Whitespace), 38 | (r'^-----BEGIN [^\n]+-----$', Generic.Heading, 'data'), 39 | (r'\S+', Comment), 40 | ], 41 | 'data': [ 42 | (r'\s+', Whitespace), 43 | (r'^([^:]+)(:)([ \t]+)(.*)', bygroups(Name.Attribute, Operator, Whitespace, String)), 44 | (r'^-----END [^\n]+-----$', Generic.Heading, 'root'), 45 | (r'\S+', String), 46 | ], 47 | } 48 | 49 | def analyse_text(text): 50 | if re.search(r'^-----BEGIN [^\n]+-----\r?\n', text): 51 | return True 52 | -------------------------------------------------------------------------------- /thirdparty/rich/screen.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, TYPE_CHECKING 2 | 3 | from .segment import Segment 4 | from .style import StyleType 5 | from ._loop import loop_last 6 | 7 | 8 | if TYPE_CHECKING: 9 | from .console import ( 10 | Console, 11 | ConsoleOptions, 12 | RenderResult, 13 | RenderableType, 14 | Group, 15 | ) 16 | 17 | 18 | class Screen: 19 | """A renderable that fills the terminal screen and crops excess. 20 | 21 | Args: 22 | renderable (RenderableType): Child renderable. 23 | style (StyleType, optional): Optional background style. Defaults to None. 24 | """ 25 | 26 | renderable: "RenderableType" 27 | 28 | def __init__( 29 | self, 30 | *renderables: "RenderableType", 31 | style: Optional[StyleType] = None, 32 | application_mode: bool = False, 33 | ) -> None: 34 | from rich.console import Group 35 | 36 | self.renderable = Group(*renderables) 37 | self.style = style 38 | self.application_mode = application_mode 39 | 40 | def __rich_console__( 41 | self, console: "Console", options: "ConsoleOptions" 42 | ) -> "RenderResult": 43 | width, height = options.size 44 | style = console.get_style(self.style) if self.style else None 45 | render_options = options.update(width=width, height=height) 46 | lines = console.render_lines( 47 | self.renderable or "", render_options, style=style, pad=True 48 | ) 49 | lines = Segment.set_shape(lines, width, height, style=style) 50 | new_line = Segment("\n\r") if self.application_mode else Segment.line() 51 | for last, line in loop_last(lines): 52 | yield from line 53 | if not last: 54 | yield new_line 55 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/layout/mouse_handlers.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | from typing import TYPE_CHECKING, Callable, DefaultDict 3 | 4 | from prompt_toolkit.mouse_events import MouseEvent 5 | 6 | if TYPE_CHECKING: 7 | from prompt_toolkit.key_binding.key_bindings import NotImplementedOrNone 8 | 9 | __all__ = [ 10 | "MouseHandler", 11 | "MouseHandlers", 12 | ] 13 | 14 | 15 | MouseHandler = Callable[[MouseEvent], "NotImplementedOrNone"] 16 | 17 | 18 | class MouseHandlers: 19 | """ 20 | Two dimensional raster of callbacks for mouse events. 21 | """ 22 | 23 | def __init__(self) -> None: 24 | def dummy_callback(mouse_event: MouseEvent) -> "NotImplementedOrNone": 25 | """ 26 | :param mouse_event: `MouseEvent` instance. 27 | """ 28 | return NotImplemented 29 | 30 | # NOTE: Previously, the data structure was a dictionary mapping (x,y) 31 | # to the handlers. This however would be more inefficient when copying 32 | # over the mouse handlers of the visible region in the scrollable pane. 33 | 34 | # Map y (row) to x (column) to handlers. 35 | self.mouse_handlers: DefaultDict[ 36 | int, DefaultDict[int, MouseHandler] 37 | ] = defaultdict(lambda: defaultdict(lambda: dummy_callback)) 38 | 39 | def set_mouse_handler_for_range( 40 | self, 41 | x_min: int, 42 | x_max: int, 43 | y_min: int, 44 | y_max: int, 45 | handler: Callable[[MouseEvent], "NotImplementedOrNone"], 46 | ) -> None: 47 | """ 48 | Set mouse handler for a region. 49 | """ 50 | for y in range(y_min, y_max): 51 | row = self.mouse_handlers[y] 52 | 53 | for x in range(x_min, x_max): 54 | row[x] = handler 55 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/amdgpu.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.amdgpu 3 | ~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for the AMDGPU ISA assembly. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer, words 12 | from pygments.token import Name, Text, Keyword, Whitespace, Number, Comment 13 | 14 | import re 15 | 16 | __all__ = ['AMDGPULexer'] 17 | 18 | 19 | class AMDGPULexer(RegexLexer): 20 | """ 21 | For AMD GPU assembly. 22 | 23 | .. versionadded:: 2.8 24 | """ 25 | name = 'AMDGPU' 26 | aliases = ['amdgpu'] 27 | filenames = ['*.isa'] 28 | 29 | flags = re.IGNORECASE 30 | 31 | tokens = { 32 | 'root': [ 33 | (r'\s+', Whitespace), 34 | (r'[\r\n]+', Text), 35 | (r'(([a-z_0-9])*:([a-z_0-9])*)', Name.Attribute), 36 | (r'(\[|\]|\(|\)|,|\:|\&)', Text), 37 | (r'([;#]|//).*?\n', Comment.Single), 38 | (r'((s_)?(ds|buffer|flat|image)_[a-z0-9_]+)', Keyword.Reserved), 39 | (r'(_lo|_hi)', Name.Variable), 40 | (r'(vmcnt|lgkmcnt|expcnt)', Name.Attribute), 41 | (words(( 42 | 'op', 'vaddr', 'vdata', 'soffset', 'srsrc', 'format', 43 | 'offset', 'offen', 'idxen', 'glc', 'dlc', 'slc', 'tfe', 'lds', 44 | 'lit', 'unorm'), suffix=r'\b'), Name.Attribute), 45 | (r'(label_[a-z0-9]+)', Keyword), 46 | (r'(_L[0-9]*)', Name.Variable), 47 | (r'(s|v)_[a-z0-9_]+', Keyword), 48 | (r'(v[0-9.]+|vcc|exec|v)', Name.Variable), 49 | (r's[0-9.]+|s', Name.Variable), 50 | (r'[0-9]+\.[^0-9]+', Number.Float), 51 | (r'(0[xX][a-z0-9]+)|([0-9]+)', Number.Integer) 52 | ] 53 | } 54 | -------------------------------------------------------------------------------- /thirdparty/rich/file_proxy.py: -------------------------------------------------------------------------------- 1 | import io 2 | from typing import IO, TYPE_CHECKING, Any, List 3 | 4 | from .ansi import AnsiDecoder 5 | from .text import Text 6 | 7 | if TYPE_CHECKING: 8 | from .console import Console 9 | 10 | 11 | class FileProxy(io.TextIOBase): 12 | """Wraps a file (e.g. sys.stdout) and redirects writes to a console.""" 13 | 14 | def __init__(self, console: "Console", file: IO[str]) -> None: 15 | self.__console = console 16 | self.__file = file 17 | self.__buffer: List[str] = [] 18 | self.__ansi_decoder = AnsiDecoder() 19 | 20 | @property 21 | def rich_proxied_file(self) -> IO[str]: 22 | """Get proxied file.""" 23 | return self.__file 24 | 25 | def __getattr__(self, name: str) -> Any: 26 | return getattr(self.__file, name) 27 | 28 | def write(self, text: str) -> int: 29 | if not isinstance(text, str): 30 | raise TypeError(f"write() argument must be str, not {type(text).__name__}") 31 | buffer = self.__buffer 32 | lines: List[str] = [] 33 | while text: 34 | line, new_line, text = text.partition("\n") 35 | if new_line: 36 | lines.append("".join(buffer) + line) 37 | del buffer[:] 38 | else: 39 | buffer.append(line) 40 | break 41 | if lines: 42 | console = self.__console 43 | with console: 44 | output = Text("\n").join( 45 | self.__ansi_decoder.decode_line(line) for line in lines 46 | ) 47 | console.print(output) 48 | return len(text) 49 | 50 | def flush(self) -> None: 51 | output = "".join(self.__buffer) 52 | if output: 53 | self.__console.print(output) 54 | del self.__buffer[:] 55 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/bdd.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.bdd 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for BDD(Behavior-driven development). 6 | More information: https://en.wikipedia.org/wiki/Behavior-driven_development 7 | 8 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.lexer import RegexLexer, include 13 | from pygments.token import Comment, Keyword, Name, String, Number, Text, Punctuation, Whitespace 14 | 15 | __all__ = ['BddLexer'] 16 | 17 | class BddLexer(RegexLexer): 18 | """ 19 | Lexer for BDD(Behavior-driven development), which highlights not only keywords, 20 | but also comments, punctuations, strings, numbers, and variables. 21 | 22 | .. versionadded:: 2.11 23 | """ 24 | 25 | name = 'Bdd' 26 | aliases = ['bdd'] 27 | filenames = ['*.feature'] 28 | mimetypes = ['text/x-bdd'] 29 | 30 | step_keywords = r'Given|When|Then|Add|And|Feature|Scenario Outline|Scenario|Background|Examples|But' 31 | 32 | tokens = { 33 | 'comments': [ 34 | (r'^\s*#.*$', Comment), 35 | ], 36 | 'miscellaneous': [ 37 | (r'(<|>|\[|\]|=|\||:|\(|\)|\{|\}|,|\.|;|-|_|\$)', Punctuation), 38 | (r'((?<=\<)[^\\>]+(?=\>))', Name.Variable), 39 | (r'"([^\"]*)"', String), 40 | (r'^@\S+', Name.Label), 41 | ], 42 | 'numbers': [ 43 | (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number), 44 | ], 45 | 'root': [ 46 | (r'\n|\s+', Whitespace), 47 | (step_keywords, Keyword), 48 | include('comments'), 49 | include('miscellaneous'), 50 | include('numbers'), 51 | (r'\S+', Text), 52 | ] 53 | } 54 | 55 | def analyse_text(self, text): 56 | return 57 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/styles/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Styling for prompt_toolkit applications. 3 | """ 4 | from .base import ( 5 | ANSI_COLOR_NAMES, 6 | DEFAULT_ATTRS, 7 | Attrs, 8 | BaseStyle, 9 | DummyStyle, 10 | DynamicStyle, 11 | ) 12 | from .defaults import default_pygments_style, default_ui_style 13 | from .named_colors import NAMED_COLORS 14 | from .pygments import ( 15 | pygments_token_to_classname, 16 | style_from_pygments_cls, 17 | style_from_pygments_dict, 18 | ) 19 | from .style import Priority, Style, merge_styles, parse_color 20 | from .style_transformation import ( 21 | AdjustBrightnessStyleTransformation, 22 | ConditionalStyleTransformation, 23 | DummyStyleTransformation, 24 | DynamicStyleTransformation, 25 | ReverseStyleTransformation, 26 | SetDefaultColorStyleTransformation, 27 | StyleTransformation, 28 | SwapLightAndDarkStyleTransformation, 29 | merge_style_transformations, 30 | ) 31 | 32 | __all__ = [ 33 | # Base. 34 | "Attrs", 35 | "DEFAULT_ATTRS", 36 | "ANSI_COLOR_NAMES", 37 | "BaseStyle", 38 | "DummyStyle", 39 | "DynamicStyle", 40 | # Defaults. 41 | "default_ui_style", 42 | "default_pygments_style", 43 | # Style. 44 | "Style", 45 | "Priority", 46 | "merge_styles", 47 | "parse_color", 48 | # Style transformation. 49 | "StyleTransformation", 50 | "SwapLightAndDarkStyleTransformation", 51 | "ReverseStyleTransformation", 52 | "SetDefaultColorStyleTransformation", 53 | "AdjustBrightnessStyleTransformation", 54 | "DummyStyleTransformation", 55 | "ConditionalStyleTransformation", 56 | "DynamicStyleTransformation", 57 | "merge_style_transformations", 58 | # Pygments. 59 | "style_from_pygments_cls", 60 | "style_from_pygments_dict", 61 | "pygments_token_to_classname", 62 | # Named colors. 63 | "NAMED_COLORS", 64 | ] 65 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/other.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.other 3 | ~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Just export lexer classes previously contained in this module. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexers.sql import SqlLexer, MySqlLexer, SqliteConsoleLexer 12 | from pygments.lexers.shell import BashLexer, BashSessionLexer, BatchLexer, \ 13 | TcshLexer 14 | from pygments.lexers.robotframework import RobotFrameworkLexer 15 | from pygments.lexers.testing import GherkinLexer 16 | from pygments.lexers.esoteric import BrainfuckLexer, BefungeLexer, RedcodeLexer 17 | from pygments.lexers.prolog import LogtalkLexer 18 | from pygments.lexers.snobol import SnobolLexer 19 | from pygments.lexers.rebol import RebolLexer 20 | from pygments.lexers.configs import KconfigLexer, Cfengine3Lexer 21 | from pygments.lexers.modeling import ModelicaLexer 22 | from pygments.lexers.scripting import AppleScriptLexer, MOOCodeLexer, \ 23 | HybrisLexer 24 | from pygments.lexers.graphics import PostScriptLexer, GnuplotLexer, \ 25 | AsymptoteLexer, PovrayLexer 26 | from pygments.lexers.business import ABAPLexer, OpenEdgeLexer, \ 27 | GoodDataCLLexer, MaqlLexer 28 | from pygments.lexers.automation import AutoItLexer, AutohotkeyLexer 29 | from pygments.lexers.dsls import ProtoBufLexer, BroLexer, PuppetLexer, \ 30 | MscgenLexer, VGLLexer 31 | from pygments.lexers.basic import CbmBasicV2Lexer 32 | from pygments.lexers.pawn import SourcePawnLexer, PawnLexer 33 | from pygments.lexers.ecl import ECLLexer 34 | from pygments.lexers.urbi import UrbiscriptLexer 35 | from pygments.lexers.smalltalk import SmalltalkLexer, NewspeakLexer 36 | from pygments.lexers.installers import NSISLexer, RPMSpecLexer 37 | from pygments.lexers.textedit import AwkLexer 38 | from pygments.lexers.smv import NuSMVLexer 39 | 40 | __all__ = [] 41 | -------------------------------------------------------------------------------- /thirdparty/elftools/construct/lib/py3compat.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # py3compat.py 3 | # 4 | # Some Python2&3 compatibility code 5 | #------------------------------------------------------------------------------- 6 | import sys 7 | PY3 = sys.version_info[0] == 3 8 | 9 | try: 10 | from collections.abc import MutableMapping # python >= 3.3 11 | except ImportError: 12 | from collections import MutableMapping # python < 3.3 13 | 14 | 15 | if PY3: 16 | import io 17 | StringIO = io.StringIO 18 | BytesIO = io.BytesIO 19 | 20 | def bchr(i): 21 | """ When iterating over b'...' in Python 2 you get single b'_' chars 22 | and in Python 3 you get integers. Call bchr to always turn this 23 | to single b'_' chars. 24 | """ 25 | return bytes((i,)) 26 | 27 | def u(s): 28 | return s 29 | 30 | def int2byte(i): 31 | return bytes((i,)) 32 | 33 | def byte2int(b): 34 | return b 35 | 36 | def str2bytes(s): 37 | return s.encode("latin-1") 38 | 39 | def str2unicode(s): 40 | return s 41 | 42 | def bytes2str(b): 43 | return b.decode('latin-1') 44 | 45 | def decodebytes(b, encoding): 46 | return bytes(b, encoding) 47 | 48 | advance_iterator = next 49 | 50 | else: 51 | import cStringIO 52 | StringIO = BytesIO = cStringIO.StringIO 53 | 54 | int2byte = chr 55 | byte2int = ord 56 | bchr = lambda i: i 57 | 58 | def u(s): 59 | return unicode(s, "unicode_escape") 60 | 61 | def str2bytes(s): 62 | return s 63 | 64 | def str2unicode(s): 65 | return unicode(s, "unicode_escape") 66 | 67 | def bytes2str(b): 68 | return b 69 | 70 | def decodebytes(b, encoding): 71 | return b.decode(encoding) 72 | 73 | def advance_iterator(it): 74 | return it.next() 75 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/srcinfo.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.srcinfo 3 | ~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for .SRCINFO files used by Arch Linux Packages. 6 | 7 | The description of the format can be found in the wiki: https://wiki.archlinux.org/title/.SRCINFO 8 | 9 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 10 | :license: BSD, see LICENSE for details. 11 | """ 12 | 13 | from pygments.lexer import RegexLexer, words 14 | from pygments.token import Text, Comment, Keyword, Name, Operator, Whitespace 15 | 16 | __all__ = ['SrcinfoLexer'] 17 | 18 | keywords = ( 19 | 'pkgbase', 'pkgname', 20 | 'pkgver', 'pkgrel', 'epoch', 21 | 'pkgdesc', 'url', 'install', 'changelog', 22 | 'arch', 'groups', 'license', 'noextract', 'options', 'backup', 'validpgpkeys', 23 | ) 24 | 25 | architecture_dependent_keywords = ( 26 | 'source', 'depends', 'checkdepends', 'makedepends', 'optdepends', 27 | 'provides', 'conflicts', 'replaces', 28 | 'md5sums', 'sha1sums', 'sha224sums', 'sha256sums', 'sha384sums', 'sha512sums' 29 | ) 30 | 31 | class SrcinfoLexer(RegexLexer): 32 | """Lexer for .SRCINFO files used by Arch Linux Packages. 33 | 34 | .. versionadded:: 2.11 35 | """ 36 | 37 | name = 'Srcinfo' 38 | aliases = ['srcinfo'] 39 | filenames = ['.SRCINFO'] 40 | 41 | tokens = { 42 | 'root': [ 43 | (r'\s+', Whitespace), 44 | (r'#.*', Comment.Single), 45 | (words(keywords), Keyword, 'assignment'), 46 | (words(architecture_dependent_keywords, suffix=r'_\w+'), Keyword, 'assignment'), 47 | (r'\w+', Name.Variable, 'assignment'), 48 | ], 49 | 'assignment': [ 50 | (r' +', Whitespace), 51 | (r'=', Operator, 'value'), 52 | ], 53 | 'value': [ 54 | (r' +', Whitespace), 55 | (r'.*', Text, '#pop:2'), 56 | ], 57 | } 58 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/onedark.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.onedark 3 | ~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | One Dark Theme for Pygments by Tobias Zoghaib (https://github.com/TobiZog) 6 | 7 | Inspired by one-dark-ui for the code editor Atom 8 | (https://atom.io/themes/one-dark-ui). 9 | 10 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 11 | :license: BSD, see LICENSE for details. 12 | """ 13 | 14 | from pygments.style import Style 15 | from pygments.token import (Comment, Generic, Keyword, Name, Number, Operator, 16 | Punctuation, String, Token, Whitespace) 17 | 18 | 19 | class OneDarkStyle(Style): 20 | """ 21 | Theme inspired by One Dark Pro for Atom 22 | 23 | .. versionadded:: 2.11 24 | """ 25 | 26 | background_color = '#282C34' 27 | 28 | styles = { 29 | Token: '#ABB2BF', 30 | 31 | Punctuation: '#ABB2BF', 32 | Punctuation.Marker: '#ABB2BF', 33 | 34 | Keyword: '#C678DD', 35 | Keyword.Constant: '#E5C07B', 36 | Keyword.Declaration: '#C678DD', 37 | Keyword.Namespace: '#C678DD', 38 | Keyword.Reserved: '#C678DD', 39 | Keyword.Type: '#E5C07B', 40 | 41 | Name: '#E06C75', 42 | Name.Attribute: '#E06C75', 43 | Name.Builtin: '#E5C07B', 44 | Name.Class: '#E5C07B', 45 | Name.Function: 'bold #61AFEF', 46 | Name.Function.Magic: 'bold #56B6C2', 47 | Name.Other: '#E06C75', 48 | Name.Tag: '#E06C75', 49 | Name.Decorator: '#61AFEF', 50 | Name.Variable.Class: '', 51 | 52 | String: '#98C379', 53 | 54 | Number: '#D19A66', 55 | 56 | Operator: '#56B6C2', 57 | 58 | Comment: '#7F848E' 59 | } 60 | -------------------------------------------------------------------------------- /thirdparty/pygments/console.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.console 3 | ~~~~~~~~~~~~~~~~ 4 | 5 | Format colored console output. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | esc = "\x1b[" 12 | 13 | codes = {} 14 | codes[""] = "" 15 | codes["reset"] = esc + "39;49;00m" 16 | 17 | codes["bold"] = esc + "01m" 18 | codes["faint"] = esc + "02m" 19 | codes["standout"] = esc + "03m" 20 | codes["underline"] = esc + "04m" 21 | codes["blink"] = esc + "05m" 22 | codes["overline"] = esc + "06m" 23 | 24 | dark_colors = ["black", "red", "green", "yellow", "blue", 25 | "magenta", "cyan", "gray"] 26 | light_colors = ["brightblack", "brightred", "brightgreen", "brightyellow", "brightblue", 27 | "brightmagenta", "brightcyan", "white"] 28 | 29 | x = 30 30 | for d, l in zip(dark_colors, light_colors): 31 | codes[d] = esc + "%im" % x 32 | codes[l] = esc + "%im" % (60 + x) 33 | x += 1 34 | 35 | del d, l, x 36 | 37 | codes["white"] = codes["bold"] 38 | 39 | 40 | def reset_color(): 41 | return codes["reset"] 42 | 43 | 44 | def colorize(color_key, text): 45 | return codes[color_key] + text + codes["reset"] 46 | 47 | 48 | def ansiformat(attr, text): 49 | """ 50 | Format ``text`` with a color and/or some attributes:: 51 | 52 | color normal color 53 | *color* bold color 54 | _color_ underlined color 55 | +color+ blinking color 56 | """ 57 | result = [] 58 | if attr[:1] == attr[-1:] == '+': 59 | result.append(codes['blink']) 60 | attr = attr[1:-1] 61 | if attr[:1] == attr[-1:] == '*': 62 | result.append(codes['bold']) 63 | attr = attr[1:-1] 64 | if attr[:1] == attr[-1:] == '_': 65 | result.append(codes['underline']) 66 | attr = attr[1:-1] 67 | result.append(codes[attr]) 68 | result.append(text) 69 | result.append(codes['reset']) 70 | return ''.join(result) 71 | -------------------------------------------------------------------------------- /thirdparty/rich/_wrap.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import Iterable, List, Tuple 3 | 4 | from ._loop import loop_last 5 | from .cells import cell_len, chop_cells 6 | 7 | re_word = re.compile(r"\s*\S+\s*") 8 | 9 | 10 | def words(text: str) -> Iterable[Tuple[int, int, str]]: 11 | position = 0 12 | word_match = re_word.match(text, position) 13 | while word_match is not None: 14 | start, end = word_match.span() 15 | word = word_match.group(0) 16 | yield start, end, word 17 | word_match = re_word.match(text, end) 18 | 19 | 20 | def divide_line(text: str, width: int, fold: bool = True) -> List[int]: 21 | divides: List[int] = [] 22 | append = divides.append 23 | line_position = 0 24 | _cell_len = cell_len 25 | for start, _end, word in words(text): 26 | word_length = _cell_len(word.rstrip()) 27 | if line_position + word_length > width: 28 | if word_length > width: 29 | if fold: 30 | chopped_words = chop_cells(word, max_size=width, position=0) 31 | for last, line in loop_last(chopped_words): 32 | if start: 33 | append(start) 34 | 35 | if last: 36 | line_position = _cell_len(line) 37 | else: 38 | start += len(line) 39 | else: 40 | if start: 41 | append(start) 42 | line_position = _cell_len(word) 43 | elif line_position and start: 44 | append(start) 45 | line_position = _cell_len(word) 46 | else: 47 | line_position += _cell_len(word) 48 | return divides 49 | 50 | 51 | if __name__ == "__main__": # pragma: no cover 52 | from .console import Console 53 | 54 | console = Console(width=10) 55 | console.print("12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345") 56 | print(chop_cells("abcdefghijklmnopqrstuvwxyz", 10, position=2)) 57 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/filters/cli.py: -------------------------------------------------------------------------------- 1 | """ 2 | For backwards-compatibility. keep this file. 3 | (Many people are going to have key bindings that rely on this file.) 4 | """ 5 | from .app import * 6 | 7 | __all__ = [ 8 | # Old names. 9 | "HasArg", 10 | "HasCompletions", 11 | "HasFocus", 12 | "HasSelection", 13 | "HasValidationError", 14 | "IsDone", 15 | "IsReadOnly", 16 | "IsMultiline", 17 | "RendererHeightIsKnown", 18 | "InEditingMode", 19 | "InPasteMode", 20 | "ViMode", 21 | "ViNavigationMode", 22 | "ViInsertMode", 23 | "ViInsertMultipleMode", 24 | "ViReplaceMode", 25 | "ViSelectionMode", 26 | "ViWaitingForTextObjectMode", 27 | "ViDigraphMode", 28 | "EmacsMode", 29 | "EmacsInsertMode", 30 | "EmacsSelectionMode", 31 | "IsSearching", 32 | "HasSearch", 33 | "ControlIsSearchable", 34 | ] 35 | 36 | # Keep the original classnames for backwards compatibility. 37 | HasValidationError = lambda: has_validation_error 38 | HasArg = lambda: has_arg 39 | IsDone = lambda: is_done 40 | RendererHeightIsKnown = lambda: renderer_height_is_known 41 | ViNavigationMode = lambda: vi_navigation_mode 42 | InPasteMode = lambda: in_paste_mode 43 | EmacsMode = lambda: emacs_mode 44 | EmacsInsertMode = lambda: emacs_insert_mode 45 | ViMode = lambda: vi_mode 46 | IsSearching = lambda: is_searching 47 | HasSearch = lambda: is_searching 48 | ControlIsSearchable = lambda: control_is_searchable 49 | EmacsSelectionMode = lambda: emacs_selection_mode 50 | ViDigraphMode = lambda: vi_digraph_mode 51 | ViWaitingForTextObjectMode = lambda: vi_waiting_for_text_object_mode 52 | ViSelectionMode = lambda: vi_selection_mode 53 | ViReplaceMode = lambda: vi_replace_mode 54 | ViInsertMultipleMode = lambda: vi_insert_multiple_mode 55 | ViInsertMode = lambda: vi_insert_mode 56 | HasSelection = lambda: has_selection 57 | HasCompletions = lambda: has_completions 58 | IsReadOnly = lambda: is_read_only 59 | IsMultiline = lambda: is_multiline 60 | 61 | HasFocus = has_focus # No lambda here! (Has_focus is callable that returns a callable.) 62 | InEditingMode = in_editing_mode 63 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/key_binding/bindings/auto_suggest.py: -------------------------------------------------------------------------------- 1 | """ 2 | Key bindings for auto suggestion (for fish-style auto suggestion). 3 | """ 4 | import re 5 | 6 | from prompt_toolkit.application.current import get_app 7 | from prompt_toolkit.filters import Condition, emacs_mode 8 | from prompt_toolkit.key_binding.key_bindings import KeyBindings 9 | from prompt_toolkit.key_binding.key_processor import KeyPressEvent 10 | 11 | __all__ = [ 12 | "load_auto_suggest_bindings", 13 | ] 14 | 15 | E = KeyPressEvent 16 | 17 | 18 | def load_auto_suggest_bindings() -> KeyBindings: 19 | """ 20 | Key bindings for accepting auto suggestion text. 21 | 22 | (This has to come after the Vi bindings, because they also have an 23 | implementation for the "right arrow", but we really want the suggestion 24 | binding when a suggestion is available.) 25 | """ 26 | key_bindings = KeyBindings() 27 | handle = key_bindings.add 28 | 29 | @Condition 30 | def suggestion_available() -> bool: 31 | app = get_app() 32 | return ( 33 | app.current_buffer.suggestion is not None 34 | and len(app.current_buffer.suggestion.text) > 0 35 | and app.current_buffer.document.is_cursor_at_the_end 36 | ) 37 | 38 | @handle("c-f", filter=suggestion_available) 39 | @handle("c-e", filter=suggestion_available) 40 | @handle("right", filter=suggestion_available) 41 | def _accept(event: E) -> None: 42 | """ 43 | Accept suggestion. 44 | """ 45 | b = event.current_buffer 46 | suggestion = b.suggestion 47 | 48 | if suggestion: 49 | b.insert_text(suggestion.text) 50 | 51 | @handle("escape", "f", filter=suggestion_available & emacs_mode) 52 | def _fill(event: E) -> None: 53 | """ 54 | Fill partial suggestion. 55 | """ 56 | b = event.current_buffer 57 | suggestion = b.suggestion 58 | 59 | if suggestion: 60 | t = re.split(r"(\S+\s+)", suggestion.text) 61 | b.insert_text(next(x for x in t if x)) 62 | 63 | return key_bindings 64 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/output/conemu.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | assert sys.platform == "win32" 4 | 5 | from typing import Any, Optional, TextIO 6 | 7 | from prompt_toolkit.data_structures import Size 8 | 9 | from .base import Output 10 | from .color_depth import ColorDepth 11 | from .vt100 import Vt100_Output 12 | from .win32 import Win32Output 13 | 14 | __all__ = [ 15 | "ConEmuOutput", 16 | ] 17 | 18 | 19 | class ConEmuOutput: 20 | """ 21 | ConEmu (Windows) output abstraction. 22 | 23 | ConEmu is a Windows console application, but it also supports ANSI escape 24 | sequences. This output class is actually a proxy to both `Win32Output` and 25 | `Vt100_Output`. It uses `Win32Output` for console sizing and scrolling, but 26 | all cursor movements and scrolling happens through the `Vt100_Output`. 27 | 28 | This way, we can have 256 colors in ConEmu and Cmder. Rendering will be 29 | even a little faster as well. 30 | 31 | http://conemu.github.io/ 32 | http://gooseberrycreative.com/cmder/ 33 | """ 34 | 35 | def __init__( 36 | self, stdout: TextIO, default_color_depth: Optional[ColorDepth] = None 37 | ) -> None: 38 | self.win32_output = Win32Output(stdout, default_color_depth=default_color_depth) 39 | self.vt100_output = Vt100_Output( 40 | stdout, lambda: Size(0, 0), default_color_depth=default_color_depth 41 | ) 42 | 43 | @property 44 | def responds_to_cpr(self) -> bool: 45 | return False # We don't need this on Windows. 46 | 47 | def __getattr__(self, name: str) -> Any: 48 | if name in ( 49 | "get_size", 50 | "get_rows_below_cursor_position", 51 | "enable_mouse_support", 52 | "disable_mouse_support", 53 | "scroll_buffer_to_prompt", 54 | "get_win32_screen_buffer_info", 55 | "enable_bracketed_paste", 56 | "disable_bracketed_paste", 57 | ): 58 | return getattr(self.win32_output, name) 59 | else: 60 | return getattr(self.vt100_output, name) 61 | 62 | 63 | Output.register(ConEmuOutput) 64 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/_ada_builtins.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers._ada_builtins 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Ada builtins. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | KEYWORD_LIST = ( 12 | 'abort', 13 | 'abs', 14 | 'abstract', 15 | 'accept', 16 | 'access', 17 | 'aliased', 18 | 'all', 19 | 'array', 20 | 'at', 21 | 'begin', 22 | 'body', 23 | 'case', 24 | 'constant', 25 | 'declare', 26 | 'delay', 27 | 'delta', 28 | 'digits', 29 | 'do', 30 | 'else', 31 | 'elsif', 32 | 'end', 33 | 'entry', 34 | 'exception', 35 | 'exit', 36 | 'interface', 37 | 'for', 38 | 'goto', 39 | 'if', 40 | 'is', 41 | 'limited', 42 | 'loop', 43 | 'new', 44 | 'null', 45 | 'of', 46 | 'or', 47 | 'others', 48 | 'out', 49 | 'overriding', 50 | 'pragma', 51 | 'protected', 52 | 'raise', 53 | 'range', 54 | 'record', 55 | 'renames', 56 | 'requeue', 57 | 'return', 58 | 'reverse', 59 | 'select', 60 | 'separate', 61 | 'some', 62 | 'subtype', 63 | 'synchronized', 64 | 'task', 65 | 'tagged', 66 | 'terminate', 67 | 'then', 68 | 'type', 69 | 'until', 70 | 'when', 71 | 'while', 72 | 'xor' 73 | ) 74 | 75 | BUILTIN_LIST = ( 76 | 'Address', 77 | 'Byte', 78 | 'Boolean', 79 | 'Character', 80 | 'Controlled', 81 | 'Count', 82 | 'Cursor', 83 | 'Duration', 84 | 'File_Mode', 85 | 'File_Type', 86 | 'Float', 87 | 'Generator', 88 | 'Integer', 89 | 'Long_Float', 90 | 'Long_Integer', 91 | 'Long_Long_Float', 92 | 'Long_Long_Integer', 93 | 'Natural', 94 | 'Positive', 95 | 'Reference_Type', 96 | 'Short_Float', 97 | 'Short_Integer', 98 | 'Short_Short_Float', 99 | 'Short_Short_Integer', 100 | 'String', 101 | 'Wide_Character', 102 | 'Wide_String' 103 | ) 104 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/trac.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.trac 3 | ~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Port of the default trac highlighter design. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Keyword, Name, Comment, String, Error, \ 13 | Number, Operator, Generic, Whitespace 14 | 15 | 16 | class TracStyle(Style): 17 | """ 18 | Port of the default trac highlighter design. 19 | """ 20 | 21 | styles = { 22 | Whitespace: '#bbbbbb', 23 | Comment: 'italic #999988', 24 | Comment.Preproc: 'bold noitalic #999999', 25 | Comment.Special: 'bold #999999', 26 | 27 | Operator: 'bold', 28 | 29 | String: '#bb8844', 30 | String.Regex: '#808000', 31 | 32 | Number: '#009999', 33 | 34 | Keyword: 'bold', 35 | Keyword.Type: '#445588', 36 | 37 | Name.Builtin: '#999999', 38 | Name.Function: 'bold #990000', 39 | Name.Class: 'bold #445588', 40 | Name.Exception: 'bold #990000', 41 | Name.Namespace: '#555555', 42 | Name.Variable: '#008080', 43 | Name.Constant: '#008080', 44 | Name.Tag: '#000080', 45 | Name.Attribute: '#008080', 46 | Name.Entity: '#800080', 47 | 48 | Generic.Heading: '#999999', 49 | Generic.Subheading: '#aaaaaa', 50 | Generic.Deleted: 'bg:#ffdddd #000000', 51 | Generic.Inserted: 'bg:#ddffdd #000000', 52 | Generic.Error: '#aa0000', 53 | Generic.Emph: 'italic', 54 | Generic.Strong: 'bold', 55 | Generic.Prompt: '#555555', 56 | Generic.Output: '#888888', 57 | Generic.Traceback: '#aa0000', 58 | 59 | Error: 'bg:#e3d2d2 #a61717' 60 | } 61 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/iolang.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.iolang 3 | ~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for the Io language. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer 12 | from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 13 | Number, Whitespace 14 | 15 | __all__ = ['IoLexer'] 16 | 17 | 18 | class IoLexer(RegexLexer): 19 | """ 20 | For Io (a small, prototype-based programming language) source. 21 | 22 | .. versionadded:: 0.10 23 | """ 24 | name = 'Io' 25 | url = 'http://iolanguage.com/' 26 | filenames = ['*.io'] 27 | aliases = ['io'] 28 | mimetypes = ['text/x-iosrc'] 29 | tokens = { 30 | 'root': [ 31 | (r'\n', Whitespace), 32 | (r'\s+', Whitespace), 33 | # Comments 34 | (r'//(.*?)$', Comment.Single), 35 | (r'#(.*?)$', Comment.Single), 36 | (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 37 | (r'/\+', Comment.Multiline, 'nestedcomment'), 38 | # DoubleQuotedString 39 | (r'"(\\\\|\\[^\\]|[^"\\])*"', String), 40 | # Operators 41 | (r'::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}', 42 | Operator), 43 | # keywords 44 | (r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b', 45 | Keyword), 46 | # constants 47 | (r'(nil|false|true)\b', Name.Constant), 48 | # names 49 | (r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b', 50 | Name.Builtin), 51 | (r'[a-zA-Z_]\w*', Name), 52 | # numbers 53 | (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), 54 | (r'\d+', Number.Integer) 55 | ], 56 | 'nestedcomment': [ 57 | (r'[^+/]+', Comment.Multiline), 58 | (r'/\+', Comment.Multiline, '#push'), 59 | (r'\+/', Comment.Multiline, '#pop'), 60 | (r'[+/]', Comment.Multiline), 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/vim.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.vim 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | A highlighting style for Pygments, inspired by vim. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Keyword, Name, Comment, String, Error, \ 13 | Number, Operator, Generic, Whitespace, Token 14 | 15 | 16 | class VimStyle(Style): 17 | """ 18 | Styles somewhat like vim 7.0 19 | """ 20 | 21 | background_color = "#000000" 22 | highlight_color = "#222222" 23 | 24 | styles = { 25 | Token: "#cccccc", 26 | Whitespace: "", 27 | Comment: "#000080", 28 | Comment.Preproc: "", 29 | Comment.Special: "bold #cd0000", 30 | 31 | Keyword: "#cdcd00", 32 | Keyword.Declaration: "#00cd00", 33 | Keyword.Namespace: "#cd00cd", 34 | Keyword.Pseudo: "", 35 | Keyword.Type: "#00cd00", 36 | 37 | Operator: "#3399cc", 38 | Operator.Word: "#cdcd00", 39 | 40 | Name: "", 41 | Name.Class: "#00cdcd", 42 | Name.Builtin: "#cd00cd", 43 | Name.Exception: "bold #666699", 44 | Name.Variable: "#00cdcd", 45 | 46 | String: "#cd0000", 47 | Number: "#cd00cd", 48 | 49 | Generic.Heading: "bold #000080", 50 | Generic.Subheading: "bold #800080", 51 | Generic.Deleted: "#cd0000", 52 | Generic.Inserted: "#00cd00", 53 | Generic.Error: "#FF0000", 54 | Generic.Emph: "italic", 55 | Generic.Strong: "bold", 56 | Generic.Prompt: "bold #000080", 57 | Generic.Output: "#888", 58 | Generic.Traceback: "#04D", 59 | 60 | Error: "border:#FF0000" 61 | } 62 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/graphviz.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.graphviz 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for the DOT language (graphviz). 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer, bygroups 12 | from pygments.token import Comment, Keyword, Operator, Name, String, Number, \ 13 | Punctuation, Whitespace 14 | 15 | 16 | __all__ = ['GraphvizLexer'] 17 | 18 | 19 | class GraphvizLexer(RegexLexer): 20 | """ 21 | For graphviz DOT graph description language. 22 | 23 | .. versionadded:: 2.8 24 | """ 25 | name = 'Graphviz' 26 | url = 'https://www.graphviz.org/doc/info/lang.html' 27 | aliases = ['graphviz', 'dot'] 28 | filenames = ['*.gv', '*.dot'] 29 | mimetypes = ['text/x-graphviz', 'text/vnd.graphviz'] 30 | tokens = { 31 | 'root': [ 32 | (r'\s+', Whitespace), 33 | (r'(#|//).*?$', Comment.Single), 34 | (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 35 | (r'(?i)(node|edge|graph|digraph|subgraph|strict)\b', Keyword), 36 | (r'--|->', Operator), 37 | (r'[{}[\]:;,]', Punctuation), 38 | (r'(\b\D\w*)(\s*)(=)(\s*)', 39 | bygroups(Name.Attribute, Whitespace, Punctuation, Whitespace), 40 | 'attr_id'), 41 | (r'\b(n|ne|e|se|s|sw|w|nw|c|_)\b', Name.Builtin), 42 | (r'\b\D\w*', Name.Tag), # node 43 | (r'[-]?((\.[0-9]+)|([0-9]+(\.[0-9]*)?))', Number), 44 | (r'"(\\"|[^"])*?"', Name.Tag), # quoted node 45 | (r'<', Punctuation, 'xml'), 46 | ], 47 | 'attr_id': [ 48 | (r'\b\D\w*', String, '#pop'), 49 | (r'[-]?((\.[0-9]+)|([0-9]+(\.[0-9]*)?))', Number, '#pop'), 50 | (r'"(\\"|[^"])*?"', String.Double, '#pop'), 51 | (r'<', Punctuation, ('#pop', 'xml')), 52 | ], 53 | 'xml': [ 54 | (r'<', Punctuation, '#push'), 55 | (r'>', Punctuation, '#pop'), 56 | (r'\s+', Whitespace), 57 | (r'[^<>\s]', Name.Tag), 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/x10.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.x10 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for the X10 programming language. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer 12 | from pygments.token import Text, Comment, Keyword, String 13 | 14 | __all__ = ['X10Lexer'] 15 | 16 | class X10Lexer(RegexLexer): 17 | """ 18 | For the X10 language. 19 | 20 | .. versionadded:: 0.1 21 | """ 22 | 23 | name = 'X10' 24 | url = 'http://x10-lang.org/' 25 | aliases = ['x10', 'xten'] 26 | filenames = ['*.x10'] 27 | mimetypes = ['text/x-x10'] 28 | 29 | keywords = ( 30 | 'as', 'assert', 'async', 'at', 'athome', 'ateach', 'atomic', 31 | 'break', 'case', 'catch', 'class', 'clocked', 'continue', 32 | 'def', 'default', 'do', 'else', 'final', 'finally', 'finish', 33 | 'for', 'goto', 'haszero', 'here', 'if', 'import', 'in', 34 | 'instanceof', 'interface', 'isref', 'new', 'offer', 35 | 'operator', 'package', 'return', 'struct', 'switch', 'throw', 36 | 'try', 'type', 'val', 'var', 'when', 'while' 37 | ) 38 | 39 | types = ( 40 | 'void' 41 | ) 42 | 43 | values = ( 44 | 'false', 'null', 'self', 'super', 'this', 'true' 45 | ) 46 | 47 | modifiers = ( 48 | 'abstract', 'extends', 'implements', 'native', 'offers', 49 | 'private', 'property', 'protected', 'public', 'static', 50 | 'throws', 'transient' 51 | ) 52 | 53 | tokens = { 54 | 'root': [ 55 | (r'[^\S\n]+', Text), 56 | (r'//.*?\n', Comment.Single), 57 | (r'/\*(.|\n)*?\*/', Comment.Multiline), 58 | (r'\b(%s)\b' % '|'.join(keywords), Keyword), 59 | (r'\b(%s)\b' % '|'.join(types), Keyword.Type), 60 | (r'\b(%s)\b' % '|'.join(values), Keyword.Constant), 61 | (r'\b(%s)\b' % '|'.join(modifiers), Keyword.Declaration), 62 | (r'"(\\\\|\\[^\\]|[^"\\])*"', String), 63 | (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 64 | (r'.', Text) 65 | ], 66 | } 67 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/key_binding/defaults.py: -------------------------------------------------------------------------------- 1 | """ 2 | Default key bindings.:: 3 | 4 | key_bindings = load_key_bindings() 5 | app = Application(key_bindings=key_bindings) 6 | """ 7 | from prompt_toolkit.filters import buffer_has_focus 8 | from prompt_toolkit.key_binding.bindings.basic import load_basic_bindings 9 | from prompt_toolkit.key_binding.bindings.cpr import load_cpr_bindings 10 | from prompt_toolkit.key_binding.bindings.emacs import ( 11 | load_emacs_bindings, 12 | load_emacs_search_bindings, 13 | load_emacs_shift_selection_bindings, 14 | ) 15 | from prompt_toolkit.key_binding.bindings.mouse import load_mouse_bindings 16 | from prompt_toolkit.key_binding.bindings.vi import ( 17 | load_vi_bindings, 18 | load_vi_search_bindings, 19 | ) 20 | from prompt_toolkit.key_binding.key_bindings import ( 21 | ConditionalKeyBindings, 22 | KeyBindingsBase, 23 | merge_key_bindings, 24 | ) 25 | 26 | __all__ = [ 27 | "load_key_bindings", 28 | ] 29 | 30 | 31 | def load_key_bindings() -> KeyBindingsBase: 32 | """ 33 | Create a KeyBindings object that contains the default key bindings. 34 | """ 35 | all_bindings = merge_key_bindings( 36 | [ 37 | # Load basic bindings. 38 | load_basic_bindings(), 39 | # Load emacs bindings. 40 | load_emacs_bindings(), 41 | load_emacs_search_bindings(), 42 | load_emacs_shift_selection_bindings(), 43 | # Load Vi bindings. 44 | load_vi_bindings(), 45 | load_vi_search_bindings(), 46 | ] 47 | ) 48 | 49 | return merge_key_bindings( 50 | [ 51 | # Make sure that the above key bindings are only active if the 52 | # currently focused control is a `BufferControl`. For other controls, we 53 | # don't want these key bindings to intervene. (This would break "ptterm" 54 | # for instance, which handles 'Keys.Any' in the user control itself.) 55 | ConditionalKeyBindings(all_bindings, buffer_has_focus), 56 | # Active, even when no buffer has been focused. 57 | load_mouse_bindings(), 58 | load_cpr_bindings(), 59 | ] 60 | ) 61 | -------------------------------------------------------------------------------- /thirdparty/rich/_windows.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from dataclasses import dataclass 3 | 4 | 5 | @dataclass 6 | class WindowsConsoleFeatures: 7 | """Windows features available.""" 8 | 9 | vt: bool = False 10 | """The console supports VT codes.""" 11 | truecolor: bool = False 12 | """The console supports truecolor.""" 13 | 14 | 15 | try: 16 | import ctypes 17 | from ctypes import LibraryLoader 18 | 19 | if sys.platform == "win32": 20 | windll = LibraryLoader(ctypes.WinDLL) 21 | else: 22 | windll = None 23 | raise ImportError("Not windows") 24 | 25 | from rich._win32_console import ( 26 | ENABLE_VIRTUAL_TERMINAL_PROCESSING, 27 | GetConsoleMode, 28 | GetStdHandle, 29 | LegacyWindowsError, 30 | ) 31 | 32 | except (AttributeError, ImportError, ValueError): 33 | 34 | # Fallback if we can't load the Windows DLL 35 | def get_windows_console_features() -> WindowsConsoleFeatures: 36 | features = WindowsConsoleFeatures() 37 | return features 38 | 39 | else: 40 | 41 | def get_windows_console_features() -> WindowsConsoleFeatures: 42 | """Get windows console features. 43 | 44 | Returns: 45 | WindowsConsoleFeatures: An instance of WindowsConsoleFeatures. 46 | """ 47 | handle = GetStdHandle() 48 | try: 49 | console_mode = GetConsoleMode(handle) 50 | success = True 51 | except LegacyWindowsError: 52 | console_mode = 0 53 | success = False 54 | vt = bool(success and console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) 55 | truecolor = False 56 | if vt: 57 | win_version = sys.getwindowsversion() 58 | truecolor = win_version.major > 10 or ( 59 | win_version.major == 10 and win_version.build >= 15063 60 | ) 61 | features = WindowsConsoleFeatures(vt=vt, truecolor=truecolor) 62 | return features 63 | 64 | 65 | if __name__ == "__main__": 66 | import platform 67 | 68 | features = get_windows_console_features() 69 | from rich import print 70 | 71 | print(f'platform="{platform.system()}"') 72 | print(repr(features)) 73 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/native.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.native 3 | ~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | pygments version of my "native" vim theme. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Keyword, Name, Comment, String, Error, \ 13 | Number, Operator, Generic, Token, Whitespace 14 | 15 | 16 | class NativeStyle(Style): 17 | """ 18 | Pygments version of the "native" vim theme. 19 | """ 20 | 21 | background_color = '#202020' 22 | highlight_color = '#404040' 23 | line_number_color = '#aaaaaa' 24 | 25 | styles = { 26 | Token: '#d0d0d0', 27 | Whitespace: '#666666', 28 | 29 | Comment: 'italic #ababab', 30 | Comment.Preproc: 'noitalic bold #cd2828', 31 | Comment.Special: 'noitalic bold #e50808 bg:#520000', 32 | 33 | Keyword: 'bold #6ebf26', 34 | Keyword.Pseudo: 'nobold', 35 | Operator.Word: 'bold #6ebf26', 36 | 37 | String: '#ed9d13', 38 | String.Other: '#ffa500', 39 | 40 | Number: '#51b2fd', 41 | 42 | Name.Builtin: '#2fbccd', 43 | Name.Variable: '#40ffff', 44 | Name.Constant: '#40ffff', 45 | Name.Class: 'underline #71adff', 46 | Name.Function: '#71adff', 47 | Name.Namespace: 'underline #71adff', 48 | Name.Exception: '#bbbbbb', 49 | Name.Tag: 'bold #6ebf26', 50 | Name.Attribute: '#bbbbbb', 51 | Name.Decorator: '#ffa500', 52 | 53 | Generic.Heading: 'bold #ffffff', 54 | Generic.Subheading: 'underline #ffffff', 55 | Generic.Deleted: '#d22323', 56 | Generic.Inserted: '#589819', 57 | Generic.Error: '#d22323', 58 | Generic.Emph: 'italic', 59 | Generic.Strong: 'bold', 60 | Generic.Prompt: '#aaaaaa', 61 | Generic.Output: '#cccccc', 62 | Generic.Traceback: '#d22323', 63 | 64 | Error: 'bg:#e3d2d2 #a61717' 65 | } 66 | -------------------------------------------------------------------------------- /thirdparty/pygments/filter.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.filter 3 | ~~~~~~~~~~~~~~~ 4 | 5 | Module that implements the default filter. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | 12 | def apply_filters(stream, filters, lexer=None): 13 | """ 14 | Use this method to apply an iterable of filters to 15 | a stream. If lexer is given it's forwarded to the 16 | filter, otherwise the filter receives `None`. 17 | """ 18 | def _apply(filter_, stream): 19 | yield from filter_.filter(lexer, stream) 20 | for filter_ in filters: 21 | stream = _apply(filter_, stream) 22 | return stream 23 | 24 | 25 | def simplefilter(f): 26 | """ 27 | Decorator that converts a function into a filter:: 28 | 29 | @simplefilter 30 | def lowercase(self, lexer, stream, options): 31 | for ttype, value in stream: 32 | yield ttype, value.lower() 33 | """ 34 | return type(f.__name__, (FunctionFilter,), { 35 | '__module__': getattr(f, '__module__'), 36 | '__doc__': f.__doc__, 37 | 'function': f, 38 | }) 39 | 40 | 41 | class Filter: 42 | """ 43 | Default filter. Subclass this class or use the `simplefilter` 44 | decorator to create own filters. 45 | """ 46 | 47 | def __init__(self, **options): 48 | self.options = options 49 | 50 | def filter(self, lexer, stream): 51 | raise NotImplementedError() 52 | 53 | 54 | class FunctionFilter(Filter): 55 | """ 56 | Abstract class used by `simplefilter` to create simple 57 | function filters on the fly. The `simplefilter` decorator 58 | automatically creates subclasses of this class for 59 | functions passed to it. 60 | """ 61 | function = None 62 | 63 | def __init__(self, **options): 64 | if not hasattr(self, 'function'): 65 | raise TypeError('%r used without bound function' % 66 | self.__class__.__name__) 67 | Filter.__init__(self, **options) 68 | 69 | def filter(self, lexer, stream): 70 | # pylint: disable=not-callable 71 | yield from self.function(lexer, stream, self.options) 72 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/sgf.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.sgf 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for Smart Game Format (sgf) file format. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer, bygroups 12 | from pygments.token import Name, Literal, String, Text, Punctuation, Whitespace 13 | 14 | __all__ = ["SmartGameFormatLexer"] 15 | 16 | 17 | class SmartGameFormatLexer(RegexLexer): 18 | """ 19 | Lexer for Smart Game Format (sgf) file format. 20 | 21 | The format is used to store game records of board games for two players 22 | (mainly Go game). 23 | 24 | .. versionadded:: 2.4 25 | """ 26 | name = 'SmartGameFormat' 27 | url = 'https://www.red-bean.com/sgf/' 28 | aliases = ['sgf'] 29 | filenames = ['*.sgf'] 30 | 31 | tokens = { 32 | 'root': [ 33 | (r'[():;]+', Punctuation), 34 | # tokens: 35 | (r'(A[BW]|AE|AN|AP|AR|AS|[BW]L|BM|[BW]R|[BW]S|[BW]T|CA|CH|CP|CR|' 36 | r'DD|DM|DO|DT|EL|EV|EX|FF|FG|G[BW]|GC|GM|GN|HA|HO|ID|IP|IT|IY|KM|' 37 | r'KO|LB|LN|LT|L|MA|MN|M|N|OB|OM|ON|OP|OT|OV|P[BW]|PC|PL|PM|RE|RG|' 38 | r'RO|RU|SO|SC|SE|SI|SL|SO|SQ|ST|SU|SZ|T[BW]|TC|TE|TM|TR|UC|US|VW|' 39 | r'V|[BW]|C)', 40 | Name.Builtin), 41 | # number: 42 | (r'(\[)([0-9.]+)(\])', 43 | bygroups(Punctuation, Literal.Number, Punctuation)), 44 | # date: 45 | (r'(\[)([0-9]{4}-[0-9]{2}-[0-9]{2})(\])', 46 | bygroups(Punctuation, Literal.Date, Punctuation)), 47 | # point: 48 | (r'(\[)([a-z]{2})(\])', 49 | bygroups(Punctuation, String, Punctuation)), 50 | # double points: 51 | (r'(\[)([a-z]{2})(:)([a-z]{2})(\])', 52 | bygroups(Punctuation, String, Punctuation, String, Punctuation)), 53 | 54 | (r'(\[)([\w\s#()+,\-.:?]+)(\])', 55 | bygroups(Punctuation, String, Punctuation)), 56 | (r'(\[)(\s.*)(\])', 57 | bygroups(Punctuation, Whitespace, Punctuation)), 58 | (r'\s+', Whitespace) 59 | ], 60 | } 61 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/styles/pygments.py: -------------------------------------------------------------------------------- 1 | """ 2 | Adaptor for building prompt_toolkit styles, starting from a Pygments style. 3 | 4 | Usage:: 5 | 6 | from pygments.styles.tango import TangoStyle 7 | style = style_from_pygments_cls(pygments_style_cls=TangoStyle) 8 | """ 9 | from typing import TYPE_CHECKING, Dict, Type 10 | 11 | from .style import Style 12 | 13 | if TYPE_CHECKING: 14 | from pygments.style import Style as PygmentsStyle 15 | from pygments.token import Token 16 | 17 | 18 | __all__ = [ 19 | "style_from_pygments_cls", 20 | "style_from_pygments_dict", 21 | "pygments_token_to_classname", 22 | ] 23 | 24 | 25 | def style_from_pygments_cls(pygments_style_cls: Type["PygmentsStyle"]) -> Style: 26 | """ 27 | Shortcut to create a :class:`.Style` instance from a Pygments style class 28 | and a style dictionary. 29 | 30 | Example:: 31 | 32 | from prompt_toolkit.styles.from_pygments import style_from_pygments_cls 33 | from pygments.styles import get_style_by_name 34 | style = style_from_pygments_cls(get_style_by_name('monokai')) 35 | 36 | :param pygments_style_cls: Pygments style class to start from. 37 | """ 38 | # Import inline. 39 | from pygments.style import Style as PygmentsStyle 40 | 41 | assert issubclass(pygments_style_cls, PygmentsStyle) 42 | 43 | return style_from_pygments_dict(pygments_style_cls.styles) 44 | 45 | 46 | def style_from_pygments_dict(pygments_dict: Dict["Token", str]) -> Style: 47 | """ 48 | Create a :class:`.Style` instance from a Pygments style dictionary. 49 | (One that maps Token objects to style strings.) 50 | """ 51 | pygments_style = [] 52 | 53 | for token, style in pygments_dict.items(): 54 | pygments_style.append((pygments_token_to_classname(token), style)) 55 | 56 | return Style(pygments_style) 57 | 58 | 59 | def pygments_token_to_classname(token: "Token") -> str: 60 | """ 61 | Turn e.g. `Token.Name.Exception` into `'pygments.name.exception'`. 62 | 63 | (Our Pygments lexer will also turn the tokens that pygments produces in a 64 | prompt_toolkit list of fragments that match these styling rules.) 65 | """ 66 | parts = ("pygments",) + token 67 | return ".".join(parts).lower() 68 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/lilypond.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.lilypond 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | LilyPond-specific style. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.style import Style 12 | from pygments.token import Token 13 | 14 | class LilyPondStyle(Style): 15 | """ 16 | Style for the LilyPond language. 17 | 18 | .. versionadded:: 2.11 19 | """ 20 | 21 | # Don't show it in the gallery, it's intended for LilyPond 22 | # input only and doesn't show good output on Python code. 23 | web_style_gallery_exclude = True 24 | 25 | styles = { 26 | Token.Text: "", 27 | Token.Keyword: "bold", 28 | Token.Comment: "italic #A3AAB2", 29 | Token.String: "#AB0909", 30 | Token.String.Escape: "#C46C6C", 31 | Token.String.Symbol: "noinherit", 32 | Token.Pitch: "", #"#911520", 33 | Token.Number: "#976806", # includes durations 34 | # A bare 11 is not distinguishable from a number, so we highlight 35 | # the same. 36 | Token.ChordModifier: "#976806", 37 | Token.Name.Lvalue: "#08547A", 38 | Token.Name.BackslashReference: "#08547A", 39 | Token.Name.Builtin.MusicCommand: "bold #08547A", 40 | Token.Name.Builtin.PaperVariable: "bold #6C5A05", 41 | Token.Name.Builtin.HeaderVariable: "bold #6C5A05", 42 | Token.Name.Builtin.MusicFunction: "bold #08547A", 43 | Token.Name.Builtin.Clef: "bold #08547A", 44 | Token.Name.Builtin.Scale: "bold #08547A", 45 | Token.Name.Builtin.RepeatType: "#08547A", 46 | Token.Name.Builtin.Dynamic: "#68175A", 47 | Token.Name.Builtin.Articulation: "#68175A", 48 | Token.Name.Builtin.SchemeFunction: "bold #A83401", 49 | Token.Name.Builtin.SchemeBuiltin: "bold", 50 | Token.Name.Builtin.MarkupCommand: "bold #831E71", 51 | Token.Name.Builtin.Context: "bold #038B8B", 52 | Token.Name.Builtin.ContextProperty: "#038B8B", 53 | Token.Name.Builtin.Grob: "bold #0C7441", 54 | Token.Name.Builtin.GrobProperty: "#0C7441", 55 | Token.Name.Builtin.Translator: "bold #6200A4", 56 | } 57 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/filters/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Filters decide whether something is active or not (they decide about a boolean 3 | state). This is used to enable/disable features, like key bindings, parts of 4 | the layout and other stuff. For instance, we could have a `HasSearch` filter 5 | attached to some part of the layout, in order to show that part of the user 6 | interface only while the user is searching. 7 | 8 | Filters are made to avoid having to attach callbacks to all event in order to 9 | propagate state. However, they are lazy, they don't automatically propagate the 10 | state of what they are observing. Only when a filter is called (it's actually a 11 | callable), it will calculate its value. So, its not really reactive 12 | programming, but it's made to fit for this framework. 13 | 14 | Filters can be chained using ``&`` and ``|`` operations, and inverted using the 15 | ``~`` operator, for instance:: 16 | 17 | filter = has_focus('default') & ~ has_selection 18 | """ 19 | from .app import * 20 | from .base import Always, Condition, Filter, FilterOrBool, Never 21 | from .cli import * 22 | from .utils import is_true, to_filter 23 | 24 | __all__ = [ 25 | # app 26 | "has_arg", 27 | "has_completions", 28 | "completion_is_selected", 29 | "has_focus", 30 | "buffer_has_focus", 31 | "has_selection", 32 | "has_validation_error", 33 | "is_done", 34 | "is_read_only", 35 | "is_multiline", 36 | "renderer_height_is_known", 37 | "in_editing_mode", 38 | "in_paste_mode", 39 | "vi_mode", 40 | "vi_navigation_mode", 41 | "vi_insert_mode", 42 | "vi_insert_multiple_mode", 43 | "vi_replace_mode", 44 | "vi_selection_mode", 45 | "vi_waiting_for_text_object_mode", 46 | "vi_digraph_mode", 47 | "vi_recording_macro", 48 | "emacs_mode", 49 | "emacs_insert_mode", 50 | "emacs_selection_mode", 51 | "shift_selection_mode", 52 | "is_searching", 53 | "control_is_searchable", 54 | "vi_search_direction_reversed", 55 | # base. 56 | "Filter", 57 | "Never", 58 | "Always", 59 | "Condition", 60 | "FilterOrBool", 61 | # utils. 62 | "is_true", 63 | "to_filter", 64 | ] 65 | 66 | from .cli import __all__ as cli_all 67 | 68 | __all__.extend(cli_all) 69 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/rnc.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.rnc 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for Relax-NG Compact syntax 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | from pygments.lexer import RegexLexer 12 | from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 13 | Punctuation 14 | 15 | __all__ = ['RNCCompactLexer'] 16 | 17 | 18 | class RNCCompactLexer(RegexLexer): 19 | """ 20 | For RelaxNG-compact syntax. 21 | 22 | .. versionadded:: 2.2 23 | """ 24 | 25 | name = 'Relax-NG Compact' 26 | url = 'http://relaxng.org' 27 | aliases = ['rng-compact', 'rnc'] 28 | filenames = ['*.rnc'] 29 | 30 | tokens = { 31 | 'root': [ 32 | (r'namespace\b', Keyword.Namespace), 33 | (r'(?:default|datatypes)\b', Keyword.Declaration), 34 | (r'##.*$', Comment.Preproc), 35 | (r'#.*$', Comment.Single), 36 | (r'"[^"]*"', String.Double), 37 | # TODO single quoted strings and escape sequences outside of 38 | # double-quoted strings 39 | (r'(?:element|attribute|mixed)\b', Keyword.Declaration, 'variable'), 40 | (r'(text\b|xsd:[^ ]+)', Keyword.Type, 'maybe_xsdattributes'), 41 | (r'[,?&*=|~]|>>', Operator), 42 | (r'[(){}]', Punctuation), 43 | (r'.', Text), 44 | ], 45 | 46 | # a variable has been declared using `element` or `attribute` 47 | 'variable': [ 48 | (r'[^{]+', Name.Variable), 49 | (r'\{', Punctuation, '#pop'), 50 | ], 51 | 52 | # after an xsd:
16 | {code}
17 |
18 |
19 |
20 | """
21 |
22 | CONSOLE_SVG_FORMAT = """\
23 |
75 | """
76 |
77 | _SVG_FONT_FAMILY = "Rich Fira Code"
78 | _SVG_CLASSES_PREFIX = "rich-svg"
79 |
--------------------------------------------------------------------------------
/thirdparty/pygments/styles/algol.py:
--------------------------------------------------------------------------------
1 | """
2 | pygments.styles.algol
3 | ~~~~~~~~~~~~~~~~~~~~~
4 |
5 | Algol publication style.
6 |
7 | This style renders source code for publication of algorithms in
8 | scientific papers and academic texts, where its format is frequently used.
9 |
10 | It is based on the style of the revised Algol-60 language report[1].
11 |
12 | o No colours, only black, white and shades of grey are used.
13 | o Keywords are rendered in lowercase underline boldface.
14 | o Builtins are rendered in lowercase boldface italic.
15 | o Docstrings and pragmas are rendered in dark grey boldface.
16 | o Library identifiers are rendered in dark grey boldface italic.
17 | o Comments are rendered in grey italic.
18 |
19 | To render keywords without underlining, refer to the `Algol_Nu` style.
20 |
21 | For lowercase conversion of keywords and builtins in languages where
22 | these are not or might not be lowercase, a supporting lexer is required.
23 | The Algol and Modula-2 lexers automatically convert to lowercase whenever
24 | this style is selected.
25 |
26 | [1] `Revised Report on the Algorithmic Language Algol-60