rbtools.clients.base.registry¶
Registry of available SCMClients.
New in version 4.0.
Module Attributes
The main SCMClients registry used by RBTools. |
Classes
A registry for looking up and fetching available SCMClients. |
- class rbtools.clients.base.registry.SCMClientRegistry[source]¶
Bases:
objectA registry for looking up and fetching available SCMClients.
This keeps track of all available
BaseSCMClientsubclasses available to RBTools. It supplies a built-in list of clients shipped with RBTools and ones provided by Python packages supplying arbtools_scm_clientsentry point group.Built-in SCMClients and ones in entry points are only loaded once per registry, and only if needed based on the operations performed. Listing will always ensure both sets of SCMClients are loaded.
Legacy SCMClients provided by entry points will be assigned a
scmclient_idbased on the entry point name, if one is not already assigned, and will emit a warning. Starting in RBTools 5.0, custom SCMClients will need to explicitly set an ID.New in version 4.0.
- __contains__(scmclient: Union[str, Type[BaseSCMClient]]) bool[source]¶
Return whether a SCMClient type or ID is in the registry.
- __iter__() Iterator[Type[BaseSCMClient]][source]¶
Iterate through all registered SCMClient classes.
This will yield each built-in SCMClient, followed by each one provided by an entrypoint.
This will force both sets of SCMClients to load, if not already loaded.
- Yields:
type– A registeredBaseSCMClientsubclass.
- get(scmclient_id: str) Type[BaseSCMClient][source]¶
Return a SCMClient class with the given ID.
This will first check the built-in list of SCMClients. If not found, entry points will be loaded (if not already loaded), and the ID will be looked up amongst that set.
- Parameters:
scmclient_id (
str) – The ID of the SCMClient.- Returns:
The registered
BaseSCMClientsubclass for the given ID.- Return type:
- Raises:
rbtools.clients.errors.SCMClientNotFoundError – A client matching the ID could not be found.
- register(scmclient_cls: Type[BaseSCMClient]) None[source]¶
Register a SCMClient class.
The class must have
scmclient_idset, and it must be unique.- Parameters:
scmclient_cls (
type) – The class to register.- Raises:
ValueError – The SCMClient ID is unset or not unique.