xloft 0.1.15__py3-none-any.whl → 0.1.17__py3-none-any.whl
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.
Potentially problematic release.
This version of xloft might be problematic. Click here for more details.
- xloft/namedtuple.py +17 -14
- {xloft-0.1.15.dist-info → xloft-0.1.17.dist-info}/METADATA +22 -11
- xloft-0.1.17.dist-info/RECORD +8 -0
- xloft-0.1.15.dist-info/RECORD +0 -8
- {xloft-0.1.15.dist-info → xloft-0.1.17.dist-info}/WHEEL +0 -0
- {xloft-0.1.15.dist-info → xloft-0.1.17.dist-info}/licenses/LICENSE +0 -0
xloft/namedtuple.py
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
Examples:
|
|
6
6
|
>>> from xloft import NamedTuple
|
|
7
|
-
>>> nt = NamedTuple(x=10, y="Hello")
|
|
7
|
+
>>> nt = NamedTuple(x=10, y="Hello", _id="507c7f79bcf86cd7994f6c0e")
|
|
8
8
|
>>> nt.x
|
|
9
9
|
10
|
|
10
|
+
>>> nt.y
|
|
11
|
+
Hello
|
|
12
|
+
>>> nt._id
|
|
13
|
+
507c7f79bcf86cd7994f6c0e
|
|
10
14
|
>>> nt.z
|
|
11
15
|
KeyError
|
|
12
16
|
>>> len(nt)
|
|
13
|
-
|
|
17
|
+
3
|
|
14
18
|
>>> nt.keys()
|
|
15
|
-
["x", "y"]
|
|
19
|
+
["x", "y", "_id"]
|
|
16
20
|
>>> nt.values()
|
|
17
|
-
[10, "Hello"]
|
|
21
|
+
[10, "Hello", "507c7f79bcf86cd7994f6c0e"]
|
|
18
22
|
>>> nt.has_key("x")
|
|
19
23
|
True
|
|
20
24
|
>>> nt.has_key("z")
|
|
@@ -27,22 +31,21 @@ Examples:
|
|
|
27
31
|
10
|
|
28
32
|
>>> nt.get("z")
|
|
29
33
|
None
|
|
30
|
-
>>> nt.update("z", [1, 2, 3])
|
|
31
|
-
KeyError
|
|
32
34
|
>>> d = nt.to_dict()
|
|
33
35
|
>>> d["x"]
|
|
34
36
|
10
|
|
35
|
-
>>> nt["z"] = [1, 2, 3]
|
|
36
|
-
TypeError
|
|
37
|
-
>>> nt.update("x", 20)
|
|
38
|
-
>>> nt.x
|
|
39
|
-
20
|
|
40
|
-
>>> from xloft import NamedTuple
|
|
41
|
-
>>> nt = NamedTuple(x=10, y="Hello")
|
|
42
37
|
>>> for key, val in nt.items():
|
|
43
38
|
... print(f"Key: {key}, Value: {val}")
|
|
44
39
|
"Key: x, Value: 10"
|
|
45
40
|
"Key: y, Value: Hello"
|
|
41
|
+
"Key: _id, value: 507c7f79bcf86cd7994f6c0e"
|
|
42
|
+
>>> nt.update("x", 20)
|
|
43
|
+
>>> nt.x
|
|
44
|
+
20
|
|
45
|
+
>>> nt.update("z", [1, 2, 3])
|
|
46
|
+
KeyError
|
|
47
|
+
>>> nt["z"] = [1, 2, 3]
|
|
48
|
+
TypeError
|
|
46
49
|
>>> nt.x = 20
|
|
47
50
|
Error: AttributeDoesNotSetValue
|
|
48
51
|
>>> del nt.x
|
|
@@ -145,7 +148,7 @@ class NamedTuple:
|
|
|
145
148
|
None
|
|
146
149
|
"""
|
|
147
150
|
keys: list[str] = self._jWjSaNy1RbtQinsN_keys
|
|
148
|
-
if not
|
|
151
|
+
if key not in keys:
|
|
149
152
|
err_msg = f"The key `{key}` is missing!"
|
|
150
153
|
raise KeyError(err_msg)
|
|
151
154
|
self.__dict__[key] = value
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xloft
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.17
|
|
4
4
|
Summary: (XLOFT) X-Library of tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/kebasyaty/xloft
|
|
6
6
|
Project-URL: Repository, https://github.com/kebasyaty/xloft
|
|
@@ -31,7 +31,7 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
<p align="center">
|
|
32
32
|
<a href="https://github.com/kebasyaty/xloft">
|
|
33
33
|
<img
|
|
34
|
-
height="
|
|
34
|
+
height="80"
|
|
35
35
|
alt="Logo"
|
|
36
36
|
src="https://raw.githubusercontent.com/kebasyaty/xloft/main/assets/logo.svg">
|
|
37
37
|
</a>
|
|
@@ -49,6 +49,7 @@ Description-Content-Type: text/markdown
|
|
|
49
49
|
<a href="https://github.com/kebasyaty/xloft/issues"><img src="https://img.shields.io/github/issues/kebasyaty/xloft.svg" alt="GitHub issues"></a>
|
|
50
50
|
<a href="https://pepy.tech/projects/xloft"><img src="https://static.pepy.tech/badge/xloft" alt="PyPI Downloads"></a>
|
|
51
51
|
<a href="https://github.com/kebasyaty/xloft/blob/main/LICENSE" alt="GitHub license"><img src="https://img.shields.io/github/license/kebasyaty/xloft" alt="GitHub license"></a>
|
|
52
|
+
<a href="https://mypy-lang.org/" alt="Types: Mypy"><img src="https://img.shields.io/badge/types-Mypy-202235.svg?color=0c7ebf" alt="Types: Mypy"></a>
|
|
52
53
|
<a href="https://docs.astral.sh/ruff/" alt="Code style: Ruff"><img src="https://img.shields.io/badge/code%20style-Ruff-FDD835.svg" alt="Code style: Ruff"></a>
|
|
53
54
|
<a href="https://github.com/kebasyaty/xloft" alt="PyPI implementation"><img src="https://img.shields.io/pypi/implementation/xloft" alt="PyPI implementation"></a>
|
|
54
55
|
<a href="https://github.com/kebasyaty/xloft" alt="GitHub repository"><img src="https://img.shields.io/badge/--ecebeb?logo=github&logoColor=000000" alt="GitHub repository"></a>
|
|
@@ -87,34 +88,38 @@ uv add xloft
|
|
|
87
88
|
from xloft import NamedTuple
|
|
88
89
|
|
|
89
90
|
|
|
90
|
-
nt = NamedTuple(x=10, y="Hello")
|
|
91
|
+
nt = NamedTuple(x=10, y="Hello", _id="507c7f79bcf86cd7994f6c0e")
|
|
91
92
|
# or
|
|
92
|
-
d = {"x": 10, "y": "Hello"}
|
|
93
|
+
d = {"x": 10, "y": "Hello", "_id": "507c7f79bcf86cd7994f6c0e"}
|
|
93
94
|
nt = NamedTuple(**d)
|
|
94
95
|
|
|
95
96
|
nt.x # => 10
|
|
96
|
-
nt.y # =>
|
|
97
|
+
nt.y # => Hello
|
|
98
|
+
nt._id # => 507c7f79bcf86cd7994f6c0e
|
|
97
99
|
nt.z # => raise: KeyError
|
|
98
100
|
|
|
99
|
-
len(nt) # =>
|
|
100
|
-
nt.keys() # => ["x", "y"]
|
|
101
|
-
nt.values() # => [10, "Hello"]
|
|
101
|
+
len(nt) # => 3
|
|
102
|
+
nt.keys() # => ["x", "y", "_id"]
|
|
103
|
+
nt.values() # => [10, "Hello", "507c7f79bcf86cd7994f6c0e"]
|
|
102
104
|
|
|
103
105
|
nt.has_key("x") # => True
|
|
104
106
|
nt.has_key("y") # => True
|
|
107
|
+
nt.hsa_key("_id") # => True
|
|
105
108
|
nt.has_key("z") # => False
|
|
106
109
|
|
|
107
110
|
nt.has_value(10) # => True
|
|
108
111
|
nt.has_value("Hello") # => True
|
|
112
|
+
nt.has_value("507c7f79bcf86cd7994f6c0e") # => True
|
|
109
113
|
nt.has_value([1, 2, 3]) # => False
|
|
110
114
|
|
|
111
115
|
nt.get("x") # => 10
|
|
112
|
-
nt.get("y") # =>
|
|
116
|
+
nt.get("y") # => Hello
|
|
117
|
+
nt.get("_id") # => 507c7f79bcf86cd7994f6c0e
|
|
113
118
|
nt.get("z") # => None
|
|
114
119
|
|
|
115
120
|
d = nt.to_dict()
|
|
116
121
|
d["x"] # => 10
|
|
117
|
-
d.get("y") # =>
|
|
122
|
+
d.get("y") # => Hello
|
|
118
123
|
d.get("z") # => None
|
|
119
124
|
|
|
120
125
|
for key, val in nt.items():
|
|
@@ -122,23 +127,29 @@ for key, val in nt.items():
|
|
|
122
127
|
|
|
123
128
|
nt.update("x", 20)
|
|
124
129
|
nt.update("y", "Hi")
|
|
130
|
+
nt.update("_id", "new_id")
|
|
125
131
|
nt.x # => 20
|
|
126
|
-
nt.y # =>
|
|
132
|
+
nt.y # => Hi
|
|
133
|
+
nt._id # => new_id
|
|
127
134
|
nt.update("z", [1, 2, 3]) # => raise: KeyError
|
|
128
135
|
|
|
129
136
|
nt["x"] # => raise: KeyError
|
|
130
137
|
nt["y"] # => raise: KeyError
|
|
138
|
+
nt["_id"] # => raise: KeyError
|
|
131
139
|
nt["z"] # => raise: KeyError
|
|
132
140
|
nt["x"] = 20 # => TypeError
|
|
133
141
|
nt["y"] = "Hi" # => TypeError
|
|
142
|
+
nt["_id"] = "new_id" # => TypeError
|
|
134
143
|
nt["z"] = [1, 2, 3] # => TypeError
|
|
135
144
|
|
|
136
145
|
nt.x = 20 # => raise: AttributeDoesNotSetValue
|
|
137
146
|
nt.y = "Hi" # => raise: AttributeDoesNotSetValue
|
|
147
|
+
nt._id = "new_id" # => raise: AttributeDoesNotSetValue
|
|
138
148
|
nt.z = [1, 2, 3] # => raise: AttributeDoesNotSetValue
|
|
139
149
|
|
|
140
150
|
del nt.x # => raise: AttributeCannotBeDelete
|
|
141
151
|
del nt.y # => raise: AttributeCannotBeDelete
|
|
152
|
+
del nt._id # => raise: AttributeCannotBeDelete
|
|
142
153
|
```
|
|
143
154
|
|
|
144
155
|
## Changelog
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
xloft/__init__.py,sha256=YtzkovVqW8hLxBXxM0U7K_qqfU8XBJ1pzX6tAgTUNFw,215
|
|
2
|
+
xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
|
|
3
|
+
xloft/namedtuple.py,sha256=OkAHqMaV4hN6Qj_oaOYQ9-y9x4Muv4mNrBn48T6RpiI,6818
|
|
4
|
+
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
xloft-0.1.17.dist-info/METADATA,sha256=o1sR41EDgbhanFcbH42an3NfaGClZW2ZsQz9tu-CDQw,6669
|
|
6
|
+
xloft-0.1.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
xloft-0.1.17.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
8
|
+
xloft-0.1.17.dist-info/RECORD,,
|
xloft-0.1.15.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
xloft/__init__.py,sha256=YtzkovVqW8hLxBXxM0U7K_qqfU8XBJ1pzX6tAgTUNFw,215
|
|
2
|
-
xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
|
|
3
|
-
xloft/namedtuple.py,sha256=JfbEisEa00m8zLtc8TMljCZmU-a9PdoAvshE6j0jSpQ,6711
|
|
4
|
-
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
xloft-0.1.15.dist-info/METADATA,sha256=MLp8eZdlYKpEo6b-sFnob7Xt02xlzcb5VFkoRvzY-qs,6037
|
|
6
|
-
xloft-0.1.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
-
xloft-0.1.15.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
8
|
-
xloft-0.1.15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|