disco.bot.parser

Constants

PARTS_RE = compile((\<|\[|\{)((?:\w+|\:|\||\.\.\.| (?:[0-9]+))+)(?:\>|\]|\}))

{'type': 'assign', 'targets': ['BOOL_OPTS'], 'value': {'keys': ['yes', 'no', 'true', 'False', '1', '0', 'on', 'off'], 'values': ['True', 'False', 'True', 'False', 'True', 'False', 'True', 'False'], 'type': 'dict'}}

{'type': 'assign', 'targets': ['TYPE_MAP'], 'value': {'keys': ['str', 'int', 'float', 'snowflake'], 'values': [{'args': {'args': ['ctx', 'data'], 'vargs': None, 'defaults': [], 'kwargs': None}, 'type': 'lambda'}, {'args': {'args': ['ctx', 'data'], 'vargs': None, 'defaults': [], 'kwargs': None}, 'type': 'lambda'}, {'args': {'args': ['ctx', 'data'], 'vargs': None, 'defaults': [], 'kwargs': None}, 'type': 'lambda'}, {'args': {'args': ['ctx', 'data'], 'vargs': None, 'defaults': [], 'kwargs': None}, 'type': 'lambda'}], 'type': 'dict'}}

{'type': 'assign', 'targets': [{'type': 'subscript'}], 'value': 'to_bool'}

Classes

ArgumentError

Inherits From Exception

An error thrown when passed in arguments cannot be conformed/casted to the argument specification.

Argument

A single argument, which is normally the member of a :class:ArgumentSet.

Attributes
Name Type Description
name str The name of this argument.
count int The number of raw arguments that compose this argument.
required bool Whether this is a required argument.
types list(type) Types this argument supports.

Functions

init(self, raw)

true_count(self)

The true number of raw arguments this argument takes.

parse(self, raw)

Attempts to parse arguments from their raw form.

ArgumentSet

A set of :class:Argument instances which forms a larger argument specification.

Attributes
Name Type Description
args list(:class:`Argument`) All arguments that are a member of this set.
types dict(str, type) All types supported by this ArgumentSet.

Functions

init(self, args, custom_types=None)

from_string(cls, line, custom_types)

Creates a new :class:ArgumentSet from a given argument string specification.

convert(self, ctx, types, value)

Attempts to convert a value to one or more types.

Parameters
Name Type Description
types list(type) List of types to attempt conversion with.
value str The string value to attempt conversion on.

append(self, arg)

Add a new :class:Argument to this argument specification/set.

parse(self, rawargs, ctx)

Parse a string of raw arguments into this argument specification.

length(self)

The number of arguments in this set/specification.

required_length(self)

The number of required arguments to compile this set/specificaiton.

Functions

to_bool(ctx, data)

results matching ""

    No results matching ""