Refactor: Node Wrangler: PreviewNode operator
commitb1786fb4a8838d0e43d7205c821f2983d96b7784
authorDamien Picard <dam.pic@free.fr>
Wed, 4 Oct 2023 14:16:21 +0000 (4 16:16 +0200)
committerDamien Picard <dam.pic@free.fr>
Sun, 17 Dec 2023 13:13:01 +0000 (17 14:13 +0100)
treec8bfed8c4898380e3d0eaaa9f670063110e50c94
parentbe5e4a14e092637c731e732b960bf1dea9cf4817
Refactor: Node Wrangler: PreviewNode operator

This commit refactors the PreviewNode operator so that code is
deduplicated between the Geometry Nodes and the shader branches.

- Extract `get_output_index()` and `create_links()` to methods to
  avoid duplication in `invoke()`
- Return `{'CANCELLED'}` instead of `{'FINISHED'}` when there was no
  change.
- Exit early when possible.
- Use `if ... is None:` instead of `if ...:` when applicable.
- Remove bits of unused code.
- Tweak comments and convert them to docstrings when extracted to a
  function.
- Convert methods to `staticmethod`s or `classmethod`s when possible.
node_wrangler/__init__.py
node_wrangler/operators.py
node_wrangler/utils/nodes.py