stalker.models.template.FilenameTemplate¶
-
class
stalker.models.template.FilenameTemplate(target_entity_type=None, path=None, filename=None, **kwargs)[source]¶ Bases:
stalker.models.entity.Entity,stalker.models.mixins.TargetEntityTypeMixinHolds templates for filename and path conventions.
FilenameTemplate objects help to specify where to place a
Versionrelated file.Although, it is mainly used by Stalker to define
Versionrelated file paths and file names to place them in to proper places inside aProject’sProject.structure, the idea behind is open to endless possibilities.Here is an example:
p1 = Project(name="Test Project") # shortened for this example # shortened for this example s1 = Structure(name="Commercial Project Structure") # this is going to be used by Stalker to decide the :stalker:`.Link` # :stalker:`.Link.filename` and :stalker:`.Link.path` (which is the way # Stalker links external files to Version instances) f1 = FilenameTemplate( name="Asset Version Template", target_entity_type="Asset", path='$REPO{{project.repository.id}}/{{project.code}}/{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}/{%- endfor -%}", filename="{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}" ) s1.templates.append(f1) p1.structure = s1 # now because we have defined a FilenameTemplate for Assets, # Stalker is now able to produce a path and a filename for any Version # related to an asset in this project.
Parameters: - target_entity_type (str) –
The class name that this FilenameTemplate is designed for. You can also pass the class itself. So both of the examples below can work:
new_filename_template1 = FilenameTemplate(target_entity_type=”Asset”) new_filename_template2 = FilenameTemplate(target_entity_type=Asset)
A TypeError will be raised when it is skipped or it is None and a ValueError will be raised when it is given as and empty string.
- path (str) –
A Jinja2 template code which specifies the path of the given item. It is relative to the repository root. A typical example could be:
’$REPO{{project.repository.id}}/{{project.code}}/{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}/{%- endfor -%}” - filename (str) –
A Jinja2 template code which specifies the file name of the given item. It is relative to the
FilenameTemplate.path. A typical example could be:’{{version.nice_name}}_v{{“%03d”|format(version.version_number)}}’Could be set to an empty string or None, the default value is None.
It can be None, or an empty string, or it can be skipped.
-
__init__(target_entity_type=None, path=None, filename=None, **kwargs)¶
Methods
__init__([target_entity_type, path, filename])Attributes
created_byThe Userwho has created this object.created_by_idThe id of the Userwho has created this entity.date_createdA datetime.datetimeinstance showing the creation date and time of this object.date_updatedA datetime.datetimeinstance showing the update date and time of this object.descriptionDescription of this object. entity_groupsentity_identity_typefilenameThe template code for the file part of the FilenameTemplate. filenameTemplate_idgeneric_dataThis attribute can hold any kind of data which exists in SOM. generic_textThis attribute can hold any text. html_classhtml_styleidmetadatanameName of this object nice_nameNice name of this object. notesAll the Notess attached to this entity.pathThe template code for the path of this FilenameTemplate. plural_class_namethe plural name of this class querytagsA list of tags attached to this object. target_entity_typeThe entity type which this object is valid for. thumbnailthumbnail_idtjp_idreturns TaskJuggler compatible id to_tjprenders a TaskJuggler compliant string used for TaskJuggler typeThe type of the object. type_idThe id of the Typeof this entity.updated_byThe Userwho has updated this object.updated_by_idThe id of the Userwho has updated this entity.-
path¶ The template code for the path of this FilenameTemplate.
-
filename¶ The template code for the file part of the FilenameTemplate.
-
date_created¶ A
datetime.datetimeinstance showing the creation date and time of this object.
-
date_updated¶ A
datetime.datetimeinstance showing the update date and time of this object.
-
description¶ Description of this object.
-
generic_data¶ This attribute can hold any kind of data which exists in SOM.
-
generic_text¶ This attribute can hold any text.
-
name¶ Name of this object
-
nice_name¶ 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.
-
notes¶ All the
Notess attached to this entity.It is a list of
Noteinstances or an empty list, setting it to None will raise a TypeError.
-
plural_class_name¶ the plural name of this class
A list of tags attached to this object.
It is a list of
Taginstances which shows the tags of this object
-
target_entity_type¶ The entity type which this object is valid for.
Usually it is set to the TargetClass directly.
-
tjp_id¶ returns TaskJuggler compatible id
-
to_tjp¶ renders a TaskJuggler compliant string used for TaskJuggler integration. Needs to be overridden in inherited classes.
-
type¶ The type of the object.
It is a
Typeinstance with a properType.target_entity_type.
- target_entity_type (str) –