RepoBee Module Reference
This is the public API of the repobee
module, which is primarily intended
for testing of plugins, but could also be used to execute RepoBee from a Python
script. For the internal API of the _repobee
package, please see the
msource code.
repobee
- repobee.run(cmd, config_file='', plugins=None, workdir='.')[source]
Run RepoBee with the provided options. This function is mostly intended to be used for testing plugins.
Important
This function will always unregister all plugins after execution, including anly plugins that may have been registered prior to running this function.
Running this function is almost equivalent to running RepoBee from the CLI, with the following exceptions:
Preparser options must be passed as arguments to this function (i.e. cannot be given as part of
cmd
).There is no error handling at the top level, so exceptions are raised instead of just logged.
As an example, the following CLI call:
$ repobee --plug ext.py --config-file config.ini config show
Can be executed as follows:
import ext from repobee import run run(["config", "show"], config_file="config.ini", plugins=[ext])
- Parameters:
- Return type:
- Returns:
A mapping (plugin_name -> plugin_results).
- repobee.try_register_plugin(plugin_module, *plugin_classes)[source]
Attempt to register a plugin module and then immediately unregister it.
Important
This is a convenience method for sanity checking plugins, and should only be called in test suites. It’s not for production use.
This convenience method can be used to sanity check plugins by registering them with RepoBee. If they have incorrectly defined hooks, this will be discovered only when registering.
As an example, assume that we have a plugin module with a single (useless) plugin class in it, like this:
useless.pyimport repobee_plug as plug class Useless(plug.Plugin): """This plugin does nothing!"""
We want to make sure that both the
useless
module and theUseless
plugin class are registered correctly, and for that we can write some simple code like this.Example test case to check registeringimport repobee # assuming that useless is defined in the external plugin # repobee_useless from repobee_useless import useless def test_register_useless_plugin(): repobee.try_register_plugin(useless, useless.Useless)
- Parameters:
plugin_module (
ModuleType
) – A plugin module.plugin_classes (
List
[type
]) – If the plugin contains any plugin classes (i.e. classes that extendrepobee_plug.Plugin
), then these must be provided here. Otherwise, this option should not be provided.
- Raises:
repobee_plug.PlugError –
or if the contained plugin classes does not match –
plugin_classes. –
- Return type: