Skip to content

packer.py

ofrak.component.packer

Packer (AbstractComponent, ABC)

Packers are components that typically mirror unpackers, taking constituent children resources (and sometimes descendants) and reassembling them to produce a new resource.

pack(self, resource, config) async

Pack the given resource.

Users should not call this method directly; rather, they should run Resource.run or Resource.pack.

Parameters:

Name Type Description Default
resource Resource required
config ~CC

Optional config for packing. If an implementation provides a default, this default will always be used when config would otherwise be None. Note that a copy of the default config will be passed, so the default config values cannot be modified persistently by a component run.

required
Source code in ofrak/component/packer.py
@abstractmethod
async def pack(self, resource: Resource, config: CC) -> None:
    """
    Pack the given resource.

    Users should not call this method directly; rather, they should run
    [Resource.run][ofrak.resource.Resource.run] or
    [Resource.pack][ofrak.resource.Resource.pack].

    :param resource:
    :param config: Optional config for packing. If an implementation provides a default,
    this default will always be used when config would otherwise be None. Note that a copy of
    the default config will be passed, so the default config values cannot be modified
    persistently by a component run.
    """
    raise NotImplementedError()

PackerError (RuntimeError)

Base exception raised by Packers.