an.semantic.registry#
The one vocabulary registry (ADR 0003 decision 6): entries and aspects, by owner.
Two kinds of source feed it:
registered entries (
register_entry(),register_aspect()): methods, motion and expression presets, camera moves, IR fields — each with an owner (the core, or a genre, throughan.genres.Genre’svocabularyandaspectsfields, so a genre’s entries come out with it);views (
register_view()): entries derived on every read from a registry that already exists — the action and entity kinds ofan.genres.registry, the easings ofan.timing.easing— so a kindor an easing is defined once, where it lives, and never copied here (design principle 3).
Like an.genres.registry this module imports nothing from an.ir: a
view imports its source lazily, when it is read.
>>> from an.semantic.entries import Entry
>>> e = register_entry(Entry("demo.wiggle", "motion_preset", name="wiggle"), owner="demo")
>>> lookup("motion_preset", "wiggle") is e, entry("demo.wiggle") is e
(True, True)
>>> drop_owner("demo"); lookup("motion_preset", "wiggle") is None
True
Functions
Spellings defined twice (a view and a registered entry disagreeing on an id count once: the registered one shadows). |
|
|
The registered aspect |
|
|
|
|
|
Remove every entry and aspect |
|
Every entry (registered and viewed), filtered by |
|
The entry with this id; |
|
The entry of |
|
Every registered method of an aspect: its chain first, in order, then the rest. |
|
|
|
Register an aspect and its default chain. |
|
Register a vocabulary entry under |
|
Register a read-time view (core only: the kinds and easing registries). |
Every deliberate replacement: |
|
|
|
|
The state of the registered tables (views are code, not state). |
Exceptions
A name or id is not in the vocabulary; the message lists what is. |
- exception an.semantic.registry.UnknownEntryError[source]#
Bases:
VocabularyError,KeyErrorA name or id is not in the vocabulary; the message lists what is.
- an.semantic.registry.aspect(name)[source]#
The registered aspect
name;UnknownEntryErrorotherwise.- Return type:
- an.semantic.registry.drop_owner(owner)[source]#
Remove every entry and aspect
ownerregistered.- Return type:
- an.semantic.registry.duplicates()[source]#
Spellings defined twice (a view and a registered entry disagreeing on an id count once: the registered one shadows). Empty when one name is one thing.
- an.semantic.registry.entries(*, kind=None, owner=None)[source]#
Every entry (registered and viewed), filtered by
kind/owner, in a stable order.
- an.semantic.registry.entry(entry_id)[source]#
The entry with this id;
UnknownEntryErrornaming the known ids otherwise.- Return type:
- an.semantic.registry.lookup(kind, name, *, aspect=None)[source]#
The entry of
kinda document spellsname(for methods, withinaspect).
- an.semantic.registry.methods_of(aspect_name)[source]#
Every registered method of an aspect: its chain first, in order, then the rest.
- an.semantic.registry.register_aspect(a, *, owner='an', replace=False)[source]#
Register an aspect and its default chain. Checked as a whole by
an.semantic.check_registry()(a chain may name methods registered after it, within the same genre).- Return type:
- an.semantic.registry.register_entry(e, *, owner='an', replace=False)[source]#
Register a vocabulary entry under
owner: ONE entry per id, and per spelling.A name means one thing everywhere (
push_inis one entry, an#257): a second entry under a taken id — registered or provided by a view — or under a taken(kind, name)(within an aspect, for methods) raises, unlessreplace=Trueis passed explicitly, and then the replacement is recorded (replacements()). Re-registering the same entry is a no-op.- Return type:
>>> from an.semantic.entries import Entry >>> register_entry(Entry("demo.push_in", "camera_move", name="push_in"), owner="demo") Traceback (most recent call last): ... an.semantic.entries.VocabularyError: camera_move 'push_in' is already defined by 'camera.push_in' (owner 'an'); ...
- an.semantic.registry.register_view(name, view)[source]#
Register a read-time view (core only: the kinds and easing registries).
- Return type: