python-utils 4.1.0__py3-none-any.whl → 4.1.1__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.
@@ -21,7 +21,8 @@ def camel_to_underscore(name: str) -> str:
21
21
 
22
22
  If there are existing underscores they will be collapsed with the
23
23
  to-be-added underscores. Multiple consecutive capital letters will not be
24
- split except for the last one.
24
+ split except for the last one. A plural ``s`` that ends a word stays with
25
+ the acronym before it.
25
26
 
26
27
  >>> camel_to_underscore('SpamEggsAndBacon')
27
28
  'spam_eggs_and_bacon'
@@ -42,12 +43,16 @@ def camel_to_underscore(name: str) -> str:
42
43
  # Uppercase and the previous character isn't upper/underscore?
43
44
  # Add the underscore
44
45
  output.append('_')
45
- elif i > 3 and c.islower():
46
- # Will return the last 3 letters to check if we are changing
47
- # case. Only a lowercase letter ends an acronym, an underscore
48
- # or a digit after it leaves the acronym whole.
49
- previous = name[i - 3 : i]
50
- if previous.isalpha() and previous.isupper():
46
+ elif i > 1 and c.islower():
47
+ # Two preceding capitals are enough to mark the boundary:
48
+ # the final capital belongs to the following word. Only a
49
+ # lowercase letter ends an acronym; an underscore or digit
50
+ # after it leaves the acronym whole.
51
+ previous = name[i - 2 : i]
52
+ # A lone ``s`` that ends the word makes the acronym plural
53
+ # (``IDs``, ``URLs``) and does not start a new word.
54
+ plural: bool = c == 's' and not name[i + 1 : i + 2].islower()
55
+ if previous.isalpha() and previous.isupper() and not plural:
51
56
  output.insert(len(output) - 1, '_')
52
57
 
53
58
  output.append(c.lower())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-utils
3
- Version: 4.1.0
3
+ Version: 4.1.1
4
4
  Summary: Python Utils is a module with some convenient utilities not included with the standard Python install
5
5
  Keywords: utils,utilities,helpers,typing,typed,async,lazy-imports
6
6
  Author: Rick van Hattem
@@ -6,7 +6,7 @@ python_utils/containers.py,sha256=kHpDgj_sAdoouL0b_CE6IHSd-qtz0KYMs_Nuiba-yEQ,37
6
6
  python_utils/converters.py,sha256=gBOjkVYGwx1aBs7OtjFrMdQgZwI6wbOU_Rvy0u9OVFE,17273
7
7
  python_utils/decorators.py,sha256=UyVuV7Phf8kjAt38uA-F9MFH2o8zM4t-fmlgt3KL5cc,8225
8
8
  python_utils/exceptions.py,sha256=B5wljs3Id6eQ9eRaur-ZMPGGmhHNwh9F08Sfw6fuLX4,1230
9
- python_utils/formatters.py,sha256=OQo-dgtKLG76OMc72jXVMA7x1N1l8h8C025G9TwgZAc,6248
9
+ python_utils/formatters.py,sha256=TgnSRHjfC9TKMp5lNUOlwDNBhFOtIaS-lOFpBcsMaEc,6611
10
10
  python_utils/generators.py,sha256=5X2mbjkEWl69syOHTxUaQS18ILZ49n2EvXb4cASVjxg,6151
11
11
  python_utils/import_.py,sha256=EnVSLs7Sk1CHrkpiKdXe8i-O6XjS5hXINpjdEohRT4A,5541
12
12
  python_utils/logger.py,sha256=-QuF7Zfo7pxc4nTmAPc9Pm-oz5wsxXIX7NeCnYEPI6I,14043
@@ -15,7 +15,7 @@ python_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  python_utils/terminal.py,sha256=GL3n2_rT98LBNmxy-amY-hezGKStCo-9_d_pR-TMgv8,6823
16
16
  python_utils/time.py,sha256=fZz00bpTeLXFFhbAo03LiMLWuzSJU4iPbyGSe7PYshU,16979
17
17
  python_utils/types.py,sha256=N1O2uFE2IuwVJk_vcwz8XNkf-taL-vJ5iNNG6FUXjTg,4336
18
- python_utils-4.1.0.dist-info/licenses/LICENSE,sha256=_Zrs9NZu-G6_aZT2g3Jv5_JREJQfhRNBC61EH6WDH-o,1501
19
- python_utils-4.1.0.dist-info/WHEEL,sha256=rp-k_VZaX8oABFEtLwG_Df95p8LSKt9-uPyQ4jKH0P4,81
20
- python_utils-4.1.0.dist-info/METADATA,sha256=H9vBD5TFJQLYKsZSY1GlK_qwb5IUELI_aWRR4v28rGE,15988
21
- python_utils-4.1.0.dist-info/RECORD,,
18
+ python_utils-4.1.1.dist-info/licenses/LICENSE,sha256=_Zrs9NZu-G6_aZT2g3Jv5_JREJQfhRNBC61EH6WDH-o,1501
19
+ python_utils-4.1.1.dist-info/WHEEL,sha256=xTCBFIZIIyRSxyowOv5Wqg_jFU6KsdIffuulBB09Ph8,80
20
+ python_utils-4.1.1.dist-info/METADATA,sha256=LObK8d9NeYLUJN3Jpi3EyfXgIR7KSrSn0z5rJm5Ew7M,15988
21
+ python_utils-4.1.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.12.22
2
+ Generator: uv 0.13.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any