reviewbot.tools.base.registry¶
Tool registration
These functions are used to register and look up known tool classes.
New in version 3.0.
Functions
|
Return the tool class with a given ID. |
Return all registered tool classes. |
|
Load tool classes provided by Review Bot and other packages. |
|
|
Register a tool class for later lookup. |
|
Unregister a tool class by its ID. |
- register_tool_class(tool_cls)[source]¶
Register a tool class for later lookup.
The tool class must have a
tool_id
attribute (either directly set, for unit tests, or throughload_tool_classes()
), and cannot conflict with another tool.- Parameters:
tool_cls (
type
) – A tool class to register (subclass ofreviewbot.tools.base.tool.BaseTool)
.- Raises:
ValueError – The tool could not be registered, either due to a missing
tool_id
or due to a conflict with another tool.
- unregister_tool_class(tool_id)[source]¶
Unregister a tool class by its ID.
- Parameters:
tool_id (
type
) – The ID of the tool to unregister.- Raises:
KeyError – The tool could not be found.
- get_tool_class(tool_id)[source]¶
Return the tool class with a given ID.
- Parameters:
tool_id (
unicode
) – The ID of the tool to return.- Returns:
The tool class, or
None
if no tool with that ID exists.- Return type:
type
- get_tool_classes()[source]¶
Return all registered tool classes.
This will be sorted in alphabetical order, based on the ID.
- Returns:
A list of tool classes (subclasses of
reviewbot.tools.base.tool.BaseTool
).- Return type:
list
oftype
- load_tool_classes()[source]¶
Load tool classes provided by Review Bot and other packages.
This will scan for any Python packages that provide
reviewbot.tools
entrypoints, loading the tools into the tool registry.Any existing tools will be cleared out before this begins, and any errors will be logged.