viscid.bucket module

class viscid.bucket.Bucket(ordered=False)[source]

Bases: object

This is basically a glorified dict

It’s a convenient dict-like object if you want lots of keys for a given value.

Note

You can add non-hashable items, but this is poorly tested. When adding / removing non-hashable items (items, not handles) the comparison is done using the object’s id. This is fundamentally different than using an object’s __hash__, but it should be fairly transparent.

contains_handle(handle)[source]
contains_item(item)[source]
get_primary_handles()[source]

Return a list of the first handles for all items

handle_string(prefix='')[source]

return string representation of handles and items

items()[source]
items_as_list()[source]
keys()[source]
print_tree(prefix='')[source]
remove_all_items()[source]

unload all items

remove_item(item)[source]
remove_item_by_handle(handle)[source]

remove item by handle, raises KeyError if handle is not found

remove_reference(item, _ref_count=1)[source]
set_item(handles, item, index_handle=True, _add_ref=False)[source]

if index_handle is true then the index of item will be included as a handle making the bucket indexable like a list

values()[source]