maxon.AssetInterface

Description

An Asset represents digital content which can be managed by an maxon.AssetRepositoryRef “asset repository”. The management includes versioning, meta data and automatic updates.

Methods Signature

AddRepositoryScope(url, repository)

Resolves the asset url and caching the assetdescription in the url.

CreateRepositoryFromUrl(rid, bases, url, …)

Creates an asset repository for the given maxon.Url.

GetApplicationRepository()

Returns the application repository.

GetAssetUrl(*args)

Returns the url to access the asset data.

GetBuiltinRepository()

Returns the built-in repository.

GetDescription()

Returns the AssetDescription of the given Asset.

GetLanguageMetaDataId(languageId)

Returns the standardized InternedId for the given languageid.

GetMetaData()

Returns the meta data of this asset.

GetPendingUpdates(updatedAssets[, receiver])

Yields all possible AssetReference updates for this asset due to updatedAssets to receiver.

GetReferencedAssets(onlyUpdatable[, receiver])

Yields all direct references which this asset makes to other assets.

GetType()

Returns the AssetType of this asset.

GetUserPrefsRepository()

Returns the asset repository in the user preferences folder.

GetVersionString(asset)

Returns the version string for the given asset.

IsAssetValid(asset)

Checks if the asset is valid for the current license and program version.

IsAssetVisible(asset)

Checks if the asset is visible for the current license and program version.

MakeUuid(prefix, compact)

Creates a UUID (universally unique identifier).

ResolveAsset(url, repository)

Returns the asset description from a given url with the URLSCHEME_ASSET (Id: “asset”).

SetId(aid, update, repository[, url])

Sets identifier, version and repository of this asset.

SetMetaData(data)

Sets the meta data object to use for this asset.

Methods Definition

static AssetInterface.AddRepositoryScope(url, repository)

Resolves the asset url and caching the assetdescription in the url.

Parameters
Returns

Modified url which contains the AssetDescription on success.

Return type

maxon.Url

static AssetInterface.CreateRepositoryFromUrl(rid, bases, url, writable, derivedInPrefs, tempRepository)

Creates an asset repository for the given maxon.Url. If there already is a directory structure in the expected format it is read as far as needed to initialize the repository with the found assets, otherwise such a directory structure is created.

Parameters
  • rid (maxon.Id) – The repository identifier. There mustn’t be a base with the same identifier.

  • bases (maxon.Block [maxon.AssetRepositoryRef]) – The base repositories for the new repository.

  • url (maxon.Url) – The root directory to use for the repository.

  • writable (bool) – True if the repository shall be writable.

  • derivedInPrefs (bool) – True if derived meta data shall be stored in the user preferences folder. This is mandatory if url is a read-only maxon.Url.

  • tempRepository (bool) – True if the repository should not be registered as a description database.

Returns

Reference to the repository in the user preferences folder.

Return type

maxon.UpdatableAssetRepositoryRef

static AssetInterface.GetApplicationRepository()

Returns the application repository. The application repository uses the AssetInterface.GetBuiltinRepository() “built-in repository” as base and adds the assets found in the resources of the asset.module.

Returns

Reference to the built-in repository.

Return type

maxon.AssetRepositoryRef

static AssetInterface.GetAssetUrl(*args)

Returns the url to access the asset data. e.g. asset:///file_634545662344

Parameters
  • asset (maxon.AssetDescription) – asset to convert.

  • isLatest (bool) – True if the asset is the latest asset. In that case the version will not be added to the url.

Returns

The url to access the asset data.

Return type

maxon.Url

static AssetInterface.GetBuiltinRepository()

Returns the built-in repository. This contains the built-in assets which are defined by program code (i.e., not by a data format to read them from a data stream).

Returns

Reference to the built-in repository.

Return type

maxon.AssetRepositoryRef

AssetInterface.GetDescription()

Returns the AssetDescription of the given Asset.

Returns

AssetDescription on success.

Return type

maxon.AssetDescription

static AssetInterface.GetLanguageMetaDataId(languageId)

Returns the standardized InternedId for the given languageid.

Parameters

languageId (maxon.Id) – Language id.

Returns

InternedId on success.

Return type

maxon.InternedId

AssetInterface.GetMetaData()

Returns the meta data of this asset.

Returns

The meta data of this asset.

Return type

maxon.AssetMetaData

