model.model.*¶
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 model.model.CellAttribute(selection: Selection, table: int, attr: AttrDict)[source]¶
Bases:
NamedTuple
Single cell attribute
Create new instance of CellAttribute(selection, table, attr)
- _asdict()¶
Return a new dict which maps field names to their values.
- _field_defaults = {}¶
- _fields = ('selection', 'table', 'attr')¶
- classmethod _make(iterable)¶
Make a new CellAttribute object from a sequence or iterable
- _replace(**kwds)¶
Return a new CellAttribute object replacing specified fields with new values
- class 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.- _attr_cache = {}¶
- _table_cache = {}¶
- append(cell_attribute)[source]¶
append that clears caches
- Parameters:
cell_attribute (
CellAttribute
) – Cell attribute to be appended
- class 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:
- _sorted_keys(keys, startkey, reverse=False)[source]¶
Generator that yields sorted keys starting with startkey
- 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 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:
- _adjust_cell_attributes(insertion_point, no_to_insert, axis, tab=None, cell_attrs=None)[source]¶
Adjusts cell attributes on insertion/deletion
- Parameters:
insertion_point (
int
) – Point on axis at which insertion takes placeno_to_insert (
int
) – Number of rows/cols/tabs to be inserted (>=0)axis (
int
) – Row insertion if 0, column insertion if 1, must be in 0, 1tab (
int
) – Table at which insertion takes place, None means all tablescell_attrs (
AttrDict
) – If given replaces the existing cell attributes
- _adjust_merge_area(attrs, insertion_point, no_to_insert, axis)[source]¶
Returns an updated merge area
- Parameters:
- Return type:
- _adjust_rowcol(insertion_point, no_to_insert, axis, tab=None)[source]¶
Adjusts row and column sizes on insertion/deletion
- _shift_rowcol(insertion_point, no_to_insert)[source]¶
Shifts row and column sizes when a table is inserted or deleted
- 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 model.model.DefaultCellAttributeDict[source]¶
Bases:
AttrDict
Holds default values for all cell attributes
- class 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.