almanac.parsing

get_lexer_cls_for_app(app: Application) → Type[RegexLexer][source]

Get a lexer class for a specific Application instance.

class IncompleteToken(token: str)[source]

Bases: object

property is_ambiguous_arg
property is_kw_arg
property is_pos_arg
property key
property value
class ParseState(value)[source]

Bases: enum.Enum

An enumeration.

FULL = 1
NONE = 3
PARTIAL = 2
class ParseStatus(results, unparsed_text, unparsed_start_pos, state)[source]

Bases: tuple

results: pyparsing.ParseResults

Alias for field number 0

state: almanac.parsing.parsing.ParseState

Alias for field number 3

unparsed_start_pos: int

Alias for field number 2

unparsed_text: str

Alias for field number 1

class Patterns[source]

Bases: object

ALLOWED_SYMBOLS_IN_STRING = '-_/#@£$€%*+~|<>?.'
BOOLEAN = '(True|true|False|false)'
COMMAND = '^([a-zA-Z_][a-zA-Z0-9_\\-]*)(\\s+|$)'
FLOAT = '\\-?\\d+\\.\\d*([eE]\\d+)?'
IDENTIFIER = '([a-zA-Z_][a-zA-Z0-9_\\-]*)'
INTEGER = '\\-?\\d+'
KWARG = '([a-zA-Z_][a-zA-Z0-9_\\-]*)(\\s*=\\s*)'
STRING_DOUBLE_QUOTE = '\\"([^\\\\\\"]|\\\\.)*\\"'
STRING_SINGLE_QUOTE = "\\'([^\\\\\\']|\\\\.)*\\'"
UNQUOTED_STRING = '([a-zA-Z0-9-_/#@£$€%*+~|<>?.]+)'
WHITESPACE = '\\s+'
static is_valid_identifier(s: str)bool[source]

Whether the specified string is a valid command name or kwarg identifier.

last_incomplete_token(document: prompt_toolkit.document.Document, unparsed_text: str)almanac.parsing.parsing.IncompleteToken[source]
last_incomplete_token_from_document(document: prompt_toolkit.document.Document)almanac.parsing.parsing.IncompleteToken[source]

Shortcut for getting the last incomplete token only from a Document.

parse_cmd_line(text: str)almanac.parsing.parsing.ParseStatus[source]

Attempt to parse a command line, returning a ParseStatus object.