-
Notifications
You must be signed in to change notification settings - Fork 0
Loader
James Lott edited this page Mar 10, 2018
·
3 revisions
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)
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__().
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.