diff options
author | Kui Shi <skuicloud@gmail.com> | 2013-10-20 16:04:21 +0800 |
---|---|---|
committer | Kui Shi <skuicloud@gmail.com> | 2013-10-22 16:03:53 +0800 |
commit | d07ec04e193cb957929f0ab5761c9f080ad89ec2 (patch) | |
tree | 20e35e540acf30cb5c27e3cfb9c36470009eb0af | |
parent | e274a23dfcb1df7a67081eaa04c9d3aa142bf4d9 (diff) | |
download | python-heatclient-d07ec04e193cb957929f0ab5761c9f080ad89ec2.tar.gz |
Use the six library for compatability
Replace dict.iteritems() with six.iteritems(dict)
Import six for StringIO
Import urlutils for urlencode
Partial implement: blueprint py33-support
Change-Id: Ieae1299915168ef10ff54e0a9e9a346350e9d1fb
-rw-r--r-- | heatclient/common/base.py | 3 | ||||
-rw-r--r-- | heatclient/tests/test_shell.py | 8 | ||||
-rw-r--r-- | heatclient/v1/stacks.py | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/heatclient/common/base.py b/heatclient/common/base.py index 02b6a69..16ea13c 100644 --- a/heatclient/common/base.py +++ b/heatclient/common/base.py @@ -18,6 +18,7 @@ Base utilities to build API operation managers and objects on top of. """ import copy +import six # Python 2.4 compat @@ -86,7 +87,7 @@ class Resource(object): self._loaded = loaded def _add_details(self, info): - for (k, v) in info.iteritems(): + for (k, v) in six.iteritems(info): setattr(self, k, v) def __getattr__(self, k): diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py index f90eced..8bd9980 100644 --- a/heatclient/tests/test_shell.py +++ b/heatclient/tests/test_shell.py @@ -11,10 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import cStringIO import httplib2 import os import re +import six import sys import urllib2 import yaml @@ -64,7 +64,7 @@ class TestCase(testtools.TestCase): def shell_error(self, argstr, error_match): orig = sys.stderr try: - sys.stderr = cStringIO.StringIO() + sys.stderr = six.StringIO() _shell = heatclient.shell.HeatShell() _shell.main(argstr.split()) except Exception as e: @@ -224,7 +224,7 @@ class ShellTest(TestCase): def shell(self, argstr): orig = sys.stdout try: - sys.stdout = cStringIO.StringIO() + sys.stdout = six.StringIO() _shell = heatclient.shell.HeatShell() _shell.main(argstr.split()) except SystemExit: @@ -654,7 +654,7 @@ class ShellEnvironmentTest(TestCase): fields = {'files': {}} if url: self.m.StubOutWithMock(urllib2, 'urlopen') - urllib2.urlopen(url).AndReturn(cStringIO.StringIO(content)) + urllib2.urlopen(url).AndReturn(six.StringIO(content)) self.m.ReplayAll() v1shell._resolve_environment_urls(fields, env_base_url, jenv) diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py index ca80293..c196e23 100644 --- a/heatclient/v1/stacks.py +++ b/heatclient/v1/stacks.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import urllib +from heatclient.openstack.common.py3kcompat import urlutils from heatclient.common import base @@ -72,7 +72,7 @@ class StackManager(base.Manager): absolute_limit = kwargs.get('limit') def paginate(qp, seen=0): - url = '/stacks?%s' % urllib.urlencode(qp) + url = '/stacks?%s' % urlutils.urlencode(qp) stacks = self._list(url, "stacks") for stack in stacks: |