Main ReBASE module
| Author: | peter1000 |
|---|---|
| Github: | |
| Copyright: |
|
All `ReBASE classes - subclasses`:
Warning
for all ReBASE classes disabled methods
any class.copy()
- e.g.: xy = myrlist.copy()
any class.clear()
- e.g.: myrlist.clear()
any __setattr__()
any __delattr__()
any __add__()
can be dumped with json: but will lose any extra data like: key_order (list) or/and any extra_data dict
can be pickled
additional methods:
set_extra_data(), update_extra_data(), replace_extra_data(): Sets/updates key/value to the additional dictionary: extra_data
copy_recursively(): recursively copy: Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)
- this will also copy any ReDICT / ReLIST / ReTUPLE / ReMATRIX extra_data dict and any key_order (list) and any extra_key_order (list)
copy_recursively_to_python_native_types(): recursively copy: changing all ReOBJ to native python types.
RdictIO, RdictFO, RdictFO2: to python `OrderedDict obj keeping their order (see also argument: use_extra_key_order)
all other ReDICT: objects will be replaced by normal python dict objs
all ReLIST obj will be replaced by normal python list objs
all ReTUPLE obj will be replaced by normal python tuple objs
all ReMATRIX obj will be replaced by normal python list of tuple objs
Warning
ReMATRIX tuple items (rows) are not recursively copied so there should be no dict, list ect.. just basic types
Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)
Note
any ReOBJ set: extra_data will be lost
topickle(): returns a new pickled dumps byte string from the obj
tojson(): returns a new json dumps string from the obj
tojson_keeporder(): returns a new json dumps string from the obj keeping the order of any RdictIO, RdictFO, RdictFO2
- this uses first the: copy_recursively_to_python_native_types()
Warning
comparisons do not take into consideration any key_order (list) or extra_data dict
Bases: ReOBJ.MainCode.ReBase, builtins.dict
An extended dictionary: E(xtended) like a normal python dict but with the additional methods of the ReBase class
| Raises: | ReOBJ.ProjectErr.Err – |
|---|
Create a new Edict from a pickled dumps.
| Returns: | a new Rdict object |
|---|---|
| Return type: | obj |
Bases: ReOBJ.MainCode.ReBase, builtins.list
An extended list: E(xtended) like a normal python list but with the additional methods of the ReBase class
| Raises: | ReOBJ.ProjectErr.Err – |
|---|
Create a new Elist from a pickled dumps.
| Returns: | a new Elist object |
|---|---|
| Return type: | obj |
Bases: ReOBJ.MainCode.ReBase, builtins.tuple
An extended tuple: E(xtended) like a normal python tuple but with the additional methods of the ReBase class
| Raises: | ReOBJ.ProjectErr.Err – |
|---|
Create a new Etuple from a pickled dumps.
| Returns: | a new Etuple object |
|---|---|
| Return type: | obj |
Bases: ReOBJ.MainCode.ReBase, builtins.list
An extended MATRIX (List-Of-Tuples): E(xtended) with the additional methods of the ReBase class
Tuple items (rows) should only be simple objects: no nested list, dictionary: this is not enforces but not all other methods support such:
e.g.: copy_recursively_to_python_native_types()
| Raises: | ReOBJ.ProjectErr.Err – |
|---|
Called to implement assignment to self[idx].
| Raises: | IndexError – : if out of idx |
|---|
Append row_tuple
Extend row_tuple
Create a new Lmatrix from a pickled dumps.
| Returns: | a new Lmatrix object |
|---|---|
| Return type: | obj |
Insert row_tuple
Replaces the column_names (tuple) with the new_column_names_tuple
| Parameters: | new_column_names_tuple (tuple) – must have the same number of names as the current column_names |
|---|---|
| Raises: | ReOBJ.Err – |
Sets/updates key/value to the additional dictionary: extra_data
Returns the items of all rows for the column
| Returns: | all items of the column for all rows |
|---|---|
| Return type: | list |
Updates/Extends the additional dictionary: extra_data
Bases: ReOBJ.MainCode.Lmatrix
A restricted MATRIX (List-Of-Tuples): F(ix)
Similar to Lmatrix but after creation/initialization no new items can be added There are some other differences too.
This is quite similar to using a Tuple-of-Tuples: but we keep it a subclass of Lmatrix
Tuple items should only be simple objects: no nested list, dictionary: this is not enforces but not all other methods support such:
e.g.: copy_recursively_to_python_native_types()
| Raises: | ReOBJ.ProjectErr.Err – |
|---|
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Create a new LmatrixF from a pickled dumps.
| Returns: | a new LmatrixF object |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Bases: ReOBJ.MainCode.ReBase, builtins.dict
A restricted dictionary:
| Raises: | MethodDeactivatedErr, KeyError, AttributeError, ReOBJ.ProjectErr.Err – |
|---|
Return state information for pickling
Create a new Rdict with keys from key_name_list and values set to value.
| Returns: | a new Rdict object |
|---|---|
| Return type: | obj |
Create a new Rdict from a pickled dumps.
| Returns: | a new Rdict object |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Bases: ReOBJ.MainCode.Rdict
A restricted dictionary: F(ix)
Similar to Rdict but after creation/initialization no new keys can be added There are some other differences too.
| Raises: | MethodDeactivatedErr, KeyError, AttributeError, ReOBJ.ProjectErr.Err – |
|---|
Called to implement assignment to self[key].
Restriction: after RdictF creation no new keys can be set.
| Raises: | KeyError – if key is not found |
|---|
Create a new RdictF from a pickled dumps.
| Returns: | a new RdictF object |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Bases: ReOBJ.MainCode.RdictIO
A restricted dictionary: F(ix) O(rder)
Similar to RdictIO but after creation/initialization no new keys can be added There are some other differences too.
can only be initialized but is fix afterwards: key_order list has the key order as in the key_value_list argument
new keys can not be added
item values can be changed
Note
keep in mind that values might be tuples: depending ont tuple_values
item can not be deleted
for arguments see: RdictIO()
| Raises: | MethodDeactivatedErr, KeyError, AttributeError, ReOBJ.ProjectErr.Err – |
|---|
Called to implement assignment to self[key].
Restriction: after RdictFO creation no new keys can be set.
| Raises: | KeyError – if key is not found |
|---|
Create a new RdictFO from a pickled dumps.
| Returns: | a new RdictFO object |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Bases: ReOBJ.MainCode.RdictFO
A restricted dictionary: F(ix) O(rder)
Similar to RdictFO but after creation/initialization values can not be changed
for arguments see: RdictIO()
| Raises: | MethodDeactivatedErr, KeyError, AttributeError, ReOBJ.ProjectErr.Err – |
|---|
Create a new RdictFO2 from a pickled dumps.
| Returns: | a new RdictFO2 object |
|---|---|
| Return type: | obj |
Bases: ReOBJ.MainCode.Rdict
A restricted dictionary: I(nsertion) O(rder)
Similar to Rdict but the order of the keys insertion are tracked in a list: key_order There are some other differences too.
new keys can be added
item values can be changed
Note
keep in mind that values might be tuples: depending ont tuple_values
item can not be deleted
| Parameters: |
|
|---|---|
| Raises: | MethodDeactivatedErr, KeyError, AttributeError, ReOBJ.ProjectErr.Err – |
Return state information for pickling
Called to implement assignment to self[key].
NOTE: Speedtest: defining __setitem__ is the main slowdown
Appends the new_key with the the user defined extra_key_order (list)
| Parameters: | new_key (obj) – append a new key to the user defined keys order (may be also just a subset of the RdictIO keys) |
|---|---|
| Raises: | ReOBJ.Err: if the `new_key` is not found in the default `key_order (list)` – |
Helper method used to raise MethodDeactivatedErr
Create a new RdictIO from a pickled dumps.
| Returns: | a new RdictIO object |
|---|---|
| Return type: | obj |
Replaces the extra_key_order (list) with the new_extra_key_order
| Parameters: | new_extra_key_order_list (list) – user defined keys order (may be also just a subset of the RdictIO keys) |
|---|---|
| Raises: | ReOBJ.Err: if any key from new_extra_key_order is not found in the default `key_order (list)` – |
Sets/updates key/value to the additional dictionary: extra_data
Updates/Extends the additional dictionary: extra_data
Returns a generator: (keys, values) over the extra_key_order (list)
| Yields: | (keys, value) in the order of the extra_key_order (list) |
|---|
Returns a generator: (keys, values) over the key_order (list)
| Yields: | (keys, value) in the order of the key_order (list) |
|---|
Bases: builtins.object
Common Base of ReOBJ
| Raises: | MethodDeactivatedErr, KeyError, AttributeError, ReOBJ.ProjectErr.Err – |
|---|
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Create a recursively copy of the ReOBJ obj
copy_recursively(): recursively copy: Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)
- this will also copy any ReDICT / ReLIST / ReTUPLE / ReMATRIX extra_data dict and any key_order (list) and any extra_key_order (list)
| Returns: | copy of the ReOBJ
|
|---|---|
| Return type: | obj |
Return a recursively copy: changing all ReOBJ to native python types.
Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)
Note
any ReOBJ set: extra_data will be lost
| Returns: | recursive copy of the obj with ReOBJs replaced by python native objs |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Replaces the extra_data (dict) with the dict
if extra_data did not exist it will be created
Sets/updates key/value to the additional dictionary: extra_data
In subclasses which use and init which sets always extra_data this method should be overwritten removing the: if
Returns a new json dumps string from the obj
- If ensure_ascii is True, the output is guaranteed to have all incoming non-ASCII characters escaped.
- If ensure_ascii is False, these characters will be output as-is.
| Returns: | a pickled ReOBJ dumps |
|---|---|
| Return type: | bytes |
Returns a new json dumps string from the obj keeping the order using first: copy_recursively_to_python_native_types()
RdictIO, RdictFO, RdictFO2: will keep their order (see also argument: use_extra_key_order)
- if True: the OrderedDict will be based on the extra_key_order (list)
- if False: it will be base on the default key_order (list)
| Returns: | a pickled ReOBJ dumps |
|---|---|
| Return type: | bytes |
Returns a new pickled dumps byte string from the obj
| Returns: | a pickled ReOBJ dumps |
|---|---|
| Return type: | bytes |
Updates/Extends the additional dictionary: extra_data
In subclasses which use and init which sets always extra_data this method should be overwritten removing the: if
Bases: ReOBJ.MainCode.ReBase, builtins.list
A restricted list:
| Raises: | MethodDeactivatedErr, ReOBJ.ProjectErr.Err – |
|---|
Create a new Rlist from a pickled dumps.
| Returns: | a new Rlist object |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Bases: ReOBJ.MainCode.Rlist
A restricted list: F(ix)
Similar to Rlist but after creation/initialization no new items can be added There are some other differences too.
| Raises: | MethodDeactivatedErr, ReOBJ.ProjectErr.Err – |
|---|
Helper method used to raise MethodDeactivatedErr
Helper method used to raise MethodDeactivatedErr
Create a new RlistF from a pickled dumps.
| Returns: | a new RlistF object |
|---|---|
| Return type: | obj |
Helper method used to raise MethodDeactivatedErr
Project Error
Bases: builtins.Exception
Prints an own raised ProjectError
| Parameters: |
|
|---|
Bases: builtins.Exception
Prints an own raised Deactivated Err
Version And Diverse Info
__version__ str - the released version (last release)
RELEASE_DATE str - the date of the last release
SHORT_VERSION str - the main version is the: __version__ stripped of the last part: e.g. used by sphinx conf.py
TESTED_HOST_OS str - Keeps track of the HOST SYSTEM used to develop/test
__title__ str -
__copyright__ str -
__license__ str -
__author__ str -
(c) 2014 peter1000 https://github.com/peter1000 All Rights Reserved
ReOBJ is distributed under the terms of the BSD 3-clause license. Consult LICENSE.rst or http://opensource.org/licenses/BSD-3-Clause.