Jump to >

rbtools.clients.base.registry

Registry of available SCMClients.

New in version 4.0.

Module Attributes

scmclient_registry

The main SCMClients registry used by RBTools.

Classes

SCMClientRegistry()

A registry for looking up and fetching available SCMClients.

class rbtools.clients.base.registry.SCMClientRegistry[source]

Bases: object

A registry for looking up and fetching available SCMClients.

This keeps track of all available BaseSCMClient subclasses available to RBTools. It supplies a built-in list of clients shipped with RBTools and ones provided by Python packages supplying a rbtools_scm_clients entry 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_id based 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.

__init__() None[source]

Initialize the registry.

__contains__(scmclient: Union[str, Type[BaseSCMClient]]) bool[source]

Return whether a SCMClient type or ID is in the registry.

Parameters:

scmclient (str or type) – The SCMClient ID or class type to check for.

Returns:

True if the registry contains this client. False if it does not.

Return type:

bool

Raises:

TypeErrorscmclient is not an ID or a SCMClient class.

__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 registered BaseSCMClient subclass.

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 BaseSCMClient subclass for the given ID.

Return type:

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_id set, and it must be unique.

Parameters:

scmclient_cls (type) – The class to register.

Raises:

ValueError – The SCMClient ID is unset or not unique.

rbtools.clients.base.registry.scmclient_registry = <rbtools.clients.base.registry.SCMClientRegistry object>[source]

The main SCMClients registry used by RBTools.

New in version 4.0.