datahold 3.1.0.dev4__tar.gz → 4.0.0a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/LICENSE.txt +1 -1
- datahold-4.0.0a0/MANIFEST.in +2 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/PKG-INFO +8 -6
- datahold-4.0.0a0/README.rst +7 -0
- datahold-4.0.0a0/docs/v1.1.rst +321 -0
- datahold-4.0.0a0/docs/v1.2.rst +349 -0
- datahold-4.0.0a0/docs/v2.0.rst +332 -0
- datahold-4.0.0a0/docs/v2.1.rst +367 -0
- datahold-4.0.0a0/docs/v2.2.rst +367 -0
- datahold-4.0.0a0/docs/v2.3.rst +475 -0
- datahold-4.0.0a0/docs/v3.0.rst +511 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/pyproject.toml +16 -5
- datahold-4.0.0a0/src/datahold/__init__.py +24 -0
- datahold-4.0.0a0/src/datahold/base/BaseDataDict.py +105 -0
- datahold-4.0.0a0/src/datahold/base/BaseDataList.py +80 -0
- datahold-4.0.0a0/src/datahold/base/BaseDataObject.py +61 -0
- datahold-4.0.0a0/src/datahold/base/BaseDataSet.py +198 -0
- datahold-4.0.0a0/src/datahold/base/BaseHoldDict.py +19 -0
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/base}/BaseHoldList.py +7 -3
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/base}/BaseHoldObject.py +2 -2
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/base}/BaseHoldSet.py +7 -3
- datahold-4.0.0a0/src/datahold/core/DataDict.py +115 -0
- datahold-4.0.0a0/src/datahold/core/DataList.py +110 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/core/DataObject.py +2 -2
- datahold-4.0.0a0/src/datahold/core/DataSet.py +132 -0
- datahold-4.0.0a0/src/datahold/core/HoldDict.py +32 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/core/HoldList.py +6 -5
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/core/HoldObject.py +2 -2
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/core/HoldSet.py +6 -5
- datahold-4.0.0a0/src/datahold/frozen/FrozenDataDict.py +13 -0
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/frozen}/FrozenDataList.py +4 -4
- datahold-4.0.0a0/src/datahold/frozen/FrozenDataObject.py +17 -0
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/frozen}/FrozenDataSet.py +4 -4
- datahold-4.0.0a0/src/datahold/frozen/FrozenHoldDict.py +27 -0
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/frozen}/FrozenHoldList.py +7 -6
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/frozen}/FrozenHoldObject.py +4 -3
- {datahold-3.1.0.dev4/src/datahold/core → datahold-4.0.0a0/src/datahold/frozen}/FrozenHoldSet.py +5 -4
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_0.py +1 -6
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestAbstractness.py +11 -18
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestCopy.py +3 -22
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestDataAttribute.py +5 -25
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestFrozenMutability.py +7 -18
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestInheritance.py +14 -33
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestMutableBehavior.py +1 -11
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_datahold_TestProtocols.py +3 -34
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/test_generic.py +1 -1
- datahold-4.0.0a0/src/datahold/tests/test_object.py +47 -0
- datahold-4.0.0a0/src/datahold/typing/SupportsKeysAndGetitem.py +13 -0
- datahold-4.0.0a0/src/datahold/typing/__init__.py +0 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold.egg-info/PKG-INFO +8 -6
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold.egg-info/SOURCES.txt +28 -25
- datahold-4.0.0a0/src/datahold.egg-info/requires.txt +5 -0
- datahold-3.1.0.dev4/MANIFEST.in +0 -1
- datahold-3.1.0.dev4/README.rst +0 -5
- datahold-3.1.0.dev4/src/datahold/__init__.py +0 -31
- datahold-3.1.0.dev4/src/datahold/_utils/wrapping.py +0 -91
- datahold-3.1.0.dev4/src/datahold/core/BaseDataDict.py +0 -129
- datahold-3.1.0.dev4/src/datahold/core/BaseDataList.py +0 -115
- datahold-3.1.0.dev4/src/datahold/core/BaseDataNaming.py +0 -117
- datahold-3.1.0.dev4/src/datahold/core/BaseDataObject.py +0 -14
- datahold-3.1.0.dev4/src/datahold/core/BaseDataSet.py +0 -155
- datahold-3.1.0.dev4/src/datahold/core/BaseHoldDict.py +0 -16
- datahold-3.1.0.dev4/src/datahold/core/BaseHoldNaming.py +0 -15
- datahold-3.1.0.dev4/src/datahold/core/DataDict.py +0 -106
- datahold-3.1.0.dev4/src/datahold/core/DataList.py +0 -142
- datahold-3.1.0.dev4/src/datahold/core/DataNaming.py +0 -95
- datahold-3.1.0.dev4/src/datahold/core/DataSet.py +0 -152
- datahold-3.1.0.dev4/src/datahold/core/FrozenDataDict.py +0 -16
- datahold-3.1.0.dev4/src/datahold/core/FrozenDataNaming.py +0 -20
- datahold-3.1.0.dev4/src/datahold/core/FrozenDataObject.py +0 -18
- datahold-3.1.0.dev4/src/datahold/core/FrozenHoldDict.py +0 -22
- datahold-3.1.0.dev4/src/datahold/core/FrozenHoldNaming.py +0 -21
- datahold-3.1.0.dev4/src/datahold/core/HoldDict.py +0 -27
- datahold-3.1.0.dev4/src/datahold/core/HoldNaming.py +0 -26
- datahold-3.1.0.dev4/src/datahold.egg-info/requires.txt +0 -6
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/setup.cfg +0 -0
- {datahold-3.1.0.dev4/src/datahold/_utils → datahold-4.0.0a0/src/datahold/core}/__init__.py +0 -0
- /datahold-3.1.0.dev4/src/datahold/core/__init__.py → /datahold-4.0.0a0/src/datahold/py.typed +0 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold/tests/__init__.py +0 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold.egg-info/dependency_links.txt +0 -0
- {datahold-3.1.0.dev4 → datahold-4.0.0a0}/src/datahold.egg-info/top_level.txt +0 -0
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datahold
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0a0
|
|
4
4
|
Summary: This project wraps common mutable datastructures for inheritance with modification.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,14 +15,14 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
17
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Typing :: Typed
|
|
18
19
|
Requires-Python: >=3.11
|
|
19
20
|
Description-Content-Type: text/x-rst
|
|
20
21
|
License-File: LICENSE.txt
|
|
21
22
|
Requires-Dist: cmp3<2,>=1.0
|
|
22
|
-
Requires-Dist: copyable<2,>=1.
|
|
23
|
-
Requires-Dist: datarepr<2,>=1.
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist: namings<2,>=1.0.dev0
|
|
23
|
+
Requires-Dist: copyable<2,>=1.1
|
|
24
|
+
Requires-Dist: datarepr<2,>=1.2
|
|
25
|
+
Requires-Dist: iterprod<2,>=1.1
|
|
26
26
|
Requires-Dist: setdoc<2,>=1.2.20
|
|
27
27
|
Dynamic: license-file
|
|
28
28
|
|
|
@@ -30,4 +30,6 @@ Dynamic: license-file
|
|
|
30
30
|
datahold
|
|
31
31
|
========
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Each minor version has its own documentation.
|
|
34
|
+
These docs can be found as rst-files in the ``docs/`` directory of this project.
|
|
35
|
+
They can also be viewed on the website `https://datahold.johannes-programming.online/ <https://datahold.johannes-programming.online/>`_.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
========
|
|
2
|
+
datahold
|
|
3
|
+
========
|
|
4
|
+
|
|
5
|
+
Each minor version has its own documentation.
|
|
6
|
+
These docs can be found as rst-files in the ``docs/`` directory of this project.
|
|
7
|
+
They can also be viewed on the website `https://datahold.johannes-programming.online/ <https://datahold.johannes-programming.online/>`_.
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
Overview
|
|
2
|
+
--------
|
|
3
|
+
|
|
4
|
+
This project wraps common mutable datastructures for inheritance with modification.
|
|
5
|
+
|
|
6
|
+
.. container:: warning
|
|
7
|
+
|
|
8
|
+
**Warning:** The major version ``1`` of ``datahold`` has reached end-of-life.
|
|
9
|
+
|
|
10
|
+
Links
|
|
11
|
+
-----
|
|
12
|
+
|
|
13
|
+
- Download: https://pypi.org/project/datahold/#files
|
|
14
|
+
- Index: https://pypi.org/project/datahold/
|
|
15
|
+
- Source: https://github.com/johannes-programming/datahold/
|
|
16
|
+
- Website: https://datahold.johannes-programming.online/
|
|
17
|
+
|
|
18
|
+
Installation
|
|
19
|
+
------------
|
|
20
|
+
|
|
21
|
+
To install ``datahold``, you can use ``pip``.
|
|
22
|
+
Open your terminal and run:
|
|
23
|
+
|
|
24
|
+
.. code-block:: shell
|
|
25
|
+
|
|
26
|
+
pip install datahold
|
|
27
|
+
|
|
28
|
+
Features
|
|
29
|
+
--------
|
|
30
|
+
|
|
31
|
+
``class datahold.HoldABC(*args: Any, **kwargs: Any)``
|
|
32
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
33
|
+
|
|
34
|
+
.. code-block:: python
|
|
35
|
+
|
|
36
|
+
class HoldABC(ABC):
|
|
37
|
+
|
|
38
|
+
__slots__ = ("_data",)
|
|
39
|
+
|
|
40
|
+
__hash__ = unhash
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def __init__(self: Self, *args: Any, **kwargs: Any) -> None:
|
|
44
|
+
"This magic method initializes self."
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def __subclasshook__(cls: type, other: type, /) -> bool:
|
|
49
|
+
"This magic classmethod can be overwritten for a custom subclass check."
|
|
50
|
+
return NotImplemented
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
@abstractmethod
|
|
54
|
+
def data(self: Self) -> Any: ...
|
|
55
|
+
|
|
56
|
+
``class datahold.HoldDict(*args: Any, **kwargs: Any)``
|
|
57
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
58
|
+
|
|
59
|
+
This class is a brute wrapper for ``dict``. It inherits from ``HoldABC`` and ``collections.abc.MutableMapping``. Its constructor passes all arguments to the constructor of ``dict`` and the result is saved within the ``data`` property.
|
|
60
|
+
|
|
61
|
+
``__contains__(key: Any, /) -> Any``
|
|
62
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
63
|
+
|
|
64
|
+
This magic method implements the ``in`` operator. Internally its code is equivalent to the following:
|
|
65
|
+
|
|
66
|
+
.. code-block:: python
|
|
67
|
+
|
|
68
|
+
def __contains__(self: Self, key: Any, /) -> Any:
|
|
69
|
+
"True if the dictionary has the specified key, else False."
|
|
70
|
+
data = self.data
|
|
71
|
+
ans = data.__contains__(*args, **kwargs)
|
|
72
|
+
self.data = data
|
|
73
|
+
return ans
|
|
74
|
+
|
|
75
|
+
The imprecise annotations and docstring are due to it adhering to the underlying ``dict.__contains__`` as closely as possible.
|
|
76
|
+
|
|
77
|
+
``__delitem__(key: Any, /) -> Any``
|
|
78
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
79
|
+
|
|
80
|
+
This magic method implements the deletion of items. Its inner workings are analogous to ``__contains__``.
|
|
81
|
+
|
|
82
|
+
``__eq__(value: Any, /) -> Any``
|
|
83
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
84
|
+
|
|
85
|
+
This magic method implements the ``==`` operator. Its inner workings are analogous to ``__contains__``.
|
|
86
|
+
|
|
87
|
+
``__format__(format_spec: Any, /) -> Any``
|
|
88
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
89
|
+
|
|
90
|
+
This magic method implements the inbuilt ``format`` function. Its inner workings are analogous to ``__contains__``.
|
|
91
|
+
|
|
92
|
+
``__ge__(value: Any, /) -> Any``
|
|
93
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
94
|
+
|
|
95
|
+
This magic method implements the ``>=`` operator. Its inner workings are analogous to ``__contains__``.
|
|
96
|
+
|
|
97
|
+
``__getitem__(key: Any, /) -> Any``
|
|
98
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
99
|
+
|
|
100
|
+
This magic method implements the returning of items. Its inner workings are analogous to ``__contains__``.
|
|
101
|
+
|
|
102
|
+
``__gt__(value: Any, /) -> Any``
|
|
103
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
104
|
+
|
|
105
|
+
This magic method implements the ``>`` operator. Its inner workings are analogous to ``__contains__``.
|
|
106
|
+
|
|
107
|
+
``__hash__() -> int``
|
|
108
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
109
|
+
|
|
110
|
+
This magic method implements the inbuilt function ``hash``. Its function is ``unhash.unhash``. It always raises a ``TypeError``.
|
|
111
|
+
|
|
112
|
+
``__ior__(value: Any, /) -> Any``
|
|
113
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
114
|
+
|
|
115
|
+
This magic method implements the ``|=`` operator. Its inner workings are analogous to ``__contains__``.
|
|
116
|
+
|
|
117
|
+
``__iter__() -> Any``
|
|
118
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
119
|
+
|
|
120
|
+
This magic method implements iteration. Its inner workings are analogous to ``__contains__``.
|
|
121
|
+
|
|
122
|
+
``__le__(value: Any, /) -> Any``
|
|
123
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
124
|
+
|
|
125
|
+
This magic method implements the ``<=`` operator. Its inner workings are analogous to ``__contains__``.
|
|
126
|
+
|
|
127
|
+
``__len__() -> Any``
|
|
128
|
+
^^^^^^^^^^^^^^^^^^^^
|
|
129
|
+
|
|
130
|
+
This magic method implements the inbuilt ``len`` function. Its inner workings are analogous to ``__contains__``.
|
|
131
|
+
|
|
132
|
+
``__lt__(value: Any, /) -> Any``
|
|
133
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
134
|
+
|
|
135
|
+
This magic method implements the ``<`` operator. Its inner workings are analogous to ``__contains__``.
|
|
136
|
+
|
|
137
|
+
``__or__(value: Any, /) -> Any``
|
|
138
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
139
|
+
|
|
140
|
+
This magic method implements the ``|`` operator. Its inner workings are analogous to ``__contains__``.
|
|
141
|
+
|
|
142
|
+
``__repr__() -> Any``
|
|
143
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
144
|
+
|
|
145
|
+
This magic method implements representation. Its inner workings are analogous to ``__contains__``.
|
|
146
|
+
|
|
147
|
+
``__reversed__() -> Any``
|
|
148
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
149
|
+
|
|
150
|
+
This magic method implements the inbuilt ``reversed`` function. Its inner workings are analogous to ``__contains__``.
|
|
151
|
+
|
|
152
|
+
``__ror__(value: Any, /) -> Any``
|
|
153
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
154
|
+
|
|
155
|
+
This magic method implements the ``|`` operator from the right side if the left operand does not have it implemented. Its inner workings are analogous to ``__contains__``.
|
|
156
|
+
|
|
157
|
+
``__setitem__(key: Any, value: Any, /) -> Any``
|
|
158
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
159
|
+
|
|
160
|
+
This magic method implements the setting of items. Its inner workings are analogous to ``__contains__``.
|
|
161
|
+
|
|
162
|
+
``__str__() -> Any``
|
|
163
|
+
^^^^^^^^^^^^^^^^^^^^
|
|
164
|
+
|
|
165
|
+
This magic method implements the explicit conversion into a string. Its inner workings are analogous to ``__contains__``.
|
|
166
|
+
|
|
167
|
+
``__subclasshook__(other: type, /) -> bool``
|
|
168
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
169
|
+
|
|
170
|
+
This classmethod is inherited directly from ``HoldABC``.
|
|
171
|
+
|
|
172
|
+
``clear() -> Any``
|
|
173
|
+
^^^^^^^^^^^^^^^^^^
|
|
174
|
+
|
|
175
|
+
This method deletes of all ``items``. Its inner workings are analogous to ``__contains__``.
|
|
176
|
+
|
|
177
|
+
``copy() -> Any``
|
|
178
|
+
^^^^^^^^^^^^^^^^^
|
|
179
|
+
|
|
180
|
+
This method implements dublication. Its inner workings are analogous to ``__contains__``. Remember that because of that a ``dict`` is returned.
|
|
181
|
+
|
|
182
|
+
``data: dict``
|
|
183
|
+
^^^^^^^^^^^^^^
|
|
184
|
+
|
|
185
|
+
This property is implemented with the equivalent to the following code:
|
|
186
|
+
|
|
187
|
+
.. code-block:: python
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def data(self: Self) -> dict:
|
|
191
|
+
return dict(self._data)
|
|
192
|
+
|
|
193
|
+
@data.setter
|
|
194
|
+
def data(self: Self, value: Any) -> None:
|
|
195
|
+
self._data = dict(value)
|
|
196
|
+
|
|
197
|
+
@data.deleter
|
|
198
|
+
def data(self: Self) -> None:
|
|
199
|
+
self._data = dict()
|
|
200
|
+
|
|
201
|
+
``get(key: Any, default: Any = None, /) -> Any``
|
|
202
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
203
|
+
|
|
204
|
+
This method implements getting an item with a ``default`` in case of its absence. Its inner workings are analogous to ``__contains__``.
|
|
205
|
+
|
|
206
|
+
``items() -> Any``
|
|
207
|
+
^^^^^^^^^^^^^^^^^^
|
|
208
|
+
|
|
209
|
+
This method returns an iterator over the ``items``. Its inner workings are analogous to ``__contains__``.
|
|
210
|
+
|
|
211
|
+
``keys() -> Any``
|
|
212
|
+
^^^^^^^^^^^^^^^^^
|
|
213
|
+
|
|
214
|
+
This method returns an iterator over the ``keys``. Its inner workings are analogous to ``__contains__``.
|
|
215
|
+
|
|
216
|
+
``popitem() -> Any``
|
|
217
|
+
^^^^^^^^^^^^^^^^^^^^
|
|
218
|
+
|
|
219
|
+
This method deletes and returns the last item. Its inner workings are analogous to ``__contains__``.
|
|
220
|
+
|
|
221
|
+
``setdefault(key: Any, default: Any = None, /) -> Any``
|
|
222
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
223
|
+
|
|
224
|
+
This method ensures the presence of a ``key``. Its inner workings are analogous to ``__contains__``.
|
|
225
|
+
|
|
226
|
+
``update(*args: Any, **kwargs: Any) -> Any``
|
|
227
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
228
|
+
|
|
229
|
+
This method updates the ``data``. Its inner workings are analogous to ``__contains__``.
|
|
230
|
+
|
|
231
|
+
``values() -> Any``
|
|
232
|
+
^^^^^^^^^^^^^^^^^^^
|
|
233
|
+
|
|
234
|
+
This method returns an iterator over the ``values``. Its inner workings are analogous to ``__contains__``.
|
|
235
|
+
|
|
236
|
+
``class datahold.HoldList(*args: Any, **kwargs: Any)``
|
|
237
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
238
|
+
|
|
239
|
+
This class is analogous to ``HoldDict``. It implements the magic methods ``__add__``, ``__contains__``, ``__delitem__``, ``__eq__``, ``__format__``, ``__ge__``, ``__getitem__``, ``__gt__``, ``__iadd__``, ``__imul__``, ``__iter__``, ``__le__``, ``__len__``, ``__lt__``, ``__mul__``, ``__repr__``, ``__reversed__``, ``__rmul__``, ``__setitem__``, and ``__str__``. The other methods implemented are ``append``, ``clear``, ``copy``, ``count``, ``extend``, ``index``, ``insert``, ``pop``, ``remove``, ``reverse``, and ``sort``. It is a child of ``HoldABC`` and of ``collections.abc.MutableSequence``, thereby also inheriting their members.
|
|
240
|
+
|
|
241
|
+
``class datahold.HoldSet(*args: Any, **kwargs: Any)``
|
|
242
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
243
|
+
|
|
244
|
+
This class is analogous to ``HoldDict``. It implements the magic methods ``__and__``, ``__contains__``, ``__eq__``, ``__format__``, ``__ge__``, ``__gt__``, ``__iand__``, ``__ior__``, ``__isub__``, ``__iter__``, ``__le__``, ``__len__``, ``__lt__``, ``__or__``, ``__rand__``, ``__repr__``, ``__ror__``, ``__rsub__``, ``__rxor__``, ``__str__``, ``__sub__``, ``__rmul__``, ``__sub__``, and ``__xor__``. The other methods implemented are ``add``, ``clear``, ``copy``, ``difference``, ``difference_update``, ``discard``, ``intersection``, ``intersection_update``, ``isdisjoint``, ``issubset``, ``issuperset``, ``pop``, ``remove``, ``symmetric_difference``, ``symmetric_difference_update``, ``union``, and ``update``. It is a child of ``HoldABC`` and of ``collections.abc.MutableSet``, thereby also inheriting their members.
|
|
245
|
+
|
|
246
|
+
``class datahold.OkayABC(*args: Any, **kwargs: Any)``
|
|
247
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
248
|
+
|
|
249
|
+
A common ABC for ``OkayList``, ``OkayDict``, and ``OkaySet``. Child of ``Scaevola`` and ``HoldABC``. It implements common-sense overwrites for some methods. For example:
|
|
250
|
+
|
|
251
|
+
- All methods that cannot actually change the underlying object are now bound to ``_data`` instead of ``data``.
|
|
252
|
+
- ``__bool__`` is implemented as ``bool(self._data)`` because neither ``list``, ``dict``, nor ``set`` have a ``__bool__`` method defined.
|
|
253
|
+
- The comparison operations are overwritten:
|
|
254
|
+
|
|
255
|
+
- ``__eq__`` returns ``self._data == type(self._data)(other)``.
|
|
256
|
+
- ``__ne__`` negates ``__eq__``.
|
|
257
|
+
- ``__ge__`` returns ``type(self)(other) <= self`` (inherited from ``scaevola.Scaevola``).
|
|
258
|
+
- ``__gt__`` returns ``not (self == other) and (self >= other)``.
|
|
259
|
+
- ``__lt__`` returns ``not (self == other) and (self <= other)``.
|
|
260
|
+
- ``__le__`` returns ``self._data <= type(self)(other)._data``.
|
|
261
|
+
|
|
262
|
+
- Modify ``__eq__`` or ``__le__`` as needed to change the behavior of the other comparison methods.
|
|
263
|
+
|
|
264
|
+
``class datahold.OkayDict(data: Iterable = (), /, **kwargs: Any)``
|
|
265
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
266
|
+
|
|
267
|
+
A subclass of ``HoldDict`` with common-sense implementations for further inheritance, just like ``OkayList`` for ``HoldList``.
|
|
268
|
+
|
|
269
|
+
``class datahold.OkayList(data: Iterable = ())``
|
|
270
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
271
|
+
|
|
272
|
+
This class inherits from ``HoldList`` and ``OkayABC``. It implements a ``data`` property that binds a variable ``_data``.
|
|
273
|
+
|
|
274
|
+
.. code-block:: python
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def data(self, /):
|
|
278
|
+
return list(self._data)
|
|
279
|
+
|
|
280
|
+
@data.setter
|
|
281
|
+
def data(self, values, /):
|
|
282
|
+
self._data = list(values)
|
|
283
|
+
|
|
284
|
+
@data.deleter
|
|
285
|
+
def data(self, /):
|
|
286
|
+
self._data = list()
|
|
287
|
+
|
|
288
|
+
Based on this, it implements common-sense methods. For example:
|
|
289
|
+
|
|
290
|
+
- All methods that returned a ``list`` before now return ``OkayList`` (type adapts to further inheritance).
|
|
291
|
+
- ``__init__`` allows setting data immediately.
|
|
292
|
+
|
|
293
|
+
``class datahold.OkaySet(data: Iterable = ())``
|
|
294
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
295
|
+
|
|
296
|
+
A subclass of ``HoldSet`` with common-sense implementations for further inheritance, just like ``OkayList`` for ``HoldList``.
|
|
297
|
+
|
|
298
|
+
``datahold.test() -> unittest.TextTestResult``
|
|
299
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
300
|
+
|
|
301
|
+
This project can be tested through its ``test`` function.
|
|
302
|
+
|
|
303
|
+
.. code-block:: python
|
|
304
|
+
|
|
305
|
+
import datahold
|
|
306
|
+
datahold.test()
|
|
307
|
+
|
|
308
|
+
License
|
|
309
|
+
-------
|
|
310
|
+
|
|
311
|
+
This project is licensed under the MIT License.
|
|
312
|
+
|
|
313
|
+
Impressum
|
|
314
|
+
---------
|
|
315
|
+
|
|
316
|
+
**Johannes Programming**
|
|
317
|
+
|
|
318
|
+
- Name: Johannes
|
|
319
|
+
- Email: johannes.programming@gmail.com
|
|
320
|
+
- Homepage: https://www.johannes-programming.online/
|
|
321
|
+
- Gravatar: https://www.johannes-programming.fyi/
|