datahold 3.1.0.dev4__tar.gz → 4.0.0.dev0__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.
Files changed (66) hide show
  1. datahold-4.0.0.dev0/MANIFEST.in +2 -0
  2. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/PKG-INFO +5 -4
  3. datahold-4.0.0.dev0/README.rst +7 -0
  4. datahold-4.0.0.dev0/docs/v1.1.rst +314 -0
  5. datahold-4.0.0.dev0/docs/v1.2.rst +343 -0
  6. datahold-4.0.0.dev0/docs/v2.0.rst +325 -0
  7. datahold-4.0.0.dev0/docs/v2.1.rst +363 -0
  8. datahold-4.0.0.dev0/docs/v2.2.rst +362 -0
  9. datahold-4.0.0.dev0/docs/v2.3.rst +464 -0
  10. datahold-4.0.0.dev0/docs/v3.0.rst +417 -0
  11. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/pyproject.toml +2 -3
  12. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/__init__.py +0 -7
  13. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseDataDict.py +2 -18
  14. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseDataList.py +0 -15
  15. datahold-4.0.0.dev0/src/datahold/core/BaseDataObject.py +24 -0
  16. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseDataSet.py +0 -15
  17. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseHoldDict.py +2 -3
  18. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/DataDict.py +11 -11
  19. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenDataDict.py +2 -3
  20. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenHoldDict.py +3 -3
  21. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/HoldDict.py +4 -4
  22. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_0.py +0 -5
  23. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestAbstractness.py +0 -8
  24. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestCopy.py +0 -19
  25. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestDataAttribute.py +2 -22
  26. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestFrozenMutability.py +1 -12
  27. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestInheritance.py +0 -19
  28. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestMutableBehavior.py +1 -11
  29. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_datahold_TestProtocols.py +0 -31
  30. datahold-4.0.0.dev0/src/datahold/tests/test_object.py +41 -0
  31. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold.egg-info/PKG-INFO +5 -4
  32. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold.egg-info/SOURCES.txt +9 -7
  33. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold.egg-info/requires.txt +1 -2
  34. datahold-3.1.0.dev4/MANIFEST.in +0 -1
  35. datahold-3.1.0.dev4/README.rst +0 -5
  36. datahold-3.1.0.dev4/src/datahold/core/BaseDataNaming.py +0 -117
  37. datahold-3.1.0.dev4/src/datahold/core/BaseDataObject.py +0 -14
  38. datahold-3.1.0.dev4/src/datahold/core/BaseHoldNaming.py +0 -15
  39. datahold-3.1.0.dev4/src/datahold/core/DataNaming.py +0 -95
  40. datahold-3.1.0.dev4/src/datahold/core/FrozenDataNaming.py +0 -20
  41. datahold-3.1.0.dev4/src/datahold/core/FrozenHoldNaming.py +0 -21
  42. datahold-3.1.0.dev4/src/datahold/core/HoldNaming.py +0 -26
  43. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/LICENSE.txt +0 -0
  44. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/setup.cfg +0 -0
  45. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/_utils/__init__.py +0 -0
  46. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/_utils/wrapping.py +0 -0
  47. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseHoldList.py +0 -0
  48. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseHoldObject.py +0 -0
  49. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/BaseHoldSet.py +0 -0
  50. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/DataList.py +0 -0
  51. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/DataObject.py +0 -0
  52. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/DataSet.py +0 -0
  53. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenDataList.py +0 -0
  54. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenDataObject.py +0 -0
  55. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenDataSet.py +0 -0
  56. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenHoldList.py +0 -0
  57. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenHoldObject.py +0 -0
  58. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/FrozenHoldSet.py +0 -0
  59. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/HoldList.py +0 -0
  60. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/HoldObject.py +0 -0
  61. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/HoldSet.py +0 -0
  62. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/core/__init__.py +0 -0
  63. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/__init__.py +0 -0
  64. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold/tests/test_generic.py +0 -0
  65. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold.egg-info/dependency_links.txt +0 -0
  66. {datahold-3.1.0.dev4 → datahold-4.0.0.dev0}/src/datahold.egg-info/top_level.txt +0 -0
