mario package

Submodules

mario.app module

Command line pipes in python.

async mario.app.async_main(basic_traversals, **kwargs)[source]
async mario.app.call_traversal(context, traversal, items, exit_stack)[source]
mario.app.main(pairs, **kwargs)[source]
async mario.app.program_runner(traversals, items, context)[source]

mario.asynch module

Command line pipes in python.

class mario.asynch.TerminatedFrameReceiver(stream, terminator, max_frame_length=16384)[source]

Bases: object

Parse frames out of a Trio stream, where each frame is terminated by a

fixed byte sequence.

For example, you can parse newline-terminated lines by setting the terminator to b”

“.

This uses some tricks to protect against denial of service attacks:

  • It puts a limit on the maximum frame size, to avoid memory overflow; you

might want to adjust the limit for your situation.

  • It uses some algorithmic trickiness to avoid “slow loris” attacks. All algorithms are amortized O(n) in the length of the input.

async receive()[source]
Return type

bytearray

mario.cli module

class mario.cli.SectionedContext(*args, sections, **kwargs)[source]

Bases: click.core.Context

make_formatter()[source]

Creates the formatter for the help and usage output.

class mario.cli.SectionedFormatter(*args, sections, **kwargs)[source]

Bases: click.formatting.HelpFormatter

write_dl(rows, *args, **kwargs)[source]

Writes a definition list into the buffer. This is how options and commands are usually formatted.

Parameters
  • rows – a list of two item tuples for the terms and values.

  • col_max – the maximum width of the first column.

  • col_spacing – the number of spaces between the first and second column.

class mario.cli.SectionedGroup(*args, sections, **kwargs)[source]

Bases: click.core.Group

format_commands(ctx, formatter)[source]

Extra format methods for multi methods that adds all the commands after the options.

make_context(info_name, args, parent=None, **extra)[source]

This function when given an info name and arguments will kick off the parsing and create a new Context. It does not invoke the actual command callback though.

Parameters
  • info_name – the info name for this invokation. Generally this is the most descriptive name for the script or command. For the toplevel script it’s usually the name of the script, for commands below it it’s the name of the script.

  • args – the arguments to parse as list of strings.

  • parent – the parent context if available.

  • extra – extra keyword arguments forwarded to the context constructor.

mario.cli.build_stages(command)[source]
mario.cli.cli_main(pairs, **kwargs)[source]
mario.cli.version_option(ctx, param, value)[source]

mario.cli_tools module

class mario.cli_tools.CommandInSection(*args, section=None, **kwargs)[source]

Bases: click.core.Command

class mario.cli_tools.DocumentedCommand(*args, section=None, **kwargs)[source]

Bases: mario.cli_tools.ReSTCommand, mario.cli_tools.CommandInSection

class mario.cli_tools.ReSTCommand(name, context_settings=None, callback=None, params=None, help=None, epilog=None, short_help=None, options_metavar='[OPTIONS]', add_help_option=True, no_args_is_help=False, hidden=False, deprecated=False)[source]

Bases: click.core.Command

Parse help as rst.

format_help_text(ctx, formatter)[source]

Writes the help text to the formatter if it exists.

mario.config module

mario.config.get_config_dir()[source]
mario.config.load_config(dir_path=None)[source]

mario.declarative module

class mario.declarative.AnyField(*, default=<marshmallow.missing>, missing=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, **metadata)[source]

Bases: marshmallow.fields.Field

class mario.declarative.ArgumentNameField(*, default=<marshmallow.missing>, missing=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, **metadata)[source]

Bases: marshmallow.fields.Field

class mario.declarative.ArgumentSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

A command-line positional argument for a new command.

make_argument(validated, partial, many)[source]
opts = <marshmallow.schema.SchemaOpts object>
class mario.declarative.CommandSpec(name, short_help, help, arguments, options, stages, inject_values, tests, section, hidden)[source]

Bases: object

class mario.declarative.CommandSpecSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

A new command.

make(validated, partial, many)[source]
opts = <marshmallow.schema.SchemaOpts object>
class mario.declarative.CommandStage(command, remap_params, params)[source]

Bases: object

class mario.declarative.CommandStageSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

A single stage of a new command pipeline.

make(validated, partial, many)[source]
opts = <marshmallow.schema.SchemaOpts object>
class mario.declarative.CommandTest(invocation, input, output)[source]

Bases: object

class mario.declarative.CommandTestSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

A test of a new command.

make(validated, partial, many)[source]
opts = <marshmallow.schema.SchemaOpts object>
class mario.declarative.OptionNameField(*, default=<marshmallow.missing>, missing=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, **metadata)[source]

Bases: marshmallow.fields.Field

class mario.declarative.OptionSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

A command line named option for a new command.

make_option(validated, partial, many)[source]
opts = <marshmallow.schema.SchemaOpts object>
class mario.declarative.RemapParam(new, old)[source]

Bases: object

class mario.declarative.RemapParamSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Translation between the name of a base command’s parameter and the name of the new command’s parameter.

make_remap(validated, partial, many)[source]
opts = <marshmallow.schema.SchemaOpts object>
class mario.declarative.TypeField(*args, **kwargs)[source]

Bases: marshmallow.fields.Field

mario.doc module

class mario.doc.HelpSection(priority, entries, doc='', name=None)[source]

Bases: object

class mario.doc.HelpSectionSpec(priority, doc='', name='')[source]

Bases: object

mario.doc.format_text(document)[source]
Return type

str

mario.doc.get_jsonschema_type_mapping(type_)[source]
mario.doc.parse_rst(text)[source]
Return type

docutils.nodes.document

mario.doc.rst2text(source)[source]
Return type

str

mario.exceptions module

