Skip to content

Commit

Permalink
Fixed shot code
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesvink committed Mar 21, 2023
1 parent df98d1e commit 79c0fa2
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions hooks/hiero_resolve_custom_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,24 @@ def execute(self, task, keyword, **kwargs):
associated string.
:rtype: str
"""
shot_code = task._item.name()

if keyword == "{Projectcode}":
# Getting shotgun credentials
sg = shotgun.get_sg_connection()

# Finding current project name
current_engine = sgtk.platform.current_engine()
current_context = current_engine.context
projectname_entity = current_context.project["name"]

# Searching for projectcode in entity's of project
def returnProjectId(projectname):
for p in sg.find("Project",[["name", "is", projectname]], ["name","sg_projectcode"]):
return p["sg_projectcode"]
projectname = current_context.project["name"]

# Executing function to find projectcode
projectcode_entity = returnProjectId(projectname_entity)
projectcode = sg.find_one(
"Project",
[["name", "is", projectname]],
["sg_projectcode"],
)

# Returning projectcode as a replacement of the keyword
return projectcode_entity
return projectcode.get("sg_projectcode")

# grab the shot from the cache, or the get_shot hook if not cached
sg_shot = self._sg_lookup_cache.get(shot_code)
Expand All @@ -74,7 +73,9 @@ def returnProjectId(projectname):
self._sg_lookup_cache[shot_code] = sg_shot

if sg_shot is None:
raise RuntimeError("Could not find shot for custom resolver: %s" % keyword)
raise RuntimeError(
"Could not find shot for custom resolver: %s" % keyword
)

# strip off the leading and trailing curly brackets
keyword = keyword[1:-1]
Expand Down

0 comments on commit 79c0fa2

Please sign in to comment.