├── 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 ENTER to quit."), 34 | key_bindings=kb, 35 | ) 36 | window = Window(content=control, height=D(min=1)) 37 | return Layout(container=window, focused_element=window) 38 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/vs.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.vs 3 | ~~~~~~~~~~~~~~~~~~ 4 | 5 | Simple style with MS Visual Studio colors. 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 VisualStudioStyle(Style): 17 | 18 | background_color = "#ffffff" 19 | 20 | styles = { 21 | Comment: "#008000", 22 | Comment.Preproc: "#0000ff", 23 | Keyword: "#0000ff", 24 | Operator.Word: "#0000ff", 25 | Keyword.Type: "#2b91af", 26 | Name.Class: "#2b91af", 27 | String: "#a31515", 28 | 29 | Generic.Heading: "bold", 30 | Generic.Subheading: "bold", 31 | Generic.Emph: "italic", 32 | Generic.Strong: "bold", 33 | Generic.Prompt: "bold", 34 | 35 | Error: "border:#FF0000" 36 | } 37 | -------------------------------------------------------------------------------- /core/riposte_sf/input_streams.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | from pathlib import Path 3 | from typing import Callable, Generator 4 | 5 | from .exceptions import StopRiposteException 6 | 7 | 8 | def prompt_input(prompt: Callable, _input: Callable) -> Generator[Callable, None, None]: 9 | """ Unexhaustible generator yielding `input` function forever. """ 10 | yield from itertools.repeat(lambda: _input(prompt())) 11 | 12 | 13 | def any_input(_input: Callable) -> Generator[Callable, None, None]: 14 | """ Unexhaustible generator yielding `input` function forever. """ 15 | yield from itertools.repeat(lambda: _input()) 16 | 17 | 18 | def cli_input(inline_commands: str) -> Generator[Callable, None, None]: 19 | """ Translate inline command provided via '-c' into input stream. """ 20 | yield lambda: inline_commands 21 | 22 | 23 | def file_input(path: Path) -> Generator[Callable, None, None]: 24 | """ Read file and translate it into input stream """ 25 | try: 26 | with open(path, "r") as file_handler: 27 | for line in file_handler: 28 | yield lambda: line 29 | except Exception: 30 | raise StopRiposteException(f"Problem with reading the file: {path}") 31 | -------------------------------------------------------------------------------- /core/utils/TextParser.py: -------------------------------------------------------------------------------- 1 | def remove_quotes(in_str): 2 | out_str = in_str.strip() 3 | 4 | if not in_str: return '' 5 | 6 | if out_str[0] in ['\'', '"']: 7 | if out_str[0] != out_str[-1]: 8 | raise ValueError('Unterminated quoted string') 9 | else: 10 | out_str = out_str[1:-1] 11 | return out_str 12 | 13 | 14 | def format_bytes(size): 15 | """Return the given bytes as a human friendly KB, MB, GB, or TB string.""" 16 | B = float(size) 17 | KB = float(1024) 18 | MB = float(KB ** 2) # 1,048,576 19 | GB = float(KB ** 3) # 1,073,741,824 20 | TB = float(KB ** 4) # 1,099,511,627,776 21 | 22 | if B < KB: 23 | return '{0} {1}'.format(B,'Bytes' if 0 == B > 1 else 'Byte') 24 | elif KB <= B < MB: 25 | return '{0:.2f} KB'.format(B / KB) 26 | elif MB <= B < GB: 27 | return '{0:.2f} MB'.format(B / MB) 28 | elif GB <= B < TB: 29 | return '{0:.2f} GB'.format(B / GB) 30 | elif TB <= B: 31 | return '{0:.2f} TB'.format(B / TB) 32 | 33 | 34 | def format_float(data): 35 | return "{:4.2f}".format(data) 36 | 37 | 38 | def get_format_arg_count(mask): 39 | 40 | for i in range(150): 41 | 42 | try: 43 | out_str = mask.format(*list(range(i))) 44 | return i 45 | except IndexError: 46 | pass 47 | 48 | -------------------------------------------------------------------------------- /thirdparty/rich/_emoji_replace.py: -------------------------------------------------------------------------------- 1 | from typing import Callable, Match, Optional 2 | import re 3 | 4 | from ._emoji_codes import EMOJI 5 | 6 | 7 | _ReStringMatch = Match[str] # regex match object 8 | _ReSubCallable = Callable[[_ReStringMatch], str] # Callable invoked by re.sub 9 | _EmojiSubMethod = Callable[[_ReSubCallable, str], str] # Sub method of a compiled re 10 | 11 | 12 | def _emoji_replace( 13 | text: str, 14 | default_variant: Optional[str] = None, 15 | _emoji_sub: _EmojiSubMethod = re.compile(r"(:(\S*?)(?:(?:\-)(emoji|text))?:)").sub, 16 | ) -> str: 17 | """Replace emoji code in text.""" 18 | get_emoji = EMOJI.__getitem__ 19 | variants = {"text": "\uFE0E", "emoji": "\uFE0F"} 20 | get_variant = variants.get 21 | default_variant_code = variants.get(default_variant, "") if default_variant else "" 22 | 23 | def do_replace(match: Match[str]) -> str: 24 | emoji_code, emoji_name, variant = match.groups() 25 | try: 26 | return get_emoji(emoji_name.lower()) + get_variant( 27 | variant, default_variant_code 28 | ) 29 | except KeyError: 30 | return emoji_code 31 | 32 | return _emoji_sub(do_replace, text) 33 | -------------------------------------------------------------------------------- /thirdparty/rich/color_triplet.py: -------------------------------------------------------------------------------- 1 | from typing import NamedTuple, Tuple 2 | 3 | 4 | class ColorTriplet(NamedTuple): 5 | """The red, green, and blue components of a color.""" 6 | 7 | red: int 8 | """Red component in 0 to 255 range.""" 9 | green: int 10 | """Green component in 0 to 255 range.""" 11 | blue: int 12 | """Blue component in 0 to 255 range.""" 13 | 14 | @property 15 | def hex(self) -> str: 16 | """get the color triplet in CSS style.""" 17 | red, green, blue = self 18 | return f"#{red:02x}{green:02x}{blue:02x}" 19 | 20 | @property 21 | def rgb(self) -> str: 22 | """The color in RGB format. 23 | 24 | Returns: 25 | str: An rgb color, e.g. ``"rgb(100,23,255)"``. 26 | """ 27 | red, green, blue = self 28 | return f"rgb({red},{green},{blue})" 29 | 30 | @property 31 | def normalized(self) -> Tuple[float, float, float]: 32 | """Convert components into floats between 0 and 1. 33 | 34 | Returns: 35 | Tuple[float, float, float]: A tuple of three normalized colour components. 36 | """ 37 | red, green, blue = self 38 | return red / 255.0, green / 255.0, blue / 255.0 39 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/clipboard/in_memory.py: -------------------------------------------------------------------------------- 1 | from collections import deque 2 | from typing import Deque, Optional 3 | 4 | from .base import Clipboard, ClipboardData 5 | 6 | __all__ = [ 7 | "InMemoryClipboard", 8 | ] 9 | 10 | 11 | class InMemoryClipboard(Clipboard): 12 | """ 13 | Default clipboard implementation. 14 | Just keep the data in memory. 15 | 16 | This implements a kill-ring, for Emacs mode. 17 | """ 18 | 19 | def __init__( 20 | self, data: Optional[ClipboardData] = None, max_size: int = 60 21 | ) -> None: 22 | 23 | assert max_size >= 1 24 | 25 | self.max_size = max_size 26 | self._ring: Deque[ClipboardData] = deque() 27 | 28 | if data is not None: 29 | self.set_data(data) 30 | 31 | def set_data(self, data: ClipboardData) -> None: 32 | self._ring.appendleft(data) 33 | 34 | while len(self._ring) > self.max_size: 35 | self._ring.pop() 36 | 37 | def get_data(self) -> ClipboardData: 38 | if self._ring: 39 | return self._ring[0] 40 | else: 41 | return ClipboardData() 42 | 43 | def rotate(self) -> None: 44 | if self._ring: 45 | # Add the very first item at the end. 46 | self._ring.append(self._ring.popleft()) 47 | -------------------------------------------------------------------------------- /thirdparty/commonmark/render/renderer.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | 4 | class Renderer(object): 5 | def render(self, ast): 6 | """Walks the AST and calls member methods for each Node type. 7 | 8 | @param ast {Node} The root of the abstract syntax tree. 9 | """ 10 | walker = ast.walker() 11 | 12 | self.buf = '' 13 | self.last_out = '\n' 14 | 15 | event = walker.nxt() 16 | while event is not None: 17 | type_ = event['node'].t 18 | if hasattr(self, type_): 19 | getattr(self, type_)(event['node'], event['entering']) 20 | event = walker.nxt() 21 | 22 | return self.buf 23 | 24 | def lit(self, s): 25 | """Concatenate a literal string to the buffer. 26 | 27 | @param str {String} The string to concatenate. 28 | """ 29 | self.buf += s 30 | self.last_out = s 31 | 32 | def cr(self): 33 | if self.last_out != '\n': 34 | self.lit('\n') 35 | 36 | def out(self, s): 37 | """Concatenate a string to the buffer possibly escaping the content. 38 | 39 | Concrete renderer implementations should override this method. 40 | 41 | @param str {String} The string to concatenate. 42 | """ 43 | self.lit(s) 44 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/procfile.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.procfile 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexer for Procfile 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, Number, String, Text, Punctuation 13 | 14 | __all__ = ["ProcfileLexer"] 15 | 16 | 17 | class ProcfileLexer(RegexLexer): 18 | """ 19 | Lexer for Procfile file format. 20 | 21 | The format is used to run processes on Heroku or is used by Foreman or 22 | Honcho tools. 23 | 24 | .. versionadded:: 2.10 25 | """ 26 | name = 'Procfile' 27 | url = 'https://devcenter.heroku.com/articles/procfile#procfile-format' 28 | aliases = ['procfile'] 29 | filenames = ['Procfile'] 30 | 31 | tokens = { 32 | 'root': [ 33 | (r'^([a-z]+)(:)', bygroups(Name.Label, Punctuation)), 34 | (r'\s+', Text.Whitespace), 35 | (r'"[^"]*"', String), 36 | (r"'[^']*'", String), 37 | (r'[0-9]+', Number.Integer), 38 | (r'\$[a-zA-Z_][\w]*', Name.Variable), 39 | (r'(\w+)(=)(\w+)', bygroups(Name.Variable, Punctuation, String)), 40 | (r'([\w\-\./]+)', Text), 41 | ], 42 | } 43 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/clipboard/pyperclip.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | import pyperclip 4 | 5 | from prompt_toolkit.selection import SelectionType 6 | 7 | from .base import Clipboard, ClipboardData 8 | 9 | __all__ = [ 10 | "PyperclipClipboard", 11 | ] 12 | 13 | 14 | class PyperclipClipboard(Clipboard): 15 | """ 16 | Clipboard that synchronizes with the Windows/Mac/Linux system clipboard, 17 | using the pyperclip module. 18 | """ 19 | 20 | def __init__(self) -> None: 21 | self._data: Optional[ClipboardData] = None 22 | 23 | def set_data(self, data: ClipboardData) -> None: 24 | self._data = data 25 | pyperclip.copy(data.text) 26 | 27 | def get_data(self) -> ClipboardData: 28 | text = pyperclip.paste() 29 | 30 | # When the clipboard data is equal to what we copied last time, reuse 31 | # the `ClipboardData` instance. That way we're sure to keep the same 32 | # `SelectionType`. 33 | if self._data and self._data.text == text: 34 | return self._data 35 | 36 | # Pyperclip returned something else. Create a new `ClipboardData` 37 | # instance. 38 | else: 39 | return ClipboardData( 40 | text=text, 41 | type=SelectionType.LINES if "\n" in text else SelectionType.CHARACTERS, 42 | ) 43 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/stata_dark.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.stata_dark 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Dark style inspired by Stata's do-file editor. Note this is not 6 | meant to be a complete style, just for Stata's file formats. 7 | 8 | 9 | :copyright: Copyright 2006-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 Token, Keyword, Name, Comment, String, Error, \ 15 | Number, Operator, Whitespace, Generic 16 | 17 | 18 | class StataDarkStyle(Style): 19 | 20 | background_color = "#232629" 21 | highlight_color = "#49483e" 22 | 23 | styles = { 24 | Token: '#cccccc', 25 | Whitespace: '#bbbbbb', 26 | Error: 'bg:#e3d2d2 #a61717', 27 | String: '#51cc99', 28 | Number: '#4FB8CC', 29 | Operator: '', 30 | Name.Function: '#6a6aff', 31 | Name.Other: '#e2828e', 32 | Keyword: 'bold #7686bb', 33 | Keyword.Constant: '', 34 | Comment: 'italic #777777', 35 | Name.Variable: 'bold #7AB4DB', 36 | Name.Variable.Global: 'bold #BE646C', 37 | Generic.Prompt: '#ffffff', 38 | } 39 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/rita.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.rita 3 | ~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for RITA 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 RegexLexer, include, bygroups, using, this, \ 14 | inherit, words 15 | from pygments.token import Comment, Operator, Keyword, Name, Literal, Punctuation, Text, Whitespace 16 | 17 | __all__ = ['RitaLexer'] 18 | 19 | 20 | class RitaLexer(RegexLexer): 21 | """ 22 | Lexer for RITA. 23 | 24 | .. versionadded:: 2.11 25 | """ 26 | name = 'Rita' 27 | url = 'https://github.com/zaibacu/rita-dsl' 28 | filenames = ['*.rita'] 29 | aliases = ['rita'] 30 | mimetypes = ['text/rita'] 31 | 32 | tokens = { 33 | 'root': [ 34 | (r'\n', Whitespace), 35 | (r'\s+', Whitespace), 36 | (r'#(.*?)\n', Comment.Single), 37 | (r'@(.*?)\n', Operator), # Yes, whole line as an operator 38 | (r'"(\w|\d|\s|(\\")|[\'_\-./,\?\!])+?"', Literal), 39 | (r'\'(\w|\d|\s|(\\\')|["_\-./,\?\!])+?\'', Literal), 40 | (r'([A-Z_]+)', Keyword), 41 | (r'([a-z0-9_]+)', Name), 42 | (r'((->)|[!?+*|=])', Operator), 43 | (r'[\(\),\{\}]', Punctuation) 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/stata_light.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.stata_light 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Light Style inspired by Stata's do-file editor. Note this is not 6 | meant to be a complete style, just for Stata's file formats. 7 | 8 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Whitespace, Text 15 | 16 | 17 | class StataLightStyle(Style): 18 | """ 19 | Light mode style inspired by Stata's do-file editor. This is not 20 | meant to be a complete style, just for use with Stata. 21 | """ 22 | 23 | styles = { 24 | Text: '#111111', 25 | Whitespace: '#bbbbbb', 26 | Error: 'bg:#e3d2d2 #a61717', 27 | String: '#7a2424', 28 | Number: '#2c2cff', 29 | Operator: '', 30 | Name.Function: '#2c2cff', 31 | Name.Other: '#be646c', 32 | Keyword: 'bold #353580', 33 | Keyword.Constant: '', 34 | Comment: 'italic #008800', 35 | Name.Variable: 'bold #35baba', 36 | Name.Variable.Global: 'bold #b5565e', 37 | } 38 | -------------------------------------------------------------------------------- /thirdparty/rich/styled.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | from .measure import Measurement 4 | from .segment import Segment 5 | from .style import StyleType 6 | 7 | if TYPE_CHECKING: 8 | from .console import Console, ConsoleOptions, RenderResult, RenderableType 9 | 10 | 11 | class Styled: 12 | """Apply a style to a renderable. 13 | 14 | Args: 15 | renderable (RenderableType): Any renderable. 16 | style (StyleType): A style to apply across the entire renderable. 17 | """ 18 | 19 | def __init__(self, renderable: "RenderableType", style: "StyleType") -> None: 20 | self.renderable = renderable 21 | self.style = style 22 | 23 | def __rich_console__( 24 | self, console: "Console", options: "ConsoleOptions" 25 | ) -> "RenderResult": 26 | style = console.get_style(self.style) 27 | rendered_segments = console.render(self.renderable, options) 28 | segments = Segment.apply_style(rendered_segments, style) 29 | return segments 30 | 31 | def __rich_measure__( 32 | self, console: "Console", options: "ConsoleOptions" 33 | ) -> Measurement: 34 | return Measurement.get(console, options, self.renderable) 35 | 36 | 37 | if __name__ == "__main__": # pragma: no cover 38 | from rich import print 39 | from rich.panel import Panel 40 | 41 | panel = Styled(Panel("hello"), "on blue") 42 | print(panel) 43 | -------------------------------------------------------------------------------- /thirdparty/rich/_loop.py: -------------------------------------------------------------------------------- 1 | from typing import Iterable, Tuple, TypeVar 2 | 3 | T = TypeVar("T") 4 | 5 | 6 | def loop_first(values: Iterable[T]) -> Iterable[Tuple[bool, T]]: 7 | """Iterate and generate a tuple with a flag for first value.""" 8 | iter_values = iter(values) 9 | try: 10 | value = next(iter_values) 11 | except StopIteration: 12 | return 13 | yield True, value 14 | for value in iter_values: 15 | yield False, value 16 | 17 | 18 | def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]: 19 | """Iterate and generate a tuple with a flag for last value.""" 20 | iter_values = iter(values) 21 | try: 22 | previous_value = next(iter_values) 23 | except StopIteration: 24 | return 25 | for value in iter_values: 26 | yield False, previous_value 27 | previous_value = value 28 | yield True, previous_value 29 | 30 | 31 | def loop_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]: 32 | """Iterate and generate a tuple with a flag for first and last value.""" 33 | iter_values = iter(values) 34 | try: 35 | previous_value = next(iter_values) 36 | except StopIteration: 37 | return 38 | first = True 39 | for value in iter_values: 40 | yield first, False, previous_value 41 | first = False 42 | previous_value = value 43 | yield first, True, previous_value 44 | -------------------------------------------------------------------------------- /thirdparty/commonmark/main.py: -------------------------------------------------------------------------------- 1 | # 2014 - Bibek Kafle & Roland Shoemaker 2 | # 2015-2017 - Nikolas Nyby 3 | # Port of @jgm's commonmark.js implementation of the CommonMark spec. 4 | 5 | # Basic usage: 6 | # 7 | # import commonmark 8 | # parser = commonmark.Parser() 9 | # renderer = commonmark.HtmlRenderer() 10 | # print(renderer.render(parser.parse('Hello *world*'))) 11 | 12 | from __future__ import absolute_import, unicode_literals 13 | 14 | from commonmark.blocks import Parser 15 | from commonmark.dump import dumpAST, dumpJSON 16 | from commonmark.render.html import HtmlRenderer 17 | from commonmark.render.rst import ReStructuredTextRenderer 18 | 19 | 20 | def commonmark(text, format="html"): 21 | """Render CommonMark into HTML, JSON or AST 22 | Optional keyword arguments: 23 | format: 'html' (default), 'json' or 'ast' 24 | 25 | >>> commonmark("*hello!*") 26 | '

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: declaration there may be attributes 53 | 'maybe_xsdattributes': [ 54 | (r'\{', Punctuation, 'xsdattributes'), 55 | (r'\}', Punctuation, '#pop'), 56 | (r'.', Text), 57 | ], 58 | 59 | # attributes take the form { key1 = value1 key2 = value2 ... } 60 | 'xsdattributes': [ 61 | (r'[^ =}]', Name.Attribute), 62 | (r'=', Operator), 63 | (r'"[^"]*"', String.Double), 64 | (r'\}', Punctuation, '#pop'), 65 | (r'.', Text), 66 | ], 67 | } 68 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/pointless.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.pointless 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for Pointless. 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 Comment, Error, Keyword, Name, Number, Operator, \ 13 | Punctuation, String, Text 14 | 15 | __all__ = ['PointlessLexer'] 16 | 17 | 18 | class PointlessLexer(RegexLexer): 19 | """ 20 | For Pointless source code. 21 | 22 | .. versionadded:: 2.7 23 | """ 24 | 25 | name = 'Pointless' 26 | url = 'https://ptls.dev' 27 | aliases = ['pointless'] 28 | filenames = ['*.ptls'] 29 | 30 | ops = words([ 31 | "+", "-", "*", "/", "**", "%", "+=", "-=", "*=", 32 | "/=", "**=", "%=", "|>", "=", "==", "!=", "<", ">", 33 | "<=", ">=", "=>", "$", "++", 34 | ]) 35 | 36 | keywords = words([ 37 | "if", "then", "else", "where", "with", "cond", 38 | "case", "and", "or", "not", "in", "as", "for", 39 | "requires", "throw", "try", "catch", "when", 40 | "yield", "upval", 41 | ], suffix=r'\b') 42 | 43 | tokens = { 44 | 'root': [ 45 | (r'[ \n\r]+', Text), 46 | (r'--.*$', Comment.Single), 47 | (r'"""', String, 'multiString'), 48 | (r'"', String, 'string'), 49 | (r'[\[\](){}:;,.]', Punctuation), 50 | (ops, Operator), 51 | (keywords, Keyword), 52 | (r'\d+|\d*\.\d+', Number), 53 | (r'(true|false)\b', Name.Builtin), 54 | (r'[A-Z][a-zA-Z0-9]*\b', String.Symbol), 55 | (r'output\b', Name.Variable.Magic), 56 | (r'(export|import)\b', Keyword.Namespace), 57 | (r'[a-z][a-zA-Z0-9]*\b', Name.Variable) 58 | ], 59 | 'multiString': [ 60 | (r'\\.', String.Escape), 61 | (r'"""', String, '#pop'), 62 | (r'"', String), 63 | (r'[^\\"]+', String), 64 | ], 65 | 'string': [ 66 | (r'\\.', String.Escape), 67 | (r'"', String, '#pop'), 68 | (r'\n', Error), 69 | (r'[^\\"]+', String), 70 | ], 71 | } 72 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/_usd_builtins.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers._usd_builtins 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | A collection of known USD-related keywords, attributes, and types. 6 | 7 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | """ 10 | 11 | COMMON_ATTRIBUTES = [ 12 | "extent", 13 | "xformOpOrder", 14 | ] 15 | 16 | KEYWORDS = [ 17 | "class", 18 | "clips", 19 | "custom", 20 | "customData", 21 | "def", 22 | "dictionary", 23 | "inherits", 24 | "over", 25 | "payload", 26 | "references", 27 | "rel", 28 | "subLayers", 29 | "timeSamples", 30 | "uniform", 31 | "variantSet", 32 | "variantSets", 33 | "variants", 34 | ] 35 | 36 | OPERATORS = [ 37 | "add", 38 | "append", 39 | "delete", 40 | "prepend", 41 | "reorder", 42 | ] 43 | 44 | SPECIAL_NAMES = [ 45 | "active", 46 | "apiSchemas", 47 | "defaultPrim", 48 | "elementSize", 49 | "endTimeCode", 50 | "hidden", 51 | "instanceable", 52 | "interpolation", 53 | "kind", 54 | "startTimeCode", 55 | "upAxis", 56 | ] 57 | 58 | TYPES = [ 59 | "asset", 60 | "bool", 61 | "color3d", 62 | "color3f", 63 | "color3h", 64 | "color4d", 65 | "color4f", 66 | "color4h", 67 | "double", 68 | "double2", 69 | "double3", 70 | "double4", 71 | "float", 72 | "float2", 73 | "float3", 74 | "float4", 75 | "frame4d", 76 | "half", 77 | "half2", 78 | "half3", 79 | "half4", 80 | "int", 81 | "int2", 82 | "int3", 83 | "int4", 84 | "keyword", 85 | "matrix2d", 86 | "matrix3d", 87 | "matrix4d", 88 | "normal3d", 89 | "normal3f", 90 | "normal3h", 91 | "point3d", 92 | "point3f", 93 | "point3h", 94 | "quatd", 95 | "quatf", 96 | "quath", 97 | "string", 98 | "syn", 99 | "token", 100 | "uchar", 101 | "uchar2", 102 | "uchar3", 103 | "uchar4", 104 | "uint", 105 | "uint2", 106 | "uint3", 107 | "uint4", 108 | "usdaType", 109 | "vector3d", 110 | "vector3f", 111 | "vector3h", 112 | ] 113 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/contrib/completers/system.py: -------------------------------------------------------------------------------- 1 | from prompt_toolkit.completion.filesystem import ExecutableCompleter, PathCompleter 2 | from prompt_toolkit.contrib.regular_languages.compiler import compile 3 | from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter 4 | 5 | __all__ = [ 6 | "SystemCompleter", 7 | ] 8 | 9 | 10 | class SystemCompleter(GrammarCompleter): 11 | """ 12 | Completer for system commands. 13 | """ 14 | 15 | def __init__(self) -> None: 16 | # Compile grammar. 17 | g = compile( 18 | r""" 19 | # First we have an executable. 20 | (?P[^\s]+) 21 | 22 | # Ignore literals in between. 23 | ( 24 | \s+ 25 | ("[^"]*" | '[^']*' | [^'"]+ ) 26 | )* 27 | 28 | \s+ 29 | 30 | # Filename as parameters. 31 | ( 32 | (?P[^\s]+) | 33 | "(?P[^\s]+)" | 34 | '(?P[^\s]+)' 35 | ) 36 | """, 37 | escape_funcs={ 38 | "double_quoted_filename": (lambda string: string.replace('"', '\\"')), 39 | "single_quoted_filename": (lambda string: string.replace("'", "\\'")), 40 | }, 41 | unescape_funcs={ 42 | "double_quoted_filename": ( 43 | lambda string: string.replace('\\"', '"') 44 | ), # XXX: not entirely correct. 45 | "single_quoted_filename": (lambda string: string.replace("\\'", "'")), 46 | }, 47 | ) 48 | 49 | # Create GrammarCompleter 50 | super().__init__( 51 | g, 52 | { 53 | "executable": ExecutableCompleter(), 54 | "filename": PathCompleter(only_directories=False, expanduser=True), 55 | "double_quoted_filename": PathCompleter( 56 | only_directories=False, expanduser=True 57 | ), 58 | "single_quoted_filename": PathCompleter( 59 | only_directories=False, expanduser=True 60 | ), 61 | }, 62 | ) 63 | -------------------------------------------------------------------------------- /core/utils/FileTools.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | 4 | 5 | class FileTools: 6 | 7 | @staticmethod 8 | def SetHome(path): 9 | home = os.path.realpath(os.path.dirname(path)) 10 | os.chdir(home) 11 | 12 | @staticmethod 13 | def GetScriptDir(): 14 | return os.path.realpath(__file__) 15 | 16 | @staticmethod 17 | def ReadFile(path): 18 | if not FileTools.IsFile(path): 19 | raise ValueError(F'file not found! {path}') 20 | with open(path, 'rb') as f: 21 | return f.read() 22 | 23 | @staticmethod 24 | def SaveFile(path, data): 25 | with open(path, 'wb') as f: 26 | f.write(data) 27 | 28 | @staticmethod 29 | def GetAbsolutePath(path): 30 | path = path.replace('\'', '') 31 | path = path.replace('\"', '') 32 | return os.path.abspath(os.path.expanduser(os.path.expandvars(path))) 33 | 34 | @staticmethod 35 | def GetDirPath(path): 36 | return os.path.realpath(os.path.dirname(path)) 37 | 38 | @staticmethod 39 | def GetFileName(path): 40 | return os.path.basename(path) 41 | 42 | @staticmethod 43 | def MakePath(file_name, dir_name): 44 | return f'{dir_name}{os.sep}{file_name}' 45 | 46 | @staticmethod 47 | def SaveFile2(file_name, dir_name, file_data): 48 | file_path = FileTools.MakePath(file_name, dir_name) 49 | FileTools.SaveFile(file_path, file_data) 50 | 51 | @staticmethod 52 | def IsFile(file_path): 53 | return os.path.isfile(file_path) 54 | 55 | @staticmethod 56 | def IsDir(file_path): 57 | return os.path.isfile(file_path) 58 | 59 | @staticmethod 60 | def DelFile(file_name, dir_name): 61 | file_path = FileTools.MakePath(file_name, dir_name) 62 | if not os.path.isfile(file_path): return 63 | os.unlink(file_path) 64 | 65 | @staticmethod 66 | def DelFile2(file_path): 67 | if not os.path.isfile(file_path): return 68 | os.unlink(file_path) 69 | 70 | @staticmethod 71 | def MkDir(dir_name): 72 | if not os.path.isdir(dir_name): 73 | # make nested path 74 | os.makedirs(dir_name) 75 | 76 | @staticmethod 77 | def RmDir(dir_name): 78 | shutil.rmtree(dir_name) 79 | 80 | @staticmethod 81 | def RmDirEmpty(dir_name): 82 | try: 83 | os.rmdir(dir_name) 84 | return True 85 | except OSError: 86 | return False 87 | 88 | @staticmethod 89 | def GetSize(path): 90 | return os.path.getsize(path) 91 | # can raise OSError 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/roboconf.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.roboconf 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for Roboconf DSL. 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, re 12 | from pygments.token import Text, Operator, Keyword, Name, Comment 13 | 14 | __all__ = ['RoboconfGraphLexer', 'RoboconfInstancesLexer'] 15 | 16 | 17 | class RoboconfGraphLexer(RegexLexer): 18 | """ 19 | Lexer for Roboconf graph files. 20 | 21 | .. versionadded:: 2.1 22 | """ 23 | name = 'Roboconf Graph' 24 | aliases = ['roboconf-graph'] 25 | filenames = ['*.graph'] 26 | 27 | flags = re.IGNORECASE | re.MULTILINE 28 | tokens = { 29 | 'root': [ 30 | # Skip white spaces 31 | (r'\s+', Text), 32 | 33 | # There is one operator 34 | (r'=', Operator), 35 | 36 | # Keywords 37 | (words(('facet', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword), 38 | (words(( 39 | 'installer', 'extends', 'exports', 'imports', 'facets', 40 | 'children'), suffix=r'\s*:?', prefix=r'\b'), Name), 41 | 42 | # Comments 43 | (r'#.*\n', Comment), 44 | 45 | # Default 46 | (r'[^#]', Text), 47 | (r'.*\n', Text) 48 | ] 49 | } 50 | 51 | 52 | class RoboconfInstancesLexer(RegexLexer): 53 | """ 54 | Lexer for Roboconf instances files. 55 | 56 | .. versionadded:: 2.1 57 | """ 58 | name = 'Roboconf Instances' 59 | aliases = ['roboconf-instances'] 60 | filenames = ['*.instances'] 61 | 62 | flags = re.IGNORECASE | re.MULTILINE 63 | tokens = { 64 | 'root': [ 65 | 66 | # Skip white spaces 67 | (r'\s+', Text), 68 | 69 | # Keywords 70 | (words(('instance of', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword), 71 | (words(('name', 'count'), suffix=r's*:?', prefix=r'\b'), Name), 72 | (r'\s*[\w.-]+\s*:', Name), 73 | 74 | # Comments 75 | (r'#.*\n', Comment), 76 | 77 | # Default 78 | (r'[^#]', Text), 79 | (r'.*\n', Text) 80 | ] 81 | } 82 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/contrib/regular_languages/validation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Validator for a regular language. 3 | """ 4 | from typing import Dict 5 | 6 | from prompt_toolkit.document import Document 7 | from prompt_toolkit.validation import ValidationError, Validator 8 | 9 | from .compiler import _CompiledGrammar 10 | 11 | __all__ = [ 12 | "GrammarValidator", 13 | ] 14 | 15 | 16 | class GrammarValidator(Validator): 17 | """ 18 | Validator which can be used for validation according to variables in 19 | the grammar. Each variable can have its own validator. 20 | 21 | :param compiled_grammar: `GrammarCompleter` instance. 22 | :param validators: `dict` mapping variable names of the grammar to the 23 | `Validator` instances to be used for each variable. 24 | """ 25 | 26 | def __init__( 27 | self, compiled_grammar: _CompiledGrammar, validators: Dict[str, Validator] 28 | ) -> None: 29 | 30 | self.compiled_grammar = compiled_grammar 31 | self.validators = validators 32 | 33 | def validate(self, document: Document) -> None: 34 | # Parse input document. 35 | # We use `match`, not `match_prefix`, because for validation, we want 36 | # the actual, unambiguous interpretation of the input. 37 | m = self.compiled_grammar.match(document.text) 38 | 39 | if m: 40 | for v in m.variables(): 41 | validator = self.validators.get(v.varname) 42 | 43 | if validator: 44 | # Unescape text. 45 | unwrapped_text = self.compiled_grammar.unescape(v.varname, v.value) 46 | 47 | # Create a document, for the completions API (text/cursor_position) 48 | inner_document = Document(unwrapped_text, len(unwrapped_text)) 49 | 50 | try: 51 | validator.validate(inner_document) 52 | except ValidationError as e: 53 | raise ValidationError( 54 | cursor_position=v.start + e.cursor_position, 55 | message=e.message, 56 | ) from e 57 | else: 58 | raise ValidationError( 59 | cursor_position=len(document.text), message="Invalid command" 60 | ) 61 | -------------------------------------------------------------------------------- /plugins/command_elf_info.py: -------------------------------------------------------------------------------- 1 | from thirdparty.rich.table import Table 2 | 3 | from core.plugin_aux import * 4 | from core.utils import * 5 | from core.config import * 6 | 7 | 8 | class COMMAND_ELF_INFO(COMMANDS_BASE): 9 | 10 | def __init__(self): 11 | self.name = 'elf' 12 | self.desc = 'elf header parser' 13 | self.req_mods = ['elf'] 14 | 15 | def execute(self): 16 | try: 17 | self.head = self.elf.header 18 | self.print_header() 19 | self.print_segments() 20 | self.print_sections() 21 | self.add_special() 22 | except Exception as e: 23 | raise ValueError("Something went wrong =)") 24 | 25 | def print_header(self): 26 | 27 | table = Table(box=None, show_header=False) 28 | table.add_column("name", style='bold') 29 | table.add_column("value") 30 | 31 | table.add_row('Machine', self.head.e_machine) 32 | table.add_row('Class', self.head.e_ident['EI_CLASS']) 33 | table.add_row('Ep Addr', hex(self.head.e_entry)) 34 | 35 | self.repl.print(table) 36 | 37 | def print_segments(self): 38 | 39 | table = Table(box=None, show_header=True) 40 | table.add_column("offset") 41 | table.add_column("size") 42 | table.add_column("type") 43 | 44 | for seg in self.elf.iter_segments(): 45 | table.add_row(str(seg['p_offset']), str(seg['p_filesz']), seg['p_type']) 46 | 47 | self.repl.new_line() 48 | self.repl.print(table) 49 | 50 | def print_sections(self): 51 | 52 | table = Table(box=None, show_header=True) 53 | table.add_column("name") 54 | table.add_column("offset") 55 | table.add_column("size") 56 | table.add_column("type") 57 | 58 | for sec in self.elf.iter_sections(): 59 | if sec.is_null(): continue 60 | table.add_row(sec.name, str(sec['sh_offset']), str(sec['sh_size']), sec['sh_type']) 61 | 62 | self.repl.new_line() 63 | self.repl.print(table) 64 | 65 | def add_special(self): 66 | self.repl.new_line() 67 | 68 | header = Range(0, self.head.e_ehsize) 69 | head_prog = Range(self.head.e_phoff, self.head.e_phentsize * self.head.e_phnum) 70 | head_sect = Range(self.head.e_shoff, self.head.e_shentsize * self.head.e_shnum) 71 | head = [header, head_prog, head_sect] 72 | 73 | full = self.get_default_range() 74 | body = RangeTools.substract_list2(full, head) 75 | 76 | self.set_spec_var(f'head', f'{header} {head_prog} {head_sect}') 77 | self.set_spec_var(f'body', f'{body}') 78 | 79 | 80 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/jmespath.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.jmespath 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for the JMESPath 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, include 12 | from pygments.token import String, Punctuation, Whitespace, Name, Operator, \ 13 | Number, Literal, Keyword 14 | 15 | __all__ = ['JMESPathLexer'] 16 | 17 | 18 | class JMESPathLexer(RegexLexer): 19 | """ 20 | For JMESPath queries. 21 | """ 22 | name = 'JMESPath' 23 | url = 'https://jmespath.org' 24 | filenames = ['*.jp'] 25 | aliases = ['jmespath', 'jp'] 26 | 27 | tokens = { 28 | 'string': [ 29 | (r"'(\\(.|\n)|[^'\\])*'", String), 30 | ], 31 | 'punctuation': [ 32 | (r'(\[\?|[\.\*\[\],:\(\)\{\}\|])', Punctuation), 33 | ], 34 | 'ws': [ 35 | (r" |\t|\n|\r", Whitespace) 36 | ], 37 | "dq-identifier": [ 38 | (r'[^\\"]+', Name.Variable), 39 | (r'\\"', Name.Variable), 40 | (r'.', Punctuation, '#pop'), 41 | ], 42 | 'identifier': [ 43 | (r'(&)?(")', bygroups(Name.Variable, Punctuation), 'dq-identifier'), 44 | (r'(")?(&?[A-Za-z][A-Za-z0-9_-]*)(")?', bygroups(Punctuation, Name.Variable, Punctuation)), 45 | ], 46 | 'root': [ 47 | include('ws'), 48 | include('string'), 49 | (r'(==|!=|<=|>=|<|>|&&|\|\||!)', Operator), 50 | include('punctuation'), 51 | (r'@', Name.Variable.Global), 52 | (r'(&?[A-Za-z][A-Za-z0-9_]*)(\()', bygroups(Name.Function, Punctuation)), 53 | (r'(&)(\()', bygroups(Name.Variable, Punctuation)), 54 | include('identifier'), 55 | (r'-?\d+', Number), 56 | (r'`', Literal, 'literal'), 57 | ], 58 | 'literal': [ 59 | include('ws'), 60 | include('string'), 61 | include('punctuation'), 62 | (r'(false|true|null)\b', Keyword.Constant), 63 | include('identifier'), 64 | (r'-?\d+\.?\d*([eE][-+]\d+)?', Number), 65 | (r'\\`', Literal), 66 | (r'`', Literal, '#pop'), 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/autumn.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.autumn 3 | ~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | A colorful style, inspired by the terminal highlighting 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, Generic, Whitespace 14 | 15 | 16 | class AutumnStyle(Style): 17 | """ 18 | A colorful style, inspired by the terminal highlighting style. 19 | """ 20 | 21 | styles = { 22 | Whitespace: '#bbbbbb', 23 | 24 | Comment: 'italic #aaaaaa', 25 | Comment.Preproc: 'noitalic #4c8317', 26 | Comment.Special: 'italic #0000aa', 27 | 28 | Keyword: '#0000aa', 29 | Keyword.Type: '#00aaaa', 30 | 31 | Operator.Word: '#0000aa', 32 | 33 | Name.Builtin: '#00aaaa', 34 | Name.Function: '#00aa00', 35 | Name.Class: 'underline #00aa00', 36 | Name.Namespace: 'underline #00aaaa', 37 | Name.Variable: '#aa0000', 38 | Name.Constant: '#aa0000', 39 | Name.Entity: 'bold #800', 40 | Name.Attribute: '#1e90ff', 41 | Name.Tag: 'bold #1e90ff', 42 | Name.Decorator: '#888888', 43 | 44 | String: '#aa5500', 45 | String.Symbol: '#0000aa', 46 | String.Regex: '#009999', 47 | 48 | Number: '#009999', 49 | 50 | Generic.Heading: 'bold #000080', 51 | Generic.Subheading: 'bold #800080', 52 | Generic.Deleted: '#aa0000', 53 | Generic.Inserted: '#00aa00', 54 | Generic.Error: '#aa0000', 55 | Generic.Emph: 'italic', 56 | Generic.Strong: 'bold', 57 | Generic.Prompt: '#555555', 58 | Generic.Output: '#888888', 59 | Generic.Traceback: '#aa0000', 60 | 61 | Error: '#F00 bg:#FAA' 62 | } 63 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/input/defaults.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import ContextManager, Optional, TextIO 3 | 4 | from .base import DummyInput, Input, PipeInput 5 | 6 | __all__ = [ 7 | "create_input", 8 | "create_pipe_input", 9 | ] 10 | 11 | 12 | def create_input( 13 | stdin: Optional[TextIO] = None, always_prefer_tty: bool = False 14 | ) -> Input: 15 | """ 16 | Create the appropriate `Input` object for the current os/environment. 17 | 18 | :param always_prefer_tty: When set, if `sys.stdin` is connected to a Unix 19 | `pipe`, check whether `sys.stdout` or `sys.stderr` are connected to a 20 | pseudo terminal. If so, open the tty for reading instead of reading for 21 | `sys.stdin`. (We can open `stdout` or `stderr` for reading, this is how 22 | a `$PAGER` works.) 23 | """ 24 | if sys.platform == "win32": 25 | from .win32 import Win32Input 26 | 27 | # If `stdin` was assigned `None` (which happens with pythonw.exe), use 28 | # a `DummyInput`. This triggers `EOFError` in the application code. 29 | if stdin is None and sys.stdin is None: 30 | return DummyInput() 31 | 32 | return Win32Input(stdin or sys.stdin) 33 | else: 34 | from .vt100 import Vt100Input 35 | 36 | # If no input TextIO is given, use stdin/stdout. 37 | if stdin is None: 38 | stdin = sys.stdin 39 | 40 | if always_prefer_tty: 41 | for io in [sys.stdin, sys.stdout, sys.stderr]: 42 | if io.isatty(): 43 | stdin = io 44 | break 45 | 46 | return Vt100Input(stdin) 47 | 48 | 49 | def create_pipe_input() -> ContextManager[PipeInput]: 50 | """ 51 | Create an input pipe. 52 | This is mostly useful for unit testing. 53 | 54 | Usage:: 55 | 56 | with create_pipe_input() as input: 57 | input.send_text('inputdata') 58 | 59 | Breaking change: In prompt_toolkit 3.0.28 and earlier, this was returning 60 | the `PipeInput` directly, rather than through a context manager. 61 | """ 62 | if sys.platform == "win32": 63 | from .win32_pipe import Win32PipeInput 64 | 65 | return Win32PipeInput.create() 66 | else: 67 | from .posix_pipe import PosixPipeInput 68 | 69 | return PosixPipeInput.create() 70 | -------------------------------------------------------------------------------- /thirdparty/elftools/construct/lib/bitstream.py: -------------------------------------------------------------------------------- 1 | from .binary import encode_bin, decode_bin 2 | 3 | class BitStreamReader(object): 4 | 5 | __slots__ = ["substream", "buffer", "total_size"] 6 | 7 | def __init__(self, substream): 8 | self.substream = substream 9 | self.total_size = 0 10 | self.buffer = "" 11 | 12 | def close(self): 13 | if self.total_size % 8 != 0: 14 | raise ValueError("total size of read data must be a multiple of 8", 15 | self.total_size) 16 | 17 | def tell(self): 18 | return self.substream.tell() 19 | 20 | def seek(self, pos, whence = 0): 21 | self.buffer = "" 22 | self.total_size = 0 23 | self.substream.seek(pos, whence) 24 | 25 | def read(self, count): 26 | if count < 0: 27 | raise ValueError("count cannot be negative") 28 | 29 | l = len(self.buffer) 30 | if count == 0: 31 | data = "" 32 | elif count <= l: 33 | data = self.buffer[:count] 34 | self.buffer = self.buffer[count:] 35 | else: 36 | data = self.buffer 37 | count -= l 38 | bytes = count // 8 39 | if count & 7: 40 | bytes += 1 41 | buf = encode_bin(self.substream.read(bytes)) 42 | data += buf[:count] 43 | self.buffer = buf[count:] 44 | self.total_size += len(data) 45 | return data 46 | 47 | class BitStreamWriter(object): 48 | 49 | __slots__ = ["substream", "buffer", "pos"] 50 | 51 | def __init__(self, substream): 52 | self.substream = substream 53 | self.buffer = [] 54 | self.pos = 0 55 | 56 | def close(self): 57 | self.flush() 58 | 59 | def flush(self): 60 | bytes = decode_bin("".join(self.buffer)) 61 | self.substream.write(bytes) 62 | self.buffer = [] 63 | self.pos = 0 64 | 65 | def tell(self): 66 | return self.substream.tell() + self.pos // 8 67 | 68 | def seek(self, pos, whence = 0): 69 | self.flush() 70 | self.substream.seek(pos, whence) 71 | 72 | def write(self, data): 73 | if not data: 74 | return 75 | if type(data) is not str: 76 | raise TypeError("data must be a string, not %r" % (type(data),)) 77 | self.buffer.append(data) 78 | -------------------------------------------------------------------------------- /thirdparty/prompt_toolkit/eventloop/async_generator.py: -------------------------------------------------------------------------------- 1 | """ 2 | Implementation for async generators. 3 | """ 4 | from asyncio import Queue 5 | from typing import AsyncGenerator, Callable, Iterable, TypeVar, Union 6 | 7 | from .utils import get_event_loop, run_in_executor_with_context 8 | 9 | __all__ = [ 10 | "generator_to_async_generator", 11 | ] 12 | 13 | 14 | _T = TypeVar("_T") 15 | 16 | 17 | class _Done: 18 | pass 19 | 20 | 21 | async def generator_to_async_generator( 22 | get_iterable: Callable[[], Iterable[_T]] 23 | ) -> AsyncGenerator[_T, None]: 24 | """ 25 | Turn a generator or iterable into an async generator. 26 | 27 | This works by running the generator in a background thread. 28 | 29 | :param get_iterable: Function that returns a generator or iterable when 30 | called. 31 | """ 32 | quitting = False 33 | _done = _Done() 34 | q: Queue[Union[_T, _Done]] = Queue() 35 | loop = get_event_loop() 36 | 37 | def runner() -> None: 38 | """ 39 | Consume the generator in background thread. 40 | When items are received, they'll be pushed to the queue. 41 | """ 42 | try: 43 | for item in get_iterable(): 44 | # When this async generator was cancelled (closed), stop this 45 | # thread. 46 | if quitting: 47 | break 48 | 49 | loop.call_soon_threadsafe(q.put_nowait, item) 50 | 51 | finally: 52 | loop.call_soon_threadsafe(q.put_nowait, _done) 53 | 54 | # Start background thread. 55 | runner_f = run_in_executor_with_context(runner) 56 | 57 | try: 58 | while True: 59 | item = await q.get() 60 | if isinstance(item, _Done): 61 | break 62 | else: 63 | yield item 64 | finally: 65 | # When this async generator is closed (GeneratorExit exception, stop 66 | # the background thread as well. - we don't need that anymore.) 67 | quitting = True 68 | 69 | # Wait for the background thread to finish. (should happen right after 70 | # the next item is yielded). If we don't do this, and the event loop 71 | # gets closed before the runner is done, then we'll get a 72 | # `RuntimeError: Event loop is closed` exception printed to stdout that 73 | # we can't handle. 74 | await runner_f 75 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/perldoc.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.perldoc 3 | ~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Style similar to the style used in the `perldoc`_ code blocks. 6 | 7 | .. _perldoc: http://perldoc.perl.org/ 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, Operator, Generic, Whitespace 16 | 17 | 18 | class PerldocStyle(Style): 19 | """ 20 | Style similar to the style used in the perldoc code blocks. 21 | """ 22 | 23 | background_color = '#eeeedd' 24 | 25 | styles = { 26 | Whitespace: '#bbbbbb', 27 | Comment: '#228B22', 28 | Comment.Preproc: '#1e889b', 29 | Comment.Special: '#8B008B bold', 30 | 31 | String: '#CD5555', 32 | String.Heredoc: '#1c7e71 italic', 33 | String.Regex: '#B452CD', 34 | String.Other: '#cb6c20', 35 | String.Regex: '#1c7e71', 36 | 37 | Number: '#B452CD', 38 | 39 | Operator.Word: '#8B008B', 40 | 41 | Keyword: '#8B008B bold', 42 | Keyword.Type: '#00688B', 43 | 44 | Name.Class: '#008b45 bold', 45 | Name.Exception: '#008b45 bold', 46 | Name.Function: '#008b45', 47 | Name.Namespace: '#008b45 underline', 48 | Name.Variable: '#00688B', 49 | Name.Constant: '#00688B', 50 | Name.Decorator: '#707a7c', 51 | Name.Tag: '#8B008B bold', 52 | Name.Attribute: '#658b00', 53 | Name.Builtin: '#658b00', 54 | 55 | Generic.Heading: 'bold #000080', 56 | Generic.Subheading: 'bold #800080', 57 | Generic.Deleted: '#aa0000', 58 | Generic.Inserted: '#00aa00', 59 | Generic.Error: '#aa0000', 60 | Generic.Emph: 'italic', 61 | Generic.Strong: 'bold', 62 | Generic.Prompt: '#555555', 63 | Generic.Output: '#888888', 64 | Generic.Traceback: '#aa0000', 65 | 66 | Error: 'bg:#e3d2d2 #a61717' 67 | } 68 | -------------------------------------------------------------------------------- /thirdparty/rich/_export_format.py: -------------------------------------------------------------------------------- 1 | CONSOLE_HTML_FORMAT = """\ 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 |
{code}
17 |
18 | 19 | 20 | """ 21 | 22 | CONSOLE_SVG_FORMAT = """\ 23 | 24 | 25 | 59 | 60 | 61 | 62 | 63 | 64 | {lines} 65 | 66 | 67 | {chrome} 68 | 69 | {backgrounds} 70 | 71 | {matrix} 72 | 73 | 74 | 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 ` 27 | 28 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 29 | :license: BSD, see LICENSE for details. 30 | """ 31 | 32 | from pygments.style import Style 33 | from pygments.token import Keyword, Name, Comment, String, Error, Operator 34 | 35 | 36 | class AlgolStyle(Style): 37 | 38 | background_color = "#ffffff" 39 | 40 | styles = { 41 | Comment: "italic #888", 42 | Comment.Preproc: "bold noitalic #888", 43 | Comment.Special: "bold noitalic #888", 44 | 45 | Keyword: "underline bold", 46 | Keyword.Declaration: "italic", 47 | 48 | Name.Builtin: "bold italic", 49 | Name.Builtin.Pseudo: "bold italic", 50 | Name.Namespace: "bold italic #666", 51 | Name.Class: "bold italic #666", 52 | Name.Function: "bold italic #666", 53 | Name.Variable: "bold italic #666", 54 | Name.Constant: "bold italic #666", 55 | 56 | Operator.Word: "bold", 57 | 58 | String: "italic #666", 59 | 60 | Error: "border:#FF0000" 61 | } 62 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/algol_nu.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.algol_nu 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Algol publication style without underlining of keywords. 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 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 with underlining, refer to the `Algol` 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 ` 27 | 28 | :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. 29 | :license: BSD, see LICENSE for details. 30 | """ 31 | 32 | from pygments.style import Style 33 | from pygments.token import Keyword, Name, Comment, String, Error, Operator 34 | 35 | 36 | class Algol_NuStyle(Style): 37 | 38 | background_color = "#ffffff" 39 | 40 | styles = { 41 | Comment: "italic #888", 42 | Comment.Preproc: "bold noitalic #888", 43 | Comment.Special: "bold noitalic #888", 44 | 45 | Keyword: "bold", 46 | Keyword.Declaration: "italic", 47 | 48 | Name.Builtin: "bold italic", 49 | Name.Builtin.Pseudo: "bold italic", 50 | Name.Namespace: "bold italic #666", 51 | Name.Class: "bold italic #666", 52 | Name.Function: "bold italic #666", 53 | Name.Variable: "bold italic #666", 54 | Name.Constant: "bold italic #666", 55 | 56 | Operator.Word: "bold", 57 | 58 | String: "italic #666", 59 | 60 | Error: "border:#FF0000" 61 | } 62 | -------------------------------------------------------------------------------- /thirdparty/pygments/styles/zenburn.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.styles.zenburn 3 | ~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Low contrast color scheme Zenburn. 6 | 7 | See: https://kippura.org/zenburnpage/ 8 | https://github.com/jnurmine/Zenburn 9 | 10 | :copyright: Copyright 2006-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 ( 16 | Token, Name, Operator, Keyword, Generic, Comment, Number, String, Literal, 17 | Punctuation, Error, 18 | ) 19 | 20 | 21 | class ZenburnStyle(Style): 22 | """ 23 | Low contrast Zenburn style. 24 | """ 25 | 26 | background_color = '#3f3f3f' 27 | highlight_color = '#484848' 28 | line_number_color = '#5d6262' 29 | line_number_background_color = '#353535' 30 | line_number_special_color = '#7a8080' 31 | line_number_special_background_color = '#353535' 32 | 33 | styles = { 34 | Token: '#dcdccc', 35 | Error: '#e37170 bold', 36 | 37 | Keyword: '#efdcbc', 38 | Keyword.Type: '#dfdfbf bold', 39 | Keyword.Constant: '#dca3a3', 40 | Keyword.Declaration: '#f0dfaf', 41 | Keyword.Namespace: '#f0dfaf', 42 | 43 | Name: '#dcdccc', 44 | Name.Tag: '#e89393 bold', 45 | Name.Entity: '#cfbfaf', 46 | Name.Constant: '#dca3a3', 47 | Name.Class: '#efef8f', 48 | Name.Function: '#efef8f', 49 | Name.Builtin: '#efef8f', 50 | Name.Builtin.Pseudo: '#dcdccc', 51 | Name.Attribute: '#efef8f', 52 | Name.Exception: '#c3bf9f bold', 53 | 54 | Literal: '#9fafaf', 55 | 56 | String: '#cc9393', 57 | String.Doc: '#7f9f7f', 58 | String.Interpol: '#dca3a3 bold', 59 | 60 | Number: '#8cd0d3', 61 | Number.Float: '#c0bed1', 62 | 63 | Operator: '#f0efd0', 64 | 65 | Punctuation: '#f0efd0', 66 | 67 | Comment: '#7f9f7f italic', 68 | Comment.Preproc: '#dfaf8f bold', 69 | Comment.PreprocFile: '#cc9393', 70 | Comment.Special: '#dfdfdf bold', 71 | 72 | Generic: '#ecbcbc bold', 73 | Generic.Emph: '#ffffff bold', 74 | Generic.Output: '#5b605e bold', 75 | Generic.Heading: '#efefef bold', 76 | Generic.Deleted: '#c3bf9f bg:#313c36', 77 | Generic.Inserted: '#709080 bg:#313c36 bold', 78 | Generic.Traceback: '#80d4aa bg:#2f2f2f bold', 79 | Generic.Subheading: '#efefef bold', 80 | } 81 | -------------------------------------------------------------------------------- /thirdparty/pygments/lexers/capnproto.py: -------------------------------------------------------------------------------- 1 | """ 2 | pygments.lexers.capnproto 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Lexers for the Cap'n Proto schema 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 RegexLexer, default 14 | from pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace 15 | 16 | __all__ = ['CapnProtoLexer'] 17 | 18 | 19 | class CapnProtoLexer(RegexLexer): 20 | """ 21 | For Cap'n Proto source. 22 | 23 | .. versionadded:: 2.2 24 | """ 25 | name = 'Cap\'n Proto' 26 | url = 'https://capnproto.org' 27 | filenames = ['*.capnp'] 28 | aliases = ['capnp'] 29 | 30 | tokens = { 31 | 'root': [ 32 | (r'#.*?$', Comment.Single), 33 | (r'@[0-9a-zA-Z]*', Name.Decorator), 34 | (r'=', Literal, 'expression'), 35 | (r':', Name.Class, 'type'), 36 | (r'\$', Name.Attribute, 'annotation'), 37 | (r'(struct|enum|interface|union|import|using|const|annotation|' 38 | r'extends|in|of|on|as|with|from|fixed)\b', 39 | Keyword), 40 | (r'[\w.]+', Name), 41 | (r'[^#@=:$\w\s]+', Text), 42 | (r'\s+', Whitespace), 43 | ], 44 | 'type': [ 45 | (r'[^][=;,(){}$]+', Name.Class), 46 | (r'[\[(]', Name.Class, 'parentype'), 47 | default('#pop'), 48 | ], 49 | 'parentype': [ 50 | (r'[^][;()]+', Name.Class), 51 | (r'[\[(]', Name.Class, '#push'), 52 | (r'[])]', Name.Class, '#pop'), 53 | default('#pop'), 54 | ], 55 | 'expression': [ 56 | (r'[^][;,(){}$]+', Literal), 57 | (r'[\[(]', Literal, 'parenexp'), 58 | default('#pop'), 59 | ], 60 | 'parenexp': [ 61 | (r'[^][;()]+', Literal), 62 | (r'[\[(]', Literal, '#push'), 63 | (r'[])]', Literal, '#pop'), 64 | default('#pop'), 65 | ], 66 | 'annotation': [ 67 | (r'[^][;,(){}=:]+', Name.Attribute), 68 | (r'[\[(]', Name.Attribute, 'annexp'), 69 | default('#pop'), 70 | ], 71 | 'annexp': [ 72 | (r'[^][;()]+', Name.Attribute), 73 | (r'[\[(]', Name.Attribute, '#push'), 74 | (r'[])]', Name.Attribute, '#pop'), 75 | default('#pop'), 76 | ], 77 | } 78 | --------------------------------------------------------------------------------