pygeobox 1.0.2__py3-none-any.whl → 1.0.4__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.
pygeobox/utils.py CHANGED
@@ -1,44 +1,44 @@
1
- from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
2
-
3
-
4
- def clean_data(data: dict) -> dict:
5
- """
6
- Cleans the input data by removing keys with None values.
7
-
8
- Args:
9
- data (dict): The input data.
10
-
11
- Returns:
12
- dict: The cleaned data.
13
- """
14
- return {k: v for k, v in data.items() if v is not None}
15
-
16
- def join_url_params(base_url: str, params: dict) -> str:
17
- """
18
- Join URL with parameters while preserving existing query parameters.
19
-
20
- Args:
21
- base_url (str): Base URL that may contain existing parameters
22
- params (dict): New parameters to add
23
-
24
- Returns:
25
- str: URL with all parameters properly joined
26
- """
27
- # Parse the URL
28
- parsed = urlparse(base_url)
29
-
30
- # Get existing parameters
31
- existing_params = parse_qs(parsed.query)
32
-
33
- # Update with new parameters
34
- existing_params.update(params)
35
-
36
- # Reconstruct the URL
37
- return urlunparse((
38
- parsed.scheme,
39
- parsed.netloc,
40
- parsed.path,
41
- parsed.params,
42
- urlencode(existing_params, doseq=True),
43
- parsed.fragment
1
+ from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
2
+
3
+
4
+ def clean_data(data: dict) -> dict:
5
+ """
6
+ Cleans the input data by removing keys with None values.
7
+
8
+ Args:
9
+ data (dict): The input data.
10
+
11
+ Returns:
12
+ dict: The cleaned data.
13
+ """
14
+ return {k: v for k, v in data.items() if v is not None}
15
+
16
+ def join_url_params(base_url: str, params: dict) -> str:
17
+ """
18
+ Join URL with parameters while preserving existing query parameters.
19
+
20
+ Args:
21
+ base_url (str): Base URL that may contain existing parameters
22
+ params (dict): New parameters to add
23
+
24
+ Returns:
25
+ str: URL with all parameters properly joined
26
+ """
27
+ # Parse the URL
28
+ parsed = urlparse(base_url)
29
+
30
+ # Get existing parameters
31
+ existing_params = parse_qs(parsed.query)
32
+
33
+ # Update with new parameters
34
+ existing_params.update(params)
35
+
36
+ # Reconstruct the URL
37
+ return urlunparse((
38
+ parsed.scheme,
39
+ parsed.netloc,
40
+ parsed.path,
41
+ parsed.params,
42
+ urlencode(existing_params, doseq=True),
43
+ parsed.fragment
44
44
  ))