xloft 0.1.14__py3-none-any.whl → 0.1.16__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 CHANGED
@@ -37,6 +37,10 @@ Examples:
37
37
  >>> nt.update("x", 20)
38
38
  >>> nt.x
39
39
  20
40
+ >>> for key, val in nt.items():
41
+ ... print(f"Key: {key}, Value: {val}")
42
+ "Key: x, Value: 10"
43
+ "Key: y, Value: Hello"
40
44
  >>> nt.x = 20
41
45
  Error: AttributeDoesNotSetValue
42
46
  >>> del nt.x
@@ -54,14 +58,11 @@ from xloft.errors import (
54
58
  class NamedTuple:
55
59
  """This class imitates the behavior of the _named tuple_."""
56
60
 
57
- VAR_NAME_FOR_KEYS_LIST: str = "_jWjSaNy1RbtQinsN_keys"
58
-
59
61
  def __init__(self, **kwargs: dict[str, Any]) -> None: # noqa: D107
60
- vnkl = self.__class__.VAR_NAME_FOR_KEYS_LIST
61
- self.__dict__[vnkl] = []
62
+ self.__dict__["_jWjSaNy1RbtQinsN_keys"] = []
62
63
  for name, value in kwargs.items():
63
64
  self.__dict__[name] = value
64
- self.__dict__[vnkl].append(name)
65
+ self._jWjSaNy1RbtQinsN_keys.append(name)
65
66
 
66
67
  def __len__(self) -> int:
67
68
  """Get the number of elements.
@@ -75,7 +76,7 @@ class NamedTuple:
75
76
  Returns:
76
77
  The number of elements in the tuple.
77
78
  """
78
- return len(self.__dict__[self.__class__.VAR_NAME_FOR_KEYS_LIST])
79
+ return len(self._jWjSaNy1RbtQinsN_keys)
79
80
 
80
81
  def __getattr__(self, name: str) -> Any:
81
82
  """Getter.
@@ -141,8 +142,8 @@ class NamedTuple:
141
142
  Returns:
142
143
  None
143
144
  """
144
- keys: list[str] = self.__dict__[self.__class__.VAR_NAME_FOR_KEYS_LIST]
145
- if not key in keys:
145
+ keys: list[str] = self._jWjSaNy1RbtQinsN_keys
146
+ if key not in keys:
146
147
  err_msg = f"The key `{key}` is missing!"
147
148
  raise KeyError(err_msg)
148
149
  self.__dict__[key] = value
@@ -161,7 +162,7 @@ class NamedTuple:
161
162
  Dictionary with keys and values of the tuple.
162
163
  """
163
164
  attrs: dict[str, Any] = self.__dict__
164
- keys: list[str] = attrs[self.__class__.VAR_NAME_FOR_KEYS_LIST]
165
+ keys: list[str] = self._jWjSaNy1RbtQinsN_keys
165
166
  return {key: attrs[key] for key in keys}
166
167
 
167
168
  def items(self) -> list[tuple[str, Any]]:
@@ -179,7 +180,7 @@ class NamedTuple:
179
180
  list[tuple[str, Any]]
180
181
  """
181
182
  attrs: dict[str, Any] = self.__dict__
182
- keys: list[str] = attrs[self.__class__.VAR_NAME_FOR_KEYS_LIST]
183
+ keys: list[str] = self._jWjSaNy1RbtQinsN_keys
183
184
  return [(key, attrs[key]) for key in keys]
184
185
 
185
186
  def keys(self) -> list[str]:
@@ -194,7 +195,7 @@ class NamedTuple:
194
195
  Returns:
195
196
  List of keys.
196
197
  """
197
- return self.__dict__[self.__class__.VAR_NAME_FOR_KEYS_LIST]
198
+ return self._jWjSaNy1RbtQinsN_keys
198
199
 
199
200
  def values(self) -> list[Any]:
200
201
  """Get a list of values.
@@ -209,7 +210,7 @@ class NamedTuple:
209
210
  List of values.
210
211
  """
211
212
  attrs: dict[str, Any] = self.__dict__
212
- keys: list[str] = attrs[self.__class__.VAR_NAME_FOR_KEYS_LIST]
213
+ keys: list[str] = self._jWjSaNy1RbtQinsN_keys
213
214
  return [attrs[key] for key in keys]
214
215
 
215
216
  def has_key(self, key: str) -> bool:
@@ -227,7 +228,7 @@ class NamedTuple:
227
228
  Returns:
228
229
  True if the key exists, otherwise False.
229
230
  """
230
- keys: list[str] = self.__dict__[self.__class__.VAR_NAME_FOR_KEYS_LIST]
231
+ keys: list[str] = self._jWjSaNy1RbtQinsN_keys
231
232
  return key in keys
232
233
 
233
234
  def has_value(self, value: Any) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xloft
3
- Version: 0.1.14
3
+ Version: 0.1.16
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="90"
34
+ height="80"
35
35
  alt="Logo"
36
36
  src="https://raw.githubusercontent.com/kebasyaty/xloft/main/assets/logo.svg">
37
37
  </a>
@@ -57,6 +57,7 @@ Description-Content-Type: text/markdown
57
57
  <a href="https://github.com/kebasyaty/xloft"><img src="https://img.shields.io/github/languages/top/kebasyaty/xloft" alt="Top"></a>
58
58
  <a href="https://github.com/kebasyaty/xloft"><img src="https://img.shields.io/github/repo-size/kebasyaty/xloft" alt="Size"></a>
59
59
  <a href="https://github.com/kebasyaty/xloft"><img src="https://img.shields.io/github/last-commit/kebasyaty/xloft/main" alt="Last commit"></a>
60
+ <a href="https://github.com/kebasyaty/xloft/releases/" alt="GitHub release"><img src="https://img.shields.io/github/release/kebasyaty/xloft" alt="GitHub release"></a>
60
61
  </p>
61
62
  <p align="center">
62
63
  Currently, the collection is represented by one element `NamedTuple`.
@@ -146,4 +147,4 @@ del nt.y # => raise: AttributeCannotBeDelete
146
147
 
147
148
  ## License
148
149
 
149
- This project is licensed under the **[MIT](https://github.com/kebasyaty/xloft/blob/main/LICENSE "MIT")**.
150
+ This project is licensed under the [MIT](https://github.com/kebasyaty/xloft/blob/main/LICENSE "MIT").
@@ -0,0 +1,8 @@
1
+ xloft/__init__.py,sha256=YtzkovVqW8hLxBXxM0U7K_qqfU8XBJ1pzX6tAgTUNFw,215
2
+ xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
3
+ xloft/namedtuple.py,sha256=3ua0zTh9aAk7pucr6Mxrn6l-vRs_Jj0LdYwhij8PFsg,6631
4
+ xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ xloft-0.1.16.dist-info/METADATA,sha256=9kqznL4M1xNoZB4POK4vkFiVeJp39L61OnLPY-E_OVk,6037
6
+ xloft-0.1.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ xloft-0.1.16.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
+ xloft-0.1.16.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- xloft/__init__.py,sha256=YtzkovVqW8hLxBXxM0U7K_qqfU8XBJ1pzX6tAgTUNFw,215
2
- xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
3
- xloft/namedtuple.py,sha256=SFiiw_i5XyKADSZQovPyvXCixXssVM6NwwLXqPEjSwA,6732
4
- xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- xloft-0.1.14.dist-info/METADATA,sha256=RdbMIOhzcI8VMpVNjTpLzARIAVxj-rGRkGounFK3YBo,5868
6
- xloft-0.1.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- xloft-0.1.14.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
- xloft-0.1.14.dist-info/RECORD,,
File without changes