rbtools.diffs.tools.registry¶
Registry of available diff tools.
New in version 4.0.
Module Attributes
The main diff tools registry. |
Classes
A registry managing known and available diff tools. |
- class rbtools.diffs.tools.registry.DiffToolsRegistry[source]¶
Bases:
object
A registry managing known and available diff tools.
This provides functionality for querying and registering diff tools classes and instances.
As a single diff tool instance can be used for multiple operations, the registry will cache any created instances and return them the next time they’re needed, instead of creating a new instance every time. This avoids the up-front cost of checking for tool availability more than once.
The registry provides a built-in list of supported tools. For future extensibility, additional tools can be registered as well.
New in version 4.0.
- iter_diff_tool_classes() Iterator[Type[BaseDiffTool]] [source]¶
Iterate through all registered diff tool classes.
This does not guarantee order.
- Yields:
type
– Each registered subclass ofBaseDiffTool
.
- get_diff_tool_class(diff_tool_id: str) Optional[Type[BaseDiffTool]] [source]¶
Return a diff tool class with the given ID.
If the ID could not be found, this will return
None
.
- get_available(compatible_diff_tool_ids: Optional[Iterable[str]] = None) BaseDiffTool [source]¶
Return an available diff tool out of an optional set of IDs.
This will attempt to find an available diff tool that, optionally restricting results to a set of compatible diff tool IDs.
The instance is cached for future lookups.
- Parameters:
compatible_diff_tool_ids (
set
, optional) – An optional set of compatible diff tool IDs.- Returns:
The available diff tool instance.
- Return type:
- Raises:
rbtools.diffs.tools.errors.MissingDiffToolError – A compatible diff tool could not be found.