@@ -0,0 +1,2 @@
1
+ recursive-include docs *.rst
2
+ recursive-include src/datahold *.toml
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datahold
3
- Version: 3.1.0.dev4
3
+ Version: 4.0.0.dev0
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
@@ -21,8 +21,7 @@ License-File: LICENSE.txt
21
21
  Requires-Dist: cmp3<2,>=1.0
22
22
  Requires-Dist: copyable<2,>=1.0
23
23
  Requires-Dist: datarepr<2,>=1.0
24
- Requires-Dist: frozendict<3,>=2.4.6
25
- Requires-Dist: namings<2,>=1.0.dev0
24
+ Requires-Dist: iterprod<2,>=1.0
26
25
  Requires-Dist: setdoc<2,>=1.2.20
27
26
  Dynamic: license-file
28
27
 
@@ -30,4 +29,6 @@ Dynamic: license-file
30
29
  datahold
31
30
  ========
32
31
 
33
- Visit the website `https://datahold.johannes-programming.online/ <https://datahold.johannes-programming.online/>`_ for more information.
32
+ Each minor version has its own documentation.
33
+ These docs can be found as rst-files in the ``docs/`` directory of this project.
34
+ 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,314 @@
1
+ Overview
2
+ --------
3
+
4
+ This project wraps common mutable datastructures for inheritance with modification.
5
+
6
+ Links
7
+ -----
8
+
9
+ - Download: https://pypi.org/project/datahold/#files
10
+ - Index: https://pypi.org/project/datahold/
11
+ - Source: https://github.com/johannes-programming/datahold/
12
+ - Website: https://datahold.johannes-programming.online/
13
+
14
+ Installation
15
+ ------------
16
+
17
+ To install datahold, you can use pip. Open your terminal and run:
18
+
19
+ .. code-block:: shell
20
+
21
+ pip install datahold
22
+
23
+ Features
24
+ --------
25
+
26
+ ``class datahold.HoldABC(*args: Any, **kwargs: Any)``
27
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28
+
29
+ .. code-block:: python
30
+
31
+ class HoldABC(ABC):
32
+
33
+ __slots__ = ("_data",)
34
+
35
+ __hash__ = unhash
36
+
37
+ @abstractmethod
38
+ def __init__(self: Self, *args: Any, **kwargs: Any) -> None:
39
+ "This magic method initializes self."
40
+ ...
41
+
42
+ @classmethod
43
+ def __subclasshook__(cls: type, other: type, /) -> bool:
44
+ "This magic classmethod can be overwritten for a custom subclass check."
45
+ return NotImplemented
46
+
47
+ @property
48
+ @abstractmethod
49
+ def data(self: Self) -> Any: ...
50
+
51
+ ``class datahold.HoldDict(*args: Any, **kwargs: Any)``
52
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53
+
54
+ 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.
55
+
56
+ ``__contains__(key: Any, /) -> Any``
57
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58
+
59
+ This magic method implements the in operator. Internally its code is equivalent to the following:
60
+
61
+ .. code-block:: python
62
+
63
+ def __contains__(self: Self, key: Any, /) -> Any:
64
+ "True if the dictionary has the specified key, else False."
65
+ data = self.data
66
+ ans = data.__contains__(*args, **kwargs)
67
+ self.data = data
68
+ return ans
69
+
70
+ The imprecise annotations and docstring are due to it adhering to the underlying dict.__contains__ as closely as possible.
71
+
72
+ ``__delitem__(key: Any, /) -> Any``
73
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74
+
75
+ This magic method implements the deletion of items. Its inner workings are analogous to __contains__ .
76
+
77
+ ``__eq__(value: Any, /) -> Any``
78
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79
+
80
+ This magic method implements the == operator. Its inner workings are analogous to __contains__ .
81
+
82
+ ``__format__(format_spec: Any, /) -> Any``
83
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84
+
85
+ This magic method implements the inbuilt format function. Its inner workings are analogous to __contains__ .
86
+
87
+ ``__ge__(value: Any, /) -> Any``
88
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89
+
90
+ This magic method implements the >= operator. Its inner workings are analogous to __contains__ .
91
+
92
+ ``__getitem__(key: Any, /) -> Any``
93
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94
+
95
+ This magic method implements the returning of items. Its inner workings are analogous to __contains__ .
96
+
97
+ ``__gt__(value: Any, /) -> Any``
98
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
+
100
+ This magic method implements the > operator. Its inner workings are analogous to __contains__ .
101
+
102
+ ``__hash__() -> int``
103
+ ^^^^^^^^^^^^^^^^^^^^^
104
+
105
+ This magic method implements the inbuilt function hash. Its function is unhash.unhash . It always raises a TypeError.
106
+
107
+ ``__ior__(value: Any, /) -> Any``
108
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
109
+
110
+ This magic method implements the ``|=`` operator. Its inner workings are analogous to __contains__ .
111
+
112
+ ``__iter__() -> Any``
113
+ ^^^^^^^^^^^^^^^^^^^^^
114
+
115
+ This magic method implements iteration. Its inner workings are analogous to __contains__ .
116
+
117
+ ``__le__(value: Any, /) -> Any``
118
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119
+
120
+ This magic method implements the <= operator. Its inner workings are analogous to __contains__ .
121
+
122
+ ``__len__() -> Any``
123
+ ^^^^^^^^^^^^^^^^^^^^
124
+
125
+ This magic method implements the inbuilt len function. Its inner workings are analogous to __contains__ .
126
+
127
+ ``__lt__(value: Any, /) -> Any``
128
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129
+
130
+ This magic method implements the < operator. Its inner workings are analogous to __contains__ .
131
+
132
+ ``__or__(value: Any, /) -> Any``
133
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134
+
135
+ This magic method implements the | operator. Its inner workings are analogous to __contains__ .
136
+
137
+ ``__repr__() -> Any``
138
+ ^^^^^^^^^^^^^^^^^^^^^
139
+
140
+ This magic method implements representation. Its inner workings are analogous to __contains__ .
141
+
142
+ ``__reversed__() -> Any``
143
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
144
+
145
+ This magic method implements the inbuilt reversed function. Its inner workings are analogous to __contains__ .
146
+
147
+ ``__ror__(value: Any, /) -> Any``
148
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149
+
150
+ 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__ .
151
+
152
+ ``__setitem__(key: Any, value: Any, /) -> Any``
153
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154
+
155
+ This magic method implements the setting of items. Its inner workings are analogous to __contains__ .
156
+
157
+ ``__str__() -> Any``
158
+ ^^^^^^^^^^^^^^^^^^^^
159
+
160
+ This magic method implements the explicit conversion into a string. Its inner workings are analogous to __contains__ .
161
+
162
+ ``__subclasshook__(other: type, /) -> bool``
163
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164
+
165
+ This classmethod is inherited directly from HoldABC.
166
+
167
+ ``clear() -> Any``
168
+ ^^^^^^^^^^^^^^^^^^
169
+
170
+ This method deletes of all items. Its inner workings are analogous to __contains__ .
171
+
172
+ ``copy() -> Any``
173
+ ^^^^^^^^^^^^^^^^^
174
+
175
+ This method implements dublication. Its inner workings are analogous to __contains__ . Remember that because of that a dict is returned.
176
+
177
+ ``data: dict``
178
+ ^^^^^^^^^^^^^^
179
+
180
+ This property is implemented with the equivalent to the following code:
181
+
182
+ .. code-block:: python
183
+
184
+ @property
185
+ def data(self: Self) -> dict:
186
+ return dict(self._data)
187
+
188
+ @data.setter
189
+ def data(self: Self, value: Any) -> None:
190
+ self._data = dict(value)
191
+
192
+ @data.deleter
193
+ def data(self: Self) -> None:
194
+ self._data = dict()
195
+
196
+ ``get(key: Any, default: Any = None, /) -> Any``
197
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198
+
199
+ This method implements getting an item with a default in case of its absence. Its inner workings are analogous to __contains__ .
200
+
201
+ ``items() -> Any``
202
+ ^^^^^^^^^^^^^^^^^^
203
+
204
+ This method returns an iterator over the items. Its inner workings are analogous to __contains__ .
205
+
206
+ ``keys() -> Any``
207
+ ^^^^^^^^^^^^^^^^^
208
+
209
+ This method returns an iterator over the keys. Its inner workings are analogous to __contains__ .
210
+
211
+ ``popitem() -> Any``
212
+ ^^^^^^^^^^^^^^^^^^^^
213
+
214
+ This method deletes and returns the last item. Its inner workings are analogous to __contains__ .
215
+
216
+ ``setdefault(key: Any, default: Any = None, /) -> Any``
217
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218
+
219
+ This method ensures the presence of a key. Its inner workings are analogous to __contains__ .
220
+
221
+ ``update(*args: Any, **kwargs: Any) -> Any``
222
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
223
+
224
+ This method updates the data. Its inner workings are analogous to __contains__ .
225
+
226
+ ``values() -> Any``
227
+ ^^^^^^^^^^^^^^^^^^^
228
+
229
+ This method returns an iterator over the values. Its inner workings are analogous to __contains__ .
230
+
231
+ ``class datahold.HoldList(*args: Any, **kwargs: Any)``
232
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233
+
234
+ 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.
235
+
236
+ ``class datahold.HoldSet(*args: Any, **kwargs: Any)``
237
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
238
+
239
+ 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.
240
+
241
+ ``class datahold.OkayABC(*args: Any, **kwargs: Any)``
242
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243
+
244
+ A common ABC for OkayList, OkayDict, and OkaySet. Child of Scaevola and HoldABC. It implements common-sense overwrites for some methods. For example:
245
+
246
+ All methods that cannot actually change the underlying object are now bound to _data instead of data.
247
+ __bool__ is implemented as bool(self._data) because neither list, dict, nor set have a __bool__ method defined.
248
+ The comparison operations are overwritten:
249
+ __eq__ returns self._data == type(self._data)(other).
250
+ __ne__ negates __eq__.
251
+ __ge__ returns type(self)(other) <= self (inherited from scaevola.Scaevola).
252
+ __gt__ returns not (self == other) and (self >= other).
253
+ __lt__ returns not (self == other) and (self <= other).
254
+ __le__ returns self._data <= type(self)(other)._data.
255
+ Modify __eq__ or __le__ as needed to change the behavior of the other comparison methods.
256
+
257
+ ``class datahold.OkayDict(data: Iterable = (), /, **kwargs: Any)``
258
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259
+
260
+ A subclass of HoldDict with common-sense implementations for further inheritance, just like OkayList for HoldList.
261
+
262
+ ``class datahold.OkayList(data: Iterable = ())``
263
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
264
+
265
+ This class inherits from HoldList and OkayABC. It implements a data property that binds a variable _data.
266
+
267
+ .. code-block:: python
268
+
269
+ @property
270
+ def data(self, /):
271
+ return list(self._data)
272
+
273
+ @data.setter
274
+ def data(self, values, /):
275
+ self._data = list(values)
276
+
277
+ @data.deleter
278
+ def data(self, /):
279
+ self._data = list()
280
+
281
+ Based on this, it implements common-sense methods. For example:
282
+
283
+ All methods that returned a list before now return OkayList (type adapts to further inheritance).
284
+ __init__ allows setting data immediately.
285
+
286
+ ``class datahold.OkaySet(data: Iterable = ())``
287
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288
+
289
+ A subclass of HoldSet with common-sense implementations for further inheritance, just like OkayList for HoldList.
290
+
291
+ ``datahold.test() -> unittest.TextTestResult``
292
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293
+
294
+ This project can be tested through its test function.
295
+
296
+ .. code-block:: python
297
+
298
+ import datahold
299
+ datahold.test()
300
+
301
+ License
302
+ -------
303
+
304
+ This project is licensed under the MIT License.
305
+
306
+ Impressum
307
+ ---------
308
+
309
+ **Johannes Programming**
310
+
311
+ - Name: Johannes
312
+ - Email: johannes.programming@gmail.com
313
+ - Homepage: https://www.johannes-programming.online/
314
+ - Gravatar: https://www.johannes-programming.fyi/
@@ -0,0 +1,343 @@
1
+ Overview
2
+ --------
3
+
4
+ This project wraps common mutable datastructures for inheritance with modification.
5
+
6
+ Links
7
+ -----
8
+
9
+ - Download: https://pypi.org/project/datahold/#files
10
+ - Index: https://pypi.org/project/datahold/
11
+ - Source: https://github.com/johannes-programming/datahold/
12
+ - Website: https://datahold.johannes-programming.online/
13
+
14
+ Installation
15
+ ------------
16
+
17
+ To install datahold, you can use pip. Open your terminal and run:
18
+
19
+ .. code-block:: shell
20
+
21
+ pip install datahold
22
+
23
+ Features
24
+ --------
25
+
26
+ ``class datahold.DataABC``
27
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
28
+
29
+ .. container:: versionadded
30
+
31
+ **Added in version 1.2.**
32
+
33
+ ``class datahold.DataDict``
34
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
35
+
36
+ .. container:: versionadded
37
+
38
+ **Added in version 1.2.**
39
+
40
+ ``class datahold.DataList``
41
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
42
+
43
+ .. container:: versionadded
44
+
45
+ **Added in version 1.2.**
46
+
47
+ ``class datahold.DataSet``
48
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
49
+
50
+ .. container:: versionadded
51
+
52
+ **Added in version 1.2.**
53
+
54
+ ``class datahold.HoldABC(*args: Any, **kwargs: Any)``
55
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
+
57
+ .. code-block:: python
58
+
59
+ class HoldABC(ABC):
60
+
61
+ __slots__ = ("_data",)
62
+
63
+ __hash__ = unhash
64
+
65
+ @abstractmethod
66
+ def __init__(self: Self, *args: Any, **kwargs: Any) -> None:
67
+ "This magic method initializes self."
68
+ ...
69
+
70
+ @classmethod
71
+ def __subclasshook__(cls: type, other: type, /) -> bool:
72
+ "This magic classmethod can be overwritten for a custom subclass check."
73
+ return NotImplemented
74
+
75
+ @property
76
+ @abstractmethod
77
+ def data(self: Self) -> Any: ...
78
+
79
+ ``class datahold.HoldDict(*args: Any, **kwargs: Any)``
80
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
+
82
+ 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.
83
+
84
+ ``__contains__(key: Any, /) -> Any``
85
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
+
87
+ This magic method implements the in operator. Internally its code is equivalent to the following:
88
+
89
+ .. code-block:: python
90
+
91
+ def __contains__(self: Self, key: Any, /) -> Any:
92
+ "True if the dictionary has the specified key, else False."
93
+ data = self.data
94
+ ans = data.__contains__(*args, **kwargs)
95
+ self.data = data
96
+ return ans
97
+
98
+ The imprecise annotations and docstring are due to it adhering to the underlying dict.__contains__ as closely as possible.
99
+
100
+ ``__delitem__(key: Any, /) -> Any``
101
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102
+
103
+ This magic method implements the deletion of items. Its inner workings are analogous to __contains__ .
104
+
105
+ ``__eq__(value: Any, /) -> Any``
106
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
+
108
+ This magic method implements the == operator. Its inner workings are analogous to __contains__ .
109
+
110
+ ``__format__(format_spec: Any, /) -> Any``
111
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112
+
113
+ This magic method implements the inbuilt format function. Its inner workings are analogous to __contains__ .
114
+
115
+ ``__ge__(value: Any, /) -> Any``
116
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117
+
118
+ This magic method implements the >= operator. Its inner workings are analogous to __contains__ .
119
+
120
+ ``__getitem__(key: Any, /) -> Any``
121
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
122
+
123
+ This magic method implements the returning of items. Its inner workings are analogous to __contains__ .
124
+
125
+ ``__gt__(value: Any, /) -> Any``
126
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
+
128
+ This magic method implements the > operator. Its inner workings are analogous to __contains__ .
129
+
130
+ ``__hash__() -> int``
131
+ ^^^^^^^^^^^^^^^^^^^^^
132
+
133
+ This magic method implements the inbuilt function hash. Its function is unhash.unhash . It always raises a TypeError.
134
+
135
+ ``__ior__(value: Any, /) -> Any``
136
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137
+
138
+ This magic method implements the ``|=`` operator. Its inner workings are analogous to __contains__ .
139
+
140
+ ``__iter__() -> Any``
141
+ ^^^^^^^^^^^^^^^^^^^^^
142
+
143
+ This magic method implements iteration. Its inner workings are analogous to __contains__ .
144
+
145
+ ``__le__(value: Any, /) -> Any``
146
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147
+
148
+ This magic method implements the <= operator. Its inner workings are analogous to __contains__ .
149
+
150
+ ``__len__() -> Any``
151
+ ^^^^^^^^^^^^^^^^^^^^
152
+
153
+ This magic method implements the inbuilt len function. Its inner workings are analogous to __contains__ .
154
+
155
+ ``__lt__(value: Any, /) -> Any``
156
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157
+
158
+ This magic method implements the < operator. Its inner workings are analogous to __contains__ .
159
+
160
+ ``__or__(value: Any, /) -> Any``
161
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162
+
163
+ This magic method implements the | operator. Its inner workings are analogous to __contains__ .
164
+
165
+ ``__repr__() -> Any``
166
+ ^^^^^^^^^^^^^^^^^^^^^
167
+
168
+ This magic method implements representation. Its inner workings are analogous to __contains__ .
169
+
170
+ ``__reversed__() -> Any``
171
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
172
+
173
+ This magic method implements the inbuilt reversed function. Its inner workings are analogous to __contains__ .
174
+
175
+ ``__ror__(value: Any, /) -> Any``
176
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177
+
178
+ 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__ .
179
+
180
+ ``__setitem__(key: Any, value: Any, /) -> Any``
181
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
182
+
183
+ This magic method implements the setting of items. Its inner workings are analogous to __contains__ .
184
+
185
+ ``__str__() -> Any``
186
+ ^^^^^^^^^^^^^^^^^^^^
187
+
188
+ This magic method implements the explicit conversion into a string. Its inner workings are analogous to __contains__ .
189
+
190
+ ``__subclasshook__(other: type, /) -> bool``
191
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192
+
193
+ This classmethod is inherited directly from HoldABC .
194
+
195
+ ``clear() -> Any``
196
+ ^^^^^^^^^^^^^^^^^^
197
+
198
+ This method deletes of all items. Its inner workings are analogous to __contains__ .
199
+
200
+ ``copy() -> Any``
201
+ ^^^^^^^^^^^^^^^^^
202
+
203
+ This method implements dublication. Its inner workings are analogous to __contains__ . Remember that because of that a dict is returned.
204
+
205
+ ``data: dict``
206
+ ^^^^^^^^^^^^^^
207
+
208
+ This property is implemented with the equivalent to the following code:
209
+
210
+ .. code-block:: python
211
+
212
+ @property
213
+ def data(self: Self) -> dict:
214
+ return dict(self._data)
215
+
216
+ @data.setter
217
+ def data(self: Self, value: Any) -> None:
218
+ self._data = dict(value)
219
+
220
+ @data.deleter
221
+ def data(self: Self) -> None:
222
+ self._data = dict()
223
+
224
+ ``get(key: Any, default: Any = None, /) -> Any``
225
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
226
+
227
+ This method implements getting an item with a default in case of its absence. Its inner workings are analogous to __contains__ .
228
+
229
+ ``items() -> Any``
230
+ ^^^^^^^^^^^^^^^^^^
231
+
232
+ This method returns an iterator over the items. Its inner workings are analogous to __contains__ .
233
+
234
+ ``keys() -> Any``
235
+ ^^^^^^^^^^^^^^^^^
236
+
237
+ This method returns an iterator over the keys. Its inner workings are analogous to __contains__ .
238
+
239
+ ``popitem() -> Any``
240
+ ^^^^^^^^^^^^^^^^^^^^
241
+
242
+ This method deletes and returns the last item. Its inner workings are analogous to __contains__ .
243
+
244
+ ``setdefault(key: Any, default: Any = None, /) -> Any``
245
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246
+
247
+ This method ensures the presence of a key. Its inner workings are analogous to __contains__ .
248
+
249
+ ``update(*args: Any, **kwargs: Any) -> Any``
250
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
251
+
252
+ This method updates the data. Its inner workings are analogous to __contains__ .
253
+
254
+ ``values() -> Any``
255
+ ^^^^^^^^^^^^^^^^^^^
256
+
257
+ This method returns an iterator over the values. Its inner workings are analogous to __contains__ .
258
+
259
+ ``class datahold.HoldList(*args: Any, **kwargs: Any)``
260
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261
+
262
+ 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.
263
+
264
+ ``class datahold.HoldSet(*args: Any, **kwargs: Any)``
265
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
266
+
267
+ 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.
268
+
269
+ ``class datahold.OkayABC(*args: Any, **kwargs: Any)``
270
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
271
+
272
+ A common ABC for OkayList, OkayDict, and OkaySet. Child of Scaevola and HoldABC. It implements common-sense overwrites for some methods. For example:
273
+
274
+ - All methods that cannot actually change the underlying object are now bound to _data instead of data.
275
+ - __bool__ is implemented as bool(self._data) because neither list, dict, nor set have a __bool__ method defined.
276
+ - The comparison operations are overwritten:
277
+ * __eq__ returns self._data == type(self._data)(other).
278
+ * __ne__ negates __eq__.
279
+ * __ge__ returns type(self)(other) <= self (inherited from scaevola.Scaevola).
280
+ * __gt__ returns not (self == other) and (self >= other).
281
+ * __lt__ returns not (self == other) and (self <= other).
282
+ * __le__ returns self._data <= type(self)(other)._data.
283
+
284
+ Modify __eq__ or __le__ as needed to change the behavior of the other comparison methods.
285
+
286
+ ``class datahold.OkayDict(data: Iterable = (), /, **kwargs: Any)``
287
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288
+
289
+ A subclass of HoldDict with common-sense implementations for further inheritance, just like OkayList for HoldList.
290
+
291
+ ``class datahold.OkayList(data: Iterable = ())``
292
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293
+
294
+ This class inherits from HoldList and OkayABC. It implements a data property that binds a variable _data.
295
+
296
+ .. code-block:: python
297
+
298
+ @property
299
+ def data(self, /):
300
+ return list(self._data)
301
+
302
+ @data.setter
303
+ def data(self, values, /):
304
+ self._data = list(values)
305
+
306
+ @data.deleter
307
+ def data(self, /):
308
+ self._data = list()
309
+
310
+ Based on this, it implements common-sense methods. For example:
311
+
312
+ - All methods that returned a list before now return OkayList (type adapts to further inheritance).
313
+ - __init__ allows setting data immediately.
314
+
315
+ ``class datahold.OkaySet(data: Iterable = ())``
316
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317
+
318
+ A subclass of HoldSet with common-sense implementations for further inheritance, just like OkayList for HoldList.
319
+
320
+ ``datahold.test() -> unittest.TextTestResult``
321
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322
+
323
+ This project can be tested through its test function.
324
+
325
+ .. code-block:: python
326
+
327
+ import datahold
328
+ datahold.test()
329
+
330
+ License
331
+ -------
332
+
333
+ This project is licensed under the MIT License.
334
+
335
+ Impressum
336
+ ---------
337
+
338
+ **Johannes Programming**
339
+
340
+ - Name: Johannes
341
+ - Email: johannes.programming@gmail.com
342
+ - Homepage: https://www.johannes-programming.online/
343
+ - Gravatar: https://www.johannes-programming.fyi/