Asset¶
An asset (file) of a Publication.
The asset is identified by its internal_path inside the virtual container of the publication.
The contents of the asset can be specified:
- by storing its bytes in the data property
- by specifying the absolute_path to a file on disk
- by specifying the absolute_path (pointing to a directory on disk) and the corresponding relative_path (to a file)
- by specifying the absolute_path (pointing to a ZIP file on disk) and the corresponding relative_path (the ZIP entry name)
-
class
yael.asset.
Asset
(absolute_path=None, relative_path=None, internal_path=None, data=None)[source]¶ Build an asset.
Parameters: - absolute_path (str) – the absolute path
- relative_path (str) – the relative path
- internal_path (str) – the internal path
- data (bytes) – a data (bytes) object
-
absolute_path
¶ The absolute path of the container of this asset (if relative_path is not None) or the absolute path of this asset (if relative_path is None).
Return type: str
-
contents
¶ The contents of this asset.
The return value is obtained by either reading the data property (case 1), or by suitably reading the contents from the file system (cases 2, 3, and 4).
If the asset is obfuscated, this function will run the (un)obfuscation algorithm on the raw_contents.
Return type: bytes
-
data
¶ The contents (i.e., bytes) of this asset, set programmatically.
Return type: bytes
-
internal_path
¶ The internal path of this asset, relative to the virtual container root.
Return type: str
-
obfuscation_algorithm
¶ The obfuscation algorithm to be used or None if the asset should not be obfuscated.
Return type: yael.obfuscation.Obfuscation
-
obfuscation_key
¶ The obfuscation key to be used or None if the asset should not be obfuscated.
Return type: str
-
raw_contents
¶ The raw contents of this asset.
The return value is obtained by either reading the data property (case 1), or by suitably reading the contents from the file system (cases 2, 3, and 4).
Return type: bytes
-
relative_path
¶ The path of this asset, relative to the container root specified by absolute_path.
Return type: str