swizzle 2.2.1__py3-none-any.whl → 2.3.0__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.
- swizzle/__init__.py +39 -3
- {swizzle-2.2.1.dist-info → swizzle-2.3.0.dist-info}/METADATA +13 -2
- swizzle-2.3.0.dist-info/RECORD +6 -0
- {swizzle-2.2.1.dist-info → swizzle-2.3.0.dist-info}/WHEEL +1 -1
- swizzle-2.2.1.dist-info/RECORD +0 -6
- {swizzle-2.2.1.dist-info → swizzle-2.3.0.dist-info/licenses}/LICENSE +0 -0
- {swizzle-2.2.1.dist-info → swizzle-2.3.0.dist-info}/top_level.txt +0 -0
swizzle/__init__.py
CHANGED
@@ -14,7 +14,7 @@ except ImportError:
|
|
14
14
|
|
15
15
|
_type = builtins.type
|
16
16
|
|
17
|
-
__version__ = "2.
|
17
|
+
__version__ = "2.3.0"
|
18
18
|
|
19
19
|
MISSING = object()
|
20
20
|
|
@@ -43,7 +43,7 @@ def swizzledtuple(typename, field_names, *, rename=False, defaults=None, module=
|
|
43
43
|
to the order given in `field_names`.
|
44
44
|
sep (str, optional): A separator string that customizes the structure of attribute
|
45
45
|
access. If provided, this sep allows attributes to be accessed by combining field
|
46
|
-
names with the sep in between them. Defaults to
|
46
|
+
names with the sep in between them. Defaults to None.
|
47
47
|
|
48
48
|
Returns:
|
49
49
|
type: A new subclass of `tuple` with named fields and customized attribute access.
|
@@ -196,6 +196,40 @@ def swizzledtuple(typename, field_names, *, rename=False, defaults=None, module=
|
|
196
196
|
def __getattribute__(self, attr_name):
|
197
197
|
return super(_tuple, self).__getattribute__(attr_name)
|
198
198
|
|
199
|
+
# def __getitem__(self, index):
|
200
|
+
# a_names = arrange_names[index]
|
201
|
+
# _sep = '' if sep is None else sep
|
202
|
+
# return getattr(self, _sep.join(a_names))
|
203
|
+
|
204
|
+
def __getitem__(self, index):
|
205
|
+
if not isinstance(index, slice):
|
206
|
+
return _tuple.__getitem__(self, index)
|
207
|
+
|
208
|
+
selected_indices = arrange_indices[index]
|
209
|
+
selected_values = _tuple.__getitem__(self, index)
|
210
|
+
|
211
|
+
seen = set()
|
212
|
+
filtered = [
|
213
|
+
(i, v, field_names[i])
|
214
|
+
for i, v in zip(selected_indices, selected_values)
|
215
|
+
if not (i in seen or seen.add(i))
|
216
|
+
]
|
217
|
+
|
218
|
+
if filtered:
|
219
|
+
_, filtered_values, filtered_names = zip(*filtered)
|
220
|
+
else:
|
221
|
+
filtered_values, filtered_names = (), ()
|
222
|
+
|
223
|
+
return swizzledtuple(
|
224
|
+
typename,
|
225
|
+
filtered_names,
|
226
|
+
rename=rename,
|
227
|
+
defaults=filtered_values,
|
228
|
+
module=module,
|
229
|
+
arrange_names=arrange_names[index],
|
230
|
+
sep=sep
|
231
|
+
)()
|
232
|
+
|
199
233
|
|
200
234
|
|
201
235
|
for method in (
|
@@ -206,6 +240,7 @@ def swizzledtuple(typename, field_names, *, rename=False, defaults=None, module=
|
|
206
240
|
_asdict,
|
207
241
|
__getnewargs__,
|
208
242
|
__getattribute__,
|
243
|
+
__getitem__
|
209
244
|
):
|
210
245
|
method.__qualname__ = f'{typename}.{method.__name__}'
|
211
246
|
|
@@ -220,7 +255,8 @@ def swizzledtuple(typename, field_names, *, rename=False, defaults=None, module=
|
|
220
255
|
'__repr__': __repr__,
|
221
256
|
'_asdict': _asdict,
|
222
257
|
'__getnewargs__': __getnewargs__,
|
223
|
-
'__getattribute__': __getattribute__
|
258
|
+
'__getattribute__': __getattribute__,
|
259
|
+
'__getitem__': __getitem__
|
224
260
|
}
|
225
261
|
seen = set()
|
226
262
|
for index, name in enumerate(arrange_names):
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: swizzle
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.3.0
|
4
4
|
Summary: Swizzle enables the retrieval of multiple attributes, similar to swizzling in computer graphics.
|
5
5
|
Home-page: https://github.com/janthmueller/swizzle
|
6
6
|
Author: Jan T. Müller
|
@@ -17,6 +17,17 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
17
|
Requires-Python: >=3.6
|
18
18
|
Description-Content-Type: text/markdown
|
19
19
|
License-File: LICENSE
|
20
|
+
Dynamic: author
|
21
|
+
Dynamic: author-email
|
22
|
+
Dynamic: classifier
|
23
|
+
Dynamic: description
|
24
|
+
Dynamic: description-content-type
|
25
|
+
Dynamic: home-page
|
26
|
+
Dynamic: license
|
27
|
+
Dynamic: license-file
|
28
|
+
Dynamic: project-url
|
29
|
+
Dynamic: requires-python
|
30
|
+
Dynamic: summary
|
20
31
|
|
21
32
|
# Swizzle
|
22
33
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
swizzle/__init__.py,sha256=oEH3oUXQiz3nl6yf0tkFyHkiK43iPNeXhP9qSsUd5yw,16406
|
2
|
+
swizzle-2.3.0.dist-info/licenses/LICENSE,sha256=WDAegKWtl3rZUiN-SQ2FEQQwEFxlM_jEKQyJRJawJXo,1070
|
3
|
+
swizzle-2.3.0.dist-info/METADATA,sha256=-eXIDaSiwrN82ROSZmJF5UDRScA5aNUQF-T8y_BaXA0,5684
|
4
|
+
swizzle-2.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
5
|
+
swizzle-2.3.0.dist-info/top_level.txt,sha256=XFSQti81x2zM0zAMCY1YD0lqB1eSg5my9BB03uFgCic,8
|
6
|
+
swizzle-2.3.0.dist-info/RECORD,,
|
swizzle-2.2.1.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
swizzle/__init__.py,sha256=_clk7y4NCO9KY-I-iSNsLc6iT8ylLcNPD4aiqoun1NE,15304
|
2
|
-
swizzle-2.2.1.dist-info/LICENSE,sha256=WDAegKWtl3rZUiN-SQ2FEQQwEFxlM_jEKQyJRJawJXo,1070
|
3
|
-
swizzle-2.2.1.dist-info/METADATA,sha256=vsupVSVUEg4uC3ZodBYPaLyUhvVPSXr2AgG9om0WMlY,5450
|
4
|
-
swizzle-2.2.1.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
5
|
-
swizzle-2.2.1.dist-info/top_level.txt,sha256=XFSQti81x2zM0zAMCY1YD0lqB1eSg5my9BB03uFgCic,8
|
6
|
-
swizzle-2.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|