-
Notifications
You must be signed in to change notification settings - Fork 0
Loader
James Lott edited this page Mar 12, 2018
·
3 revisions
[[TOC]]
from mkproject.loader import BaseLoader
from mkproject.loader import LoaderError
class MyLoader(BaseLoader):
def load(self, pack):
try:
for path, data, meta in self._fetch_external(self.location):
pack.register_path(path, data, **meta)
self.log('loaded: %s' % path)
except EnvironmentError as e:
raise LoaderError(e)
def _fetch_external(self, location):
# Some logic to fetch asset data from an external source
return (
('/dev/null', '', {}),
)This property is the value which the loader can use to
locate the external resource to load assets from. It
is populated by __init__().
This attribute is a function allowing the loader to output informational messages. The base implementation does not output messages messages anywhere, and this method should be overridden by the instantiator.
instance.load(pack)
This method must be implemented by each loader class. Its job is to fetch assets
from an external location and populate the AssetPack passed in the pack parameter
with the fetched assets. This population should be performed using the AssetPack.register_path method. If
the loader fails to fetch any asset for any reason, it is expected to raise a
LoaderError.