diff --git a/pype/hosts/photoshop/__init__.py b/pype/hosts/photoshop/__init__.py index 564e9c8a05..e69de29bb2 100644 --- a/pype/hosts/photoshop/__init__.py +++ b/pype/hosts/photoshop/__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", - "photoshop" - ) - - 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/photoshop/api/__init__.py b/pype/hosts/photoshop/api/__init__.py new file mode 100644 index 0000000000..78d5311fed --- /dev/null +++ b/pype/hosts/photoshop/api/__init__.py @@ -0,0 +1,78 @@ +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 +from pyblish import api as pyblish +import pype.hosts.photoshop + +log = logging.getLogger("pype.hosts.photoshop") + +HOST_DIR = os.path.dirname(os.path.abspath(pype.hosts.photoshop.__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 = avalon.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/photoshop/hooks/__init__.py b/pype/hosts/photoshop/hooks/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pype/hooks/photoshop/pre_launch_args.py b/pype/hosts/photoshop/hooks/pre_launch_args.py similarity index 100% rename from pype/hooks/photoshop/pre_launch_args.py rename to pype/hosts/photoshop/hooks/pre_launch_args.py diff --git a/pype/hosts/photoshop/plugins/__init__.py b/pype/hosts/photoshop/plugins/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pype/plugins/photoshop/create/create_image.py b/pype/hosts/photoshop/plugins/create/create_image.py similarity index 100% rename from pype/plugins/photoshop/create/create_image.py rename to pype/hosts/photoshop/plugins/create/create_image.py diff --git a/pype/plugins/photoshop/load/load_image.py b/pype/hosts/photoshop/plugins/load/load_image.py similarity index 100% rename from pype/plugins/photoshop/load/load_image.py rename to pype/hosts/photoshop/plugins/load/load_image.py diff --git a/pype/plugins/photoshop/publish/collect_current_file.py b/pype/hosts/photoshop/plugins/publish/collect_current_file.py similarity index 100% rename from pype/plugins/photoshop/publish/collect_current_file.py rename to pype/hosts/photoshop/plugins/publish/collect_current_file.py diff --git a/pype/plugins/photoshop/publish/collect_instances.py b/pype/hosts/photoshop/plugins/publish/collect_instances.py similarity index 100% rename from pype/plugins/photoshop/publish/collect_instances.py rename to pype/hosts/photoshop/plugins/publish/collect_instances.py diff --git a/pype/plugins/photoshop/publish/collect_review.py b/pype/hosts/photoshop/plugins/publish/collect_review.py similarity index 100% rename from pype/plugins/photoshop/publish/collect_review.py rename to pype/hosts/photoshop/plugins/publish/collect_review.py diff --git a/pype/plugins/photoshop/publish/collect_workfile.py b/pype/hosts/photoshop/plugins/publish/collect_workfile.py similarity index 100% rename from pype/plugins/photoshop/publish/collect_workfile.py rename to pype/hosts/photoshop/plugins/publish/collect_workfile.py diff --git a/pype/plugins/photoshop/publish/extract_image.py b/pype/hosts/photoshop/plugins/publish/extract_image.py similarity index 100% rename from pype/plugins/photoshop/publish/extract_image.py rename to pype/hosts/photoshop/plugins/publish/extract_image.py diff --git a/pype/plugins/photoshop/publish/extract_review.py b/pype/hosts/photoshop/plugins/publish/extract_review.py similarity index 100% rename from pype/plugins/photoshop/publish/extract_review.py rename to pype/hosts/photoshop/plugins/publish/extract_review.py diff --git a/pype/plugins/photoshop/publish/extract_save_scene.py b/pype/hosts/photoshop/plugins/publish/extract_save_scene.py similarity index 100% rename from pype/plugins/photoshop/publish/extract_save_scene.py rename to pype/hosts/photoshop/plugins/publish/extract_save_scene.py diff --git a/pype/plugins/photoshop/publish/increment_workfile.py b/pype/hosts/photoshop/plugins/publish/increment_workfile.py similarity index 100% rename from pype/plugins/photoshop/publish/increment_workfile.py rename to pype/hosts/photoshop/plugins/publish/increment_workfile.py diff --git a/pype/plugins/photoshop/publish/validate_instance_asset.py b/pype/hosts/photoshop/plugins/publish/validate_instance_asset.py similarity index 100% rename from pype/plugins/photoshop/publish/validate_instance_asset.py rename to pype/hosts/photoshop/plugins/publish/validate_instance_asset.py diff --git a/pype/plugins/photoshop/publish/validate_naming.py b/pype/hosts/photoshop/plugins/publish/validate_naming.py similarity index 100% rename from pype/plugins/photoshop/publish/validate_naming.py rename to pype/hosts/photoshop/plugins/publish/validate_naming.py diff --git a/pype/hosts/photoshop/template.psd b/pype/hosts/photoshop/resources/template.psd similarity index 100% rename from pype/hosts/photoshop/template.psd rename to pype/hosts/photoshop/resources/template.psd