This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
pick_environment.py
51 lines (41 loc) · 1.67 KB
/
pick_environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) 2015 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
"""
Hook which chooses an environment file to use based on the current context.
"""
from tank import Hook
class PickEnvironment(Hook):
def execute(self, context, **kwargs):
"""
The default implementation assumes there are three environments, called shot, asset
and project, and switches to these based on entity type.
"""
if context.project is None:
# our context is completely empty!
# don't know how to handle this case.
return None
if context.entity is None:
# we have a project but not an entity
return "project"
if context.entity and context.step is None:
# we have an entity but no step!
if context.entity["type"] == "Shot":
return "shot"
if context.entity["type"] == "Asset":
return "asset"
if context.entity["type"] == "Sequence":
return "sequence"
if context.entity and context.step:
# we have a step and an entity
if context.entity["type"] == "Shot":
return "shot_step"
if context.entity["type"] == "Asset":
return "asset_step"
return None