common.data#

Interface to interact with the item data cache.

All data loaded by the item models are stored in item_data. The module provides methods for the models to access, load and reset the cached data.

Functions:

data_count(key, task, data_type)

Number of items in the data dictionary.

get_data(key, task, data_type)

Get a cached data dict from item_data.

get_data_ref(key, task, data_type)

Get a data pointer from bookmarks.common.item_data cache.

get_ref_from_source_index(index)

Get a weakref pointer from source item model index.

get_task_data(key, task)

Get cached data from item_data.

is_data_loaded(key, task, data_type)

Checks if the cached is completely loaded.

reset_data(key, task)

Delete the requested data from the cache.

set_data(key, task, data_type, data)

Set data to bookmarks.common.item_data.

sort_data(ref, sort_by, sort_order)

Sort the given data using sort_by and sort_order.

bookmarks.common.data.data_count(key, task, data_type)[source]#

Number of items in the data dictionary.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

  • data_type (int) – One of FileItem or SequenceItem.

Returns:

The number of items in the data dictionary.

Return type:

int

bookmarks.common.data.get_data(key, task, data_type)[source]#

Get a cached data dict from item_data.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

  • data_type (int) – One of FileItem or SequenceItem.

Returns:

The cached data.

Return type:

common.DataDict

bookmarks.common.data.get_data_ref(key, task, data_type)[source]#

Get a data pointer from bookmarks.common.item_data cache.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

  • data_type (int) – One of bookmarks.common.FileItem or bookmarks.common.SequenceItem.

Returns:

Pointer to the requested data set.

Return type:

weakref.ref

bookmarks.common.data.get_ref_from_source_index(index)[source]#

Get a weakref pointer from source item model index.

bookmarks.common.data.get_task_data(key, task)[source]#

Get cached data from item_data.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

Returns:

The cached data.

Return type:

common.DataDict

bookmarks.common.data.is_data_loaded(key, task, data_type)[source]#

Checks if the cached is completely loaded.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

  • data_type (int) – One of FileItem or SequenceItem.

Returns:

True if loaded, false otherwise.

Return type:

bool

bookmarks.common.data.reset_data(key, task)[source]#

Delete the requested data from the cache.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

bookmarks.common.data.set_data(key, task, data_type, data)[source]#

Set data to bookmarks.common.item_data.

Parameters:
  • key (tuple) – A tuple of path segments.

  • task (str) – A task folder.

  • data_type (int) – One of bookmarks.common.FileItem or bookmarks.common.SequenceItem.

  • data (common.DataDict) – The data to set in the cache.

bookmarks.common.data.sort_data(ref, sort_by, sort_order)[source]#

Sort the given data using sort_by and sort_order.

Parameters:
  • ref (weakref.ref) – Pointer to a DataDict instance.

  • sort_by (int) – The role to use to sort the data.

  • sort_order (bool) – The sort order.

Returns:

A sorted copy of the source data.

Return type:

common.DataDict