You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/04/06 02:33:09 UTC
[3/4] libcloud git commit: cleanup old decompression code
cleanup old decompression code
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1fd49ed6
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1fd49ed6
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1fd49ed6
Branch: refs/heads/trunk
Commit: 1fd49ed6caa64ebe261bfdc93eaf1fd2209578ad
Parents: a4830d2
Author: Anthony Shaw <an...@apache.org>
Authored: Thu Apr 6 11:41:49 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Thu Apr 6 11:41:49 2017 +1000
----------------------------------------------------------------------
libcloud/common/base.py | 26 -----------------
libcloud/test/test_logging_connection.py | 1 -
libcloud/utils/compression.py | 42 ---------------------------
libcloud/utils/loggingconnection.py | 1 -
4 files changed, 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1fd49ed6/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 0d458fc..ca510e7 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -42,8 +42,6 @@ from libcloud.utils.py3 import urlparse
from libcloud.utils.py3 import urlencode
from libcloud.utils.misc import lowercase_keys, retry
-from libcloud.utils.compression import decompress_data
-
from libcloud.common.exceptions import exception_from_message
from libcloud.common.types import LibcloudError, MalformedResponseError
from libcloud.httplib_ssl import LibcloudConnection, HttpLibResponseProxy
@@ -200,30 +198,6 @@ class Response(object):
return self.status in [requests.codes.ok, requests.codes.created,
httplib.OK, httplib.CREATED, httplib.ACCEPTED]
- def _decompress_response(self, body, headers):
- """
- Decompress a response body if it is using deflate or gzip encoding.
-
- :param body: Response body.
- :type body: ``str``
-
- :param headers: Response headers.
- :type headers: ``dict``
-
- :return: Decompressed response
- :rtype: ``str``
- """
- encoding = headers.get('content-encoding', None)
-
- if encoding in ['zlib', 'deflate']:
- body = decompress_data('zlib', body)
- elif encoding in ['gzip', 'x-gzip']:
- body = decompress_data('gzip', body)
- else:
- body = body.strip()
-
- return body
-
class JsonResponse(Response):
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1fd49ed6/libcloud/test/test_logging_connection.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_logging_connection.py b/libcloud/test/test_logging_connection.py
index c1dbee6..85c6547 100644
--- a/libcloud/test/test_logging_connection.py
+++ b/libcloud/test/test_logging_connection.py
@@ -21,7 +21,6 @@ import requests_mock
import libcloud
from libcloud.test import unittest
from libcloud.common.base import Connection
-from libcloud.utils.py3 import b
from libcloud.httplib_ssl import LibcloudConnection
from libcloud.utils.loggingconnection import LoggingConnection
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1fd49ed6/libcloud/utils/compression.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/compression.py b/libcloud/utils/compression.py
deleted file mode 100644
index 9840538..0000000
--- a/libcloud/utils/compression.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import zlib
-import gzip
-
-from libcloud.utils.py3 import PY3
-from libcloud.utils.py3 import StringIO
-
-
-__all__ = [
- 'decompress_data'
-]
-
-
-def decompress_data(compression_type, data):
- if compression_type == 'zlib':
- return zlib.decompress(data)
- elif compression_type == 'gzip':
- # TODO: Should export BytesIO as StringIO in libcloud.utils.py3
- if PY3:
- from io import BytesIO
- cls = BytesIO
- else:
- cls = StringIO
-
- return gzip.GzipFile(fileobj=cls(data)).read()
- else:
- raise Exception('Invalid or onsupported compression type: %s' %
- (compression_type))
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1fd49ed6/libcloud/utils/loggingconnection.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/loggingconnection.py b/libcloud/utils/loggingconnection.py
index 7756b13..265f645 100644
--- a/libcloud/utils/loggingconnection.py
+++ b/libcloud/utils/loggingconnection.py
@@ -30,7 +30,6 @@ from libcloud.common.base import (LibcloudConnection,
from libcloud.utils.py3 import _real_unicode as u
from libcloud.utils.misc import lowercase_keys
-from libcloud.utils.compression import decompress_data
class LoggingConnection(LibcloudConnection):