mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
changed creators in testhost for new structure
This commit is contained in:
parent
521a701c2e
commit
256d1784c6
3 changed files with 86 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from openpype.hosts.testhost import api
|
||||
from openpype.hosts.testhost.api import pipeline
|
||||
from openpype.pipeline import (
|
||||
AutoCreator,
|
||||
CreatedInstance,
|
||||
|
|
@ -8,8 +8,36 @@ from avalon import io
|
|||
|
||||
|
||||
class MyAutoCreator(AutoCreator):
|
||||
identifier = "workfile"
|
||||
family = "workfile"
|
||||
|
||||
def get_attribute_defs(self):
|
||||
output = [
|
||||
lib.NumberDef("number_key", label="Number")
|
||||
]
|
||||
return output
|
||||
|
||||
def collect_instances(self, attr_plugins=None):
|
||||
for instance_data in pipeline.list_instances():
|
||||
creator_id = instance_data.get("creator_identifier")
|
||||
if creator_id is not None:
|
||||
if creator_id == self.identifier:
|
||||
subset_name = instance_data["subset"]
|
||||
instance = CreatedInstance(
|
||||
self.family, subset_name, instance_data, self
|
||||
)
|
||||
self.create_context.add_instance(instance)
|
||||
|
||||
elif instance_data["family"] == self.identifier:
|
||||
instance_data["creator_identifier"] = self.identifier
|
||||
instance = CreatedInstance.from_existing(
|
||||
instance_data, self, attr_plugins
|
||||
)
|
||||
self.create_context.add_instance(instance)
|
||||
|
||||
def update_instances(self, update_list):
|
||||
pipeline.update_instances(update_list)
|
||||
|
||||
def create(self, options=None):
|
||||
existing_instance = None
|
||||
for instance in self.create_context.instances:
|
||||
|
|
@ -40,7 +68,7 @@ class MyAutoCreator(AutoCreator):
|
|||
existing_instance = CreatedInstance(
|
||||
self.family, subset_name, data, self
|
||||
)
|
||||
api.pipeline.HostContext.add_instance(
|
||||
pipeline.HostContext.add_instance(
|
||||
existing_instance.data_to_store()
|
||||
)
|
||||
|
||||
|
|
@ -56,9 +84,3 @@ class MyAutoCreator(AutoCreator):
|
|||
existing_instance.data["task"] = task_name
|
||||
|
||||
return existing_instance
|
||||
|
||||
def get_attribute_defs(self):
|
||||
output = [
|
||||
lib.NumberDef("number_key", label="Number")
|
||||
]
|
||||
return output
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from openpype import resources
|
||||
from openpype.hosts.testhost import api
|
||||
from openpype.hosts.testhost.api import pipeline
|
||||
from openpype.pipeline import (
|
||||
Creator,
|
||||
CreatedInstance,
|
||||
|
|
@ -8,15 +8,40 @@ from openpype.pipeline import (
|
|||
|
||||
|
||||
class TestCreatorOne(Creator):
|
||||
family = "test_one"
|
||||
identifier = "test_one"
|
||||
family = "test"
|
||||
description = "Testing creator of testhost"
|
||||
|
||||
def get_icon(self):
|
||||
return resources.get_openpype_splash_filepath()
|
||||
|
||||
def collect_instances(self, attr_plugins):
|
||||
for instance_data in pipeline.list_instances():
|
||||
creator_id = instance_data.get("creator_identifier")
|
||||
if creator_id is not None:
|
||||
if creator_id == self.identifier:
|
||||
subset_name = instance_data["subset"]
|
||||
instance = CreatedInstance(
|
||||
self.family, subset_name, instance_data, self
|
||||
)
|
||||
self.create_context.add_instance(instance)
|
||||
|
||||
elif instance_data["family"] == self.identifier:
|
||||
instance_data["creator_identifier"] = self.identifier
|
||||
instance = CreatedInstance.from_existing(
|
||||
instance_data, self, attr_plugins
|
||||
)
|
||||
self.create_context.add_instance(instance)
|
||||
|
||||
def update_instances(self, update_list):
|
||||
pipeline.update_instances(update_list)
|
||||
|
||||
def remove_instances(self, instances):
|
||||
pipeline.remove_instances(instances)
|
||||
|
||||
def create(self, subset_name, data, options=None):
|
||||
avalon_instance = CreatedInstance(self.family, subset_name, data, self)
|
||||
api.pipeline.HostContext.add_instance(avalon_instance.data_to_store())
|
||||
pipeline.HostContext.add_instance(avalon_instance.data_to_store())
|
||||
self.log.info(avalon_instance.data)
|
||||
return avalon_instance
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from openpype.hosts.testhost import api
|
||||
from openpype.hosts.testhost.api import pipeline
|
||||
from openpype.pipeline import (
|
||||
Creator,
|
||||
CreatedInstance,
|
||||
|
|
@ -7,7 +7,8 @@ from openpype.pipeline import (
|
|||
|
||||
|
||||
class TestCreatorTwo(Creator):
|
||||
family = "test_two"
|
||||
identifier = "test_two"
|
||||
family = "test"
|
||||
description = "A second testing creator"
|
||||
|
||||
def get_icon(self):
|
||||
|
|
@ -15,10 +16,34 @@ class TestCreatorTwo(Creator):
|
|||
|
||||
def create(self, subset_name, data, options=None):
|
||||
avalon_instance = CreatedInstance(self.family, subset_name, data, self)
|
||||
api.pipeline.HostContext.add_instance(avalon_instance.data_to_store())
|
||||
pipeline.HostContext.add_instance(avalon_instance.data_to_store())
|
||||
self.log.info(avalon_instance.data)
|
||||
return avalon_instance
|
||||
|
||||
def collect_instances(self, attr_plugins):
|
||||
for instance_data in pipeline.list_instances():
|
||||
creator_id = instance_data.get("creator_identifier")
|
||||
if creator_id is not None:
|
||||
if creator_id == self.identifier:
|
||||
subset_name = instance_data["subset"]
|
||||
instance = CreatedInstance(
|
||||
self.family, subset_name, instance_data, self
|
||||
)
|
||||
self.create_context.add_instance(instance)
|
||||
|
||||
elif instance_data["family"] == self.identifier:
|
||||
instance_data["creator_identifier"] = self.identifier
|
||||
instance = CreatedInstance.from_existing(
|
||||
instance_data, self, attr_plugins
|
||||
)
|
||||
self.create_context.add_instance(instance)
|
||||
|
||||
def update_instances(self, update_list):
|
||||
pipeline.update_instances(update_list)
|
||||
|
||||
def remove_instances(self, instances):
|
||||
pipeline.remove_instances(instances)
|
||||
|
||||
def get_attribute_defs(self):
|
||||
output = [
|
||||
lib.NumberDef("number_key"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue