From 9c1cc0cfdf2145f701d4c72f72cf75790584cb27 Mon Sep 17 00:00:00 2001 From: sblack-usu Date: Tue, 14 Oct 2025 10:25:10 -0600 Subject: [PATCH] remove url encoding, rely on default encoding from tools as needed --- hsclient/hydroshare.py | 10 +++++----- hsclient/utils.py | 14 -------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index 59ef710..72be7e5 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -51,7 +51,7 @@ from hsclient.json_models import ResourcePreview, User from hsclient.oauth2_model import Token -from hsclient.utils import attribute_filter, encode_resource_url, is_aggregation, main_file_type +from hsclient.utils import attribute_filter, is_aggregation, main_file_type import pkg_resources # part of setuptools VERSION = pkg_resources.get_distribution(__package__).version @@ -1429,7 +1429,7 @@ def upload_file(self, path, files, status_code=204): return self.post(path, files=files, status_code=status_code) def post(self, path, status_code, data=None, params={}, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.post(url, params=params, data=data, **kwargs) if response.status_code != status_code: raise Exception( @@ -1438,7 +1438,7 @@ def post(self, path, status_code, data=None, params={}, **kwargs): return response def put(self, path, status_code, data=None, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.put(url, data=data, **kwargs) if response.status_code != status_code: raise Exception( @@ -1447,7 +1447,7 @@ def put(self, path, status_code, data=None, **kwargs): return response def get(self, path, status_code, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.get(url, **kwargs) if response.status_code != status_code: raise Exception( @@ -1456,7 +1456,7 @@ def get(self, path, status_code, **kwargs): return response def delete(self, path, status_code, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.delete(url, **kwargs) if response.status_code != status_code: raise Exception( diff --git a/hsclient/utils.py b/hsclient/utils.py index a8ef779..4275b06 100644 --- a/hsclient/utils.py +++ b/hsclient/utils.py @@ -52,20 +52,6 @@ def attribute_filter(o, key, value) -> bool: return attr == value -def encode_resource_url(url): - """ - URL encodes a full resource file/folder url. - :param url: a string url - :return: url encoded string - """ - import urllib - - parsed_url = urllib.parse.urlparse(url) - url_encoded_path = pathname2url(parsed_url.path) - encoded_url = parsed_url._replace(path=url_encoded_path).geturl() - return encoded_url - - def is_folder(path): """Checks for an extension to determine if the path is to a folder""" return splitext(path)[1] == ''