libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [6/6] git commit: Use parse_qs and parse_qsl from libcloud.utils.py3.
Date Sat, 15 Jun 2013 08:20:16 GMT
Use parse_qs and parse_qsl from libcloud.utils.py3.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/45338e02
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/45338e02
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/45338e02

Branch: refs/heads/0.12.x
Commit: 45338e0288511aab4e9652e63440b62a1e2289b6
Parents: d7c8d21
Author: Tomaz Muraus <tomaz@tomaz.me>
Authored: Sat Jun 15 01:06:14 2013 -0700
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Sat Jun 15 01:15:06 2013 -0700

----------------------------------------------------------------------
 libcloud/test/__init__.py                     |  3 +--
 libcloud/test/common/test_cloudstack.py       |  7 +------
 libcloud/test/compute/test_cloudstack.py      |  7 +------
 libcloud/test/compute/test_ec2.py             |  7 +------
 libcloud/test/compute/test_gogrid.py          |  6 +-----
 libcloud/test/compute/test_ktucloud.py        |  7 +------
 libcloud/test/loadbalancer/test_cloudstack.py |  7 +------
 libcloud/test/storage/test_azure_blobs.py     |  8 +-------
 libcloud/test/storage/test_s3.py              |  8 +-------
 libcloud/utils/py3.py                         | 12 ++++++++++++
 10 files changed, 21 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/test/__init__.py b/libcloud/test/__init__.py
index 20c8a75..5351992 100644
--- a/libcloud/test/__init__.py
+++ b/libcloud/test/__init__.py
@@ -17,11 +17,10 @@ import sys
 import random
 import unittest
 
-from cgi import parse_qs
-
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import StringIO
 from libcloud.utils.py3 import urlparse
+from libcloud.utils.py3 import parse_qs
 from libcloud.utils.py3 import u
 
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/common/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_cloudstack.py b/libcloud/test/common/test_cloudstack.py
index 62d6abf..1c7c624 100644
--- a/libcloud/test/common/test_cloudstack.py
+++ b/libcloud/test/common/test_cloudstack.py
@@ -24,12 +24,7 @@ except ImportError:
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
 from libcloud.utils.py3 import b
-
-try:
-    parse_qsl = urlparse.parse_qsl
-except AttributeError:
-    import cgi
-    parse_qsl = cgi.parse_qsl
+from libcloud.utils.py3 import parse_qsl
 
 from libcloud.common.cloudstack import CloudStackConnection, CloudStackResponse
 from libcloud.common.types import MalformedResponseError

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index 2e72fc3..864cff4 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -18,18 +18,13 @@ import unittest
 
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
+from libcloud.utils.py3 import parse_qsl
 
 try:
     import simplejson as json
 except ImportError:
     import json
 
-try:
-    parse_qsl = urlparse.parse_qsl
-except AttributeError:
-    import cgi
-    parse_qsl = cgi.parse_qsl
-
 from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
 from libcloud.compute.types import DeploymentError, LibcloudError
 from libcloud.compute.base import Node, NodeImage, NodeSize, NodeLocation

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 260a4f7..d0e2c8a 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -16,6 +16,7 @@ import sys
 import unittest
 
 from libcloud.utils.py3 import httplib
+from libcloud.utils.py3 import parse_qsl
 
 from libcloud.compute.drivers.ec2 import EC2NodeDriver, EC2APSENodeDriver
 from libcloud.compute.drivers.ec2 import EC2USWestNodeDriver
@@ -39,12 +40,6 @@ from libcloud.test.file_fixtures import ComputeFileFixtures
 
 from libcloud.test.secrets import EC2_PARAMS
 
-try:
-    parse_qsl = urlparse.parse_qsl
-except AttributeError:
-    import cgi
-    parse_qsl = cgi.parse_qsl
-
 
 class EC2Tests(LibcloudTestCase, TestCaseMixin):
     image_name = 'ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml'

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/compute/test_gogrid.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gogrid.py b/libcloud/test/compute/test_gogrid.py
index 823f328..65b9327 100644
--- a/libcloud/test/compute/test_gogrid.py
+++ b/libcloud/test/compute/test_gogrid.py
@@ -17,6 +17,7 @@ import unittest
 
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
+from libcloud.utils.py3 import parse_qs
 
 from libcloud.compute.base import NodeState, NodeLocation
 from libcloud.common.types import LibcloudError, InvalidCredsError
@@ -266,11 +267,6 @@ class GoGridMockHttp(MockHttp):
     def _api_common_lookup_list(self, method, url, body, headers):
         _valid_lookups = ("ip.datacenter",)
 
