Skip to main content

nkparser

nkparser parses, queries, validates, and round-trips Foundry Nuke .nk script files.

Install

This project is managed with uv.

uv sync

Install the package into the current environment:

uv pip install .

Install with Graphviz rendering support:

uv pip install '.[graphviz]'

CLI

The package exposes the nkparser console script:

uv run nkparser --help

You can also run it as a module:

uv run python -m nkparser --help

Examples

uv run nkparser info tests/fixtures/minimal.nk
uv run nkparser validate tests/fixtures/malformed_unclosed.nk
uv run nkparser tree tests/fixtures/complex_groups.nk --knobs
uv run nkparser tree tests/fixtures/complex_groups.nk --knobs --format json
uv run nkparser show tests/fixtures/minimal.nk --format json
uv run nkparser nodes tests/fixtures/minimal.nk --class Grade
uv run nkparser dot tests/fixtures/minimal.nk -o graph.dot
uv run nkparser dot tests/fixtures/minimal.nk -o graph.dot --render --dot-command /opt/homebrew/bin/dot
uv run nkparser diff v012.nk v013.nk --ignore xpos,ypos,selected

nkparser diff prints one line per change and exits 0 when the scripts match, 1 when they differ:

- Merge1 (Merge2)
+ Blur2 (Blur)
~ Grade1 (Grade) white: 1.2 -> 1.4
~ Merge1 (Merge2) inputs: ['Grade1', 'Read1'] -> ['Grade1', None]

Add --format json to get the raw dict from diff_scripts.

Use with git

nkparser git-diff is a git external diff driver: git diff then shows node changes for .nk files instead of raw text.

Add to .gitattributes in the repository:

*.nk diff=nk

Register the driver (once per repository, or add --global):

git config diff.nk.command "nkparser git-diff --ignore xpos,ypos,selected"

nkparser must be on PATH for git. Drop --ignore to also see node moves. To see the raw text diff for one command, run git diff --no-ext-diff.

The driver always exits 0, because git stops the whole diff when an external driver exits non-zero. Added and deleted files show every node as + or -.

Development

Sync the dev environment:

uv sync --dev

Run checks:

uv run pytest
uv run ruff check .
uv run mypy

Build distributions:

uv build

Python API

import nkparser

script = nkparser.Script.from_file("comp.nk")

print(script.nuke_version)
print(len(list(script.all_nodes())))

reads = script.query().of_class("Read").all()
grade = script.find("Grade1")

if grade:
    grade.set("disable", "true")

script.write("comp_modified.nk")

Metadata

Release files for nkparser 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nkparser 0.4.0
File Size Uploaded Provenance Actions
nkparser-0.4.0.tar.gz 62.1 kB Without provenance Details for nkparser-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nkparser 0.4.0
File Interpreter ABI Platform Actions
nkparser-0.4.0-py3-none-any.whl Python 3 none any Details for nkparser-0.4.0-py3-none-any.whl

Total release size: 96.6 kB

Release files / nkparser-0.4.0.tar.gz

Download URL nkparser-0.4.0.tar.gz
Size 62.1 kB
Tags Source
SHA-256 checksum
How to use checksums
11f6890051641c2a7fb142e7410eecf2df0a386a62c28d67f48b408517b79775
BLAKE2b-256 checksum
How to use checksums
d19fda6f48c68421849158f13a4784ac7473b6974559deaef58f5c9f1a615406
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / nkparser-0.4.0-py3-none-any.whl

Download URL nkparser-0.4.0-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2129307cc5752195a754e6affe7a373df9b8c4a06ad93c1652fe7bc61b95aea7
BLAKE2b-256 checksum
How to use checksums
2ffc455c10798767a6c6f66c85835cb0af84ac8a810da155211eec100800226f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for nkparser 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page