b.commands : module documentation

Part of bzrlib

No module docstring
Class CommandInfo Information about a command.
Class CommandRegistry Special registry mapping command names to command classes.
Function register_command Register a plugin command.
Function all_command_names Return a set of all command names.
Function builtin_command_names Return list of builtin command names.
Function plugin_command_names Returns command names from commands registered by plugins.
Function get_cmd_object Return the command object for a command.
Function probe_for_provider Look for a provider for cmd_name.
Class Command Base class for commands.
Class CommandHooks Hooks related to Command object creation/enumeration.
Function parse_args Parse command line.
Function apply_coveraged Undocumented
Function apply_profiled Undocumented
Function exception_to_return_code UI level helper for profiling and coverage.
Function apply_lsprofiled Undocumented
Function get_alias Return an expanded alias, or None if no alias exists.
Function run_bzr Execute a command.
Function display_command Decorator that suppresses pipe/interrupt errors.
Function install_bzr_command_hooks Install the hooks to supply bzr's own commands.
Function main Main entry point of command-line interface.
Function run_bzr_catch_errors Run a bzr command with parameters as described by argv.
Function run_bzr_catch_user_errors Run bzr and report user errors, but let internal errors propagate.
Class HelpCommandIndex A index for bzr help that returns commands.
Class Provider Generic class to be overriden by plugins
Class ProvidersRegistry This registry exists to allow other providers to exist
Function _squish_command_name Undocumented
Function _unsquish_command_name Undocumented
Function _register_builtin_commands Undocumented
Function _scan_module_for_commands Undocumented
Function _list_bzr_commands Find commands from bzr's core and plugins.
Function _get_cmd_object Get a command object.
Function _try_plugin_provider Probe for a plugin provider having cmd_name.
Function _get_bzr_command Get a command from bzr's core.
Function _get_external_command Lookup a command that is a shell script.
Function _get_plugin_command Get a command from bzr's plugins.
Function _match_argform Undocumented
Function _specified_or_unicode_argv Undocumented
def register_command(cmd, decorate=False):
Register a plugin command.

Should generally be avoided in favor of lazy registration.

def _squish_command_name(cmd):
Undocumented
def _unsquish_command_name(cmd):
Undocumented
def _register_builtin_commands():
Undocumented
def _scan_module_for_commands(module):
Undocumented
def _list_bzr_commands(names):
Find commands from bzr's core and plugins.

This is not the public interface, just the default hook called by all_command_names.

def all_command_names():
Return a set of all command names.
def builtin_command_names():
Return list of builtin command names.

Use of all_command_names() is encouraged rather than builtin_command_names and/or plugin_command_names.

def plugin_command_names():
Returns command names from commands registered by plugins.
def get_cmd_object(cmd_name, plugins_override=True):

Return the command object for a command.

plugins_override
If true, plugin commands can override builtins.
def _get_cmd_object(cmd_name, plugins_override=True, check_missing=True):
Get a command object.
Parameterscmd_nameThe name of the command.
plugins_overrideAllow plugins to override builtins.
check_missingLook up commands not found in the regular index via the get_missing_command hook.
ReturnsA Command object instance
RaisesKeyErrorIf no command is found.
def _try_plugin_provider(cmd_name):
Probe for a plugin provider having cmd_name.
def probe_for_provider(cmd_name):
Look for a provider for cmd_name.
Parameterscmd_nameThe command name.
Returnsplugin_metadata, provider for getting cmd_name.
RaisesNoPluginAvailableWhen no provider can supply the plugin.
def _get_bzr_command(cmd_or_None, cmd_name):
Get a command from bzr's core.
def _get_external_command(cmd_or_None, cmd_name):
Lookup a command that is a shell script.
def _get_plugin_command(cmd_or_None, cmd_name):
Get a command from bzr's plugins.
def parse_args(command, argv, alias_argv=None):
Parse command line.

Arguments and options are parsed at this level before being passed down to specific command handlers. This routine knows, from a lookup table, something about the available options, what optargs they take, and which commands will accept them.

def _match_argform(cmd, takes_args, args):
Undocumented
def apply_coveraged(dirname, the_callable, *args, **kwargs):
Undocumented
def apply_profiled(the_callable, *args, **kwargs):
Undocumented
def exception_to_return_code(the_callable, *args, **kwargs):
UI level helper for profiling and coverage.

This transforms exceptions into a return value of 3. As such its only relevant to the UI layer, and should never be called where catching exceptions may be desirable.

def apply_lsprofiled(filename, the_callable, *args, **kwargs):
Undocumented
def get_alias(cmd, config=None):

Return an expanded alias, or None if no alias exists.

cmd
Command to be checked for an alias.
config
Used to specify an alternative config to use, which is especially useful for testing. If it is unspecified, the global config will be used.
def run_bzr(argv, load_plugins=load_plugins, disable_plugins=disable_plugins):

Execute a command.

Special master options: these must come before the command because they control how the command is interpreted.

--no-plugins Do not load plugin modules at all
--no-aliases Do not allow aliases
--builtin Only use builtin commands. (Plugins are still allowed to change other behaviour.)
--profile Run under the Python hotshot profiler.
--lsprof Run under the Python lsprof profiler.
--coverage Generate line coverage report in the specified directory.
--concurrency Specify the number of processes that can be run concurrently (selftest).
ParametersargvThe command-line arguments, without the program name from argv[0] These should already be decoded. All library/test code calling run_bzr should be passing valid strings (don't need decoding).
load_pluginsWhat function to call when triggering plugin loading. This function should take no arguments and cause all plugins to be loaded.
disable_pluginsWhat function to call when disabling plugin loading. This function should take no arguments and cause all plugin loading to be prohibited (so that code paths in your application that know about some plugins possibly being present will fail to import those plugins even if they are installed.)
ReturnsReturns a command exit code or raises an exception.
def display_command(func):
Decorator that suppresses pipe/interrupt errors.
def install_bzr_command_hooks():
Install the hooks to supply bzr's own commands.
def _specified_or_unicode_argv(argv):
Undocumented
def main(argv=None):
Main entry point of command-line interface.

Typically bzrlib.initialize should be called first.

Parametersargvlist of unicode command-line arguments similar to sys.argv. argv[0] is script name usually, it will be ignored. Don't pass here sys.argv because this list contains plain strings and not unicode; pass None instead.
Returnsexit code of bzr command.
def run_bzr_catch_errors(argv):
Run a bzr command with parameters as described by argv.

This function assumed that that UI layer is setup, that symbol deprecations are already applied, and that unicode decoding has already been performed on argv.

def run_bzr_catch_user_errors(argv):
Run bzr and report user errors, but let internal errors propagate.

This is used for the test suite, and might be useful for other programs that want to wrap the commandline interface.

API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.