Bases: stalker.core.models.Entity
Holds templates for filename conventions.
FilenameTemplate objects help to specify where to place a file related to its target_entity_type.
The first very important usage of FilenameTemplates is to place asset file Version‘s to proper places inside a Project‘s Structure.
Secondly, it can be used in the process of injecting files in to the repository. By creating templates for Links.
Parameters: |
|
---|
Examples:
A template for asset versions can be used like this:
from stalker.core.models import Type, FilenameTemplate, TaskTemplate
# create a couple of variables
path_code = "ASSETS/{{asset_type.name}}/{{task_type.code}}"
file_code =
"{{asset.name}}_{{take.name}}_{{asset_type.name}}_v{{version.version_number}}"
output_path_code = "OUTPUT"
output_file_code = file_code
# create a type for modeling task
modeling = Type(
name="Modeling",
code="MODEL",
description="The modeling step of the asset",
target_entity_type=Task
)
# create a "Character" Type for Asset classes
character = Type(
name="Character",
description="this is the character asset type",
target_entity_type=Asset
)
# now create our FilenameTemplate
char_template = FilenameTemplate(
name="Character",
description="this is the template which explains how to place Character assets",
target_entity_type="Asset",
path_code=path_code,
file_code=file_code,
output_path_code=output_path_code,
output_file_code=output_file_code,
output_is_relative=True,
)
# assign this type template to the structure of the project with id=101
myProject = query(Project).filter_by(id=101).first()
# append the type template to the structures' templates
myProject.structure.templates.append(char_template)
# commit everything to the database
session.commit()
Now with the code above, whenever a new Version created for a Character asset, Stalker will automatically place the related file to a certain folder and with a certain file name defined by the template. For example the above template should render something like below for Windows:
|- M:\\PROJECTS --> {{repository.path}}
|- PRENSESIN_UYKUSU --> {{project.code}}
|- ASSETS --> "ASSETS"
|- Character --> {{asset_type.name}}
|- Olum --> {{asset.name}}
|- MODEL --> {{task_type.code}}
|- Olum_MAIN_MODEL_v001.ma --> {{asset.name}}_{{take.name}}_{{asset_type.name}}_v{{version.version_number}}
And one of the best side is you can create a version from Linux, Windows or OSX all the paths will be correctly handled by Stalker.
Methods
__init__(**kwargs[, target_entity_type, ...]) |
Attributes
code | The code name of this object. |
created_by | The User who has created this object. |
created_by_id | |
date_created | A datetime.datetime instance showing the creation date and time of this object. |
date_updated | A datetime.datetime instance showing the update date and time of this object. |
description | Description of this object. |
entity_id | |
entity_type | |
file_code | The templating code for the file part of the FilenameTemplate. |
filenameTemplate_id | |
id | |
name | Name of this object |
nice_name | Nice name of this object. |
notes | All the Notess attached to this entity. |
output_file_code | The output_file_code of this FilenameTemplate object. |
output_is_relative | Specifies if the output should be calculated relative to the path attribute. |
output_path_code | The output_path_code of this FilenameTemplate object. |
path_code | The templating code for the path of this FilenameTemplate. |
reviews | All the Reviews about this Entity. |
tags | A list of tags attached to this object. |
target_entity_type | The target entity type this FilenameTemplate object should work on. |
type | The type of the object. |
type_id | |
updated_by | The User who has updated this object. |
updated_by_id |
The templating code for the path of this FilenameTemplate.
The templating code for the file part of the FilenameTemplate.
Specifies if the output should be calculated relative to the path attribute.
The output_path_code of this FilenameTemplate object.
Should be a unicode string. None and empty string is also accepted, but in this case the value is copied from the path_code if also the output_is_relative is False. If output_is_relative is True then it will left as an empty string.
The output_file_code of this FilenameTemplate object.
Should be a unicode string. None and empty string is also accepted, but in this case the value is copied from the file_code if also the output_is_relative is False. If output_is_relative is True then it will left as an empty string.
The target entity type this FilenameTemplate object should work on.
Should be a string value or the class itself
The code name of this object.
It accepts string or unicode values and any other kind of objects will be converted to string. In any update to the name attribute the code also will be updated. If the code is not initialized or given as None, it will be set to the uppercase version of the nice_name attribute. Setting the code attribute to None will reset it to the default value. The default value is the upper case form of the nice_name.
A datetime.datetime instance showing the creation date and time of this object.
A datetime.datetime instance showing the update date and time of this object.
Description of this object.
Name of this object
Nice name of this object.
It has the same value with the name (contextually) but with a different format like, all the white spaces replaced by underscores (“_”), all the CamelCase form will be expanded by underscore (_) characters and it is always lower case.
There is also the code attribute which is simply the upper case form of nice_name if it is not defined differently (i.e set to another value).
All the Notess attached to this entity.
It is a list of Note instances or an empty list, setting it None will raise a TypeError.
All the Reviews about this Entity.
It is a list of Review instances or an empty list, setting it None will raise a TypeError.
A list of tags attached to this object.
It is a list of Tag instances which shows the tags of this object
The type of the object.
It is an instance of Type with a proper target_entity_type.