A mapping of registered projection names to projection classes.
| 67 | |
| 68 | |
| 69 | class ProjectionRegistry: |
| 70 | """A mapping of registered projection names to projection classes.""" |
| 71 | |
| 72 | def __init__(self): |
| 73 | self._all_projection_types = {} |
| 74 | |
| 75 | def register(self, *projections): |
| 76 | """Register a new set of projections.""" |
| 77 | for projection in projections: |
| 78 | name = projection.name |
| 79 | self._all_projection_types[name] = projection |
| 80 | |
| 81 | def get_projection_class(self, name, _error_cls=KeyError): |
| 82 | """Get a projection class from its *name*.""" |
| 83 | return _api.getitem_checked(self._all_projection_types, _error_cls=_error_cls, |
| 84 | projection=name) |
| 85 | |
| 86 | def get_projection_names(self): |
| 87 | """Return the names of all projections currently registered.""" |
| 88 | return sorted(self._all_projection_types) |
| 89 | |
| 90 | |
| 91 | projection_registry = ProjectionRegistry() |
no outgoing calls
no test coverage detected
searching dependent graphs…