Python3: Use six.moves for py2 compatibility

Use 'range', 'reduce', 'map', 'cStringIO' from six.moves
for python3 compatibility.

Blueprint murano-python-3-support

Change-Id: I823c44d51db72ddb30a14f5755d781eca0d91e50
This commit is contained in:
Ravi Shekhar Jethani 2016-01-18 23:01:22 -08:00
parent b8d3ce1b73
commit 651cc3ba49
8 changed files with 11 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import eventlet.greenpool
import eventlet.greenthread
import semantic_version
import six
from six.moves import reduce
import yaql.language.exceptions
import yaql.language.expressions
from yaql.language import utils as yaqlutils

View File

@ -14,6 +14,7 @@
import six
from six.moves import range
from murano.dsl import constants
from murano.dsl import dsl_exception

View File

@ -17,6 +17,7 @@ import weakref
import semantic_version
import six
from six.moves import range
from yaql.language import utils
from murano.dsl import constants

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import itertools
import eventlet
import six
from yaql.language import specs
@ -75,7 +73,7 @@ def super_(context, sender, func=None):
if func is None:
return [sender.cast(type) for type in cast_type.parents(
sender.real_this.type)]
return itertools.imap(func, super_(context, sender))
return six.moves.map(func, super_(context, sender))
@specs.parameter('value', dsl_types.MuranoObject)

View File

@ -18,6 +18,7 @@ import collections
import random
import re
import six
from six.moves import range
import string
import time

View File

@ -14,7 +14,6 @@
# limitations under the License.
import cgi
import cStringIO
import imghdr
import json
import os
@ -22,6 +21,8 @@ import uuid
import mock
from oslo_utils import timeutils
from six.moves import cStringIO
from six.moves import range
from murano.api.v1 import catalog
from murano.db.catalog import api as db_catalog_api
@ -497,7 +498,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.expect_policy_check('upload_package')
self.expect_policy_check('publicize_package')
file_obj_str = cStringIO.StringIO("This is some dummy data")
file_obj_str = cStringIO("This is some dummy data")
file_obj = mock.MagicMock(cgi.FieldStorage)
file_obj.file = file_obj_str
package_from_dir, _ = self._test_package()

View File

@ -14,6 +14,7 @@
import uuid
from oslo_db import exception as db_exception
from six.moves import range
from webob import exc
from murano.db.catalog import api

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import range
from murano.dsl import helpers