Supported by Supported by Advertisement

Access items

class items

The items object provides dict-like access to the items. It's mainly useful for programatically executing items.

In addition to the functions listed below, the following semantics are supported:

Example:

# Programmatically prepare and run a sketchpad item.
items.execute(u'my_sketchpad')
# Check if an item exists
if u'my_sketchpad' in items:
        print(u'my_sketchpad exists')
# Delete an item
del items[u'my_sketchpad']
# Walk through all item names
for item_name in items:
        print(item_name)

function items.execute(name)

Executes the run and prepare phases of an item, and updates the item stack.

Arguments:

property items.items

Returns a list of (item name, item object) tuples.

property items.keys

Returns a list of item names.

function items.new(_type, name=None, script=None)

Creates a new item.

Example:

items.new(u'sketchpad', name=u'my_sketchpad')
items[u'my_sketchpad'].prepare()
items[u'my_sketchpad'].run()

Arguments:

  • _type -- The item type.
    • Type: unicode

Keywords:

  • name -- The item name, or None to choose a unique name based on the item type.
    • Type: unicode, NoneType
    • Default: None
  • script -- A definition script, or None to start with a blank item.
    • Type: unicode, NoneType
    • Default: None

Returns:

The newly generated item.

  • Type: item

function items.prepare(name)

Executes the prepare phase of an item, and updates the item stack.

Arguments:

  • name -- An item name.
    • Type: str

function items.run(name)

Executes the run phase of an item, and updates the item stack.

Arguments:

  • name -- An item name.
    • Type: str

function items.valid_name(item_type, suggestion=None)

Generates a unique name that is valid and resembles the desired name.

Arguments:

  • item_type -- The type of the item to suggest a name for.
    • Type: unicode

Keywords:

  • suggestion -- The desired name, or None to choose a name based on the item's type.
    • Type: unicode, NoneType
    • Default: None

Returns:

A unique name.

  • Type: unicode

property items.values

Returns a list of item objects.