Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #907 from pypeclub/feature/906-hiero-convert-to-pype3
Browse files Browse the repository at this point in the history
Refactoring hiero #648 PR to pype3
  • Loading branch information
mkolar authored Feb 2, 2021
2 parents b52c1ec + a343111 commit f87081b
Show file tree
Hide file tree
Showing 122 changed files with 4,222 additions and 3,773 deletions.
121 changes: 0 additions & 121 deletions pype/hosts/hiero/__init__.py
Original file line number Diff line number Diff line change
@@ -1,121 +0,0 @@
import os
from pype.api import Logger
from avalon import api as avalon
from pyblish import api as pyblish
from pype import PLUGINS_DIR

from .workio import (
open_file,
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
)

from .menu import (
install as menu_install,
_update_menu_task_label
)

from .events import register_hiero_events

__all__ = [
# Workfiles API
"open_file",
"save_file",
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
]

# get logger
log = Logger().get_logger(__name__)


''' Creating all important host related variables '''
AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype")

# plugin root path
PUBLISH_PATH = os.path.join(PLUGINS_DIR, "hiero", "publish")
LOAD_PATH = os.path.join(PLUGINS_DIR, "hiero", "load")
CREATE_PATH = os.path.join(PLUGINS_DIR, "hiero", "create")
INVENTORY_PATH = os.path.join(PLUGINS_DIR, "hiero", "inventory")

# registering particular pyblish gui but `lite` is recomended!!
if os.getenv("PYBLISH_GUI", None):
pyblish.register_gui(os.getenv("PYBLISH_GUI", None))


def install():
"""
Installing Hiero integration for avalon
Args:
config (obj): avalon config module `pype` in our case, it is not
used but required by avalon.api.install()
"""

# adding all events
_register_events()

log.info("Registering Hiero plug-ins..")
pyblish.register_host("hiero")
pyblish.register_plugin_path(PUBLISH_PATH)
avalon.register_plugin_path(avalon.Loader, LOAD_PATH)
avalon.register_plugin_path(avalon.Creator, CREATE_PATH)
avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH)

# Disable all families except for the ones we explicitly want to see
family_states = [
"write",
"review",
"plate"
]

avalon.data["familiesStateDefault"] = False
avalon.data["familiesStateToggled"] = family_states

# install menu
menu_install()

# register hiero events
register_hiero_events()


def uninstall():
"""
Uninstalling Hiero integration for avalon
"""
log.info("Deregistering Hiero plug-ins..")
pyblish.deregister_host("hiero")
pyblish.deregister_plugin_path(PUBLISH_PATH)
avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH)
avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH)


def _register_events():
"""
Adding all callbacks.
"""

# if task changed then change notext of hiero
avalon.on("taskChanged", _update_menu_task_label)
log.info("Installed event callback for 'taskChanged'..")


def ls():
"""List available containers.
This function is used by the Container Manager in Nuke. You'll
need to implement a for-loop that then *yields* one Container at
a time.
See the `container.json` schema for details on how it should look,
and the Maya equivalent, which is in `avalon.maya.pipeline`
"""
# TODO: listing all availabe containers form sequence
return
101 changes: 101 additions & 0 deletions pype/hosts/hiero/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from .workio import (
open_file,
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
)

from .pipeline import (
launch_workfiles_app,
ls,
install,
uninstall,
reload_config,
containerise,
publish,
maintained_selection,
parse_container,
update_container,
reset_selection
)

from .lib import (
get_track_items,
get_current_project,
get_current_sequence,
get_current_track,
get_track_item_pype_tag,
set_track_item_pype_tag,
get_track_item_pype_data,
set_publish_attribute,
get_publish_attribute,
imprint,
get_selected_track_items,
set_selected_track_items,
create_nuke_workfile_clips,
create_bin,
apply_colorspace_project,
apply_colorspace_clips,
is_overlapping,
get_sequence_pattern_and_padding
)

from .plugin import (
CreatorWidget,
Creator,
PublishClip,
SequenceLoader,
ClipLoader
)

__all__ = [
# avalon pipeline module
"launch_workfiles_app",
"ls",
"install",
"uninstall",
"reload_config",
"containerise",
"publish",
"maintained_selection",
"parse_container",
"update_container",
"reset_selection",

# Workfiles API
"open_file",
"save_file",
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",

# Lib functions
"get_track_items",
"get_current_project",
"get_current_sequence",
"get_current_track",
"get_track_item_pype_tag",
"set_track_item_pype_tag",
"get_track_item_pype_data",
"set_publish_attribute",
"get_publish_attribute",
"imprint",
"get_selected_track_items",
"set_selected_track_items",
"create_nuke_workfile_clips",
"create_bin",
"is_overlapping",
"apply_colorspace_project",
"apply_colorspace_clips",
"get_sequence_pattern_and_padding",

# plugins
"CreatorWidget",
"Creator",
"PublishClip",
"SequenceLoader",
"ClipLoader"
]
20 changes: 16 additions & 4 deletions pype/hosts/hiero/events.py → pype/hosts/hiero/api/events.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import hiero.core.events
import avalon.api as avalon
from pype.api import Logger
from .lib import sync_avalon_data_to_workfile, launch_workfiles_app
from .tags import add_tags_from_presets
from .tags import add_tags_to_workfile
from .menu import update_menu_task_label

log = Logger().get_logger(__name__)

Expand All @@ -28,7 +30,7 @@ def afterNewProjectCreated(event):
sync_avalon_data_to_workfile()

# add tags from preset
add_tags_from_presets()
add_tags_to_workfile()

# Workfiles.
if int(os.environ.get("WORKFILES_STARTUP", "0")):
Expand All @@ -48,7 +50,7 @@ def afterProjectLoad(event):
sync_avalon_data_to_workfile()

# add tags from preset
add_tags_from_presets()
add_tags_to_workfile()


def beforeProjectClosed(event):
Expand Down Expand Up @@ -77,7 +79,7 @@ def register_hiero_events():
"kAfterNewProjectCreated, kBeforeProjectLoad, kAfterProjectLoad, "
"kBeforeProjectSave, kAfterProjectSave, kBeforeProjectClose, "
"kAfterProjectClose, kShutdown, kStartup"
)
)

# hiero.core.events.registerInterest(
# "kBeforeNewProjectCreated", beforeNewProjectCreated)
Expand Down Expand Up @@ -105,3 +107,13 @@ def register_hiero_events():
# workfiles
hiero.core.events.registerEventType("kStartWorkfiles")
hiero.core.events.registerInterest("kStartWorkfiles", launch_workfiles_app)


def register_events():
"""
Adding all callbacks.
"""

# if task changed then change notext of hiero
avalon.on("taskChanged", update_menu_task_label)
log.info("Installed event callback for 'taskChanged'..")
Loading

0 comments on commit f87081b

Please sign in to comment.