comicbox.formats.base.transforms.spec ¶
Transform maps.
A MetaSpec maps destination keypaths to source keypaths. _create_specs compiles a set of them into one glom spec in two phases, and refuses to compile a set whose declarations contradict each other.
Destination keyspace: a compile owns its destinations. Two metaspecs claiming the same keypath, or one claiming a keypath nested inside another’s, raise at import. glom’s assign used to resolve those silently – the later mapping won the value at the earlier one’s slot, and a nested pair either lost the whole subtree or was set as an attribute of the enclosing spec and never reached the output.
Scope channel: a metaspec with assign_global publishes its spec function’s result into glom’s per call globals, and other metaspecs read it back by naming S.globals.comicbox.<key> among their sources. glom evaluates a compiled dict in key insertion order, so phase one compiles the producers and phase two everything else. Declaration order no longer decides whether a read resolves. Only one producer per compile: a second publish replaces the whole scope mapping. Readers still supply their own default, because publishing happens at runtime over data that may hold nothing; the compile only proves a producer exists.
MetaSpec dataclass ¶
Define a key mapping and transform functions.
Source code in comicbox/formats/base/transforms/spec.py
40 41 42 43 44 45 46 47 48 | |
create_specs_from_comicbox(*metaspecs, format_root_keypath='', comicbox_root_keypath=ROOT_KEYPATH) ¶
Create from comicbox specs.
Source code in comicbox/formats/base/transforms/spec.py
347 348 349 350 351 352 353 354 355 356 357 358 359 | |
create_specs_to_comicbox(*metaspecs, format_root_keypath='', comicbox_root_keypath=ROOT_KEYPATH) ¶
Create to comicbox specs.
Source code in comicbox/formats/base/transforms/spec.py
334 335 336 337 338 339 340 341 342 343 344 | |