puzzlepiece.parse module
- puzzlepiece.parse.parse_params(text, puzzle)[source]
Parse a string of the following format to construct references to
BaseParamobjects:[Piece name]:[param name], [Piece name]:[param name], ...- Parameters:
text – The string to parse.
puzzle – The app’s
Puzzle.
- Return type:
list(puzzlepiece.param.BaseParam, )
- puzzlepiece.parse.run(text, puzzle)[source]
Execute a set of puzzlepiece script commands.
Commands can be separated by new lines, or a semicolon (
;) + space.If a command needs to include a semicolon followed by a space, it can be inserted as
\;(backslash character + semicolon + space).Comments can be added by starting the line with
#.- The available commands are:
set:[Piece name]:[param name]:[value]run:[Piece name]:[action name]get:[Piece name]:[param name]sleep:[duration in s]prompt:[text]print:[text]
- Parameters:
text – The string to parse.
puzzle – The app’s
Puzzle.
- puzzlepiece.parse.format(text, puzzle)[source]
Insert values of
BaseParamobjects into a string.To insert a value, use the following format:
The value is: {[Piece name]:[param name]}If a param has a getter, it will be called.
One can also apply additional formatting:
The formatted value is {[Piece name]:[param/readout name];[format]}where format follows the ‘new’ standard as described at https://pyformat.info/. For example:The laser power is {laser:power;:.1f}- Parameters:
text – The string to parse.
puzzle – The app’s
Puzzle.
- Return type:
str