pyspread.model package¶
Subpackages¶
- pyspread.model.test package
- Submodules
- pyspread.model.test.test_model module
- test_model
Settings
TestCellAttributes
TestCellAttributes.setup_method()
TestCellAttributes.test_append()
TestCellAttributes.test_for_table()
TestCellAttributes.test_get_merging_cell()
TestCellAttributes.test_getitem()
TestCellAttributes.test_len_table_cache()
TestCellAttributes.test_setitem()
TestCellAttributes.test_update_table_cache()
TestCodeArray
TestCodeArray.data_eval_cell
TestCodeArray.param_test_setitem
TestCodeArray.setup_method()
TestCodeArray.test_eval_cell()
TestCodeArray.test_execute_macros()
TestCodeArray.test_findnextmatch()
TestCodeArray.test_make_nested_list()
TestCodeArray.test_setitem()
TestCodeArray.test_slicing()
TestCodeArray.test_sorted_keys()
TestCodeArray.test_string_match()
TestDataArray
TestDataArray.param_adjust_cell_attributes
TestDataArray.param_adjust_rowcol
TestDataArray.param_get_last_filled_cell
TestDataArray.param_test_delete
TestDataArray.param_test_insert
TestDataArray.setup_method()
TestDataArray.test_adjust_cell_attributes()
TestDataArray.test_adjust_rowcol()
TestDataArray.test_cell_array_generator()
TestDataArray.test_delete()
TestDataArray.test_delete_error()
TestDataArray.test_get_last_filled_cell()
TestDataArray.test_get_shape()
TestDataArray.test_getstate()
TestDataArray.test_insert()
TestDataArray.test_iter()
TestDataArray.test_keys()
TestDataArray.test_pop()
TestDataArray.test_set_cell_attributes()
TestDataArray.test_set_col_width()
TestDataArray.test_set_row_height()
TestDataArray.test_set_shape()
TestDataArray.test_slicing()
TestDictGrid
TestKeyValueStore
- Module contents
Submodules¶
pyspread.model.model module¶
The model contains the core data structures of pyspread and is divided into the following layers.
Layer 3:
CodeArray
Layer 2:
DataArray
Layer 1:
DictGrid
Layer 0:
KeyValueStore
Provides
- class pyspread.model.model.CellAttribute(selection: Selection, table: int, attr: AttrDict)[source]¶
Bases:
NamedTuple
Single cell attribute
Create new instance of CellAttribute(selection, table, attr)
- class pyspread.model.model.CellAttributes(*args, **kwargs)[source]¶
Bases:
list
Stores cell formatting attributes in a list of CellAttribute instances
The class stores cell attributes as a list of layers. Each layer describes attributes for one selection in one table. Ultimately, a cell’s attributes are determined by going through all elements of an CellAttributes instance. A default AttrDict is updated with the one in the list element if it is relevant for the respective cell. Therefore, attributes are efficiently stored for large sets of cells.
The class provides attribute read access to single cells via
__getitem__()
. Otherwise it behaves similar to a list.- append(cell_attribute)[source]¶
append that clears caches
- Parameters:
cell_attribute (
CellAttribute
) – Cell attribute to be appended
- class pyspread.model.model.CodeArray(shape, settings)[source]¶
Bases:
DataArray
CodeArray provides objects when accessing cells via __getitem__
Cell code can be accessed via function call
This class represents layer 3 of the model.
- Parameters:
- exec_then_eval(code, _globals=None, _locals=None)[source]¶
execs multiline code and returns eval of last code line
- execute_macros()[source]¶
Executes all macros and returns result string and error string
Executes macros only when not in safe_mode
- findnextmatch(startkey, find_string, up=False, word=False, case=False, regexp=False, results=True)[source]¶
Returns tuple with position of the next match of find_string or None
- Parameters:
- Return type:
- frozen_cache = {}¶
- result_cache = {}¶
- safe_mode = False¶
- class pyspread.model.model.DataArray(shape, settings)[source]¶
Bases:
object
DataArray provides enhanced grid read/write access.
- Enhancements comprise:
Slicing
Multi-dimensional operations such as insertion and deletion along one axis
This class represents layer 2 of the model.
- Parameters:
- cell_array_generator(key)[source]¶
Generator traversing cells specified in key
Yields cells’ contents.
- property cell_attributes: CellAttributes¶
cell_attributes interface to dict_grid
- property col_widths: defaultdict¶
col_widths interface to dict_grid
- property data: dict¶
Returns dict of data content.
Data is the central content interface for loading / saving data.
It shall be used for loading and saving from and to .pys and other files.
It shall be used for loading and saving macros.
However, it is not used for importing and exporting data because these operations are partial to the grid.
Content of returned dict
- Parameters:
- delete(deletion_point, no_to_delete, axis, tab=None)[source]¶
Deletes no_to_delete rows/cols/… starting with deletion_point
- get_last_filled_cell(table=None)[source]¶
Returns key for the bottommost rightmost cell with content
- insert(insertion_point, no_to_insert, axis, tab=None)[source]¶
Inserts no_to_insert rows/cols/tabs/… before insertion_point
- property row_heights: defaultdict¶
row_heights interface to dict_grid
- class pyspread.model.model.DefaultCellAttributeDict[source]¶
Bases:
AttrDict
Holds default values for all cell attributes
- class pyspread.model.model.DictGrid(shape)[source]¶
Bases:
KeyValueStore
Core data class with all information that is stored in a .pys file.
Besides grid code access via standard dict operations, it provides the following attributes:
cell_attributes
- Stores cell formatting attributesmacros
- String of all macros
This class represents layer 1 of the model.