script_inspector.py¶
Public interface for inspecting scripts and callbacks in Houdini nodes.
This module provides functionality for searching, analyzing and extracting scripts from nodes, including callbacks, expressions, menu scripts, and conditionals.
Example
inspector = ScriptInspector() inspector.print_scripts_in_selected_nodes()
Classes:
Name | Description |
---|---|
ScriptInspector |
Main script inspection functionality |
ScriptInspector
¶
Inspects and analyzes scripts and callbacks in Houdini nodes.
Provides methods to search, analyze and extract scripts from node parameters, including callbacks, expressions, menu scripts, and conditionals.
Attributes:
Name | Type | Description |
---|---|---|
search_mode |
Optional[int]
|
Current search mode (None until first search) |
search_str |
Optional[str]
|
Current search string (None until first search) |
Example
inspector = ScriptInspector() scripts = inspector.search_scripts(node) for script in scripts: ... print(f"{script['type']}: {script['script']}")
Source code in core/script_inspector.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
__init__()
¶
Initialize the ScriptInspector.
Creates a new ScriptInspector instance with default settings for analyzing Houdini scripts.
format_script(label, script, indent=4)
staticmethod
¶
Format a script with proper indentation and wrapping.
Takes raw script content and formats it with consistent indentation, line wrapping and optional label prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label
|
str
|
Script type label to prefix (e.g. 'Python', 'VEX') |
required |
script
|
str
|
The raw script content to format |
required |
indent
|
int
|
Number of spaces for indentation. Defaults to 4. |
4
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The formatted script string with proper indentation and wrapping |
Raises:
Type | Description |
---|---|
ValueError
|
If script is None or empty |
TypeError
|
If indent is not an integer |
Example
inspector = ScriptInspector() formatted = inspector.format_script("Python", "def foo():\n pass", 4)
Source code in core/script_inspector.py
print_scripts_in_selected_nodes()
¶
Search and print scripts from all selected nodes.
Finds all script-type parameters in the selected nodes and prints their contents, organized by node and parameter name.
Raises:
Type | Description |
---|---|
RuntimeError
|
If no nodes are selected |
ValueError
|
If selected nodes contain no script parameters |
Example
inspector = ScriptInspector() inspector.search_selected() # Prints all scripts in selected nodes
Source code in core/script_inspector.py
search_scripts(node)
¶
Search for scripts in a node's parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
Node to search |
required |
Returns:
Type | Description |
---|---|
List[Dict[str, str]]
|
List of found scripts with their metadata: |
List[Dict[str, str]]
|
|
List[Dict[str, str]]
|
|
List[Dict[str, str]]
|
|
Raises:
Type | Description |
---|---|
ValueError
|
If node is None |
Example
scripts = inspector.search_scripts(node) for script in scripts: ... print(f"{script['parameter']}: {script['script']}")