xml_parser — Tool XML Parser
rappture2web.xml_parser parses Rappture tool.xml files into Python
data structures for rendering.
Data classes
- ToolInfo
Tool metadata from the
<tool>section:title— tool titleabout— description textcommand— execution command templateuq_enabled— True if<uq>true</uq>is set
- WidgetNode
An input widget:
type— widget type (number, integer, choice, etc.)id— element idpath— Rappture path (e.g.input.number(temperature))label,description,hintsdefault,currentenable— conditional enable expressionchildren— child widgets (for groups, phases, structures)attrs— type-specific attributes (units, min, max, options, presets, uq_enabled)
- OutputNode
An output element with the same base fields plus type-specific attrs.
- ToolDef
Complete parsed tool:
tool— ToolInfoinputs— list of WidgetNodeoutputs— list of OutputNode
Functions
from rappture2web.xml_parser import parse_tool_xml, parse_run_xml
# Parse a tool definition
tool_def = parse_tool_xml('/path/to/tool.xml')
print(tool_def.tool.title)
print(tool_def.tool.uq_enabled)
for inp in tool_def.inputs:
print(inp.type, inp.id, inp.label)
# Parse a run.xml output file
outputs = parse_run_xml('/path/to/run.xml')
# Returns a dict of output_id → output_data