Magic Helper Methods

Module:share.process.components.magic_helpers
ActionOutput(value: dict, attrs: dict, UUID_glyphs: dict = {})

Returns a magic variable representing output from a previous action.

Handles both normal outputs and lookups of dictionary values.

class AddField(name: str)

Decorator. Adds a field entry to every parameter dictionary in to_html results.

As opposed to class and css_class (which provide styling information), field will specify the type of editing interface when editing is implemented.

classify_magic(value: dict, var_type: str, attrs: dict, ask_each_time: str = 'Ask Each Time', UUID_glyphs: dict = {}) → dict

Returns an appropriate magic variable dict.

Parameters:
  • value – dict of information about the variable
  • var_type

    “Type” entry in value, indicating whether the variable is:

    • Clipboard
    • Ask Each Time
    • Current Date
    • Shortcut Input (from Share sheet)
    • Output from other actions
    • A named variable (from Set Variable or Add to Variable actions)
  • ask_each_time – The text used when Ask Each Time is selected as an option.
  • UUID_glyphs – Maps actions’ output UUIDs to their glyphs.

Side Note: function contains a Python implementation of JavaScript’s switch-case structure that I am quite proud of :). The lambda stop Python from evaluating every possible outcome beforehand.

magic_dct(value: str, attrs: dict, empty: bool = False, glyph: str = '', UUID: str = None) → dict

Wraps a given value in a magic-var dict for the django templater.

Parameters:
  • glyph – icon to be displayed to the left of magic variables.
  • UUID – UUID of the action that supplied the magic variable, if any.
  • empty – determines whether CSS class empty should be applied. empty greys out the value, indicating that it was left blank.
value_dct(value: str, attrs: dict, css_class: [<class 'str'>] = [], empty: bool = False)

Wraps a given value in a dict for the django templater.

Parameters:
  • css_class – list of CSS classes to be applied to the variable.
  • empty – determines whether CSS class empty should be applied. empty greys out the value, indicating that it was left blank.