liblaf.melon.io.abc
¶
Reusable dispatchers for readers, writers, and converters.
Classes:
-
AbstractConverter–Callable that converts one object into another mesh representation.
-
AbstractReader–Callable that loads an object from a path.
-
AbstractWriter–Callable that writes an object to a path.
-
ConverterDispatcher–Single-dispatch conversion registry with identity conversion built in.
-
ReaderDispatcher–Dispatch readers by file suffix with an optional fallback reader.
-
WriterDispatcher–Dispatch writers first by file suffix and then by object type.
Attributes:
-
save(WriterDispatcher[Any]) –Write registered mesh and scene objects to disk based on path suffix.
save
module-attribute
¶
save: WriterDispatcher[Any] = WriterDispatcher()
Write registered mesh and scene objects to disk based on path suffix.
AbstractConverter
¶
Bases: Protocol
flowchart TD
liblaf.melon.io.abc.AbstractConverter[AbstractConverter]
click liblaf.melon.io.abc.AbstractConverter href "" "liblaf.melon.io.abc.AbstractConverter"
Callable that converts one object into another mesh representation.
-
API Reference
melonioConverterDispatcherregister -
API Reference
melonioabcConverterDispatcherregister
-
API Reference
melonioConverterDispatcherregister -
API Reference
melonioabcConverterDispatcherregister
Methods:
-
__call__–
AbstractReader
¶
Bases: Protocol
flowchart TD
liblaf.melon.io.abc.AbstractReader[AbstractReader]
click liblaf.melon.io.abc.AbstractReader href "" "liblaf.melon.io.abc.AbstractReader"
Callable that loads an object from a path.
-
API Reference
melonioReaderDispatcherfallback -
API Reference
melonioReaderDispatcherregistry -
API Reference
melonioReaderDispatcherregister -
API Reference
melonioReaderDispatcherregister_fallback -
API Reference
melonioabcReaderDispatcherfallback -
API Reference
melonioabcReaderDispatcherregistry -
API Reference
melonioabcReaderDispatcherregister -
API Reference
melonioabcReaderDispatcherregister_fallback
-
API Reference
melonioReaderDispatcher -
API Reference
melonioReaderDispatcherregister -
API Reference
melonioReaderDispatcherregister_fallback -
API Reference
melonioabcReaderDispatcher -
API Reference
melonioabcReaderDispatcherregister -
API Reference
melonioabcReaderDispatcherregister_fallback
Methods:
-
__call__–
AbstractWriter
¶
Bases: Protocol
flowchart TD
liblaf.melon.io.abc.AbstractWriter[AbstractWriter]
click liblaf.melon.io.abc.AbstractWriter href "" "liblaf.melon.io.abc.AbstractWriter"
Callable that writes an object to a path.
-
API Reference
melonioWriterDispatcherregister -
API Reference
melonioabcWriterDispatcherregister
-
API Reference
melonioWriterDispatcherregister -
API Reference
melonioabcWriterDispatcherregister
Methods:
-
__call__–
ConverterDispatcher
¶
Single-dispatch conversion registry with identity conversion built in.
The target type is registered as an identity conversion, so callers can pass through objects that are already in the requested representation.
Examples:
>>> converter = ConverterDispatcher(str)
>>> converter("mesh")
'mesh'
>>> @converter.register(int)
... def _from_int(obj, /, **kwargs):
... return str(obj)
>>> converter(42)
'42'
Parameters:
-
to_type(type[T]) –Target type returned unchanged when the input already has that runtime type.
-
registry(_SingleDispatchCallable[T], default:<dynamic>) –Underlying
functools.singledispatchregistry.
-
API Reference
melonioas_multiblock -
API Reference
melonioas_polydata -
API Reference
melonioas_trimesh -
API Reference
melonioas_unstructured_grid -
API Reference
melonioas_warp_mesh -
API Reference
meloniopyvistaas_multiblock -
API Reference
meloniopyvistaas_polydata -
API Reference
meloniopyvistaas_unstructured_grid -
API Reference
meloniopyvistamultiblockas_multiblock -
API Reference
meloniopyvistapolydataas_polydata -
API Reference
meloniopyvistaunstructured_gridas_unstructured_grid -
API Reference
meloniotrimeshas_trimesh -
API Reference
meloniowarpas_warp_mesh
-
API Reference
melonioas_multiblock -
API Reference
melonioas_polydata -
API Reference
melonioas_trimesh -
API Reference
melonioas_unstructured_grid -
API Reference
melonioas_warp_mesh -
API Reference
meloniopyvistaas_multiblock -
API Reference
meloniopyvistaas_polydata -
API Reference
meloniopyvistaas_unstructured_grid -
API Reference
meloniopyvistamultiblockas_multiblock -
API Reference
meloniopyvistapolydataas_polydata -
API Reference
meloniopyvistaunstructured_gridas_unstructured_grid -
API Reference
meloniotrimeshas_trimesh -
API Reference
meloniowarpas_warp_mesh
Methods:
Attributes:
-
registry(_SingleDispatchCallable[T]) –Underlying
functools.singledispatchregistry. -
to_type(type[T]) –Target type returned unchanged when the input already has that runtime type.
registry
class-attribute
instance-attribute
¶
registry: _SingleDispatchCallable[T] = attrs.field(
default=attrs.Factory(
_default_registry, takes_self=True
)
)
Underlying functools.singledispatch registry.
to_type
instance-attribute
¶
to_type: type[T]
Target type returned unchanged when the input already has that runtime type.
register
¶
register[F](
cls: _RegType, converter: AbstractConverter[F, T]
) -> AbstractConverter[F, T]
register[F](
cls: _RegType, converter: None = None
) -> Callable[
[AbstractConverter[F, T]],
AbstractConverter[F, T],
]
Source code in src/liblaf/melon/io/abc/_converter.py
ReaderDispatcher
¶
Dispatch readers by file suffix with an optional fallback reader.
Raises:
-
KeyError–If the path suffix is unknown and no fallback reader exists.
Attributes:
Parameters:
-
to_type(type[T]) – -
fallback(AbstractReader[T] | None, default:None) – -
registry(dict[str, AbstractReader[T]], default:<class 'dict'>) –dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
-
API Reference
melonioload_multiblock -
API Reference
melonioload_polydata -
API Reference
melonioload_unstructured_grid -
API Reference
meloniopyvistaload_multiblock -
API Reference
meloniopyvistaload_polydata -
API Reference
meloniopyvistaload_unstructured_grid -
API Reference
meloniopyvistamultiblockload_multiblock -
API Reference
meloniopyvistapolydataload_polydata -
API Reference
meloniopyvistaunstructured_gridload_unstructured_grid
-
API Reference
melonioload_multiblock -
API Reference
melonioload_polydata -
API Reference
melonioload_unstructured_grid -
API Reference
meloniopyvistaload_multiblock -
API Reference
meloniopyvistaload_polydata -
API Reference
meloniopyvistaload_unstructured_grid -
API Reference
meloniopyvistamultiblockload_multiblock -
API Reference
meloniopyvistapolydataload_polydata -
API Reference
meloniopyvistaunstructured_gridload_unstructured_grid
Methods:
registry
class-attribute
instance-attribute
¶
registry: dict[str, AbstractReader[T]] = attrs.field(
factory=dict
)
__call__
¶
Source code in src/liblaf/melon/io/abc/_reader.py
register
¶
register(
suffixes: Iterable[str], reader: AbstractReader[T]
) -> AbstractReader[T]
register(
suffixes: Iterable[str], reader: None = None
) -> Callable[[AbstractReader[T]], AbstractReader[T]]
Source code in src/liblaf/melon/io/abc/_reader.py
register_fallback
¶
register_fallback(
reader: AbstractReader[T],
) -> AbstractReader[T]
WriterDispatcher
¶
Dispatch writers first by file suffix and then by object type.
Registered writers receive a pathlib.Path. Parent directories are created
before the writer is called, which keeps concrete writer implementations
focused on serialization.
Raises:
-
KeyError–If no writer registry exists for the path suffix.
-
NotImplementedError–If the suffix exists but the object type is not registered for that suffix.
Parameters:
-
registry(dict[str, _SingleDispatchCallable[None]], default:<class 'dict'>) –dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
Methods:
Attributes:
registry
class-attribute
instance-attribute
¶
__call__
¶
Source code in src/liblaf/melon/io/abc/_writer.py
register
¶
register(
cls: _RegType,
suffixes: Iterable[str],
writer: AbstractWriter[T],
) -> AbstractWriter[T]
register(
cls: _RegType,
suffixes: Iterable[str],
writer: None = None,
) -> Callable[[AbstractWriter[T]], AbstractWriter[T]]