diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index 59ef710..1363f0d 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -14,7 +14,7 @@ from posixpath import basename, dirname, join as urljoin, splitext from pprint import pformat from typing import Callable, Dict, List, TYPE_CHECKING, Union -from urllib.parse import quote, unquote, urlparse +from urllib.parse import unquote, urlparse from uuid import uuid4 from zipfile import ZipFile @@ -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 @@ -243,7 +243,7 @@ def _retrieve_checksums(self, path): # split string by lines, then split line by delimiter into a dict delimiter = " " data = { - quote(path): checksum for checksum, path in [line.split(delimiter) for line in file_str.split("\n") if line] + path: checksum for checksum, path in [line.split(delimiter) for line in file_str.split("\n") if line] } return data @@ -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] == '' diff --git a/setup.py b/setup.py index a3868da..357f46d 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='hsclient', - version='1.1.6', + version='1.1.7', packages=find_packages(include=['hsclient', 'hsclient.*'], exclude=("tests",)), install_requires=[