Dumper - lottspot/mkproject GitHub Wiki
[[TOC]]
from mkproject.dumper import BaseDumper
from mkproject.dumper import DumperError
class MyDumper(BaseDumper):
def dump(self, pack):
try:
for path in pack.paths():
data = pack.data(path)
self._write_asset(path, data)
self.log('dumped file: %s' % path)
except EnvironmentError as e:
raise DumperError(e)
def _write_asset(self, path, data):
full_path = '%s/%s' % (self.location, path)
# Some other business logic to write the data to its destinationThis value represents the base location which the write destination of all other
assets should be relative to. It is populated by __init__().
This attribute is a function allowing the dumper to output informational messages. The base implementation does not output messages messages anywhere, and this method should be overridden by the instantiator.
instance.dump(pack)
This method must be implemented by each dumper class. Its job is to determine the write
destination for each asset in the AssetPack passed in pack and write the asset data
to that destination. If any asset fails to write for any reason, this method is expected
to raise a DumperError.