PyLinks 0.0.0.dev25__tar.gz → 0.0.0.dev27__tar.gz
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.
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/PKG-INFO +1 -1
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/pyproject.toml +1 -1
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/PyLinks.egg-info/PKG-INFO +1 -1
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/PyLinks.egg-info/SOURCES.txt +1 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/__init__.py +1 -1
- pylinks-0.0.0.dev27/src/pylinks/string.py +39 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/url.py +2 -2
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/setup.cfg +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/PyLinks.egg-info/dependency_links.txt +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/PyLinks.egg-info/not-zip-safe +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/PyLinks.egg-info/requires.txt +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/PyLinks.egg-info/top_level.txt +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/_settings.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/api/__init__.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/api/doi.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/api/github.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/api/orcid.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/exception/__init__.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/exception/base.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/exception/media_type.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/exception/uri.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/exceptions.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/http.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/media_type.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/__init__.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/binder.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/conda.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/github.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/lib_io.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/pypi.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/site/readthedocs.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/uri/__init__.py +0 -0
- {pylinks-0.0.0.dev25 → pylinks-0.0.0.dev27}/src/pylinks/uri/data.py +0 -0
|
@@ -17,7 +17,7 @@ namespaces = true
|
|
|
17
17
|
# ----------------------------------------- Project Metadata -------------------------------------
|
|
18
18
|
#
|
|
19
19
|
[project]
|
|
20
|
-
version = "0.0.0.
|
|
20
|
+
version = "0.0.0.dev27"
|
|
21
21
|
name = "PyLinks"
|
|
22
22
|
dependencies = [
|
|
23
23
|
"requests >= 2.31.0, < 3",
|
|
@@ -12,4 +12,4 @@ Other available modules offer shortcuts for creating useful URLs for popular onl
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
from pylinks._settings import settings
|
|
15
|
-
from pylinks import url, http, api, site, exceptions, uri, media_type
|
|
15
|
+
from pylinks import url, http, api, site, exceptions, uri, media_type, string
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import re as _re
|
|
2
|
+
import unicodedata as _unicodedata
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def to_slug(string: str) -> str:
|
|
6
|
+
"""Convert a string to a URL-friendly slug.
|
|
7
|
+
|
|
8
|
+
This function performs unicode-normalization on the string,
|
|
9
|
+
converts it to lowercase,
|
|
10
|
+
replaces any non-alphanumeric characters with hyphens, and
|
|
11
|
+
removes leading and trailing hyphens.
|
|
12
|
+
"""
|
|
13
|
+
# Normalize the string to decompose special characters
|
|
14
|
+
normalized_string = _unicodedata.normalize('NFKD', string)
|
|
15
|
+
# Encode the string to ASCII bytes, ignoring non-ASCII characters
|
|
16
|
+
ascii_bytes = normalized_string.encode('ascii', 'ignore')
|
|
17
|
+
# Decode back to a string
|
|
18
|
+
ascii_string = ascii_bytes.decode('ascii')
|
|
19
|
+
lower_case_string = ascii_string.lower()
|
|
20
|
+
return _re.sub(r'[^a-z0-9]+', '-', lower_case_string).strip('-')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def camel_to_title(string: str) -> str:
|
|
24
|
+
"""Convert a 'CamelCase' string to a 'Title Case' string.
|
|
25
|
+
|
|
26
|
+
This function inserts spaces before each uppercase letter (except the first letter)
|
|
27
|
+
and capitalizes the first letter of each word.
|
|
28
|
+
"""
|
|
29
|
+
# Insert spaces before each uppercase letter (except the first letter)
|
|
30
|
+
spaced_str = _re.sub(r'(?<!^)(?=[A-Z])', ' ', string)
|
|
31
|
+
# Convert to title-case
|
|
32
|
+
title_str = spaced_str.title()
|
|
33
|
+
return title_str
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def snake_to_camel(string):
|
|
37
|
+
components = string.split('_')
|
|
38
|
+
return ''.join([components[0]] + [x.title() for x in components[1:]])
|
|
39
|
+
|
|
@@ -93,14 +93,14 @@ class URL:
|
|
|
93
93
|
for key, val in self.queries.items():
|
|
94
94
|
if val is None:
|
|
95
95
|
continue
|
|
96
|
-
q_key = urllib.parse.quote(str(key), safe=self.quote_safe)
|
|
96
|
+
q_key = urllib.parse.quote(urllib.parse.unquote(str(key)), safe=self.quote_safe)
|
|
97
97
|
if isinstance(val, bool) and val is True:
|
|
98
98
|
queries.append(q_key)
|
|
99
99
|
else:
|
|
100
100
|
q_val = (
|
|
101
101
|
val.decode("utf8")
|
|
102
102
|
if isinstance(val, bytes)
|
|
103
|
-
else urllib.parse.quote(str(val), safe=self.quote_safe)
|
|
103
|
+
else urllib.parse.quote(urllib.parse.unquote(str(val)), safe=self.quote_safe)
|
|
104
104
|
)
|
|
105
105
|
queries.append(f"{q_key}={q_val}")
|
|
106
106
|
return self.query_delimiter.join(queries)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|