nrcats.registry

Catalog plugin registry.

Provides a lightweight decorator + lookup mechanism so that new catalogs can be registered without editing __init__.py or any core module.

Built-in registration

RITCatalog, SXSCatalog, and MayaCatalog are all registered automatically when the nrcats package is imported.

Third-party registration

A downstream package (or a user in an interactive session) can register an additional catalog at runtime::

from nrcats.registry import register_catalog
from nrcats.catalog import CatalogBase

@register_catalog("LVCNR")
class LVCNRCatalog(CatalogBase):
    CATALOG_TYPE = "LVCNR"
    ...

Lookup

::

from nrcats.registry import get_catalog
cls = get_catalog("RIT")   # → RITCatalog
obj = cls.load()

Contents

  1. nrcats.registry
    1. Built-in registration
    2. Third-party registration
    3. Lookup
      1. register_catalog
        1. Parameters
        2. Returns
        3. Raises
        4. Examples
      2. get_catalog
        1. Parameters
        2. Returns
        3. Raises
        4. Examples
      3. list_catalogs
        1. Returns
        2. Examples

register_catalog

register_catalog(tag: str) -> Callable[[Type], Type]

Class decorator that registers a catalog under tag.

Parameters

Name Type Description
tag str Short uppercase identifier (e.g. "RIT"). Must be unique within the registry.

Returns

Name Type Description
  callable A class decorator; the class itself is returned unchanged so the decorator can be stacked with other decorators.

Raises

Exception Condition
ValueError If tag is already registered, to prevent silent overwrites.

Examples

>>> @register_catalog("LVCNR")
... class LVCNRCatalog(CatalogBase):
...     CATALOG_TYPE = "LVCNR"

get_catalog

get_catalog(tag: str) -> Type

Return the catalog class registered under tag.

Parameters

Name Type Description
tag str Short uppercase identifier (e.g. "RIT").

Returns

Name Type Description
  type The registered catalog class.

Raises

Exception Condition
KeyError If tag is not in the registry.

Examples

>>> cls = get_catalog("SXS")
>>> catalog = cls.load()

list_catalogs

list_catalogs() -> set

Return the set of all registered catalog tags.

Returns

Name Type Description
  set[str] Copy of the current tag set; modifying it has no effect on the registry.

Examples

>>> list_catalogs()
{'MAYA', 'RIT', 'SXS'}