plainbox.impl.box – command line interface

Warning

THIS MODULE DOES NOT HAVE STABLE PUBLIC API

class plainbox.impl.box.PlainBoxTool[source]

Bases: plainbox.impl.clitools.LazyLoadingToolMixIn, plainbox.impl.commands.PlainBoxToolBase

Command line interface to PlainBox

add_early_parser_arguments(parser)
add_subcommands()

Add top-level subcommands to the argument parser.

Parameters:
  • subparsers – A part of argparse that can be used to create additional parsers for specific subcommands.
  • early_ns – (optional) An argparse namespace from earlier parsing. If it is not None, it must have the rest attribute which is used as a list of hints.

Note

This method is customized by LazyLoadingToolMixIn and should not be overriden directly. To register your commands use get_command_collection()

add_subcommands_with_hints()

Add top-level subcommands to the argument parser, using a list of hints.

Parameters:
  • subparsers – A part of argparse that can be used to create additional parsers for specific subcommands.
  • hint_list – A list of strings that should be used as hints.

This method tries to optimize the time needed to register and setup all of the subcommands by looking at a list of hints in search for the (likely) command that will be executed.

Things that look like options are ignored. The first element of hint_list that matches a known command name, as provided by meth:get_command_collection(), is used as a sign that that command will be executed and all other commands don’t have to be loaded or initialized. If no hints are found (e.g. when running tool --help) the slower fallback mode is used and all subcommands are added.

Note

This method is customized by LazyLoadingToolMixIn and should not be overriden directly. To register your commands use get_command_collection()

add_subcommands_without_hints(subparsers: argparse._SubParsersAction, command_collection: plainbox.impl.secure.plugins.IPlugInCollection) → None

Add top-level subcommands to the argument parser (fallback mode)

Parameters:
  • subparsers – A part of argparse that can be used to create additional parsers for specific subcommands.
  • command_collection – A collection of commands that was obtaioned from get_command_collection() earlier.

This method is called when hint-based optimization cannot be used and all commands need to be loaded and initialized.

Note

This method is customized by LazyLoadingToolMixIn and should not be overriden directly. To register your commands use get_command_collection()

construct_early_parser()

Create a parser that captures some of the early data we need to be able to have a real parser and initialize the rest.

construct_parser(early_ns=None)
create_parser_object()[source]
dispatch_and_catch_exceptions(ns)
dispatch_command(ns)
early_init()

Do very early initialization. This is where we initialize stuff even without seeing a shred of command line data or anything else.

enable_argcomplete_if_possible(parser)
final_init(ns)

Do some final initialization just before the command gets dispatched. This is empty here but maybe useful for subclasses.

format_version_tuple(version_tuple)
get_command_collection()[source]
classmethod get_config_cls()[source]

Get the Config class that is used by this implementation.

This can be overridden by subclasses to use a different config class that is suitable for the particular application.

classmethod get_exec_name()[source]

Get the name of this executable

classmethod get_exec_version()[source]

Get the version reported by this executable

get_gettext_domain()[source]
get_locale_dir()[source]
late_init(early_ns)

Initialize with early command line arguments being already parsed

main(argv=None)

Run as if invoked from command line directly

setup_i18n()

Setup i18n and l10n system.

class plainbox.impl.box.StubBoxTool[source]

Bases: plainbox.impl.box.PlainBoxTool

Command line interface to StubBox

The ‘stubbox’ executable is just just like plainbox but it contains the special stubbox provider with representative test jobs.

add_early_parser_arguments(parser)
add_subcommands()

Add top-level subcommands to the argument parser.

Parameters:
  • subparsers – A part of argparse that can be used to create additional parsers for specific subcommands.
  • early_ns – (optional) An argparse namespace from earlier parsing. If it is not None, it must have the rest attribute which is used as a list of hints.

Note

This method is customized by LazyLoadingToolMixIn and should not be overriden directly. To register your commands use get_command_collection()

add_subcommands_with_hints()

Add top-level subcommands to the argument parser, using a list of hints.

Parameters:
  • subparsers – A part of argparse that can be used to create additional parsers for specific subcommands.
  • hint_list – A list of strings that should be used as hints.

This method tries to optimize the time needed to register and setup all of the subcommands by looking at a list of hints in search for the (likely) command that will be executed.

Things that look like options are ignored. The first element of hint_list that matches a known command name, as provided by meth:get_command_collection(), is used as a sign that that command will be executed and all other commands don’t have to be loaded or initialized. If no hints are found (e.g. when running tool --help) the slower fallback mode is used and all subcommands are added.

Note

This method is customized by LazyLoadingToolMixIn and should not be overriden directly. To register your commands use get_command_collection()

add_subcommands_without_hints(subparsers: argparse._SubParsersAction, command_collection: plainbox.impl.secure.plugins.IPlugInCollection) → None

Add top-level subcommands to the argument parser (fallback mode)

Parameters:
  • subparsers – A part of argparse that can be used to create additional parsers for specific subcommands.
  • command_collection – A collection of commands that was obtaioned from get_command_collection() earlier.

This method is called when hint-based optimization cannot be used and all commands need to be loaded and initialized.

Note

This method is customized by LazyLoadingToolMixIn and should not be overriden directly. To register your commands use get_command_collection()

construct_early_parser()

Create a parser that captures some of the early data we need to be able to have a real parser and initialize the rest.

construct_parser(early_ns=None)
create_parser_object()
dispatch_and_catch_exceptions(ns)
dispatch_command(ns)
early_init()

Do very early initialization. This is where we initialize stuff even without seeing a shred of command line data or anything else.

enable_argcomplete_if_possible(parser)
final_init(ns)

Do some final initialization just before the command gets dispatched. This is empty here but maybe useful for subclasses.

format_version_tuple(version_tuple)
get_command_collection()
get_config_cls()

Get the Config class that is used by this implementation.

This can be overridden by subclasses to use a different config class that is suitable for the particular application.

classmethod get_exec_name()[source]
get_exec_version()

Get the version reported by this executable

get_gettext_domain()
get_locale_dir()
late_init(early_ns)

Initialize with early command line arguments being already parsed

main(argv=None)

Run as if invoked from command line directly

setup_i18n()

Setup i18n and l10n system.

plainbox.impl.box.get_parser_for_sphinx()[source]
plainbox.impl.box.main(argv=None)[source]
plainbox.impl.box.stubbox_main(argv=None)[source]
comments powered by Disqus