Actions

Base Classes

class action(dct: dict)

Represents a single “action” in a shortcut.

UUID = None

UUID string identifying the result variable produced by the action.

Used to link result variables to their origin.

classmethod action_hook(dct: dict)

Used to deserialize action objects from JSON.

category = ''

The action’s category (e.g. SCRIPTING or MATH). Always in ALL CAPS.

May be excluded for control-flow blocks, such as the If block’s End If.

css_class = []

List of CSS classes (str) to apply to special actions (e.g. Comment action)

get_line(key: str)

Return a particular element in lines, as identified by its key. Usually used in modify to pick a line out for modification.

Raises ValueError if the key does not a match a line.

get_title(key: str)

Return a particular element in title, as identified by its key. Usually used in modify to pick an element out for modification.

Raises ValueError if the key does not a match an element.

glyph = ''

The action’s glyph, usually matching the category. If there is no category, there is also no glyph, and vice versa.

Actions donated from an app have the app icon as their glyph

hide_line(key: str)

Add the “hidden” CSS class to particular element in line, as identified by its key.

Raises ValueError if the label does not a match a line.

hide_text(value: str)

Add the “hidden” CSS class to text element in title, as identified by its value.

Raises ValueError if the value does not a match any text.

hide_title(key: str)

Add the “hidden” CSS class to particular element in title, as identified by its key.

Raises ValueError if the label does not a match an element.

indent = 0

Visual indentation level for actions inside control flow blocks.

Control flow blocks may be nested indefinitely, but stop visually indenting after 8 levels.

indent_delta = 0

Determines whether subsequent actions are (un)-indented. Permitted values: -1, 0, +1.

Todo:Check whether indentation delta is either -1, 0, or +1.
inherit()

Copies (inherited) class variables to instance.

Allows us to make defining actions with similar category, glyph, and result DRYer.

Creates instance specific title, lines, and elem so that their values may be individually set.

items = []

List of keys and values particular to the Dictionary action.

lines = []

List of additional options customizing an action’s behaviour.

Populated with line_${elem} objects.

modify()

Called after to_html has been invoked on title, lines, and elem.

Houses special logic for each action. Usually, this means hiding element X if element Y has value Z.

Meant to be overriden.

name = ''

The action’s name when searched in Shortcuts.

result = None

Every action may (or may not) produce one result, which may (or may not) be given a custom name.

This field define’s the action’s default result name (if any). None means the action does not produce a result.

title = []

List of element objects composing the title (large head text).

Populated with text objects, and children of base_magic.

to_django(UUID_glyphs: dict, indent: int)

Invokes to_html method of every object in title, lines, and elem, transforming these into lists of dict for the Django template engine.

Invokes action’s modify method last.

class control

Represents a control flow action such as If, Repeat, or Choose from Menu.

flow_mode()

Looks up the action’s WFControlFlowMode.

mod_indent()

Adjusts action based on it’s flow_mode value

0: Head block

  • Has a category & glyph
  • Accepts parameters
  • Indents inner actions by +1

1: Body block

  • No category or glyph
  • Does not accept parameters
  • Unindented 1 level from inner blocks (same indentation as Head)
  • Does not change indentation of subsequent blocks

2: Foot block

  • No category or glyph
  • Does not accept parameters
  • Unindented 1 level from inner blocks (same indentation as Head)
  • Unindents subsequent blocks -1.