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.
Attributes¶
Methods Signature¶
|
Resolves the asset url and caching the assetdescription in the url. |
|
Creates an asset repository for the given |
Returns the application repository. |
|
|
Returns the url to access the asset data. |
Returns the built-in repository. |
|
Returns the AssetDescription of the given Asset. |
|
|
Returns the standardized InternedId for the given languageid. |
Returns the meta data of this asset. |
|
|
Yields all possible AssetReference updates for this asset due to updatedAssets to receiver. |
|
Yields all direct references which this asset makes to other assets. |
|
Returns the AssetType of this asset. |
Returns the asset repository in the user preferences folder. |
|
|
Returns the version string for the given asset. |
|
Checks if the asset is valid for the current license and program version. |
|
Checks if the asset is visible for the current license and program version. |
|
Creates a UUID (universally unique identifier). |
|
Returns the asset description from a given url with the URLSCHEME_ASSET (Id: “asset”). |
|
Sets identifier, version and repository of this asset. |
|
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
url (
maxon.Url
) – Url to investigate.repository (
maxon.AssetRepositoryRef
) – Repository to search.
- Returns
Modified url which contains the AssetDescription on success.
- Return type
-
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
-
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
-
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
-
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
-
AssetInterface.
GetDescription
()¶ Returns the AssetDescription of the given Asset.
- Returns
AssetDescription on success.
- Return type
-
static
AssetInterface.
GetLanguageMetaDataId
(languageId)¶ Returns the standardized InternedId for the given languageid.
- Parameters
languageId (
maxon.Id
) – Language id.- Returns
InternedId on success.
- Return type
-
AssetInterface.
GetMetaData
()¶ Returns the meta data of this asset.
- Returns
The meta data of this asset.
- Return type
-
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 updatablemaxon.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
updatedAssets (
maxon.BaseArray
[maxon.AssetMetaData
]) – An array of assets with (potentially) newer versions.receiver (Optional[list, Callable[[
maxon.AssetReference
,maxon.AssetBase
], bool]]) – Receiver to which all pending updates due to #updatedAssets are reported.
- Returns
If callback is None or a list of
maxon.AssetReference
andmaxon.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 methodUpdatableAssetInterface.Update()
gets a block of tuples (maxon.AssetReference
,maxon.AssetBase
) as input, and each tuple indicates to which asset anmaxon.AssetReference
shall be updated. So for example if an asset has two links to the same asset this has to be reported as twomaxon.AssetReference
objects, and when only the first one is passed toUpdatableAssetInterface.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
-
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
-
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
-
static
AssetInterface.
ResolveAsset
(url, repository)¶ Returns the asset description from a given url with the URLSCHEME_ASSET (Id: “asset”).
- Parameters
url (
maxon.Url
) – Url to search.repository (
maxon.AssetRepositoryRef
) – Lookup repository.
- Returns
AssetDescription on success.
- Return type
-
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
aid (
maxon.Tuple
[maxon.Id
,maxon.Id
]) – Identifier and version identifier of the asset.update (int) – Update counter, see
AssetBaseWithUpdateInterface.GetUpdate()
.repository (
maxon.AssetRepositoryRef
) – The repository which stored the asset.url (Optional[
maxon.Url
]) – An optional Url where the repository stored the asset.
-
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.