Skip to content

Types

momapy_kb.lpg.types

Custom type plugins for momapy-specific types.

Provides node classes and PylpgTypePlugin implementations for types that are specific to momapy: FrozenDict, NoneValueType, LayoutModelMapping, and FrozenSurjectionDict.

Functions:

Name Description
register_momapy_plugins

Register all momapy-specific type plugins on a context.

register_momapy_plugins

register_momapy_plugins(ctx: PylpgContext) -> None

Register all momapy-specific type plugins on a context.

Registers plugins for FrozenDict, NoneValueType, LayoutModelMapping, and FrozenSurjectionDict, and adds the corresponding type-to-node-class and node-class-to-type mappings.

Parameters:

Name Type Description Default
ctx PylpgContext

The pylpg context to register plugins on.

required
Source code in src/momapy_kb/lpg/types.py
def register_momapy_plugins(ctx: fieldz_kb.lpg.core.PylpgContext) -> None:
    """Register all momapy-specific type plugins on a context.

    Registers plugins for FrozenDict, NoneValueType, LayoutModelMapping,
    and FrozenSurjectionDict, and adds the corresponding type-to-node-class
    and node-class-to-type mappings.

    Args:
        ctx: The pylpg context to register plugins on.
    """
    ctx.register(FrozenDictPlugin)
    ctx.register(NoneValueTypePlugin)
    ctx.register(LayoutModelMappingPlugin)
    ctx.register(FrozenSurjectionDictPlugin)

    ctx.type_to_node_class[frozendict.frozendict] = FrozenDict
    ctx.type_to_node_class[momapy.drawing.NoneValueType] = NoneValueType
    ctx.type_to_node_class[momapy.core.mapping.LayoutModelMapping] = (
        LayoutModelMapping
    )
    ctx.type_to_node_class[momapy.utils.FrozenSurjectionDict] = (
        FrozenSurjectionDict
    )

    ctx.node_class_to_type[FrozenDict] = frozendict.frozendict
    ctx.node_class_to_type[NoneValueType] = momapy.drawing.NoneValueType
    ctx.node_class_to_type[LayoutModelMapping] = (
        momapy.core.mapping.LayoutModelMapping
    )
    ctx.node_class_to_type[FrozenSurjectionDict] = (
        momapy.utils.FrozenSurjectionDict
    )