API Documentation

Template module

class nuketemplate.template.AbstractTemplate(root, attrs='attrs', nodes='nodes', template=[])[source]

Template class, automates Jinja2 loader and environment generation, wraps Jinja2 rendering and JSON encoding.

Parameters:
  • root (str) – Template root location
  • nodes (str) – Node templates’ folder name, (default: nodes)
  • attrs (str) – Attribute templates’ folder name, (default: attrs)
render(template='main.j2', **kwargs)[source]

Compile the main node template to JSON and store as an instance attribute

Parameters:
  • template (str) – Main template name
  • **kwargs (dict) – Template data
save(filename='template.json')[source]

Given a root folder and a filename, save the template JSON encoded to a file.

Parameters:
  • root (str) – Saving location
  • filename (str) – Filename

Graph module

class nuketemplate.graph.AbstractGraph(nx_graph, start=None, end=None, end_slot=0)[source]

Abstraction of a NetworkX Directed Graph, adds start, end attributes for simplified graph combination.

Parameters:
class nuketemplate.graph.GenericNode(name)[source]

Generic Node, used with AbstractGraph

Parameters:name (str) – Node name
class nuketemplate.graph.NukeNode(name, type, attr, id, nuke_node=None, nuke_name=None)[source]

Nuke Node, used with AbstractGraph, inherits from GenericNode

Parameters:
  • name (str) – Node name
  • _type (str) – Nuke node type
  • _attr (dict) – Nuke node attributes
  • _id (dict) – Node UUIDs
  • _nuke_node (Node) – Nuke node, generated by build()
  • _nuke_name (str) – Nuke node name, generated by build()
build()[source]

Build and return the Nuke node.

Returns:Nuke node
Return type:Node
nuketemplate.graph.is_node_in_nx_graph(instance, attribute, value)[source]

Input validator for AbstractGraph. Check whether start and end node inputs are part of the graph.

Parameters:

Convert module

class nuketemplate.convert.AbstractTemplateConverter(template, start='>>', end='<<', subgraphs=[], result=None)[source]

Template to Graph Converter

Parameters:
  • template (list, dict) – JSON Template
  • start (str) – Start characters, default: >>
  • end (str) – End characters, default: <<
convert()[source]

Convert the JSON template into an AbstractGraph, if the template consists of multiple sub graphs, convert and combine otherwise convert in one pass.

to_dot(dot_filename='graph.dot')[source]

Save the converted graph to a dot file at location dot_filename

Parameters:dot_filename (str) – Filename, default: graph.dot
to_png(png_filename='graph.png', dot_executable='/usr/local/bin/dot')[source]

Save the converted graph to a png file at location png_filename

Parameters:
  • png_filename (str) – Filename, default: graph.png
  • dot_executable (str) – Path to the dot executable, default: /usr/local/bin/dot

Build module

class nuketemplate.build.NukeGraphBuilder(abstract_graph)[source]

NukeGraphBuilder, convert an AbstractGraph to a Nuke compositing script

Parameters:abstract_graph (AbstractGraph) – Abstract graph
build()[source]

Build the Nuke node graph from the object’s abstract_graph.

Returns:Number of nodes built
Return type:int