Dumper - lottspot/mkproject GitHub Wiki

[[TOC]]

Synopsis

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 destination

BaseDumper.location

This value represents the base location which the write destination of all other assets should be relative to. It is populated by __init__().

BaseDumper.log

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.

BaseDumper.dump

Spec

instance.dump(pack)

Description

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.

⚠️ **GitHub.com Fallback** ⚠️