collection

Module Contents

Classes

Attributes

class SingleObjectSaveLoad[source]
class DataStruct_Interface[source]
__str__()[source]

Return str(self).

class ListDataStruct_Interface[source]

Bases: DataStruct_Interface

get_list_attributes(attributeName)[source]

Get the value of attributeName of all the data in the Collection

Parameters:attributeName – string (name of the attribute to get)
Returns:list
class AutosaveStruct(dataStruct, filename='', change_filename_if_exists=True)[source]

Structure that provides automated save of DataStructures

__str__()[source]

Return str(self).

get_filename()[source]

Get set filename

set_filename(filename, change_filename_if_exists)[source]
Parameters:
  • filename – Filename to set
  • change_filename_if_exists – If already exists, create a new filename
stop_autosave()[source]

Stop autosave

start_autosave(timer_autosave, safe_save=True)[source]

Start autosave

save(safe_save=True)[source]

Save

get_datastruct()[source]

Return :class:’~DataStruct_Interface’

__getstate__()[source]
__setstate__(state)[source]
class ListDataStruct(compress_save=False)[source]

Bases: ListDataStruct_Interface

__len__()[source]
get_length()[source]
clone(filename)[source]

Clone the datastructure to a new location

save(filename)[source]

Save data using json format. The data to be saved are automatically detected, see obj_to_json()

extract_collection_from_indices(indices)[source]

Extract data from the collection at specific indices, and return it as new collection

_format_str_save()[source]

Save data using json format. The data to be saved are automatically detected, see obj_to_json()

_format_data_lines()[source]
_get_json_module_tree()[source]
add_data(data_in)[source]

Add a data to the list

get_data()[source]

Get full list of datas

get_data_generator()[source]

Get a generator to all the data stored

get_data_at_index(index)[source]
set_data(theData)[source]

Set full list of datas

set_data_at_index(data_in, index)[source]

Replace data at specific index

extract_collection_from_attribute(attributeName)[source]

Convenience class to create a sub-collection from an attribute of all the items.

Parameters:attributeName – Name of the attribute to extract
Returns:ListDataStruct
reset_data()[source]
delete_points_at_indices(indices)[source]

Delete several elements from the Collection

Parameters:indices – list of indices to delete
merge(collection)[source]

Merge a collection with the current collection

Parameters:collectionCollection to merge
get_nbr_elements()[source]
Returns:the number of elements contained inside the structure
theLock
class Performance_ListDataStruct(stack_size=500)[source]

Bases: ListDataStruct_Interface

_initialize(filename)[source]
_get_list_from_file(filenumber)[source]
extract_collection_from_indices(indices)[source]

Extract data from the collection at specific indices, and return it as new collection

clone(filename)[source]

Clone the datastructure to a new location

_get_str_mainfile()[source]
get_total_nbr_elements(count_unsaved=True)[source]
add_data(theData)[source]

Add data to the collection

add_json_data(theStr)[source]

Add already deserialized data to the collection

_save_moduletree(theDict)[source]
_map_index_to_file(index)[source]
_get_json_str_at_index(index, refresh_cache=False)[source]

Internal method to return the json string at index

get_attribute_value_at_index_fast(attribute, index)[source]

Experimental method to extract the value of an attribute without converting the string to an object. It is based on regex search, and will fail if the element is the last in string.

Parameters:
  • attribute – attribute to search
  • index – index of the element in collection
Returns:

reorder(permutations)[source]

Reorder collection accordingly to permutations. E.G, permutations [0,2,1] with collection elems [0,3,2] => collection elems = [0,2,3] :param permutations: :return: /

get_data_at_index(index, ignore_attributes=None, none_if_error=False)[source]

Same as parent, with additional kwargs

Parameters:
  • index
  • ignore_attributes – ignore attributes to deserialize (list)
  • none_if_error
Returns:

save(filename)[source]

Save the datastructure to filename

get_data_generator(**kwargs)[source]
get_nbr_elements()[source]
Returns:the number of elements contained inside the structure
set_data_at_index(data_in, index)[source]

Replace data at specific index

set_data_at_indices(data_list, indices)[source]

Replace datas at specific indices :param data_list: list of objects to set to the collection, at specific indices :param indices: list of indices :return:

delete_points_at_indices(indices)[source]

Delete several elements from the Collection

Parameters:indices – list of indices to delete