Skip to content

Commit

Permalink
- Fix pyblish.util import.
Browse files Browse the repository at this point in the history
- Code cosmetics.
  • Loading branch information
tokejepsen committed Aug 3, 2018
1 parent b2b749f commit fcb05eb
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions pyblish_nuke/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import sys

# Pyblish libraries
import pyblish.api
import pyblish
from pyblish import api, util

# Host libraries
import nuke
Expand Down Expand Up @@ -75,7 +76,7 @@ def _discover_gui():
"""Return the most desirable of the currently registered GUIs"""

# Prefer last registered
guis = reversed(pyblish.api.registered_guis())
guis = reversed(api.registered_guis())

for gui in guis:
try:
Expand Down Expand Up @@ -112,28 +113,24 @@ def remove_from_filemenu():
def deregister_plugins():
# De-register accompanying plugins
plugin_path = os.path.dirname(plugins.__file__)
pyblish.api.deregister_plugin_path(plugin_path)
api.deregister_plugin_path(plugin_path)
print("pyblish: Deregistered %s" % plugin_path)


def register_host():
"""Register supported hosts"""
pyblish.api.register_host("nuke")
api.register_host("nuke")


def deregister_host():
"""De-register supported hosts"""
pyblish.api.deregister_host("nuke")
api.deregister_host("nuke")


def register_plugins():
# Register accompanying plugins
plugin_path = os.path.dirname(plugins.__file__)
pyblish.api.register_plugin_path(plugin_path)


def filemenu_publish():
"""DEPRECATED"""
api.register_plugin_path(plugin_path)


def add_to_filemenu():
Expand Down Expand Up @@ -186,7 +183,7 @@ def publish():
splash.show()

def on_published(context):
pyblish.api.deregister_callback(*callback)
api.deregister_callback(*callback)

try:
splash.close()
Expand Down Expand Up @@ -218,11 +215,11 @@ def on_published(context):
messagebox.exec_()

callback = "published", on_published
pyblish.api.register_callback(*callback)
api.register_callback(*callback)

def publish_iter():

for result in pyblish.util.publish_iter():
for result in util.publish_iter():
splash.bar.setValue(result["progress"] * 100)

QtCore.QTimer.singleShot(10, publish_iter)
Expand Down Expand Up @@ -256,7 +253,7 @@ def _show_no_gui():
messagebox.setWindowTitle("Uh oh")
messagebox.setText("No registered GUI found.")

if not pyblish.api.registered_guis():
if not api.registered_guis():
messagebox.setInformativeText(
"In order to show you a GUI, one must first be registered. "
"Press \"Show details...\" below for information on how to "
Expand All @@ -277,8 +274,8 @@ def _show_no_gui():
"Then register it, like so:"
"\n"
"\n"
">>> import pyblish.api\n"
">>> pyblish.api.register_gui(\"pyblish_lite\")"
">>> from pyblish import api\n"
">>> api.register_gui(\"pyblish_lite\")"
"\n"
"\n"
"The next time you try running this, Lite will appear."
Expand All @@ -297,16 +294,12 @@ def _show_no_gui():
messagebox.setDetailedText(
"These interfaces are currently registered."
"\n"
"%s" % "\n".join(pyblish.api.registered_guis()))
"%s" % "\n".join(api.registered_guis()))

messagebox.setStandardButtons(messagebox.Ok)
messagebox.exec_()


def where(program):
"""DEPRECATED"""


def _nuke_set_zero_margins(widget_object):
"""Remove Nuke margins when docked UI
.. _More info:
Expand All @@ -328,7 +321,7 @@ def _nuke_set_zero_margins(widget_object):
for tinychild in sub.children():
try:
tinychild.setContentsMargins(0, 0, 0, 0)
except:
except Exception:
pass


Expand All @@ -345,7 +338,7 @@ def dock(window):
# Deleting existing dock
# There is a bug where existing docks are kept in-memory when closed via UI
if self._dock:
print "Deleting existing dock..."
print("Deleting existing dock...")
parent = self._dock
dialog = None
stacked_widget = None
Expand Down

0 comments on commit fcb05eb

Please sign in to comment.