PyLinks 0.0.0.dev67__py3-none-any.whl → 0.0.0.dev69__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyLinks
3
- Version: 0.0.0.dev67
3
+ Version: 0.0.0.dev69
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: requests<3,>=2.31.0
6
- Requires-Dist: ExceptionMan==0.0.0.dev54
7
- Requires-Dist: MDit==0.0.0.dev54
6
+ Requires-Dist: ExceptionMan==0.0.0.dev56
7
+ Requires-Dist: MDit==0.0.0.dev56
@@ -2,7 +2,7 @@ pylinks/__init__.py,sha256=75Tgq2JiBuCPJWBTV4JNEEMBtKGw3pEk9jRnoW8KIDs,710
2
2
  pylinks/_settings.py,sha256=gC_S-EQJQNmXT73UWwEwnAZu5nlPrt9f39n99Xd9fFw,322
3
3
  pylinks/http.py,sha256=cXK_eLtijinWpYDerCla_EF2XUOzPQteAphejgam0fs,15257
4
4
  pylinks/media_type.py,sha256=VIeCZYIfmArMjH2jlPIl51Z3GVVBztXBEE5x48IKpIw,4014
5
- pylinks/string.py,sha256=yoORoiILKAKzzfDw-bwePBTwb3Shr_RvOSB2tdEZuSU,1397
5
+ pylinks/string.py,sha256=XotIPr2RdPQzu2wuD1HrfgIXgQsjFOVJWYHR04ttXSQ,1756
6
6
  pylinks/url.py,sha256=4YzmNn0U1nzWmcdzEW6RKaZd5uu-MZRimHGl5Xi60Cg,7815
7
7
  pylinks/api/__init__.py,sha256=q7hhZabjTajBYxDxzJy44y8Rx_-5sye9VnVnkytIua8,488
8
8
  pylinks/api/doi.py,sha256=7YnMqy4_Ct2sw9Wz4mQC5S4xAahwh6fMUPKAx_qqj-M,5899
@@ -23,7 +23,7 @@ pylinks/site/pypi.py,sha256=-NSglDo-k55bALi-aN0iF2I6z1WXsjYOIVDyjNUxuuU,1944
23
23
  pylinks/site/readthedocs.py,sha256=_s27ETa3oRoeDdQvFrrtuSh2my6cjWEIEVhwHz0yZ90,1797
24
24
  pylinks/uri/__init__.py,sha256=W38fMHGgV7mg8uPWC8IMWGgmlCQO9VHIqNpInG2NS2I,29
25
25
  pylinks/uri/data.py,sha256=uD1CipMo4oFpxH8liOY24PsxMyuR5kEH2a0XDkO1dgI,6380
26
- PyLinks-0.0.0.dev67.dist-info/METADATA,sha256=im0QUCjPzIS1hDu0YReDPv7kNMMEBwm2HjdAuENGoaw,190
27
- PyLinks-0.0.0.dev67.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
28
- PyLinks-0.0.0.dev67.dist-info/top_level.txt,sha256=LlaTHnPw89VppYU3vCciF81IOSzvc16RkdNkOCqhAcs,8
29
- PyLinks-0.0.0.dev67.dist-info/RECORD,,
26
+ PyLinks-0.0.0.dev69.dist-info/METADATA,sha256=a-7f-on1Rx1P0TZOxX7I92cXLOkRM9btY2jBJxng08w,190
27
+ PyLinks-0.0.0.dev69.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
28
+ PyLinks-0.0.0.dev69.dist-info/top_level.txt,sha256=LlaTHnPw89VppYU3vCciF81IOSzvc16RkdNkOCqhAcs,8
29
+ PyLinks-0.0.0.dev69.dist-info/RECORD,,
pylinks/string.py CHANGED
@@ -2,7 +2,7 @@ import re as _re
2
2
  import unicodedata as _unicodedata
3
3
 
4
4
 
5
- def to_slug(string: str) -> str:
5
+ def to_slug(string: str, reduce: bool = True) -> str:
6
6
  """Convert a string to a URL-friendly slug.
7
7
 
8
8
  This function performs unicode-normalization on the string,
@@ -17,11 +17,13 @@ def to_slug(string: str) -> str:
17
17
  # Decode back to a string
18
18
  ascii_string = ascii_bytes.decode('ascii')
19
19
  lower_case_string = ascii_string.lower()
20
- return _re.sub(r'[^a-z0-9]+', '-', lower_case_string).strip('-')
20
+ if reduce:
21
+ return _re.sub(r'[^a-z0-9]+', '-', lower_case_string).strip('-')
22
+ return _re.sub(r'[^a-z0-9]', '-', lower_case_string)
21
23
 
22
24
 
23
25
  def camel_to_title(string: str) -> str:
24
- """Convert a 'CamelCase' string to a 'Title Case' string.
26
+ """Convert a 'camelCase' string to 'Title Case'.
25
27
 
26
28
  This function inserts spaces before each uppercase letter (except the first letter)
27
29
  and capitalizes the first letter of each word.
@@ -32,6 +34,13 @@ def camel_to_title(string: str) -> str:
32
34
  title_str = spaced_str.title()
33
35
  return title_str
34
36
 
37
+ def camel_to_snake(camel_str):
38
+ """Convert a 'camelCase' case string to 'snake_case'.
39
+
40
+ This function inserts underscores before uppercase letters and lowercases them.
41
+ """
42
+ snake_str = _re.sub(r'(?<!^)(?=[A-Z])', '_', camel_str).lower()
43
+ return snake_str
35
44
 
36
45
  def snake_to_camel(string):
37
46
  components = string.split('_')