Provides access to asset path properties. The attributes object is created with environment object and relative (or logical) asset path.
Some properties may be useful or not, depending on the type of passed path. If it is a relative asset path, you can use all properties except search_paths. In case of a logical asset path it makes sense to use only those properties that are not related to processors and compressor.
Parameters: |
|
---|
The list of compiler extensions. Example:
>>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
>>> attrs.suffix
['.coffee']
The list of compilers used to build asset.
The compressors used to compress the asset.
The relative path to the directory the asset.
Used to access the registries of compilers, processors, etc. It can be also used by asset. See Environment for more information.
The list of asset extensions. Example:
>>> attrs = AssetAttributes(environment, 'js/models.js.coffee')
>>> attrs.extensions
['.js', '.coffee']
>>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
>>> attrs.format_extension
['.min', '.js', '.coffee']
The format extension of asset. Example:
>>> attrs = AssetAttributes(environment, 'js/models.js.coffee')
>>> attrs.format_extension
'.js'
>>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
>>> attrs.format_extension
'.js'
The logical path to asset. Example:
>>> attrs = AssetAttributes(environment, 'js/models.js.coffee')
>>> attrs.logical_path
'js/models.js'
MIME-type of the asset.
The relative (or logical) path to asset.
The relative path to asset without suffix. Example:
>>> attrs = AssetAttributes(environment, 'js/app.js')
>>> attrs.path_without_suffix
'js/app'
The list of postprocessors used to build asset.
The list of preprocessors used to build asset.
The list of all processors (preprocessors, compilers, postprocessors) used to build asset.
The list of logical paths which are used to search for an asset. This property makes sense only if the attributes was created with logical path.
It is assumed that the logical path can be a directory containing a file named index with the same suffix.
Example:
>>> attrs = AssetAttributes(environment, 'js/app.js')
>>> attrs.search_paths
['js/app.js', 'js/app/index.js']
>>> attrs = AssetAttributes(environment, 'js/app/index.js')
>>> attrs.search_paths
['js/models/index.js']
The list of asset extensions starting from the format extension. Example:
>>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
>>> attrs.suffix
['.js', '.coffee']
Base class for all asset handlers (processors, compilers and compressors). A subclass has to implement __call__() which is called with asset as argument.
Subclasses have to override this method to implement the actual handler function code. This method is called with asset as argument. Depending on the type of the handler, this method must change asset state (as it does in Directivesprocessor) or return some value (in case of asset compressors).
Converts the class into an actual handler function that can be used when registering different types of processors in Environment class instance.
The arguments passed to as_handler() are forwarded to the constructor of the class.
Provides the ability to process asset through external command.
The name of the executable to run. It must be a command name, if it is available in the PATH environment variable, or a path to the executable.
Returns the list of subprocess.Popen arguments.
Returns subprocess.Popen instance with args from get_args() result and piped stdin, stdout and stderr.
The list of executable parameters.
Runs executable with input as stdin. AssetHandlerError exception is raised, if execution is failed, otherwise stdout is returned.