synapse-sdk 1.0.0a25__py3-none-any.whl → 1.0.0a26__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.

Potentially problematic release.


This version of synapse-sdk might be problematic. Click here for more details.

synapse_sdk/utils/file.py CHANGED
@@ -10,18 +10,20 @@ import aiohttp
10
10
  import requests
11
11
  import yaml
12
12
 
13
+ from synapse_sdk.utils.network import clean_url
13
14
  from synapse_sdk.utils.string import hash_text
14
15
 
15
16
 
16
17
  def download_file(url, path_download, name=None, coerce=None, use_cached=True):
17
18
  chunk_size = 1024 * 1024 * 50
19
+ cleaned_url = clean_url(url) # remove query params and fragment
18
20
 
19
21
  if name:
20
22
  use_cached = False
21
23
  else:
22
- name = hash_text(url)
24
+ name = hash_text(cleaned_url)
23
25
 
24
- name += Path(url).suffix
26
+ name += Path(cleaned_url).suffix
25
27
 
26
28
  path = Path(path_download) / name
27
29
 
@@ -73,13 +75,14 @@ def files_url_to_path_from_objs(objs, files_fields, coerce=None, is_list=False,
73
75
 
74
76
  async def adownload_file(url, path_download, name=None, coerce=None, use_cached=True):
75
77
  chunk_size = 1024 * 1024 * 50
78
+ cleaned_url = clean_url(url) # remove query params and fragment
76
79
 
77
80
  if name:
78
81
  use_cached = False
79
82
  else:
80
- name = hash_text(url)
83
+ name = hash_text(cleaned_url)
81
84
 
82
- name += Path(url).suffix
85
+ name += Path(cleaned_url).suffix
83
86
 
84
87
  path = Path(path_download) / name
85
88
 
@@ -0,0 +1,16 @@
1
+ from urllib.parse import urlparse, urlunparse
2
+
3
+
4
+ def clean_url(url, remove_query_params=True, remove_fragment=True):
5
+ parsed = urlparse(url)
6
+ query = '' if remove_query_params else parsed.query
7
+ fragment = '' if remove_fragment else parsed.fragment
8
+
9
+ return urlunparse((
10
+ parsed.scheme,
11
+ parsed.netloc,
12
+ parsed.path,
13
+ parsed.params,
14
+ query,
15
+ fragment,
16
+ ))
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a25
3
+ Version: 1.0.0a26
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -99,17 +99,18 @@ synapse_sdk/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
99
99
  synapse_sdk/shared/enums.py,sha256=WMZPag9deVF7VCXaQkLk7ly_uX1KwbNzRx9TdvgaeFE,138
100
100
  synapse_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
101
  synapse_sdk/utils/debug.py,sha256=F7JlUwYjTFZAMRbBqKm6hxOIz-_IXYA8lBInOS4jbS4,100
102
- synapse_sdk/utils/file.py,sha256=HgSFZ5O_pYCumLH0Qft6C_NVz-H-ECaUfNcs3sTs43g,5443
102
+ synapse_sdk/utils/file.py,sha256=eF1GDxjPaq2QOiKKCHSzgCkBRYSBSwP4rKOAApAQR3E,5661
103
103
  synapse_sdk/utils/module_loading.py,sha256=chHpU-BZjtYaTBD_q0T7LcKWtqKvYBS4L0lPlKkoMQ8,1020
104
+ synapse_sdk/utils/network.py,sha256=wg-oFM0gKK5REqIUO8d-x9yXJfqbnkSbbF0_qyxpwz4,412
104
105
  synapse_sdk/utils/storage.py,sha256=a8OVbd38ATr0El4G4kuV07lr_tJZrpIJBSy4GHb0qZ8,2581
105
106
  synapse_sdk/utils/string.py,sha256=rEwuZ9SAaZLcQ8TYiwNKr1h2u4CfnrQx7SUL8NWmChg,216
106
107
  synapse_sdk/utils/pydantic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
108
  synapse_sdk/utils/pydantic/config.py,sha256=1vYOcUI35GslfD1rrqhFkNXXJOXt4IDqOPSx9VWGfNE,123
108
109
  synapse_sdk/utils/pydantic/errors.py,sha256=0v0T12eQBr1KrFiEOBu6KMaPK4aPEGEC6etPJGoR5b4,1061
109
110
  synapse_sdk/utils/pydantic/validators.py,sha256=G47P8ObPhsePmd_QZDK8EdPnik2CbaYzr_N4Z6En8dc,193
110
- synapse_sdk-1.0.0a25.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
111
- synapse_sdk-1.0.0a25.dist-info/METADATA,sha256=U7zm1tGFEUpAF4cjcsjPSXf1-RGR0GTD6cDyCeFA918,1070
112
- synapse_sdk-1.0.0a25.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
113
- synapse_sdk-1.0.0a25.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
114
- synapse_sdk-1.0.0a25.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
115
- synapse_sdk-1.0.0a25.dist-info/RECORD,,
111
+ synapse_sdk-1.0.0a26.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
112
+ synapse_sdk-1.0.0a26.dist-info/METADATA,sha256=DnO5NIlrAWVsCnkh8YXP-5ujNpt_NxijYyOeJ_ZQF2M,1070
113
+ synapse_sdk-1.0.0a26.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
114
+ synapse_sdk-1.0.0a26.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
115
+ synapse_sdk-1.0.0a26.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
116
+ synapse_sdk-1.0.0a26.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.7.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5