Bases: object
Connects the environment (the host program) to Stalker.
In Stalker, an Environment is a host application like Maya, Nuke, Houdini etc.
Generally a GUI for the end user is given an environment which helps the QtGui to be able to open, save, import or export a Version without knowing the details of the environment.
The environment object supplies methods like open, save, export, import or reference. The main duty of the Environment object is to introduce the host application (Maya, Houdini, Nuke, etc.) to Stalker and let it to open, save, export, import or reference a file.
It is the pipeline developers duty to create the environment classes for the programs used in the studio by instantiating this class and overriding the methods as necessary. You can find good examples in `Anima Tools`_ which is a Python package developed in `Anima Istanbul`_.
Here is a brief example for creating an environment for a generic program:
from Stalker import EnvironmentBase
class MyProgramEnv(EnvironmentBase):
"""This is a class which will be used by the UI
"""
def open():
"""uses the programs own Python API to open a version of an
asset
"""
# do anything that needs to be done before opening the file
my_programs_own_python_api.open(filepath=self.version.full_path)
def save():
"""uses the programs own Python API to save the current file
as a new version.
"""
# do anything that needs to be done before saving the file
my_programs_own_python_api.save(filepath=self.version.full_path)
# do anything that needs to be done after saving the file
and that is it.
The environment class by default has a property called version. Holding the current open Version. It is None for a new scene and a Version instance in any other case.
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Methods
check_referenced_versions() | Checks the referenced versions |
export_as(version) | Exports the contents of the open document as the given version. |
find_repo(path) | returns the repository from the given path |
get_current_version() | Returns the current Version instance from the environment. |
get_fps() | Returns the frame rate of this current environment |
get_frame_range() | Returns the frame range from the environment |
get_last_version() | Returns the last opened Version instance from the environment. |
get_project() | returns the current project from environment |
get_referenced_versions() | Returns the Version instances which |
get_version_from_full_path(full_path) | Finds the Version instance from the given full_path value. |
get_versions_from_path(path) | Finds Version instances from the given path value. |
has_extension(filename) | Returns True if the given file names extension is in the extensions |
import_(asset) | the import action |
load_referenced_versions() | loads all the references |
open_(version[, force]) | the open action |
post_open(version) | Runs after opening a file |
reference(asset) | the reference action |
replace_external_paths([mode]) | Replaces the external paths (which are not starting with the environment variable) with a proper path. |
replace_version(source_version, target_version) | Replaces the source_version with the target_version |
save_as(version) | The save as action of this environment. |
set_fps([fps]) | Sets the frame rate of the environment. |
set_frame_range([start_frame, end_frame, ...]) | Sets the frame range in the environment to the given start and end |
set_project(version) | Sets the project to the given Versions project. |
trim_repo_path(path) | Trims the repository path value from the given path |
Attributes
extensions | Returns the valid native extensions for this environment. |
name | returns the environment name |
version | returns the current Version instance which is open in the |
The save as action of this environment. It should save the current scene or file to the given version.full_path
Exports the contents of the open document as the given version.
Parameters: | version – A Version instance holding the desired version. |
---|
Trims the repository path value from the given path
Parameters: | path – The path that wanted to be trimmed |
---|---|
Returns: | str |
returns the repository from the given path
Parameters: | path (str) – path in a repository |
---|---|
Returns: | stalker.models.repository.Repository |
Finds Version instances from the given path value.
Finds and returns the Version instances from the given path value.
Returns an empty list if it can’t find any matching.
This method is different than get_version_from_full_path() because it returns a list of Version instances which are residing in that path. The list is ordered by the ids of the instances.
Parameters: | path – A path which has possible Version instances. |
---|---|
Returns: | A list of Version instances. |
Finds the Version instance from the given full_path value.
Finds and returns a Version instance from the given full_path value.
Returns None if it can’t find any matching.
Parameters: | full_path – The full_path of the desired Version instance. |
---|---|
Returns: | Version |
Returns the current Version instance from the environment.
Returns: | Version instance or None |
---|
Returns the last opened Version instance from the environment.
Returns: | Version instance or None. |
---|
Sets the project to the given Versions project.
Parameters: | version – A Version. |
---|
Returns the Version instances which are referenced in to the current scene
Returns: | list of Version instances. |
---|
Returns the frame range from the environment
Returns: | a tuple of integers containing the start and end frame numbers |
---|
Sets the frame range in the environment to the given start and end frames
Returns the valid native extensions for this environment.
Returns: | a list of strings |
---|
Returns True if the given file names extension is in the extensions list false otherwise.
accepts: * a full path with extension or not * a file name with extension or not * an extension with a dot on the start or not
Parameters: | filename – A string containing the filename |
---|
Replaces the source_version with the target_version
Parameters: |
---|
Replaces the external paths (which are not starting with the environment variable) with a proper path. The mode controls if the resultant path should be absolute or relative to the project dir.
Parameters: | mode – Controls the resultant path is absolute or relative. mode 0: absolute (a path which starts with $REPO) mode 1: relative (to project path) |
---|---|
Returns: |