[Python-modules-commits] [lazr.restfulclient] 02/07: unapply patches
Mattia Rizzolo
mattia at debian.org
Thu May 19 09:31:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository lazr.restfulclient.
commit 5a7a3fe80fb1636f37d1cd1c5551008387e42818
Author: Mattia Rizzolo <mattia at debian.org>
Date: Thu May 19 09:16:56 2016 +0000
unapply patches
Gbp-Dch: Ignore
---
src/lazr/restfulclient/_browser.py | 2 --
src/lazr/restfulclient/resource.py | 42 ++++++++++++--------------------------
2 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/src/lazr/restfulclient/_browser.py b/src/lazr/restfulclient/_browser.py
index e8e2717..8e5cad6 100644
--- a/src/lazr/restfulclient/_browser.py
+++ b/src/lazr/restfulclient/_browser.py
@@ -318,8 +318,6 @@ class MultipleRepresentationCache(AtomicFileCache):
(scheme, authority, request_uri, cachekey) = urlnorm(uri)
cached_value = self.get(cachekey)
header_start = header + ':'
- if not isinstance(header_start, bytes):
- header_start = header_start.encode('utf-8')
if cached_value is not None:
for line in BytesIO(cached_value):
if line.startswith(header_start):
diff --git a/src/lazr/restfulclient/resource.py b/src/lazr/restfulclient/resource.py
index 702cc67..3026a07 100644
--- a/src/lazr/restfulclient/resource.py
+++ b/src/lazr/restfulclient/resource.py
@@ -48,10 +48,9 @@ except ImportError:
try:
# Python 3.
- from urllib.parse import urljoin, urlparse, parse_qs, unquote
+ from urllib.parse import urljoin, urlparse, parse_qs
except ImportError:
from urlparse import urljoin, urlparse, parse_qs
- from urllib import unquote
import types
import urllib
@@ -382,7 +381,7 @@ class Resource(RestfulBase):
representation = self._root._browser.get(self._wadl_resource)
if isinstance(representation, binary_type):
representation = representation.decode('utf-8')
- representation = loads(representation)
+ representation = loads(text_type(representation))
# In rare cases, the resource type served by the
# server conflicts with the type the client thought
@@ -531,10 +530,8 @@ class ServiceRoot(Resource):
url = url[1:]
url = str(self._root_uri.append(url))
document = self._browser.get(url)
- if isinstance(document, binary_type):
- document = document.decode('utf-8')
try:
- representation = loads(document)
+ representation = loads(text_type(document))
except ValueError:
raise ValueError("%s doesn't serve a JSON document." % url)
type_link = representation.get("resource_type_link")
@@ -650,18 +647,13 @@ class NamedOperation(RestfulBase):
# The operation returned a document with nothing
# special about it.
if content_type == self.JSON_MEDIA_TYPE:
- if isinstance(content, binary_type):
- content = content.decode('utf-8')
- return loads(content)
+ return loads(text_type(content))
# We don't know how to process the content.
return content
# The operation returned a representation of some
# resource. Instantiate a Resource object for it.
- if isinstance(content, binary_type):
- content = content.decode('utf-8')
-
- document = loads(content)
+ document = loads(text_type(content))
if document is None:
# The operation returned a null value.
return document
@@ -785,9 +777,7 @@ class Entry(Resource):
if response.status == 209 and content_type == self.JSON_MEDIA_TYPE:
# The server sent back a new representation of the object.
# Use it in preference to the existing representation.
- if isinstance(content, binary_type):
- content = content.decode('utf-8')
- new_representation = loads(content)
+ new_representation = loads(text_type(content))
self._wadl_resource.representation = new_representation
self._wadl_resource.media_type = content_type
@@ -832,10 +822,8 @@ class Collection(Resource):
next_link = current_page.get('next_collection_link')
if next_link is None:
break
- next_get = self._root._browser.get(URI(next_link))
- if isinstance(next_get, binary_type):
- next_get = next_get.decode('utf-8')
- current_page = loads(next_get)
+ current_page = loads(
+ text_type(self._root._browser.get(URI(next_link))))
def __getitem__(self, key):
"""Look up a slice, or a subordinate resource by index.
@@ -907,10 +895,8 @@ class Collection(Resource):
# Iterate over pages until we have the correct number of entries.
while more_needed > 0 and page_url is not None:
- page_get = self._root._browser.get(page_url)
- if isinstance(page_get, binary_type):
- page_get = page_get.decode('utf-8')
- representation = loads(page_get)
+ representation = loads(
+ text_type(self._root._browser.get(page_url)))
current_page_entries = representation['entries']
entry_dicts += current_page_entries[:more_needed]
more_needed = desired_size - len(entry_dicts)
@@ -1034,10 +1020,8 @@ class CollectionWithKeyBasedLookup(Collection):
# retrieve a representation of the resource and see how
# the resource describes itself.
try:
- url_get = self._root._browser.get(url)
- if isinstance(url_get, binary_type):
- url_get = url_get.decode('utf-8')
- representation = loads(url_get)
+ representation = loads(
+ text_type(self._root._browser.get(url)))
except HTTPError as error:
# There's no resource corresponding to the given ID.
if error.response.status == 404:
@@ -1083,7 +1067,7 @@ class HostedFileBuffer(BytesIO):
# file.
content_location = response['content-location']
path = urlparse(content_location)[2]
- filename = unquote(path.split("/")[-1])
+ filename = urllib.unquote(path.split("/")[-1])
elif mode == 'w':
value = ''
if content_type is None:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/lazr.restfulclient.git
More information about the Python-modules-commits
mailing list