From fda065a691a58cfc9f00ec29911c8f027bf7e4df Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 16 Feb 2021 09:17:32 +0100 Subject: [PATCH] AE move to 3.0 structure --- pype/hosts/aftereffects/__init__.py | 74 ---------------- pype/hosts/aftereffects/api/__init__.py | 83 ++++++++++++++++++ pype/hosts/aftereffects/plugins/__init__.py | 0 .../plugins}/create/create_render.py | 0 .../plugins}/load/load_background.py | 0 .../aftereffects/plugins}/load/load_file.py | 0 .../plugins}/publish/collect_audio.py | 0 .../plugins}/publish/collect_current_file.py | 0 .../plugins}/publish/collect_render.py | 0 .../plugins}/publish/collect_workfile.py | 0 .../plugins}/publish/extract_save_scene.py | 0 .../plugins}/publish/increment_workfile.py | 0 .../aftereffects/{ => resources}/template.aep | Bin 13 files changed, 83 insertions(+), 74 deletions(-) create mode 100644 pype/hosts/aftereffects/api/__init__.py create mode 100644 pype/hosts/aftereffects/plugins/__init__.py rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/create/create_render.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/load/load_background.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/load/load_file.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/publish/collect_audio.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/publish/collect_current_file.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/publish/collect_render.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/publish/collect_workfile.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/publish/extract_save_scene.py (100%) rename pype/{plugins/aftereffects => hosts/aftereffects/plugins}/publish/increment_workfile.py (100%) rename pype/hosts/aftereffects/{ => resources}/template.aep (100%) diff --git a/pype/hosts/aftereffects/__init__.py b/pype/hosts/aftereffects/__init__.py index 184a9a59d6..e69de29bb2 100644 --- a/pype/hosts/aftereffects/__init__.py +++ b/pype/hosts/aftereffects/__init__.py @@ -1,74 +0,0 @@ -import os -import sys - -from avalon import api, io -from avalon.vendor import Qt -from pype import lib -import pyblish.api - - -def check_inventory(): - if not lib.any_outdated(): - return - - host = api.registered_host() - outdated_containers = [] - for container in host.ls(): - representation = container['representation'] - representation_doc = io.find_one( - { - "_id": io.ObjectId(representation), - "type": "representation" - }, - projection={"parent": True} - ) - if representation_doc and not lib.is_latest(representation_doc): - outdated_containers.append(container) - - # Warn about outdated containers. - print("Starting new QApplication..") - app = Qt.QtWidgets.QApplication(sys.argv) - - message_box = Qt.QtWidgets.QMessageBox() - message_box.setIcon(Qt.QtWidgets.QMessageBox.Warning) - msg = "There are outdated containers in the scene." - message_box.setText(msg) - message_box.exec_() - - # Garbage collect QApplication. - del app - - -def application_launch(): - check_inventory() - - -def install(): - print("Installing Pype config...") - - plugins_directory = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(__file__))), - "plugins", - "aftereffects" - ) - - pyblish.api.register_plugin_path( - os.path.join(plugins_directory, "publish") - ) - api.register_plugin_path( - api.Loader, os.path.join(plugins_directory, "load") - ) - api.register_plugin_path( - api.Creator, os.path.join(plugins_directory, "create") - ) - - pyblish.api.register_callback( - "instanceToggled", on_pyblish_instance_toggled - ) - - api.on("application.launched", application_launch) - - -def on_pyblish_instance_toggled(instance, old_value, new_value): - """Toggle layer visibility on instance toggles.""" - instance[0].Visible = new_value diff --git a/pype/hosts/aftereffects/api/__init__.py b/pype/hosts/aftereffects/api/__init__.py new file mode 100644 index 0000000000..a11da027f0 --- /dev/null +++ b/pype/hosts/aftereffects/api/__init__.py @@ -0,0 +1,83 @@ +import os +import sys +import logging + +from avalon import io +from avalon import api as avalon +from avalon.vendor import Qt +from pype import lib +import pyblish.api as pyblish +import pype.hosts.aftereffects + + +log = logging.getLogger("pype.hosts.maya") + + +HOST_DIR = os.path.dirname(os.path.abspath(pype.hosts.aftereffects.__file__)) +PLUGINS_DIR = os.path.join(HOST_DIR, "plugins") +PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish") +LOAD_PATH = os.path.join(PLUGINS_DIR, "load") +CREATE_PATH = os.path.join(PLUGINS_DIR, "create") +INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") + + +def check_inventory(): + if not lib.any_outdated(): + return + + host = pyblish.registered_host() + outdated_containers = [] + for container in host.ls(): + representation = container['representation'] + representation_doc = io.find_one( + { + "_id": io.ObjectId(representation), + "type": "representation" + }, + projection={"parent": True} + ) + if representation_doc and not lib.is_latest(representation_doc): + outdated_containers.append(container) + + # Warn about outdated containers. + print("Starting new QApplication..") + app = Qt.QtWidgets.QApplication(sys.argv) + + message_box = Qt.QtWidgets.QMessageBox() + message_box.setIcon(Qt.QtWidgets.QMessageBox.Warning) + msg = "There are outdated containers in the scene." + message_box.setText(msg) + message_box.exec_() + + # Garbage collect QApplication. + del app + + +def application_launch(): + check_inventory() + + +def install(): + print("Installing Pype config...") + + pyblish.register_plugin_path(PUBLISH_PATH) + avalon.register_plugin_path(avalon.Loader, LOAD_PATH) + avalon.register_plugin_path(avalon.Creator, CREATE_PATH) + log.info(PUBLISH_PATH) + + pyblish.register_callback( + "instanceToggled", on_pyblish_instance_toggled + ) + + avalon.on("application.launched", application_launch) + + +def uninstall(): + pyblish.deregister_plugin_path(PUBLISH_PATH) + avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH) + avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH) + + +def on_pyblish_instance_toggled(instance, old_value, new_value): + """Toggle layer visibility on instance toggles.""" + instance[0].Visible = new_value diff --git a/pype/hosts/aftereffects/plugins/__init__.py b/pype/hosts/aftereffects/plugins/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pype/plugins/aftereffects/create/create_render.py b/pype/hosts/aftereffects/plugins/create/create_render.py similarity index 100% rename from pype/plugins/aftereffects/create/create_render.py rename to pype/hosts/aftereffects/plugins/create/create_render.py diff --git a/pype/plugins/aftereffects/load/load_background.py b/pype/hosts/aftereffects/plugins/load/load_background.py similarity index 100% rename from pype/plugins/aftereffects/load/load_background.py rename to pype/hosts/aftereffects/plugins/load/load_background.py diff --git a/pype/plugins/aftereffects/load/load_file.py b/pype/hosts/aftereffects/plugins/load/load_file.py similarity index 100% rename from pype/plugins/aftereffects/load/load_file.py rename to pype/hosts/aftereffects/plugins/load/load_file.py diff --git a/pype/plugins/aftereffects/publish/collect_audio.py b/pype/hosts/aftereffects/plugins/publish/collect_audio.py similarity index 100% rename from pype/plugins/aftereffects/publish/collect_audio.py rename to pype/hosts/aftereffects/plugins/publish/collect_audio.py diff --git a/pype/plugins/aftereffects/publish/collect_current_file.py b/pype/hosts/aftereffects/plugins/publish/collect_current_file.py similarity index 100% rename from pype/plugins/aftereffects/publish/collect_current_file.py rename to pype/hosts/aftereffects/plugins/publish/collect_current_file.py diff --git a/pype/plugins/aftereffects/publish/collect_render.py b/pype/hosts/aftereffects/plugins/publish/collect_render.py similarity index 100% rename from pype/plugins/aftereffects/publish/collect_render.py rename to pype/hosts/aftereffects/plugins/publish/collect_render.py diff --git a/pype/plugins/aftereffects/publish/collect_workfile.py b/pype/hosts/aftereffects/plugins/publish/collect_workfile.py similarity index 100% rename from pype/plugins/aftereffects/publish/collect_workfile.py rename to pype/hosts/aftereffects/plugins/publish/collect_workfile.py diff --git a/pype/plugins/aftereffects/publish/extract_save_scene.py b/pype/hosts/aftereffects/plugins/publish/extract_save_scene.py similarity index 100% rename from pype/plugins/aftereffects/publish/extract_save_scene.py rename to pype/hosts/aftereffects/plugins/publish/extract_save_scene.py diff --git a/pype/plugins/aftereffects/publish/increment_workfile.py b/pype/hosts/aftereffects/plugins/publish/increment_workfile.py similarity index 100% rename from pype/plugins/aftereffects/publish/increment_workfile.py rename to pype/hosts/aftereffects/plugins/publish/increment_workfile.py diff --git a/pype/hosts/aftereffects/template.aep b/pype/hosts/aftereffects/resources/template.aep similarity index 100% rename from pype/hosts/aftereffects/template.aep rename to pype/hosts/aftereffects/resources/template.aep