Skip to content
This repository was archived by the owner on Oct 10, 2024. It is now read-only.

Commit 9de6668

Browse files
Merge pull request #70 from pypeclub/hotfix/nuke-pipeline-little-fixes
fix(nk): little pipeline fix
2 parents c793e29 + f6d0179 commit 9de6668

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

avalon/nuke/pipeline.py

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import os
2-
import sys
3-
from collections import OrderedDict
4-
from bson.objectid import ObjectId
5-
import importlib
6-
from .. import api, io
2+
import logging
73
import contextlib
4+
import importlib
5+
from collections import OrderedDict
86
from pyblish import api as pyblish
9-
from ..vendor import toml
10-
import logging
11-
import nuke
7+
from .. import api, io
128
from . import lib
13-
9+
import nuke
1410

1511
log = logging.getLogger(__name__)
1612

@@ -21,7 +17,6 @@ def reload_pipeline():
2117
"""Attempt to reload pipeline at run-time.
2218
2319
CAUTION: This is primarily for development and debugging purposes.
24-
2520
"""
2621

2722
import importlib
@@ -60,21 +55,21 @@ def containerise(node,
6055
context,
6156
loader=None,
6257
data=None):
63-
"""Bundle `nodes` into an assembly and imprint it with metadata
58+
"""Bundle `node` into an assembly and imprint it with metadata
6459
6560
Containerisation enables a tracking of version, author and origin
6661
for loaded assets.
6762
6863
Arguments:
69-
node (object): The node in Nuke to imprint as container,
70-
usually a Reader.
64+
node (obj): Nuke's node object to imprint as container,
65+
usually a Reader.
7166
name (str): Name of resulting assembly
7267
namespace (str): Namespace under which to host container
7368
context (dict): Asset information
7469
loader (str, optional): Name of node used to produce this container.
7570
7671
Returns:
77-
None
72+
node (obj): containerised nuke's node object
7873
7974
"""
8075

@@ -90,18 +85,23 @@ def containerise(node,
9085
if data:
9186
{data_imprint.update({k: v}) for k, v in data.items()}
9287

93-
log.info("data_imprint: {}".format(data_imprint))
88+
log.debug("Imprinting data: {}".format(data_imprint))
9489

9590
lib.set_avalon_knob_data(node, data_imprint)
96-
91+
9792
return node
9893

9994

10095
def parse_container(node):
10196
"""Returns containerised data of a node
10297
103-
This reads the imprinted data from `containerise`.
98+
Reads the imprinted data from `containerise`.
99+
100+
Arguments:
101+
node (obj): Nuke's node object to read imprinted data
104102
103+
Returns:
104+
container (dict): imprinted container data
105105
"""
106106
data = lib.get_avalon_knob_data(node)
107107

@@ -167,16 +167,18 @@ def update_container(node, keys=dict()):
167167

168168

169169
class Creator(api.Creator):
170+
"""Creator cass wrapper
171+
"""
170172
def process(self):
171-
nodes = nuke.allNodes()
172-
173173
if (self.options or {}).get("useSelection"):
174174
nodes = nuke.selectedNodes()
175175

176-
instance = [n for n in nodes
177-
if n["name"].value() in self.name] or None
176+
if len(nodes) > 0:
177+
node = nodes[0]
178+
elif len(nodes) > 1:
179+
nuke.message("Please select only one node")
178180

179-
instance = lib.imprint(instance, self.data)
181+
instance = lib.imprint(node, self.data)
180182

181183
return instance
182184

@@ -193,11 +195,10 @@ def ls():
193195
"""
194196
all_nodes = nuke.allNodes(recurseGroups=False)
195197

196-
# TODO: add readgeo, readcamera, readimage
197198
nodes = [n for n in all_nodes]
198199

199200
for n in nodes:
200-
log.info("__ name node ls: `{}`".format(n.name()))
201+
log.debug("Listing node: `{}`".format(n.name()))
201202
container = parse_container(n)
202203
if container:
203204
yield container
@@ -225,7 +226,7 @@ def install(config):
225226
if hasattr(config, "install"):
226227
config.install()
227228

228-
log.info("config.nuke installed")
229+
log.info("{}.nuke installed".format(config.__name__))
229230

230231

231232
def find_host_config(config):
@@ -240,7 +241,7 @@ def find_host_config(config):
240241

241242

242243
def uninstall(config):
243-
"""Uninstall all tha was installed
244+
"""Uninstall all that was previously installed
244245
245246
This is where you undo everything that was done in `install()`.
246247
That means, removing menus, deregistering families and data
@@ -260,6 +261,8 @@ def uninstall(config):
260261

261262

262263
def _install_menu():
264+
"""Installing Avalon menu to Nuke
265+
"""
263266
from ..tools import (
264267
creator,
265268
publish,
@@ -388,10 +391,10 @@ def get_handles(asset):
388391
if "visualParent" in data:
389392
vp = data["visualParent"]
390393
if vp is not None:
391-
parent_asset = io.find_one({"_id": ObjectId(vp)})
394+
parent_asset = io.find_one({"_id": io.ObjectId(vp)})
392395

393396
if parent_asset is None:
394-
parent_asset = io.find_one({"_id": ObjectId(asset['parent'])})
397+
parent_asset = io.find_one({"_id": io.ObjectId(asset['parent'])})
395398

396399
if parent_asset is not None:
397400
return get_handles(parent_asset)

0 commit comments

Comments
 (0)