collect anatomy was split into 2 plugins to be able to collect anatomy obj before collect rendered files

This commit is contained in:
iLLiCiTiT 2020-04-09 14:27:02 +02:00
parent 182502c5e4
commit 2e431b32e1
2 changed files with 61 additions and 18 deletions

View file

@ -1,13 +1,14 @@
"""Collect Anatomy and global anatomy data.
"""Collect global context Anatomy data.
Requires:
context -> anatomy
context -> projectEntity
context -> assetEntity
context -> username
context -> datetimeData
session -> AVALON_TASK
projectEntity, assetEntity -> collect_avalon_entities *(pyblish.api.CollectorOrder)
username -> collect_pype_user *(pyblish.api.CollectorOrder + 0.001)
datetimeData -> collect_datetime_data *(pyblish.api.CollectorOrder)
Provides:
context -> anatomy (pypeapp.Anatomy)
context -> anatomyData
"""
@ -15,15 +16,31 @@ import os
import json
from avalon import api, lib
from pypeapp import Anatomy
import pyblish.api
class CollectAnatomy(pyblish.api.ContextPlugin):
"""Collect Anatomy into Context"""
class CollectAnatomyContextData(pyblish.api.ContextPlugin):
"""Collect Anatomy Context data.
Example:
context.data["anatomyData"] = {
"project": {
"name": "MyProject",
"code": "myproj"
},
"asset": "AssetName",
"hierarchy": "path/to/asset",
"task": "Working",
"username": "MeDespicable",
*** OPTIONAL ***
"app": "maya" # Current application base name
+ mutliple keys from `datetimeData` # see it's collector
}
"""
order = pyblish.api.CollectorOrder + 0.002
label = "Collect Anatomy"
label = "Collect Anatomy Context Data"
def process(self, context):
task_name = api.Session["AVALON_TASK"]
@ -31,13 +48,6 @@ class CollectAnatomy(pyblish.api.ContextPlugin):
project_entity = context.data["projectEntity"]
asset_entity = context.data["assetEntity"]
project_name = project_entity["name"]
context.data["anatomy"] = Anatomy(project_name)
self.log.info(
"Anatomy object collected for project \"{}\".".format(project_name)
)
hierarchy_items = asset_entity["data"]["parents"]
hierarchy = ""
if hierarchy_items:
@ -45,13 +55,12 @@ class CollectAnatomy(pyblish.api.ContextPlugin):
context_data = {
"project": {
"name": project_name,
"name": project_entity["name"],
"code": project_entity["data"].get("code")
},
"asset": asset_entity["name"],
"hierarchy": hierarchy.replace("\\", "/"),
"task": task_name,
"username": context.data["user"]
}

View file

@ -0,0 +1,34 @@
"""Collect Anatomy object.
Requires:
os.environ -> AVALON_PROJECT
Provides:
context -> anatomy (pypeapp.Anatomy)
"""
from avalon import io
from pypeapp import Anatomy
import pyblish.api
class CollectAnatomyObject(pyblish.api.ContextPlugin):
"""Collect Anatomy object into Context"""
order = pyblish.api.CollectorOrder - 0.11
label = "Collect Anatomy Object"
def process(self, context):
io.install()
project_name = io.Session.get("AVALON_PROJECT")
if project_name is None:
raise AssertionError(
"Environment `AVALON_PROJECT` is not set."
"Could not initialize project's Anatomy."
)
context.data["anatomy"] = Anatomy(project_name)
self.log.info(
"Anatomy object collected for project \"{}\".".format(project_name)
)