ModuleRegistry
dcmspec.module_registry.ModuleRegistry
Bases: UserDict
Registry for sharing module models by table_id across IODs.
This class manages a mapping from table_id (str) to SpecModel. The table_id is typically a string like "table_C.7-1", as found in the HTML anchor tag: It is used to avoid duplicating module models in memory when building many IODs.
Access patterns
- registry[table_id] -> SpecModel
- registry.get(table_id) -> SpecModel or None
- for table_id, model in registry.items(): ...
Example
registry = ModuleRegistry()
# When building IODs, pass registry to IODSpecBuilder(module_registry=registry)
# Setting a module model:
registry["table_C.7-1"] = module_model # module_model is a SpecModel
# Getting a module model (returns SpecModel):
model = registry["table_C.7-1"]
# Safe get (returns SpecModel or None):
model = registry.get("table_C.7-1")
# Checking if a module is present:
if "table_C.7-1" in registry:
...
# Iterating over all table_ids and models:
for table_id, model in registry.items():
# table_id: str, model: SpecModel
...
All values in the registry are instances of SpecModel.
Source code in src/dcmspec/module_registry.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|