-
Notifications
You must be signed in to change notification settings - Fork 42
Convert specified nodes #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alxkocic
wants to merge
2
commits into
shotgunsoftware:master
Choose a base branch
from
alxkocic:implement-convert-single-node
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| # Copyright (c) 2013 Shotgun Software Inc. | ||
| # | ||
| # | ||
| # CONFIDENTIAL AND PROPRIETARY | ||
| # | ||
| # This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit | ||
| # | ||
| # This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit | ||
| # Source Code License included in this distribution package. See LICENSE. | ||
| # By accessing, using, copying or modifying this work you indicate your | ||
| # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights | ||
| # By accessing, using, copying or modifying this work you indicate your | ||
| # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights | ||
| # not expressly granted therein are reserved by Shotgun Software Inc. | ||
|
|
||
| """ | ||
|
|
@@ -18,6 +18,7 @@ | |
| import tank | ||
| from tank import TankError | ||
|
|
||
|
|
||
| class NukeWriteNode(tank.platform.Application): | ||
|
|
||
| def init_app(self): | ||
|
|
@@ -51,10 +52,10 @@ def destroy_app(self): | |
| Called when the app is unloaded/destroyed | ||
| """ | ||
| self.log_debug("Destroying tk-nuke-writenode app") | ||
|
|
||
| # remove any callbacks that were registered by the handler: | ||
| self.__write_node_handler.remove_callbacks() | ||
|
|
||
| # clean up the nuke module: | ||
| if hasattr(nuke, "_shotgun_write_node_handler"): | ||
| del nuke._shotgun_write_node_handler | ||
|
|
@@ -80,7 +81,7 @@ def post_context_change(self, old_context, new_context): | |
| # these are triggered before the engine changes context, so we must manually call it here. | ||
| # this will force the path to reset and the profiles to be rebuilt. | ||
| self.__write_node_handler.setup_new_node(node) | ||
|
|
||
| def process_placeholder_nodes(self): | ||
| """ | ||
| Convert any placeholder nodes to TK Write Nodes | ||
|
|
@@ -89,14 +90,14 @@ def process_placeholder_nodes(self): | |
|
|
||
| # interface for other apps to query write node info: | ||
| # | ||
|
|
||
| # access general information: | ||
| def get_write_nodes(self): | ||
| """ | ||
| Return list of all write nodes | ||
| """ | ||
| return self.__write_node_handler.get_nodes() | ||
|
|
||
| def get_node_name(self, node): | ||
| """ | ||
| Return the name for the specified node | ||
|
|
@@ -109,11 +110,11 @@ def get_node_profile_name(self, node): | |
| is using | ||
| """ | ||
| return self.__write_node_handler.get_node_profile_name(node) | ||
|
|
||
| def get_node_tank_type(self, node): | ||
| """ | ||
| Return the tank type for the specified node | ||
|
|
||
| Note: Legacy version with old 'Tank Type' name - use | ||
| get_node_published_file_type instead! | ||
| """ | ||
|
|
@@ -124,7 +125,7 @@ def get_node_published_file_type(self, node): | |
| Return the published file type for the specified node | ||
| """ | ||
| return self.__write_node_handler.get_node_tank_type(node) | ||
|
|
||
| def is_node_render_path_locked(self, node): | ||
| """ | ||
| Determine if the render path for the specified node | ||
|
|
@@ -134,77 +135,77 @@ def is_node_render_path_locked(self, node): | |
| can happen if the file is moved on disk or if the template | ||
| is changed. | ||
| """ | ||
| return self.__write_node_handler.render_path_is_locked(node) | ||
| return self.__write_node_handler.render_path_is_locked(node) | ||
|
|
||
| # access full-res render information: | ||
| def get_node_render_path(self, node): | ||
| """ | ||
| Return the render path for the specified node | ||
| """ | ||
| return self.__write_node_handler.compute_render_path(node) | ||
| return self.__write_node_handler.compute_render_path(node) | ||
|
|
||
| def get_node_render_files(self, node): | ||
| """ | ||
| Return the list of rendered files for the node | ||
| """ | ||
| return self.__write_node_handler.get_files_on_disk(node) | ||
|
|
||
| def get_node_render_template(self, node): | ||
| """ | ||
| Return the render template for the specified node | ||
| """ | ||
| return self.__write_node_handler.get_render_template(node) | ||
|
|
||
| def get_node_publish_template(self, node): | ||
| """ | ||
| Return the publish template for the specified node | ||
| """ | ||
| return self.__write_node_handler.get_publish_template(node) | ||
|
|
||
| # access proxy-res render information: | ||
| def get_node_proxy_render_path(self, node): | ||
| """ | ||
| Return the render path for the specified node | ||
| """ | ||
| return self.__write_node_handler.compute_proxy_path(node) | ||
| return self.__write_node_handler.compute_proxy_path(node) | ||
|
|
||
| def get_node_proxy_render_files(self, node): | ||
| """ | ||
| Return the list of rendered files for the node | ||
| """ | ||
| return self.__write_node_handler.get_proxy_files_on_disk(node) | ||
|
|
||
| def get_node_proxy_render_template(self, node): | ||
| """ | ||
| Return the render template for the specified node | ||
| """ | ||
| return self.__write_node_handler.get_proxy_render_template(node) | ||
|
|
||
| def get_node_proxy_publish_template(self, node): | ||
| """ | ||
| Return the publish template for the specified node | ||
| """ | ||
| return self.__write_node_handler.get_proxy_publish_template(node) | ||
| return self.__write_node_handler.get_proxy_publish_template(node) | ||
|
|
||
| # useful utility functions: | ||
| def generate_node_thumbnail(self, node): | ||
| """ | ||
| Generate a thumnail for the specified node | ||
| """ | ||
| return self.__write_node_handler.generate_thumbnail(node) | ||
|
|
||
| def reset_node_render_path(self, node): | ||
| """ | ||
| Reset the render path of the specified node. This | ||
| will force the render path to be updated based on | ||
| the current script path and configuration. | ||
|
|
||
| Note, this should really never be needed now that the | ||
| path is reset automatically when the user changes something. | ||
| """ | ||
| self.__write_node_handler.reset_render_path(node) | ||
|
|
||
| def convert_to_write_nodes(self, show_warning=False): | ||
| def convert_to_write_nodes(self, nodes=list(), show_warning=False): | ||
| """ | ||
| Convert all Shotgun write nodes found in the current Script to regular | ||
| Nuke Write nodes. Additional toolkit information will be stored on | ||
|
|
@@ -223,8 +224,8 @@ def convert_to_write_nodes(self, show_warning=False): | |
| # defer importing the QT module so the app doesn't require QT unless running this method with the warning. | ||
| from sgtk.platform.qt import QtGui | ||
| res = QtGui.QMessageBox.question(None, | ||
| "Convert All SG Write Nodes?", | ||
| "This will convert all Shotgun write nodes to standard write nodes." | ||
| "Convert SG Write Nodes?", | ||
| "This will convert Shotgun write nodes to standard write nodes." | ||
| "\nOK to proceed?", | ||
| QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) | ||
|
|
||
|
|
@@ -233,9 +234,9 @@ def convert_to_write_nodes(self, show_warning=False): | |
| continue_with_convert = False | ||
|
|
||
| if continue_with_convert: | ||
| self.__write_node_handler.convert_sg_to_nuke_write_nodes() | ||
| self.__write_node_handler.convert_sg_to_nuke_write_nodes(nodes) | ||
|
|
||
| def convert_from_write_nodes(self, show_warning=False): | ||
| def convert_from_write_nodes(self, nodes=list(), show_warning=False): | ||
| """ | ||
| Convert all regular Nuke Write nodes that have previously been converted | ||
| from Shotgun Write nodes, back into Shotgun Write nodes. | ||
|
|
@@ -251,19 +252,18 @@ def convert_from_write_nodes(self, show_warning=False): | |
| # defer importing the QT module so the app doesn't require QT unless running this method with the warning. | ||
| from sgtk.platform.qt import QtGui | ||
| res = QtGui.QMessageBox.question(None, | ||
| "Convert All Write Nodes?", | ||
| "This will convert any Shotgun Write Nodes that have been converted " | ||
| "Convert Write Nodes?", | ||
| "This will convert Shotgun Write Nodes that have been converted " | ||
| "into standard write nodes back to their original form." | ||
| "\nOK to proceed?", | ||
| QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) | ||
|
|
||
|
|
||
| if res != QtGui.QMessageBox.Yes: | ||
| # User chose to abort the operation, we should not convert the write nodes | ||
| continue_with_convert = False | ||
|
|
||
| if continue_with_convert: | ||
| self.__write_node_handler.convert_nuke_to_sg_write_nodes() | ||
| self.__write_node_handler.convert_nuke_to_sg_write_nodes(nodes) | ||
|
|
||
| def create_new_write_node(self, profile_name): | ||
| """ | ||
|
|
@@ -284,10 +284,10 @@ def __add_write_node_commands(self, context=None): | |
|
|
||
| for profile_name in self.__write_node_handler.profile_names: | ||
| # add to toolbar menu | ||
| cb_fn = lambda pn=profile_name: self.__write_node_handler.create_new_node(pn) | ||
| def cb_fn(pn=profile_name): return self.__write_node_handler.create_new_node(pn) | ||
| self.engine.register_command( | ||
| "%s [Shotgun]" % profile_name, | ||
| cb_fn, | ||
| cb_fn, | ||
| dict( | ||
| type="node", | ||
| icon=write_node_icon, | ||
|
|
@@ -307,8 +307,8 @@ def __add_write_node_commands(self, context=None): | |
| if not promoted_knob_write_nodes: | ||
| # no presets use promoted knobs so we are OK to register the menus. | ||
|
|
||
| convert_to_write_nodes_action = lambda :self.convert_to_write_nodes(show_warning=True) | ||
| convert_from_write_nodes_action = lambda: self.convert_from_write_nodes(show_warning=True) | ||
| def convert_to_write_nodes_action(): return self.convert_to_write_nodes(show_warning=True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. multiple statements on one line (def) |
||
| def convert_from_write_nodes_action(): return self.convert_from_write_nodes(show_warning=True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expected 1 blank line before a nested definition, found 0 |
||
|
|
||
| self.engine.register_command( | ||
| "Convert SG Write Nodes to Write Nodes...", | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple statements on one line (def)