Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
diegogarciahuerta committed Jun 19, 2020
1 parent 1cc0e9e commit 178594a
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 265 deletions.
63 changes: 16 additions & 47 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ def refresh_engine(scene_name, prev_context):
try:
# could not detect context from path, will use the project context
# for menus if it exists
ctx = engine.sgtk.context_from_entity_dictionary(
engine.context.project
)
ctx = engine.sgtk.context_from_entity_dictionary(engine.context.project)
message = (
"Shotgun Harmony Engine could not detect "
"the context\n from the project loaded. "
Expand Down Expand Up @@ -182,9 +180,7 @@ def show_message(self, msg, level="info"):
dlg.setIcon(level_icon[level])
dlg.setText(msg)
dlg.setWindowTitle("Shotgun Harmony Engine")
dlg.setWindowFlags(
dlg.windowFlags() | QtCore.Qt.WindowStaysOnTopHint
)
dlg.setWindowFlags(dlg.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
dlg.show()
dlg.exec_()

Expand Down Expand Up @@ -229,9 +225,7 @@ def __toggle_debug_logging(self):
Toggles global debug logging on and off in the log manager.
This will affect all logging across all of toolkit.
"""
self.logger.debug(
"calling Harmony with debug: %s" % LogManager().global_debug
)
self.logger.debug("calling Harmony with debug: %s" % LogManager().global_debug)

# flip debug logging
LogManager().global_debug = not LogManager().global_debug
Expand Down Expand Up @@ -268,9 +262,7 @@ def __register_open_log_folder_command(self):
{
"short_name": "open_log_folder",
"icon": icon_path,
"description": (
"Opens the folder where log files are " "being stored."
),
"description": ("Opens the folder where log files are " "being stored."),
"type": "context_menu",
},
)
Expand Down Expand Up @@ -382,15 +374,10 @@ def warn_dcc_app_version(self):
# split off the major version number - accomodate complex
# version strings and decimals:
major_version_number_str = app_version_str.split(".")[0]
if (
major_version_number_str
and major_version_number_str.isdigit()
):
if major_version_number_str and major_version_number_str.isdigit():
# check against the compatibility_dialog_min_version
# setting
min_ver = self.get_setting(
"compatibility_dialog_min_version"
)
min_ver = self.get_setting("compatibility_dialog_min_version")
if int(major_version_number_str) < min_ver:
show_warning_dlg = False

Expand Down Expand Up @@ -433,22 +420,16 @@ def pre_app_init(self):
self.logger.debug("port: %s", port)

application_client_class = self.tk_harmony.application.Application
self.logger.debug(
" application_client_class: %s " % application_client_class
)
self.logger.debug(" application_client_class: %s " % application_client_class)

self._dcc_app = application_client_class(
self, parent=self._qt_app_central_widget, host=host, port=int(port)
)
self.logger.debug(" self._dcc_app: %s " % self._dcc_app)

self._dcc_app.register_callback("SHOW_MENU", self.on_show_menu)
self._dcc_app.register_callback(
"NEW_PROJECT_CREATED", self.on_new_project_created
)
self._dcc_app.register_callback(
"PROJECT_OPENED", self.on_project_opened
)
self._dcc_app.register_callback("NEW_PROJECT_CREATED", self.on_new_project_created)
self._dcc_app.register_callback("PROJECT_OPENED", self.on_project_opened)
self._dcc_app.register_callback("PING", self.on_ping)
self._dcc_app.register_callback("QUIT", self.on_app_quit)

Expand Down Expand Up @@ -482,9 +463,7 @@ def create_shotgun_menu(self, disabled=False):
if self.has_ui:
# create our menu handler
self.logger.debug("self._menu_generator: %s", self._menu_generator)
self._menu_generator = self.tk_harmony.MenuGenerator(
self, self._menu_name
)
self._menu_generator = self.tk_harmony.MenuGenerator(self, self._menu_name)

self.logger.debug("self._menu_generator: %s", self._menu_generator)
self._qt_app.setActiveWindow(self._menu_generator.menu_handle)
Expand Down Expand Up @@ -524,7 +503,7 @@ def init_qt_app(self):
self._qt_app_main_window.setCentralWidget(self._qt_app_central_widget)
self._qt_app.setQuitOnLastWindowClosed(False)

# Make the QApplication use the dark theme. Must be called after the
# Make the QApplication use the dark theme. Must be called after the
# QApplication is instantiated
self._initialize_dark_look_and_feel()

Expand Down Expand Up @@ -605,9 +584,7 @@ def _run_app_instance_commands(self):
if app_instance:
# Add entry 'command name: command function' to the command
# dictionary of this app instance.
cmd_dict = app_instance_commands.setdefault(
app_instance.instance_name, {}
)
cmd_dict = app_instance_commands.setdefault(app_instance.instance_name, {})
cmd_dict[cmd_name] = value["callback"]

# Run the series of app instance commands listed in the
Expand Down Expand Up @@ -657,9 +634,7 @@ def _run_app_instance_commands(self):

command_function()
else:
known_commands = ", ".join(
"'%s'" % name for name in cmd_dict
)
known_commands = ", ".join("'%s'" % name for name in cmd_dict)
self.logger.warning(
"%s configuration setting 'run_at_startup' "
"requests app '%s' unknown command '%s'. "
Expand Down Expand Up @@ -707,9 +682,7 @@ def _emit_log_message(self, handler, record):
# where "basename" is the leaf part of the logging record name,
# for example "tk-multi-shotgunpanel" or "qt_importer".
if record.levelno < logging.INFO:
formatter = logging.Formatter(
"Debug: Shotgun %(basename)s: %(message)s"
)
formatter = logging.Formatter("Debug: Shotgun %(basename)s: %(message)s")
else:
formatter = logging.Formatter("Shotgun %(basename)s: %(message)s")

Expand Down Expand Up @@ -750,9 +723,7 @@ def close_windows(self):
dialog.close()
except Exception as exception:
traceback.print_exc()
self.logger.error(
"Cannot close dialog %s: %s", dialog_window_title, exception
)
self.logger.error("Cannot close dialog %s: %s", dialog_window_title, exception)

# --------------------
# callbacks
Expand All @@ -779,9 +750,7 @@ def on_show_menu(self, **kwargs):

def on_new_project_created(self, **kwargs):
path = kwargs.get("path")
change_context = self.get_setting(
"change_context_on_new_project", False
)
change_context = self.get_setting("change_context_on_new_project", False)
if change_context:
refresh_engine(path, self.context)
else:
Expand Down
11 changes: 3 additions & 8 deletions hooks/tk-multi-breakdown/tk-harmony_scene_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def scan_scene(self):
for read_node in read_nodes:
ref_path = dcc_app.get_node_metadata(read_node, attr_name)
if ref_path:
ref_path = sgtk.util.shotgun_path.ShotgunPath.from_current_os_path(
ref_path
)
ref_path = sgtk.util.shotgun_path.ShotgunPath.from_current_os_path(ref_path)

refs.append(
{
Expand All @@ -79,9 +77,7 @@ def scan_scene(self):
ref_path = dcc_app.get_scene_metadata(audio_metadata_name)

if ref_path:
ref_path = sgtk.util.shotgun_path.ShotgunPath.from_current_os_path(
ref_path
)
ref_path = sgtk.util.shotgun_path.ShotgunPath.from_current_os_path(ref_path)

refs.append(
{
Expand Down Expand Up @@ -120,6 +116,5 @@ def update(self, items):

if items:
engine.show_busy(
"tk-multi-breakdown",
"Updating functionality has not been implemented yet.",
"tk-multi-breakdown", "Updating functionality has not been implemented yet."
)
6 changes: 2 additions & 4 deletions hooks/tk-multi-loader2/tk-harmony_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def generate_actions(self, sg_publish_data, actions, ui_area):
app = self.parent
app.log_debug(
"Generate actions called for UI element %s. "
"Actions: %s. Publish Data: %s"
% (ui_area, actions, sg_publish_data)
"Actions: %s. Publish Data: %s" % (ui_area, actions, sg_publish_data)
)

published_file_type = sg_publish_data["published_file_type"]["name"]
Expand All @@ -93,8 +92,7 @@ def generate_actions(self, sg_publish_data, actions, ui_area):
for action in actions:
action_instances.append(
{
"name": "Import %s as %s"
% (published_file_type, action.capitalize()),
"name": "Import %s as %s" % (published_file_type, action.capitalize()),
"params": {
"action": action,
"published_file_type": published_file_type,
Expand Down
23 changes: 6 additions & 17 deletions hooks/tk-multi-publish2/basic/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,22 @@ def get_export_path(self, settings):
work_template = None
work_template_setting = settings.get("Work Template")
if work_template_setting:
work_template = publisher.engine.get_template_by_name(
work_template_setting.value
)
work_template = publisher.engine.get_template_by_name(work_template_setting.value)

self.logger.debug(
"Work template defined for Toon Boom Harmony collection."
)
self.logger.debug("Work template defined for Toon Boom Harmony collection.")

work_export_template = None
work_export_template_setting = settings.get("Work Export Template")
if work_export_template_setting:
self.logger.debug(
"Work Export template settings: %s"
% work_export_template_setting
"Work Export template settings: %s" % work_export_template_setting
)

work_export_template = publisher.engine.get_template_by_name(
work_export_template_setting.value
)

self.logger.debug(
"Work Export template defined for Toon Boom Harmony collection."
)
self.logger.debug("Work Export template defined for Toon Boom Harmony collection.")

if work_export_template and work_template:
path = publisher.engine.app.get_current_project_path()
Expand Down Expand Up @@ -150,19 +143,15 @@ def collect_current_harmony_session(self, settings, parent_item):
)

# get the icon path to display for this item
icon_path = os.path.join(
self.disk_location, os.pardir, "icons", "session.png"
)
icon_path = os.path.join(self.disk_location, os.pardir, "icons", "session.png")
session_item.set_icon_from_path(icon_path)

# if a work template is defined, add it to the item properties so
# that it can be used by attached publish plugins
work_template_setting = settings.get("Work Template")
if work_template_setting:

work_template = publisher.engine.get_template_by_name(
work_template_setting.value
)
work_template = publisher.engine.get_template_by_name(work_template_setting.value)

# store the template on the item for use by publish plugins. we
# can't evaluate the fields here because there's no guarantee the
Expand Down
32 changes: 9 additions & 23 deletions hooks/tk-multi-publish2/basic/publish_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def description(self):
contain simple html for formatting.
"""

loader_url = (
"https://support.shotgunsoftware.com/hc/en-us/articles/219033078"
)
loader_url = "https://support.shotgunsoftware.com/hc/en-us/articles/219033078"

return """
Publishes the file to Shotgun. A <b>Publish</b> entry will be
Expand Down Expand Up @@ -121,9 +119,7 @@ def settings(self):
# inherit the settings from the base publish plugin
base_settings = super(HarmonySessionPublishPlugin, self).settings or {}

base_settings["File Types"]["default"].append(
["Harmony Project File", "xstage"]
)
base_settings["File Types"]["default"].append(["Harmony Project File", "xstage"])

# settings specific to this class
harmony_publish_settings = {
Expand Down Expand Up @@ -191,13 +187,10 @@ def accept(self, settings, item):
# provide a save button. the session will need to be saved before
# validation will succeed.
self.logger.warn(
"The Harmony session has not been saved.",
extra=_get_save_as_action(),
"The Harmony session has not been saved.", extra=_get_save_as_action()
)

self.logger.info(
"Harmony '%s' plugin accepted the current session." % (self.name,)
)
self.logger.info("Harmony '%s' plugin accepted the current session." % (self.name,))
return {"accepted": True, "checked": True}

def validate(self, settings, item):
Expand Down Expand Up @@ -238,22 +231,18 @@ def validate(self, settings, item):
if work_template:
if not work_template.validate(path):
self.logger.warning(
"The current session does not match the configured work "
"file template.",
"The current session does not match the configured work " "file template.",
extra={
"action_button": {
"label": "Save File",
"tooltip": "Save the current session to a "
"different file name",
"tooltip": "Save the current session to a " "different file name",
# will launch wf2 if configured
"callback": _get_save_as_action(),
}
},
)
else:
self.logger.debug(
"Work template configured and matches session file."
)
self.logger.debug("Work template configured and matches session file.")
else:
self.logger.debug("No work template configured.")

Expand Down Expand Up @@ -331,9 +320,7 @@ def publish(self, settings, item):

# let the base class register the publish
super(HarmonySessionPublishPlugin, self).publish(settings, item)
item.properties.sg_publish_path = item.properties.sg_publish_data[
"path"
]["local_path"]
item.properties.sg_publish_path = item.properties.sg_publish_data["path"]["local_path"]

def finalize(self, settings, item):
"""
Expand Down Expand Up @@ -381,8 +368,7 @@ def _copy_work_to_publish(self, settings, item):
work_template = item.properties.get("work_template")
if not work_template:
self.logger.debug(
"No work template set on the item. "
"Skipping copy file to publish location."
"No work template set on the item. " "Skipping copy file to publish location."
)
return

Expand Down
Loading

0 comments on commit 178594a

Please sign in to comment.