swizzle 2.3.1__py3-none-any.whl → 2.3.6__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 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 EnumType
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,10 +17,21 @@ 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
- __version__ = "2.3.1"
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
 
@@ -441,8 +453,16 @@ def swizzle_attributes_retriever(
441
453
  )
442
454
 
443
455
  if type == swizzledtuple:
444
- field_names = set(arranged_names)
445
- field_values = [retrieve_attribute(obj, name) for name in field_names]
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 == EnumType:
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 == EnumType:
534
+ if meta_cls == EnumMeta:
515
535
  SwizzledMetaType._check_for_existing_members_ = cfem
516
536
 
517
537
  # Preserve metadata on swizzled meta and class
@@ -535,6 +555,10 @@ def swizzle(cls=None, meta=False, sep=None, type=tuple, only_attrs=None):
535
555
  return class_decorator(cls)
536
556
 
537
557
 
558
+ t = swizzledtuple
559
+ # c = swizzledclass
560
+
561
+
538
562
  class Swizzle(types.ModuleType):
539
563
  def __init__(self):
540
564
  types.ModuleType.__init__(self, __name__)
swizzle/trie.py CHANGED
@@ -48,14 +48,3 @@ class Trie:
48
48
  result.append(query[i:longest_end])
49
49
  i = longest_end
50
50
  return result
51
-
52
-
53
- if __name__ == "__main__":
54
- words = ["mango", "man", "go", "bat", "manbat"]
55
- trie = Trie(words)
56
-
57
- print(trie.split_longest_prefix("mangomanmanbat")) # ['mango', 'man', 'bat']
58
- print(trie.split_longest_prefix("manbat")) # ['manbat']
59
- print(trie.split_longest_prefix("mango")) # ['mango']
60
- print(trie.split_longest_prefix("mangoman")) # ['mango', 'man']
61
- print(trie.split_longest_prefix("unknownword")) # None
@@ -1,33 +1,23 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swizzle
3
- Version: 2.3.1
3
+ Version: 2.3.6
4
4
  Summary: Swizzle enables the retrieval of multiple attributes, similar to swizzling in computer graphics.
5
- Home-page: https://github.com/janthmueller/swizzle
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: Documentation, https://github.com/janthmueller/swizzle/blob/main/README.md
10
- Project-URL: Source, https://github.com/janthmueller/swizzle
11
- Project-URL: Tracker, https://github.com/janthmueller/swizzle/issues
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.6
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
 
@@ -0,0 +1,7 @@
1
+ swizzle/__init__.py,sha256=Vmm7VJxtDci2_3X5eoJCloN8HUNPVC98Ti3ORR6jR6I,20647
2
+ swizzle/trie.py,sha256=fa5iRR-6dZ8nHsuqalGxH40uYiP5Ge7Kc4r51aCOwbk,1355
3
+ swizzle-2.3.6.dist-info/licenses/LICENSE,sha256=WDAegKWtl3rZUiN-SQ2FEQQwEFxlM_jEKQyJRJawJXo,1070
4
+ swizzle-2.3.6.dist-info/METADATA,sha256=0842gc0BTgJKoI2ZCmxhsfWbpCVMz78-x9E6yQbIZuo,5530
5
+ swizzle-2.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ swizzle-2.3.6.dist-info/top_level.txt,sha256=XFSQti81x2zM0zAMCY1YD0lqB1eSg5my9BB03uFgCic,8
7
+ swizzle-2.3.6.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- swizzle/__init__.py,sha256=8lOReILgZiQ38ez_BTRsVTbWbHJ2cHfQM9edkU6voOQ,19996
2
- swizzle/trie.py,sha256=JutRoUHut2kbNJZ8hmHMCaXP8QHGl7KXzLv2rRVFrb0,1791
3
- swizzle-2.3.1.dist-info/licenses/LICENSE,sha256=WDAegKWtl3rZUiN-SQ2FEQQwEFxlM_jEKQyJRJawJXo,1070
4
- swizzle-2.3.1.dist-info/METADATA,sha256=QYsGAWzGAB3i25i6zZZOqHM7PkIbMmEqNleLNOr-ttk,5684
5
- swizzle-2.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- swizzle-2.3.1.dist-info/top_level.txt,sha256=XFSQti81x2zM0zAMCY1YD0lqB1eSg5my9BB03uFgCic,8
7
- swizzle-2.3.1.dist-info/RECORD,,