exception mario.exceptions.MarioException[source]

Bases: Exception

Base class for all Mario package exceptions.

mario.interfaces module

class mario.interfaces.Context(global_options=NOTHING)[source]

Bases: object

class mario.interfaces.Traversal(global_invocation_options, specific_invocation_params, runtime_parameters=None, plugin_object=None)[source]

Bases: object

global_invocation_options = None

mario map –special reversed

runtime_parameters = None

the actual traversal function

specific_invocation_params = None

stack, items

mario.interpret module

Command line pipes in python.

class mario.interpret.Function(wrapped, global_namespace, source)[source]

Bases: object

class mario.interpret.HowCall[source]

Bases: enum.Enum

An enumeration.

NONE = ''
SINGLE = '(x)'
VARARGS = '(*x)'
VARKWARGS = '(**x)'
class mario.interpret.HowSig[source]

Bases: enum.Enum

An enumeration.

NONE = 'x'
SINGLE = 'x'
VARARGS = '*x'
VARKWARGS = '**x'
mario.interpret.build_function(code, global_namespace, howcall)[source]
mario.interpret.build_global_namespace(source)[source]
mario.interpret.build_name_to_module(code)[source]
mario.interpret.build_source(components, howcall)[source]
mario.interpret.find_maybe_module_names(text)[source]
mario.interpret.make_autocall(expression, howcall)[source]
mario.interpret.split_pipestring(s, sep='!')[source]

mario.plug module

class mario.plug.CommandCommand(name, components, short_help, options=NOTHING, arguments=NOTHING)[source]

Bases: object

class mario.plug.CommandStage(name, options, arguments, remap_params)[source]

Bases: object

class mario.plug.GlobalOption(name, type, default)[source]

Bases: object

class mario.plug.PluginObject(name, traversal_function, required_parameters, calculate_more_params=<function PluginObject.<lambda>>)[source]

Bases: object

class mario.plug.Registry(traversals=NOTHING, global_options=NOTHING, cli_functions=NOTHING, commands=NOTHING)[source]

Bases: object

add_cli(name=None)[source]
add_traversal(name=None, calculate_more_params=<function Registry.<lambda>>)[source]
mario.plug.collect_modules(import_paths)[source]
Return type

List[module]

mario.plug.combine_registries(registries)[source]
mario.plug.make_commands(conf)[source]
mario.plug.make_config_commands_registry()[source]
mario.plug.make_config_registry()[source]
mario.plug.make_global_registry()[source]
mario.plug.make_plugin_commands_registry(package='mario.plugins')[source]
mario.plug.make_plugin_registry()[source]
mario.plug.plugin_module_paths()[source]
Return type

List[str]

mario.sphinx_click module

class mario.sphinx_click.ClickDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.Directive

has_content = False
option_spec = {'commands': <function unchanged>, 'prog': <function unchanged_required>, 'show-nested': <function flag>}
required_arguments = 1
run()[source]
mario.sphinx_click.setup(app)[source]

mario.sphinx_jsonschema module

class mario.sphinx_jsonschema.DefinitionJsonSchema(directive, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: sphinx-jsonschema.JsonSchema

run()[source]
class mario.sphinx_jsonschema.DefinitionWideFormat(state, lineno, app)[source]

Bases: sphinx-jsonschema.wide_format.WideFormat

Add definition field.

mario.sphinx_jsonschema.setup(app)[source]

mario.sphinx_marshmallow module

class mario.sphinx_marshmallow.Field(name, type, required, default)[source]

Bases: object

default
name
required
type
class mario.sphinx_marshmallow.Marshmallow3JSONSchema(*args, **kwargs)[source]

Bases: marshmallow_jsonschema.base.JSONSchema

get_definition(obj)[source]
get_properties(obj)[source]

Fill out properties field.

get_required(obj)[source]

Fill out required field.

opts = <marshmallow.schema.SchemaOpts object>
wrap(*args, many, **kwargs)[source]

Wrap this with the root schema definitions.

class mario.sphinx_marshmallow.SchemaDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.Directive

has_content = False
option_spec = {'commands': <function unchanged>, 'prog': <function unchanged_required>, 'show-nested': <function flag>}
required_arguments = 1
run()[source]
class mario.sphinx_marshmallow.SchemaSpec(name, fields)[source]

Bases: object

fields
name
class mario.sphinx_marshmallow.Table(title, header, body=NOTHING, widths='auto')[source]

Bases: object

body
header
title
widths
mario.sphinx_marshmallow.quote(s)[source]
mario.sphinx_marshmallow.setup(app)[source]

mario.traversals module

class mario.traversals.AsyncIterableWrapper(iterable)[source]

Bases: object

mario.traversals.aenumerate(items, start=0)[source]
mario.traversals.async_filter(function, iterable, max_concurrent)[source]
Return type

AsyncIterator[AsyncIterable[~T]]

mario.traversals.async_map(function, iterable, max_concurrent)[source]
Return type

AsyncIterator[AsyncIterable[~U]]

mario.traversals.async_map_unordered(function, iterable, max_concurrent)[source]
Return type

AsyncIterator[AsyncIterable[~U]]

mario.traversals.async_reduce(function, iterable, max_concurrent, initializer=<object object>)[source]
Return type

AsyncIterator[AsyncIterable[~U]]

mario.traversals.sync_chain(iterable, **_kwargs)[source]
mario.traversals.sync_filter(function, iterable, max_concurrent)[source]
Return type

AsyncIterator[AsyncIterable[~U]]

mario.traversals.sync_map(function, iterable, max_concurrent)[source]
Return type

AsyncIterator[AsyncIterable[~U]]

async mario.traversals.wait_for(x)[source]

mario.utils module

Module contents