register_writer#
- eoio.writers.factory.register_writer(name: str, writer_cls: Type[BaseWriter], overwrite: bool = False) Type[BaseWriter][source]#
- eoio.writers.factory.register_writer(name: str, writer_cls: None = None, overwrite: bool = False) Callable[[Type[BaseWriter]], Type[BaseWriter]]
Register a writer class under a name.
Used as a decorator, matching
eoio.processors.registry.register_processor():@register_writer("netcdf") class NetCDFWriter(BaseWriter): ...
Or called directly, which is what you want for a class you do not own:
register_writer("geotiff", SomeThirdPartyWriter)
Either way the class gets its
nameset, so a registered writer always knows what it is called - which is what ends up in the provenance a write records.- Parameters:
name – Name used to select the writer, e.g.
"netcdf".writer_cls – Writer class. Omit it to use this as a decorator.
overwrite – Whether replacing an already-registered name is permitted.
- Returns:
The registered class, or the decorator that will register it.
- Raises:
KeyError – If the name is taken and
overwriteis False.