-        try:
-            from urlparse import parse_qs
-        except ImportError:
-            from cgi import parse_qs
-
         lookup = parse_qs(urlparse.urlparse(url).query)["lookup"][0]
         if lookup in _valid_lookups:
             fixture_path = "lookup_list_%s.json" % \

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/compute/test_ktucloud.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ktucloud.py b/libcloud/test/compute/test_ktucloud.py
index 8a637c0..319d6b0 100644
--- a/libcloud/test/compute/test_ktucloud.py
+++ b/libcloud/test/compute/test_ktucloud.py
@@ -18,18 +18,13 @@ import unittest
 
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
+from libcloud.utils.py3 import parse_qsl
 
 try:
     import simplejson as json
 except ImportError:
     import json
 
-try:
-    parse_qsl = urlparse.parse_qsl
-except AttributeError:
-    import cgi
-    parse_qsl = cgi.parse_qsl
-
 from libcloud.compute.drivers.ktucloud import KTUCloudNodeDriver
 from libcloud.compute.types import DeploymentError, LibcloudError
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/loadbalancer/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/loadbalancer/test_cloudstack.py b/libcloud/test/loadbalancer/test_cloudstack.py
index b4ea3a2..6c924b9 100644
--- a/libcloud/test/loadbalancer/test_cloudstack.py
+++ b/libcloud/test/loadbalancer/test_cloudstack.py
@@ -8,12 +8,7 @@ except ImportError:
 
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
-
-try:
-    parse_qsl = urlparse.parse_qsl
-except AttributeError:
-    import cgi
-    parse_qsl = cgi.parse_qsl
+from libcloud.utils.py3 import parse_qsl
 
 from libcloud.common.types import LibcloudError
 from libcloud.loadbalancer.base import LoadBalancer, Member, Algorithm

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/storage/test_azure_blobs.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_azure_blobs.py b/libcloud/test/storage/test_azure_blobs.py
index eb30cc4..3255d9d 100644
--- a/libcloud/test/storage/test_azure_blobs.py
+++ b/libcloud/test/storage/test_azure_blobs.py
@@ -23,6 +23,7 @@ import tempfile
 from xml.etree import ElementTree as ET
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
+from libcloud.utils.py3 import parse_qs
 
 from libcloud.common.types import InvalidCredsError
 from libcloud.common.types import LibcloudError
@@ -44,13 +45,6 @@ from libcloud.test.file_fixtures import StorageFileFixtures # pylint: disable-ms
 from libcloud.test.secrets import STORAGE_AZURE_BLOBS_PARAMS
 
 
-try:
-    parse_qs = urlparse.parse_qs
-except AttributeError:
-    import cgi
-    parse_qs = cgi.parse_qs
-
-
 class AzureBlobsMockHttp(StorageMockHttp, MockHttpTestCase):
 
     fixtures = StorageFileFixtures('azure_blobs')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/test/storage/test_s3.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_s3.py b/libcloud/test/storage/test_s3.py
index ff96202..2287d5c 100644
--- a/libcloud/test/storage/test_s3.py
+++ b/libcloud/test/storage/test_s3.py
@@ -20,6 +20,7 @@ import unittest
 from xml.etree import ElementTree as ET
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
+from libcloud.utils.py3 import parse_qs
 
 from libcloud.common.types import InvalidCredsError
 from libcloud.common.types import LibcloudError
@@ -41,13 +42,6 @@ from libcloud.test.file_fixtures import StorageFileFixtures # pylint: disable-ms
 from libcloud.test.secrets import STORAGE_S3_PARAMS
 
 
-try:
-    parse_qs = urlparse.parse_qs
-except AttributeError:
-    import cgi
-    parse_qs = cgi.parse_qs
-
-
 class S3MockHttp(StorageMockHttp, MockHttpTestCase):
 
     fixtures = StorageFileFixtures('s3')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/45338e02/libcloud/utils/py3.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/py3.py b/libcloud/utils/py3.py
index 3a41bc1..18055f0 100644
--- a/libcloud/utils/py3.py
+++ b/libcloud/utils/py3.py
@@ -59,6 +59,9 @@ if PY3:
     from builtins import bytes
     from builtins import next
 
+    parse_qs = urlparse.parse_qs
+    parse_qsl = urlparse.parse_qsl
+
     basestring = str
 
     def method_type(callable, instance, klass):
@@ -94,6 +97,15 @@ else:
 
     from __builtin__ import reload
 
+    if PY25:
+        import cgi
+
+        parse_qs = cgi.parse_qs
+        parse_qsl = cgi.parse_qsl
+    else:
+        parse_qs = urlparse.parse_qs
+        parse_qsl = urlparse.parse_qsl
+
     if not PY25:
         from os.path import relpath
 


Mime
View raw message