swizzle 2.3.2__py3-none-any.whl → 2.4.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 +29 -9
- {swizzle-2.3.2.dist-info → swizzle-2.4.0.dist-info}/METADATA +9 -19
- swizzle-2.4.0.dist-info/RECORD +7 -0
- swizzle-2.3.2.dist-info/RECORD +0 -7
- {swizzle-2.3.2.dist-info → swizzle-2.4.0.dist-info}/WHEEL +0 -0
- {swizzle-2.3.2.dist-info → swizzle-2.4.0.dist-info}/licenses/LICENSE +0 -0
- {swizzle-2.3.2.dist-info → swizzle-2.4.0.dist-info}/top_level.txt +0 -0
swizzle/__init__.py
CHANGED
@@ -4,8 +4,9 @@ import builtins
|
|
4
4
|
import sys as _sys
|
5
5
|
import types
|
6
6
|
import unicodedata
|
7
|
-
from enum import
|
7
|
+
from enum import EnumMeta
|
8
8
|
from functools import wraps
|
9
|
+
from importlib.metadata import version as get_version
|
9
10
|
from keyword import iskeyword as _iskeyword
|
10
11
|
from operator import itemgetter as _itemgetter
|
11
12
|
|
@@ -16,21 +17,32 @@ try:
|
|
16
17
|
except ImportError:
|
17
18
|
_tuplegetter = lambda index, doc: property(_itemgetter(index), doc=doc)
|
18
19
|
|
19
|
-
_type = builtins.type
|
20
20
|
|
21
|
-
|
21
|
+
try:
|
22
|
+
from importlib.metadata import PackageNotFoundError
|
23
|
+
from importlib.metadata import version as _version
|
24
|
+
|
25
|
+
__version__ = _version("swizzle")
|
26
|
+
except PackageNotFoundError:
|
27
|
+
try:
|
28
|
+
from setuptools_scm import get_version
|
22
29
|
|
30
|
+
__version__ = get_version(root=".", relative_to=__file__)
|
31
|
+
except Exception:
|
32
|
+
__version__ = "0.0.0-dev"
|
33
|
+
|
34
|
+
_type = builtins.type
|
23
35
|
MISSING = object()
|
24
36
|
|
25
37
|
|
26
38
|
def swizzledtuple(
|
27
39
|
typename,
|
28
40
|
field_names,
|
41
|
+
arrange_names=None,
|
29
42
|
*,
|
30
43
|
rename=False,
|
31
44
|
defaults=None,
|
32
45
|
module=None,
|
33
|
-
arrange_names=None,
|
34
46
|
sep=None,
|
35
47
|
):
|
36
48
|
"""
|
@@ -175,7 +187,7 @@ def swizzledtuple(
|
|
175
187
|
if num_fields == 1:
|
176
188
|
arg_list += ","
|
177
189
|
repr_fmt = "(" + ", ".join(f"{name}=%r" for name in arrange_names) + ")"
|
178
|
-
_dict, _tuple, _len,
|
190
|
+
_dict, _tuple, _len, _zip = dict, tuple, len, zip
|
179
191
|
|
180
192
|
namespace = {
|
181
193
|
"_tuple_new": tuple_new,
|
@@ -441,8 +453,16 @@ def swizzle_attributes_retriever(
|
|
441
453
|
)
|
442
454
|
|
443
455
|
if type == swizzledtuple:
|
444
|
-
|
445
|
-
|
456
|
+
|
457
|
+
seen = set()
|
458
|
+
field_names, field_values = zip(
|
459
|
+
*[
|
460
|
+
(name, matched_attributes[i])
|
461
|
+
for i, name in enumerate(arranged_names)
|
462
|
+
if name not in seen and not seen.add(name)
|
463
|
+
]
|
464
|
+
)
|
465
|
+
|
446
466
|
name = "swizzledtuple"
|
447
467
|
if hasattr(obj, "__name__"):
|
448
468
|
name = obj.__name__
|
@@ -500,7 +520,7 @@ def swizzle(cls=None, meta=False, sep=None, type=tuple, only_attrs=None):
|
|
500
520
|
class SwizzledMetaType(meta_cls):
|
501
521
|
pass
|
502
522
|
|
503
|
-
if meta_cls ==
|
523
|
+
if meta_cls == EnumMeta:
|
504
524
|
|
505
525
|
def cfem_dummy(*args, **kwargs):
|
506
526
|
pass
|
@@ -511,7 +531,7 @@ def swizzle(cls=None, meta=False, sep=None, type=tuple, only_attrs=None):
|
|
511
531
|
class SwizzledClass(cls, metaclass=SwizzledMetaType):
|
512
532
|
pass
|
513
533
|
|
514
|
-
if meta_cls ==
|
534
|
+
if meta_cls == EnumMeta:
|
515
535
|
SwizzledMetaType._check_for_existing_members_ = cfem
|
516
536
|
|
517
537
|
# Preserve metadata on swizzled meta and class
|
@@ -1,33 +1,23 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: swizzle
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.4.0
|
4
4
|
Summary: Swizzle enables the retrieval of multiple attributes, similar to swizzling in computer graphics.
|
5
|
-
|
6
|
-
Author: Jan T. Müller
|
7
|
-
Author-email: mail@jantmueller.com
|
5
|
+
Author-email: "Jan T. Müller" <mail@jantmueller.com>
|
8
6
|
License: MIT
|
9
|
-
Project-URL:
|
10
|
-
Project-URL:
|
11
|
-
Project-URL:
|
7
|
+
Project-URL: homepage, https://github.com/janthmueller/swizzle
|
8
|
+
Project-URL: documentation, https://github.com/janthmueller/swizzle/blob/main/README.md
|
9
|
+
Project-URL: source, https://github.com/janthmueller/swizzle
|
10
|
+
Project-URL: tracker, https://github.com/janthmueller/swizzle/issues
|
11
|
+
Keywords: swizzle,attributes,graphics,development
|
12
12
|
Classifier: Intended Audience :: Developers
|
13
13
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
15
15
|
Classifier: Operating System :: OS Independent
|
16
16
|
Classifier: Programming Language :: Python :: 3 :: Only
|
17
|
-
Requires-Python: >=3.
|
17
|
+
Requires-Python: >=3.8
|
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
20
|
Dynamic: license-file
|
28
|
-
Dynamic: project-url
|
29
|
-
Dynamic: requires-python
|
30
|
-
Dynamic: summary
|
31
21
|
|
32
22
|
# Swizzle
|
33
23
|
|
@@ -134,7 +124,7 @@ Create swizzled named tuples inspired by `namedtuple`:
|
|
134
124
|
```python
|
135
125
|
from swizzle import swizzledtuple
|
136
126
|
|
137
|
-
Vector = swizzledtuple('Vector', 'x y z')
|
127
|
+
Vector = swizzledtuple('Vector', 'x y z') # Equivalent to swizzle.t('Vector', 'x y z')
|
138
128
|
|
139
129
|
v = Vector(1, 2, 3)
|
140
130
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
swizzle/__init__.py,sha256=-TULOghrDcJWrIHvSG_j7r2_PxTaB_kxU3oVis5dBHw,20636
|
2
|
+
swizzle/trie.py,sha256=fa5iRR-6dZ8nHsuqalGxH40uYiP5Ge7Kc4r51aCOwbk,1355
|
3
|
+
swizzle-2.4.0.dist-info/licenses/LICENSE,sha256=WDAegKWtl3rZUiN-SQ2FEQQwEFxlM_jEKQyJRJawJXo,1070
|
4
|
+
swizzle-2.4.0.dist-info/METADATA,sha256=tiejU_zOQ6gK73kfuIW9p4jaJr6cXj0Jjkyc8Y-7WIM,5575
|
5
|
+
swizzle-2.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
swizzle-2.4.0.dist-info/top_level.txt,sha256=XFSQti81x2zM0zAMCY1YD0lqB1eSg5my9BB03uFgCic,8
|
7
|
+
swizzle-2.4.0.dist-info/RECORD,,
|
swizzle-2.3.2.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
swizzle/__init__.py,sha256=qPf9IXyZ3JGA2nVM_fCcsxluoxxHumIfHHkL-VE5MZg,20040
|
2
|
-
swizzle/trie.py,sha256=fa5iRR-6dZ8nHsuqalGxH40uYiP5Ge7Kc4r51aCOwbk,1355
|
3
|
-
swizzle-2.3.2.dist-info/licenses/LICENSE,sha256=WDAegKWtl3rZUiN-SQ2FEQQwEFxlM_jEKQyJRJawJXo,1070
|
4
|
-
swizzle-2.3.2.dist-info/METADATA,sha256=wDotyAgFlMThAENLwZYkEoEhR_QiO2NcOXqylkzVQdc,5684
|
5
|
-
swizzle-2.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
swizzle-2.3.2.dist-info/top_level.txt,sha256=XFSQti81x2zM0zAMCY1YD0lqB1eSg5my9BB03uFgCic,8
|
7
|
-
swizzle-2.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|