iblviewer.collection

Classes

Collection

class Collection[source]

Bases: collections.OrderedDict

current = None
current_key_id = 0
targets = []
get_current_key()[source]

Get the current key that maps to the current object

set_current(target)[source]

Set the current data

Parameters

key_or_id – A valid key or an int or the data

object itself

next(loop=False)[source]

Set the next data as current one

Parameters

loop – Whether looping is enabled, which means that if next value is out of range, we start back at 0

previous(loop=False)[source]

Set the previous data as current one

Parameters

loop – Whether looping is enabled, which means that if previous value is out of range, we go to -1 in a backward loop

store(data, data_id=None, replace_existing=True, set_current=False)[source]

Store a data

Parameters
  • data – data instance

  • data_id – data id, a unique string if possible. If it’s not a unique string, it will be appended a number so that it’s unique.

  • replace_existing – Whether any existing data with the same id is replaced or not

  • set_current – Whether the newly stored data is set as the current one

Returns

The new data_id or None

get_or_create(data_id, data_class=None)[source]

Get a data from a dictionary of data or create it if none found. This method works only with datas that have a name (str) property.

Parameters
  • data_id – Either a data name or its id

  • data_class – The class of the data

Returns

A data of type data_class

get_keys()[source]

Get all data ids

find_keys(id_or_subid)[source]

Get all ids/keys that have the given param as a substring

get_new_name(obj)[source]

Get a new name derived from an object’s class name :return: String

get_name(*args)[source]

Get given arguments separated by underscores as a single string :return: String