AssetInterface.GetPendingUpdates(updatedAssets, receiver=None)

Yields all possible AssetReference updates for this asset due to updatedAssets to receiver.

This method finds all direct references which this asset makes to other assets, and checks if they are affected by the list of updatedAssets. This check takes into account the update policy of the maxon.AssetLink used for the reference. Whenever there is an updatable maxon.AssetLink and updatedAssets contains a newer version for that link, this is reported by a call to receiver with the reference as first argument and the newer asset from updatedAssets as second argument.

Parameters
Returns

If callback is None or a list of maxon.AssetReference and maxon.AssetBase is returned. Otherwise False if callback cancelled further evaluation, True otherwise.

Return type

Union[list[maxon.AssetReference, maxon.AssetBase], bool]

AssetInterface.GetReferencedAssets(onlyUpdatable, receiver=None)

Yields all direct references which this asset makes to other assets. The maxon.AssetReference objects are used later for the update mechanism: The method UpdatableAssetInterface.Update() gets a block of tuples (maxon.AssetReference, maxon.AssetBase) as input, and each tuple indicates to which asset an maxon.AssetReference shall be updated. So for example if an asset has two links to the same asset this has to be reported as two maxon.AssetReference objects, and when only the first one is passed to UpdatableAssetInterface.Update() only the first link has to be updated, while the second has to remain unchanged.

Parameters
  • onlyUpdatable (bool) – True only references which use updatable links shall be reported (update policy different from ASSET_UPDATE_POLICY.NEVER), otherwise all references.

  • receiver (Optional[list, Callable[[maxon.AssetReference], bool]) – Receiver to which references are reported.

Returns

If callback is None or a list of maxon.AssetReference is returned. Otherwise False if callback cancelled further evaluation, True otherwise.

Return type

Union[list[maxon.AssetReference], bool]

AssetInterface.GetType()

Returns the AssetType of this asset.

Returns

The asset’s type.

Return type

maxon.AssetType

static AssetInterface.GetUserPrefsRepository()

Returns the asset repository in the user preferences folder. This repository is writable for the user.

Returns

Reference to the repository in the user preferences folder.

Return type

maxon.UpdatableAssetRepositoryRef

static AssetInterface.GetVersionString(asset)

Returns the version string for the given asset.

Parameters

asset (Union[maxon.Asset], maxon.AssetDescription]) – Asset to look at.

Returns

Version string on success.

Return type

str

static AssetInterface.IsAssetValid(asset)

Checks if the asset is valid for the current license and program version.

Parameters

asset (maxon.AssetDescription) – Asset to check

Returns

True on success

Return type

bool

static AssetInterface.IsAssetVisible(asset)

Checks if the asset is visible for the current license and program version.

Parameters

asset (maxon.AssetDescription) – Asset to check

Returns

True on success

Return type

bool

static AssetInterface.MakeUuid(prefix, compact)

Creates a UUID (universally unique identifier). If prefix is given, the returned identifier starts with prefix, followed by an @ sign, followed by the UUID such as {base@5e75b5e319f64055ac5387490d7355c0}, otherwise it is a UUID only. If prefix already contains an @ sign, only the part before that sign is used. If compact is True, a Base64-encoding with $ and _ as last characters is used for the UUID instead of the default Hex encoding, this results in shorter UUIDs like {FR4pAc$UFR_jXb16rXadEB}.

Parameters
  • prefix (str) – The prefix for the identifier, may be nullptr. Only the characters up to the first @ sign are used.

  • compact (bool) – True if the shorter Base64-encoding shall be used, false for Hex encoding.

Returns

A new UUID. It is safe to assume that this UUID differs from any other UUID returned by this method.

Return type

maxon.Id

static AssetInterface.ResolveAsset(url, repository)

Returns the asset description from a given url with the URLSCHEME_ASSET (Id: “asset”).

Parameters
Returns

AssetDescription on success.

Return type

maxon.AssetDescription

AssetInterface.SetId(aid, update, repository, url=None)

Sets identifier, version and repository of this asset.

This method should only be called by the owning asset repository when it stores an asset to establish the link between asset and repository.

Parameters
AssetInterface.SetMetaData(data)

Sets the meta data object to use for this asset. This method should only be called by the owning asset repository.

Parameters

data (maxon.AssetMetaData) – The meta data of the asset.