pytableaux.logics
registry
- registry: Registry
The default built-in registry
- Parameters:
key (str | ModuleType) --
- Return type:
LogicType
- class Registry(*, source=None)[source]
Logic module registry.
- __call__(key, /)[source]
Get a logic from the registry, importing if needed. See
get()
- Parameters:
key (str | module) --
- Return type:
LogicType
- get(ref, default=<object object>, /)[source]
Get a logic from the registry, importing if needed.
- Parameters:
key --
One of the following:
Full
module.__name__
local ID (lowercase last part of
module.__name__
)The module's
Meta.name
attributeModule object
default -- A default value to suppress error.
- Returns:
The logic module
- Raises:
ModuleNotFoundError -- if not found.
TypeError -- on bad key argument.
- Return type:
LogicType
- locate(ref, default=<object object>, /)[source]
Like
get()
but also searches the__module__
attribute of classes, methods, and functions to locate the logic in which it was defined.- Parameters:
ref -- A key accepted by
get()
, or a class, method, or function defined in a logic module.default -- A default value to suppress not found error.
- Returns:
The logic module
- Raises:
ValueError -- if not found.
TypeError -- on bad key argument.
- Return type:
LogicType
- package_all(package, /)[source]
Yield the package's declared logic modules from its
__all__
attribute.- Parameters:
package (str | module) --
- import_all()[source]
Import all logics for all registry packages. See
import_package()
.- Return type:
None
- import_package(package, /)[source]
Import all logic modules for a package. Uses the
__all__
attribute to list the logic names.- Raises:
ValueError -- if the package is not in the registry packages.
- Parameters:
package (str | module) --
- Return type:
None
- grouped(keys=None, /, *, sort=True, key=None, reverse=False)[source]
Group logics by category.
- Parameters:
keys -- Iterable of keys accepted by
get()
.sort -- Whether to sort each group. Default
True
.key -- The sort key for the groups. Default is
logic.Meta
.reverse -- Whether to reverse sort each group.
- Returns:
A dict from each category name to the list of logic modules.
- Raises:
ValueError -- if any not found.
- Return type: