Variables¶
Base Classes¶
Base class for magic variables.
Parameters: - key – Key (in the action’s WFWorkflowActionParameters dictionary) to the magic variable’s value
- ask_each_time – The text used when Ask Each Time is selected as an option.
- attrs – Dict of information to be passed to HTML.
Ask_each_time: - Usually, the text is simply “Ask Each Time”. In inline variables, it is usually “Text”
- If Ask Each Time is not offered as an valid input, set this value as
None
Handles output when the variable was left blank.
Invoked by the
to_djangomethod to convert a variable object to a dict describing the contents of the action.Parameters: - params – The action’s WFWorkflowActionParameters dict. Contains information on what values were filled into each magic variable.
- UUID_glyphs – Previous actions’ outputs can be used as magic variable inputs, and are displayed alongside the output-action’s glyph.
UUID Glyphsmaps actions’ output UUIDs to their glyphs.
Base class for line variables.
Parameters: - label – Label to the left of the parameter, detailing what it is.
- leftify – Whether or not to flush the variable left against the label. Usually used for
line_inline.
Simply returns the label wrapped in a dict.
Title Variables¶
Basic Magic Variable Field.
In Shortcuts, this simplest of fields can accept:
- results from other actions
- “global” variables such as Clipboard, Current Date, Shortcut Input
- blank (nothing)
Handles output when the variable was left blank.
Field that accepts numbers.
In Shortcuts, this accepts:
- signed floats and integers
- a single magic variable (no inline expressions)
- blank (nothing)
NOTE: numbermay accept adefaultvalue. If the defaultstate is blank, simply self
default=None.Handles output when the variable was left blank.
Field that accepts only whole numbers.
In Shortcuts, this is identical to
number, except the decimal point is not available.
Field that counts things.
Plural sensitive, e.g. “1 time” vs “2 times”.
In Shortcuts, this accepts:
- a natural number (0 or positive ints)
- can be incremented or decremented
- Ask Each Time
TODO: implement magic variable support. TODO: account for the field accepting / not accepting 0 as a valid number. Handles output when the variable was left blank.
Field that offers a list of valid choices, with a default pre-selected.
- In Shortcuts, this field accepts:
- one of the offered
options. - a magic variable, and Ask Each Time, may or may not be valid
- one of the offered
Some fields simply prompt the user to “Choose a variable…” with no other options.
TODO: account for “Choose a variable…” case. Handles output when the variable was left blank.