Skip to content

Asset Pack

James Lott edited this page Mar 11, 2018 · 9 revisions

[[TOC]]

Synopsis

from mkproject.asset_pack import AssetPack
asset_pack = AssetPack()

asset_pack.register_path('/path/a', 'data-a', {'arbitrary metadata': 'extra information'})
asset_path.register_path('/path/b', 'data-b')

asset_pack.paths()
# ('/path/a', '/path/b')
asset_pack.data('/path/a')
# 'data-a'
asset_pack.meta('/path/a')
# {'arbitrary metadata': 'extra information'}
asset_pack.meta('/path/b')
# {}
asset_pack.assets()
# (('/path/a', 'data-a', {'arbitrary metadata': 'extra information'}),
#  ('/path/b', 'data-b', {}))

new_asset_pack = asset_pack.transform()

AssetPack.register_path

Spec

instance.register_path(path, data, meta={})

Description

This interface should only be used by loaders. Append asset data to the pack. Asset data has three properties:

  • path: A key representing the path under which this data is stored
  • data: The asset data
  • meta: Optional dictionary assigned as arbitrary metadata to the path

AssetPack.paths

Spec

instance.paths()

Description

Returns all registered paths as a tuple

AssetPack.data

Spec

instance.data(path)

Description

Returns the data associated with the registered path path.

AssetPack.meta

Spec

instance.meta(path)

Description

Returns a dictionary containing all metadata associated with path path

AssetPack.assets

Spec

instance.assets()

Description

Returns a tuple of assets, within which each asset is itself represented as a tuple in the order (path, data, meta).

AssetPack.transform

Spec

instance.transform(transform_map={}, cfg={})

Description

Returns a new AssetPack containing copies of the assets in the calling AssetPack. The method accepts two optional parameters:

If a transform_map is provided, each asset copy will be transformed using the transformers specified in its pipeline metadata key. The value for the pipeline metadata key must be an iterable containing the names of all transformers to be invoked.

Clone this wiki locally