Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using six.iteritems to achieve iterators. We can use dict.items instead, as it will return iterators in PY3 as well. And dict.items/keys will more readable. 2.In py2, the performance about list should be negligible, see the link [2]. [1] https://wiki.openstack.org/wiki/Python3 [2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: I45fa65427318e1c35bb521de46e81ea12ca7b770
This commit is contained in:
parent
1f0064213e
commit
580677eedc
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from murano.packages import exceptions
|
from murano.packages import exceptions
|
||||||
@ -87,7 +86,7 @@ class CloudifyToscaPackage(package_base.PackageBase):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_properties(inputs, outputs):
|
def _generate_properties(inputs, outputs):
|
||||||
contracts = {}
|
contracts = {}
|
||||||
for name, value in six.iteritems(inputs):
|
for name, value in inputs.items():
|
||||||
prop = {
|
prop = {
|
||||||
'Contract': YAQL('$.string().notNull()'),
|
'Contract': YAQL('$.string().notNull()'),
|
||||||
'Usage': 'In'
|
'Usage': 'In'
|
||||||
@ -96,7 +95,7 @@ class CloudifyToscaPackage(package_base.PackageBase):
|
|||||||
prop['Default'] = value['default']
|
prop['Default'] = value['default']
|
||||||
contracts[name] = prop
|
contracts[name] = prop
|
||||||
|
|
||||||
for name in six.iterkeys(outputs):
|
for name in outputs.keys():
|
||||||
contracts[name] = {
|
contracts[name] = {
|
||||||
'Contract': YAQL('$.string()'),
|
'Contract': YAQL('$.string()'),
|
||||||
'Usage': 'Out'
|
'Usage': 'Out'
|
||||||
@ -107,7 +106,7 @@ class CloudifyToscaPackage(package_base.PackageBase):
|
|||||||
def _generate_describe_method(self, inputs):
|
def _generate_describe_method(self, inputs):
|
||||||
input_values = {
|
input_values = {
|
||||||
name: YAQL('$.' + name)
|
name: YAQL('$.' + name)
|
||||||
for name in six.iterkeys(inputs)
|
for name in inputs.keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -123,7 +122,7 @@ class CloudifyToscaPackage(package_base.PackageBase):
|
|||||||
def _generate_update_outputs_method(outputs):
|
def _generate_update_outputs_method(outputs):
|
||||||
assignments = [
|
assignments = [
|
||||||
{YAQL('$.' + name): YAQL('$outputs.get({0})'.format(name))}
|
{YAQL('$.' + name): YAQL('$outputs.get({0})'.format(name))}
|
||||||
for name in six.iterkeys(outputs)
|
for name in outputs.keys()
|
||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
'Arguments': [{
|
'Arguments': [{
|
||||||
@ -147,7 +146,7 @@ class CloudifyToscaPackage(package_base.PackageBase):
|
|||||||
package_version=None):
|
package_version=None):
|
||||||
section = {
|
section = {
|
||||||
key: YAQL(
|
key: YAQL(
|
||||||
'$.appConfiguration.' + key) for key in six.iterkeys(inputs)
|
'$.appConfiguration.' + key) for key in inputs.keys()
|
||||||
}
|
}
|
||||||
section.update({
|
section.update({
|
||||||
'?': {
|
'?': {
|
||||||
@ -169,7 +168,7 @@ class CloudifyToscaPackage(package_base.PackageBase):
|
|||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True,
|
'required': True,
|
||||||
'description': value.get('description', key)
|
'description': value.get('description', key)
|
||||||
} for key, value in six.iteritems(inputs)
|
} for key, value in inputs.items()
|
||||||
]
|
]
|
||||||
return [{
|
return [{
|
||||||
'appConfiguration': {
|
'appConfiguration': {
|
||||||
|
@ -396,7 +396,7 @@ class CSARPackage(package_base.PackageBase):
|
|||||||
|
|
||||||
rest_group = []
|
rest_group = []
|
||||||
properties = []
|
properties = []
|
||||||
for key, value in six.iteritems(tosca_inputs):
|
for key, value in tosca_inputs.items():
|
||||||
if key not in used_inputs:
|
if key not in used_inputs:
|
||||||
rest_group.append(CSARPackage._translate_ui_parameter(
|
rest_group.append(CSARPackage._translate_ui_parameter(
|
||||||
key, value))
|
key, value))
|
||||||
|
@ -24,7 +24,6 @@ from oslo_config import cfg
|
|||||||
from oslo_db import exception as db_exc
|
from oslo_db import exception as db_exc
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_log import versionutils
|
from oslo_log import versionutils
|
||||||
import six
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
import murano.api.v1
|
import murano.api.v1
|
||||||
@ -262,7 +261,7 @@ class Controller(object):
|
|||||||
tempf.name, target_dir=None,
|
tempf.name, target_dir=None,
|
||||||
drop_dir=True) as pkg_to_upload:
|
drop_dir=True) as pkg_to_upload:
|
||||||
# extend dictionary for update db
|
# extend dictionary for update db
|
||||||
for k, v in six.iteritems(PKG_PARAMS_MAP):
|
for k, v in PKG_PARAMS_MAP.items():
|
||||||
if hasattr(pkg_to_upload, k):
|
if hasattr(pkg_to_upload, k):
|
||||||
package_meta[v] = getattr(pkg_to_upload, k)
|
package_meta[v] = getattr(pkg_to_upload, k)
|
||||||
if len(package_meta['name']) > 80:
|
if len(package_meta['name']) > 80:
|
||||||
|
@ -17,7 +17,6 @@ import uuid
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
import tenacity
|
import tenacity
|
||||||
from webob import response
|
from webob import response
|
||||||
|
|
||||||
@ -167,7 +166,7 @@ class Controller(object):
|
|||||||
params = [parameters]
|
params = [parameters]
|
||||||
while params:
|
while params:
|
||||||
a = params.pop()
|
a = params.pop()
|
||||||
for k, v in six.iteritems(a):
|
for k, v in a.items():
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
params.append(v)
|
params.append(v)
|
||||||
if k == '?':
|
if k == '?':
|
||||||
|
@ -25,7 +25,6 @@ from oslo_db import options
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.common import config
|
from murano.common import config
|
||||||
from murano.common import engine
|
from murano.common import engine
|
||||||
@ -107,7 +106,7 @@ class MuranoTestRunner(object):
|
|||||||
# Check for method name occurrence in all methods.
|
# Check for method name occurrence in all methods.
|
||||||
# if there is no dot in provided item - it is a method name
|
# if there is no dot in provided item - it is a method name
|
||||||
if '.' not in item:
|
if '.' not in item:
|
||||||
for class_name, methods in six.iteritems(class_to_methods):
|
for class_name, methods in class_to_methods.items():
|
||||||
methods_to_run[class_name] = []
|
methods_to_run[class_name] = []
|
||||||
if item in methods:
|
if item in methods:
|
||||||
methods_to_run[class_name].append(item)
|
methods_to_run[class_name].append(item)
|
||||||
@ -126,9 +125,9 @@ class MuranoTestRunner(object):
|
|||||||
m for m in class_to_methods[class_to_test]
|
m for m in class_to_methods[class_to_test]
|
||||||
if m == test_method]
|
if m == test_method]
|
||||||
continue
|
continue
|
||||||
methods_count = sum(len(v) for v in six.itervalues(methods_to_run))
|
methods_count = sum(len(v) for v in methods_to_run.values())
|
||||||
methods = [k + '.' + method
|
methods = [k + '.' + method
|
||||||
for k, v in six.iteritems(methods_to_run) for method in v]
|
for k, v in methods_to_run.items() for method in v]
|
||||||
LOG.debug('{0} method(s) is(are) going to be executed: '
|
LOG.debug('{0} method(s) is(are) going to be executed: '
|
||||||
'\n{1}'.format(methods_count, '\n'.join(methods)))
|
'\n{1}'.format(methods_count, '\n'.join(methods)))
|
||||||
return methods_to_run
|
return methods_to_run
|
||||||
@ -187,7 +186,7 @@ class MuranoTestRunner(object):
|
|||||||
# Load keystone configuration parameters from config
|
# Load keystone configuration parameters from config
|
||||||
importutils.import_module('keystonemiddleware.auth_token')
|
importutils.import_module('keystonemiddleware.auth_token')
|
||||||
|
|
||||||
for param, value in six.iteritems(ks_opts):
|
for param, value in ks_opts.items():
|
||||||
if not value:
|
if not value:
|
||||||
ks_opts[param] = getattr(CONF.keystone_authtoken,
|
ks_opts[param] = getattr(CONF.keystone_authtoken,
|
||||||
ks_opts_to_config[param])
|
ks_opts_to_config[param])
|
||||||
@ -230,7 +229,7 @@ class MuranoTestRunner(object):
|
|||||||
class_to_methods)
|
class_to_methods)
|
||||||
max_length = 0
|
max_length = 0
|
||||||
num_tests = 0
|
num_tests = 0
|
||||||
for pkg_class, test_cases in six.iteritems(run_set):
|
for pkg_class, test_cases in run_set.items():
|
||||||
for m in test_cases:
|
for m in test_cases:
|
||||||
max_length = max(max_length, len(pkg_class)+len(m)+1)
|
max_length = max(max_length, len(pkg_class)+len(m)+1)
|
||||||
num_tests += len(test_cases)
|
num_tests += len(test_cases)
|
||||||
@ -247,7 +246,7 @@ class MuranoTestRunner(object):
|
|||||||
run_count = 0
|
run_count = 0
|
||||||
error_count = 0
|
error_count = 0
|
||||||
started = timeutils.utcnow()
|
started = timeutils.utcnow()
|
||||||
for pkg_class, test_cases in six.iteritems(run_set):
|
for pkg_class, test_cases in run_set.items():
|
||||||
for m in test_cases:
|
for m in test_cases:
|
||||||
# Create new executor for each test case to provide
|
# Create new executor for each test case to provide
|
||||||
# pure test environment
|
# pure test environment
|
||||||
|
@ -17,7 +17,6 @@ import re
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
from stevedore import dispatch
|
from stevedore import dispatch
|
||||||
|
|
||||||
from murano.dsl import murano_package
|
from murano.dsl import murano_package
|
||||||
@ -70,7 +69,7 @@ class PluginLoader(object):
|
|||||||
class_name=name, dist=dist_name))
|
class_name=name, dist=dist_name))
|
||||||
|
|
||||||
def cleanup_duplicates(self, name_map):
|
def cleanup_duplicates(self, name_map):
|
||||||
for class_name, package_names in six.iteritems(name_map):
|
for class_name, package_names in name_map.items():
|
||||||
if len(package_names) >= 2:
|
if len(package_names) >= 2:
|
||||||
LOG.warning("Class is defined in multiple packages!")
|
LOG.warning("Class is defined in multiple packages!")
|
||||||
for package_name in package_names:
|
for package_name in package_names:
|
||||||
@ -95,7 +94,7 @@ class PluginLoader(object):
|
|||||||
"{err}".format(ep=ep.name, dist=ep.dist, err=exc))
|
"{err}".format(ep=ep.name, dist=ep.dist, err=exc))
|
||||||
|
|
||||||
def register_in_loader(self, package_loader):
|
def register_in_loader(self, package_loader):
|
||||||
for package in six.itervalues(self.packages):
|
for package in self.packages.values():
|
||||||
package_loader.register_package(
|
package_loader.register_package(
|
||||||
MuranoPackage(package_loader, package))
|
MuranoPackage(package_loader, package))
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ class MuranoPackage(murano_package.MuranoPackage):
|
|||||||
def __init__(self, pkg_loader, package_definition):
|
def __init__(self, pkg_loader, package_definition):
|
||||||
super(MuranoPackage, self).__init__(
|
super(MuranoPackage, self).__init__(
|
||||||
pkg_loader, package_definition.name, runtime_version='1.0')
|
pkg_loader, package_definition.name, runtime_version='1.0')
|
||||||
for class_name, clazz in six.iteritems(package_definition.classes):
|
for class_name, clazz in package_definition.classes.items():
|
||||||
if hasattr(clazz, "_murano_class_name"):
|
if hasattr(clazz, "_murano_class_name"):
|
||||||
LOG.warning("Class '%(class_name)s' has a MuranoPL "
|
LOG.warning("Class '%(class_name)s' has a MuranoPL "
|
||||||
"name '%(name)s' defined which will be "
|
"name '%(name)s' defined which will be "
|
||||||
|
@ -212,7 +212,7 @@ def build_entity_map(value):
|
|||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
if '?' in value and 'id' in value['?']:
|
if '?' in value and 'id' in value['?']:
|
||||||
id_map[value['?']['id']] = value
|
id_map[value['?']['id']] = value
|
||||||
for v in six.itervalues(value):
|
for v in value.values():
|
||||||
build_entity_map_recursive(v, id_map)
|
build_entity_map_recursive(v, id_map)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
for item in value:
|
for item in value:
|
||||||
|
@ -224,7 +224,7 @@ class Debug(Middleware):
|
|||||||
resp = req.get_response(self.application)
|
resp = req.get_response(self.application)
|
||||||
|
|
||||||
print(("*" * 40) + " RESPONSE HEADERS")
|
print(("*" * 40) + " RESPONSE HEADERS")
|
||||||
for (key, value) in six.iteritems(resp.headers):
|
for (key, value) in resp.headers.items():
|
||||||
print(key, "=", value)
|
print(key, "=", value)
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ class Resource(object):
|
|||||||
"X-User-Id",
|
"X-User-Id",
|
||||||
"X-Tenant-Id")
|
"X-Tenant-Id")
|
||||||
|
|
||||||
for header, value in six.iteritems(headers):
|
for header, value in headers.items():
|
||||||
if header.startswith("X-") and header not in useful_headers:
|
if header.startswith("X-") and header not in useful_headers:
|
||||||
continue
|
continue
|
||||||
string_parts.append("{0}: {1}".format(header, value))
|
string_parts.append("{0}: {1}".format(header, value))
|
||||||
@ -1116,7 +1116,7 @@ class FormDataDeserializer(TextDeserializer):
|
|||||||
|
|
||||||
def default(self, request):
|
def default(self, request):
|
||||||
form_data_parts = request.POST
|
form_data_parts = request.POST
|
||||||
for key, value in six.iteritems(form_data_parts):
|
for key, value in form_data_parts.items():
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, six.string_types):
|
||||||
form_data_parts[key] = self._from_json(value)
|
form_data_parts[key] = self._from_json(value)
|
||||||
return {'body': form_data_parts}
|
return {'body': form_data_parts}
|
||||||
|
@ -17,7 +17,6 @@ from oslo_db import exception as db_exceptions
|
|||||||
from oslo_db.sqlalchemy import utils
|
from oslo_db.sqlalchemy import utils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
from sqlalchemy.orm import attributes
|
from sqlalchemy.orm import attributes
|
||||||
@ -420,7 +419,7 @@ def package_upload(values, tenant_id):
|
|||||||
_check_for_public_packages_with_fqn(
|
_check_for_public_packages_with_fqn(
|
||||||
session,
|
session,
|
||||||
values.get('fully_qualified_name'))
|
values.get('fully_qualified_name'))
|
||||||
for attr, func in six.iteritems(composite_attr_to_func):
|
for attr, func in composite_attr_to_func.items():
|
||||||
if values.get(attr):
|
if values.get(attr):
|
||||||
result = func(values[attr], session)
|
result = func(values[attr], session)
|
||||||
setattr(package, attr, result)
|
setattr(package, attr, result)
|
||||||
|
@ -17,7 +17,6 @@ SQLAlchemy models for murano data
|
|||||||
"""
|
"""
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy.ext import declarative
|
from sqlalchemy.ext import declarative
|
||||||
from sqlalchemy import orm as sa_orm
|
from sqlalchemy import orm as sa_orm
|
||||||
@ -47,7 +46,7 @@ class TimestampMixin(object):
|
|||||||
class _MuranoBase(models.ModelBase):
|
class _MuranoBase(models.ModelBase):
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
dictionary = self.__dict__.copy()
|
dictionary = self.__dict__.copy()
|
||||||
return dict((k, v) for k, v in six.iteritems(dictionary)
|
return dict((k, v) for k, v in dictionary.items()
|
||||||
if k != '_sa_instance_state')
|
if k != '_sa_instance_state')
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ class EnvironmentServices(object):
|
|||||||
if isinstance(data.get('?'), dict):
|
if isinstance(data.get('?'), dict):
|
||||||
data['?']['id'] = uuidutils.generate_uuid()
|
data['?']['id'] = uuidutils.generate_uuid()
|
||||||
result = {}
|
result = {}
|
||||||
for key, value in six.iteritems(data):
|
for key, value in data.items():
|
||||||
result[key] = EnvironmentServices._objectify(
|
result[key] = EnvironmentServices._objectify(
|
||||||
value, replacements)
|
value, replacements)
|
||||||
return result
|
return result
|
||||||
@ -262,7 +262,7 @@ class EnvironmentServices(object):
|
|||||||
return [EnvironmentServices._objectify(v, replacements)
|
return [EnvironmentServices._objectify(v, replacements)
|
||||||
for v in data]
|
for v in data]
|
||||||
elif isinstance(data, six.string_types):
|
elif isinstance(data, six.string_types):
|
||||||
for key, value in six.iteritems(replacements):
|
for key, value in replacements.items():
|
||||||
data = data.replace('%' + key + '%', value)
|
data = data.replace('%' + key + '%', value)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.dsl import dsl_types
|
from murano.dsl import dsl_types
|
||||||
|
|
||||||
@ -49,8 +48,8 @@ class AttributeStore(object):
|
|||||||
def serialize(self, known_objects):
|
def serialize(self, known_objects):
|
||||||
return [
|
return [
|
||||||
[key1, key2[0], key2[1], value]
|
[key1, key2[0], key2[1], value]
|
||||||
for key1, inner in six.iteritems(self._attributes)
|
for key1, inner in self._attributes.items()
|
||||||
for key2, value in six.iteritems(inner)
|
for key2, value in inner.items()
|
||||||
if key1 in known_objects
|
if key1 in known_objects
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import six
|
|
||||||
from yaql.language import specs
|
from yaql.language import specs
|
||||||
from yaql.language import utils
|
from yaql.language import utils
|
||||||
from yaql.language import yaqltypes
|
from yaql.language import yaqltypes
|
||||||
@ -144,7 +143,7 @@ class Contract(object):
|
|||||||
return data
|
return data
|
||||||
result = {}
|
result = {}
|
||||||
yaql_key = None
|
yaql_key = None
|
||||||
for key, value in six.iteritems(spec):
|
for key, value in spec.items():
|
||||||
if isinstance(key, dsl_types.YaqlExpression):
|
if isinstance(key, dsl_types.YaqlExpression):
|
||||||
if yaql_key is not None:
|
if yaql_key is not None:
|
||||||
raise exceptions.DslContractSyntaxError(
|
raise exceptions.DslContractSyntaxError(
|
||||||
@ -159,7 +158,7 @@ class Contract(object):
|
|||||||
|
|
||||||
if yaql_key is not None:
|
if yaql_key is not None:
|
||||||
yaql_value = spec[yaql_key]
|
yaql_value = spec[yaql_key]
|
||||||
for key, value in six.iteritems(data):
|
for key, value in data.items():
|
||||||
if key in result:
|
if key in result:
|
||||||
continue
|
continue
|
||||||
key = self._map(key, yaql_key, context, path)
|
key = self._map(key, yaql_key, context, path)
|
||||||
@ -252,7 +251,7 @@ class Contract(object):
|
|||||||
contract_context = base_context_func(
|
contract_context = base_context_func(
|
||||||
self._runtime_version).create_child_context()
|
self._runtime_version).create_child_context()
|
||||||
contract_context['root_context'] = context
|
contract_context['root_context'] = context
|
||||||
for key, value in six.iteritems(kwargs):
|
for key, value in kwargs.items():
|
||||||
contract_context[key] = value
|
contract_context[key] = value
|
||||||
contract_context[constants.CTX_NAMES_SCOPE] = \
|
contract_context[constants.CTX_NAMES_SCOPE] = \
|
||||||
context[constants.CTX_NAMES_SCOPE]
|
context[constants.CTX_NAMES_SCOPE]
|
||||||
|
@ -138,7 +138,7 @@ class MuranoDslExecutor(object):
|
|||||||
with self._acquire_method_lock(method, this_lock, arg_values_for_lock):
|
with self._acquire_method_lock(method, this_lock, arg_values_for_lock):
|
||||||
for i, arg in enumerate(args, 2):
|
for i, arg in enumerate(args, 2):
|
||||||
context[str(i)] = arg
|
context[str(i)] = arg
|
||||||
for key, value in six.iteritems(kwargs):
|
for key, value in kwargs.items():
|
||||||
context[key] = value
|
context[key] = value
|
||||||
|
|
||||||
def call():
|
def call():
|
||||||
@ -238,7 +238,7 @@ class MuranoDslExecutor(object):
|
|||||||
param_gen = itertools.chain(
|
param_gen = itertools.chain(
|
||||||
(six.text_type(arg) for arg in args),
|
(six.text_type(arg) for arg in args),
|
||||||
(u'{0} => {1}'.format(name, value)
|
(u'{0} => {1}'.format(name, value)
|
||||||
for name, value in six.iteritems(kwargs)))
|
for name, value in kwargs.items()))
|
||||||
params_str = u', '.join(param_gen)
|
params_str = u', '.join(param_gen)
|
||||||
method_name = '::'.join((method.declaring_type.name, method.name))
|
method_name = '::'.join((method.declaring_type.name, method.name))
|
||||||
thread_id = helpers.get_current_thread_id()
|
thread_id = helpers.get_current_thread_id()
|
||||||
@ -274,7 +274,7 @@ class MuranoDslExecutor(object):
|
|||||||
vararg_values = []
|
vararg_values = []
|
||||||
kwargs_arg = None
|
kwargs_arg = None
|
||||||
kwarg_values = {}
|
kwarg_values = {}
|
||||||
for name, definition in six.iteritems(arguments_scheme):
|
for name, definition in arguments_scheme.items():
|
||||||
if definition.usage == dsl_types.MethodArgumentUsages.VarArgs:
|
if definition.usage == dsl_types.MethodArgumentUsages.VarArgs:
|
||||||
varargs_arg = name
|
varargs_arg = name
|
||||||
parameter_values[name] = vararg_values
|
parameter_values[name] = vararg_values
|
||||||
@ -293,7 +293,7 @@ class MuranoDslExecutor(object):
|
|||||||
else:
|
else:
|
||||||
parameter_values[name] = arg
|
parameter_values[name] = arg
|
||||||
|
|
||||||
for name, value in six.iteritems(utils.filter_parameters_dict(kwargs)):
|
for name, value in utils.filter_parameters_dict(kwargs).items():
|
||||||
if name in arguments_scheme and name not in (
|
if name in arguments_scheme and name not in (
|
||||||
varargs_arg, kwargs_arg):
|
varargs_arg, kwargs_arg):
|
||||||
parameter_values[name] = value
|
parameter_values[name] = value
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.dsl import dsl_exception
|
from murano.dsl import dsl_exception
|
||||||
from murano.dsl import helpers
|
from murano.dsl import helpers
|
||||||
from murano.dsl import lhs_expression
|
from murano.dsl import lhs_expression
|
||||||
@ -84,7 +82,7 @@ def parse_expression(expr):
|
|||||||
result = Statement(expr)
|
result = Statement(expr)
|
||||||
elif isinstance(expr, dict):
|
elif isinstance(expr, dict):
|
||||||
kwds = {}
|
kwds = {}
|
||||||
for key, value in six.iteritems(expr):
|
for key, value in expr.items():
|
||||||
if isinstance(key, yaql_expression.YaqlExpression):
|
if isinstance(key, yaql_expression.YaqlExpression):
|
||||||
if result is not None:
|
if result is not None:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
@ -55,7 +55,7 @@ def evaluate(value, context, freeze=True):
|
|||||||
return dict_type(
|
return dict_type(
|
||||||
(evaluate(d_key, context, freeze),
|
(evaluate(d_key, context, freeze),
|
||||||
evaluate(d_value, context, freeze))
|
evaluate(d_value, context, freeze))
|
||||||
for d_key, d_value in six.iteritems(value))
|
for d_key, d_value in value.items())
|
||||||
elif yaqlutils.is_sequence(value):
|
elif yaqlutils.is_sequence(value):
|
||||||
return list_type(evaluate(t, context, freeze) for t in value)
|
return list_type(evaluate(t, context, freeze) for t in value)
|
||||||
elif isinstance(value, yaqlutils.SetType):
|
elif isinstance(value, yaqlutils.SetType):
|
||||||
@ -574,7 +574,7 @@ def parse_object_definition(spec, scope_type, context):
|
|||||||
'destroyed': system_data.get('destroyed', False),
|
'destroyed': system_data.get('destroyed', False),
|
||||||
'dependencies': system_data.get('dependencies', {}),
|
'dependencies': system_data.get('dependencies', {}),
|
||||||
'extra': {
|
'extra': {
|
||||||
key: value for key, value in six.iteritems(system_data)
|
key: value for key, value in system_data.items()
|
||||||
if key.startswith('_')
|
if key.startswith('_')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import six
|
|
||||||
from yaql.language import specs
|
from yaql.language import specs
|
||||||
from yaql.language import utils
|
from yaql.language import utils
|
||||||
from yaql.language import yaqltypes
|
from yaql.language import yaqltypes
|
||||||
@ -52,7 +51,7 @@ def _prepare_context():
|
|||||||
src_property.set(
|
src_property.set(
|
||||||
utils.FrozenDict(
|
utils.FrozenDict(
|
||||||
itertools.chain(
|
itertools.chain(
|
||||||
six.iteritems(src),
|
src.items(),
|
||||||
((key, value),))))
|
((key, value),))))
|
||||||
elif isinstance(src, dsl_types.MuranoObject):
|
elif isinstance(src, dsl_types.MuranoObject):
|
||||||
src.set_property(key, value, context['#root_context'])
|
src.set_property(key, value, context['#root_context'])
|
||||||
|
@ -189,7 +189,7 @@ class MatchMacro(expressions.DslExpression):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
match_value = helpers.evaluate(self._value, context)
|
match_value = helpers.evaluate(self._value, context)
|
||||||
for key, value in six.iteritems(self._switch):
|
for key, value in self._switch.items():
|
||||||
if key == match_value:
|
if key == match_value:
|
||||||
CodeBlock(value).execute(context)
|
CodeBlock(value).execute(context)
|
||||||
return
|
return
|
||||||
@ -207,7 +207,7 @@ class SwitchMacro(expressions.DslExpression):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
matched = False
|
matched = False
|
||||||
for key, value in six.iteritems(self._switch):
|
for key, value in self._switch.items():
|
||||||
if helpers.evaluate(key, context):
|
if helpers.evaluate(key, context):
|
||||||
matched = True
|
matched = True
|
||||||
CodeBlock(value).execute(context)
|
CodeBlock(value).execute(context)
|
||||||
|
@ -93,7 +93,7 @@ class MuranoMethod(dsl_types.MuranoMethod, meta.MetaProvider):
|
|||||||
arguments_scheme = helpers.list_value(payload.get('Arguments'))
|
arguments_scheme = helpers.list_value(payload.get('Arguments'))
|
||||||
if isinstance(arguments_scheme, dict):
|
if isinstance(arguments_scheme, dict):
|
||||||
arguments_scheme = [{key: value} for key, value in
|
arguments_scheme = [{key: value} for key, value in
|
||||||
six.iteritems(arguments_scheme)]
|
arguments_scheme.items()]
|
||||||
self._arguments_scheme = collections.OrderedDict()
|
self._arguments_scheme = collections.OrderedDict()
|
||||||
seen_varargs = False
|
seen_varargs = False
|
||||||
seen_kwargs = False
|
seen_kwargs = False
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.dsl import constants
|
from murano.dsl import constants
|
||||||
from murano.dsl import dsl
|
from murano.dsl import dsl
|
||||||
@ -93,7 +92,7 @@ class MuranoObject(dsl_types.MuranoObject):
|
|||||||
used_names = used_names or set()
|
used_names = used_names or set()
|
||||||
names = set(self.type.properties)
|
names = set(self.type.properties)
|
||||||
if init:
|
if init:
|
||||||
names.update(six.iterkeys(init.arguments_scheme))
|
names.update(init.arguments_scheme.keys())
|
||||||
last_errors = len(names)
|
last_errors = len(names)
|
||||||
init_args = {}
|
init_args = {}
|
||||||
while True:
|
while True:
|
||||||
@ -376,7 +375,7 @@ class MuranoObject(dsl_types.MuranoObject):
|
|||||||
self._owner = None
|
self._owner = None
|
||||||
self._destruction_dependencies = None
|
self._destruction_dependencies = None
|
||||||
self._this = None
|
self._this = None
|
||||||
for p in six.itervalues(self._parents):
|
for p in self._parents.values():
|
||||||
p.mark_destroyed(clear_data)
|
p.mark_destroyed(clear_data)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -50,7 +50,7 @@ class MuranoPackage(dsl_types.MuranoPackage, dslmeta.MetaProvider):
|
|||||||
semantic_version.Spec('==0')
|
semantic_version.Spec('==0')
|
||||||
self._classes = {}
|
self._classes = {}
|
||||||
self._imported_types = {object, murano_object.MuranoObject}
|
self._imported_types = {object, murano_object.MuranoObject}
|
||||||
for key, value in six.iteritems(requirements or {}):
|
for key, value in (requirements or {}).items():
|
||||||
self._requirements[key] = helpers.parse_version_spec(value)
|
self._requirements[key] = helpers.parse_version_spec(value)
|
||||||
|
|
||||||
self._load_queue = {}
|
self._load_queue = {}
|
||||||
@ -181,8 +181,7 @@ class MuranoPackage(dsl_types.MuranoPackage, dslmeta.MetaProvider):
|
|||||||
return result
|
return result
|
||||||
if search_requirements:
|
if search_requirements:
|
||||||
pkgs_for_search = []
|
pkgs_for_search = []
|
||||||
for package_name, version_spec in six.iteritems(
|
for package_name, version_spec in self._requirements.items():
|
||||||
self._requirements):
|
|
||||||
if package_name == self.name:
|
if package_name == self.name:
|
||||||
continue
|
continue
|
||||||
referenced_package = self._package_loader.load_package(
|
referenced_package = self._package_loader.load_package(
|
||||||
|
@ -263,7 +263,7 @@ class MuranoClass(dsl_types.MuranoClass, MuranoType, dslmeta.MetaProvider):
|
|||||||
def find_methods(self, predicate):
|
def find_methods(self, predicate):
|
||||||
result = list(filter(predicate, self.methods.values()))
|
result = list(filter(predicate, self.methods.values()))
|
||||||
for c in self.ancestors():
|
for c in self.ancestors():
|
||||||
for method in six.itervalues(c.methods):
|
for method in c.methods.values():
|
||||||
if predicate(method) and method not in result:
|
if predicate(method) and method not in result:
|
||||||
result.append(method)
|
result.append(method)
|
||||||
return result
|
return result
|
||||||
@ -345,7 +345,7 @@ class MuranoClass(dsl_types.MuranoClass, MuranoType, dslmeta.MetaProvider):
|
|||||||
(parent.package, requirement))
|
(parent.package, requirement))
|
||||||
|
|
||||||
package_bindings = {}
|
package_bindings = {}
|
||||||
for versions in six.itervalues(aggregation):
|
for versions in aggregation.values():
|
||||||
mappings = self._remap_package(versions)
|
mappings = self._remap_package(versions)
|
||||||
package_bindings.update(mappings)
|
package_bindings.update(mappings)
|
||||||
|
|
||||||
@ -504,7 +504,7 @@ def _create_class(cls, name, ns_resolver, data, package, *args, **kwargs):
|
|||||||
data.get('Import'), *args, **kwargs)
|
data.get('Import'), *args, **kwargs)
|
||||||
|
|
||||||
properties = data.get('Properties') or {}
|
properties = data.get('Properties') or {}
|
||||||
for property_name, property_spec in six.iteritems(properties):
|
for property_name, property_spec in properties.items():
|
||||||
spec = murano_property.MuranoProperty(
|
spec = murano_property.MuranoProperty(
|
||||||
type_obj, property_name, property_spec)
|
type_obj, property_name, property_spec)
|
||||||
type_obj.add_property(spec)
|
type_obj.add_property(spec)
|
||||||
@ -516,7 +516,7 @@ def _create_class(cls, name, ns_resolver, data, package, *args, **kwargs):
|
|||||||
'destroy': '.destroy'
|
'destroy': '.destroy'
|
||||||
}
|
}
|
||||||
|
|
||||||
for method_name, payload in six.iteritems(methods):
|
for method_name, payload in methods.items():
|
||||||
type_obj.add_method(
|
type_obj.add_method(
|
||||||
method_mappings.get(method_name, method_name), payload)
|
method_mappings.get(method_name, method_name), payload)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import gc
|
|||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.dsl import dsl_types
|
from murano.dsl import dsl_types
|
||||||
from murano.dsl import helpers
|
from murano.dsl import helpers
|
||||||
@ -60,7 +59,7 @@ class ObjectStore(object):
|
|||||||
self._store[murano_object.object_id] = murano_object
|
self._store[murano_object.object_id] = murano_object
|
||||||
|
|
||||||
def iterate(self):
|
def iterate(self):
|
||||||
return six.iterkeys(self._store)
|
return self._store.keys()
|
||||||
|
|
||||||
def remove(self, object_id):
|
def remove(self, object_id):
|
||||||
self._store.pop(object_id)
|
self._store.pop(object_id)
|
||||||
@ -85,7 +84,7 @@ class ObjectStore(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_designer_attributes(header):
|
def _get_designer_attributes(header):
|
||||||
return dict((k, v) for k, v in six.iteritems(header)
|
return dict((k, v) for k, v in header.items()
|
||||||
if str(k).startswith('_'))
|
if str(k).startswith('_'))
|
||||||
|
|
||||||
def designer_attributes(self, object_id):
|
def designer_attributes(self, object_id):
|
||||||
@ -109,7 +108,7 @@ class ObjectStore(object):
|
|||||||
def prepare_finalize(self, used_objects):
|
def prepare_finalize(self, used_objects):
|
||||||
used_objects = set(used_objects) if used_objects else []
|
used_objects = set(used_objects) if used_objects else []
|
||||||
sentenced_objects = [
|
sentenced_objects = [
|
||||||
obj for obj in six.itervalues(self._store)
|
obj for obj in self._store.values()
|
||||||
if obj not in used_objects
|
if obj not in used_objects
|
||||||
]
|
]
|
||||||
with helpers.with_object_store(self):
|
with helpers.with_object_store(self):
|
||||||
|
@ -122,7 +122,7 @@ def generate_entity_schema(entity, context, declaring_type, meta):
|
|||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
name: generate_property_schema(prop, context, type_weights)
|
name: generate_property_schema(prop, context, type_weights)
|
||||||
for name, prop in six.iteritems(properties)
|
for name, prop in properties.items()
|
||||||
},
|
},
|
||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
'formSections': generate_sections(meta, type_weights)
|
'formSections': generate_sections(meta, type_weights)
|
||||||
@ -248,7 +248,7 @@ def translate_dict(contract, context, runtime_version):
|
|||||||
"""Translates dictionary contracts into json-schema objects"""
|
"""Translates dictionary contracts into json-schema objects"""
|
||||||
properties = {}
|
properties = {}
|
||||||
additional_properties = False
|
additional_properties = False
|
||||||
for key, value in six.iteritems(contract):
|
for key, value in contract.items():
|
||||||
if isinstance(key, dsl_types.YaqlExpression):
|
if isinstance(key, dsl_types.YaqlExpression):
|
||||||
additional_properties = translate(value, context, runtime_version)
|
additional_properties = translate(value, context, runtime_version)
|
||||||
else:
|
else:
|
||||||
|
@ -163,7 +163,7 @@ def _pass12_serialize(value, parent, serialized_objects,
|
|||||||
result = {}
|
result = {}
|
||||||
need_another_pass = False
|
need_another_pass = False
|
||||||
|
|
||||||
for d_key, d_value in six.iteritems(value):
|
for d_key, d_value in value.items():
|
||||||
if (isinstance(d_key, dsl_types.MuranoType) and
|
if (isinstance(d_key, dsl_types.MuranoType) and
|
||||||
serialization_type == dsl_types.DumpTypes.Serializable):
|
serialization_type == dsl_types.DumpTypes.Serializable):
|
||||||
result_key = str(d_key)
|
result_key = str(d_key)
|
||||||
@ -244,7 +244,7 @@ def collect_objects(root_object):
|
|||||||
for t in rec(value):
|
for t in rec(value):
|
||||||
yield t
|
yield t
|
||||||
elif isinstance(obj, utils.MappingType):
|
elif isinstance(obj, utils.MappingType):
|
||||||
for value in six.itervalues(obj):
|
for value in obj.values():
|
||||||
for t in rec(value):
|
for t in rec(value):
|
||||||
yield t
|
yield t
|
||||||
elif isinstance(obj, dsl_types.MuranoObjectInterface):
|
elif isinstance(obj, dsl_types.MuranoObjectInterface):
|
||||||
|
@ -53,7 +53,7 @@ def new(__context, __type_name, __owner=None, __object_name=None, __extra=None,
|
|||||||
__type_name: parameters,
|
__type_name: parameters,
|
||||||
'name': __object_name
|
'name': __object_name
|
||||||
}
|
}
|
||||||
for key, value in six.iteritems(__extra or {}):
|
for key, value in (__extra or {}).items():
|
||||||
if key.startswith('_'):
|
if key.startswith('_'):
|
||||||
data[key] = value
|
data[key] = value
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ def call_func(context, op_dot, base, name, args, kwargs,
|
|||||||
args += tuple(
|
args += tuple(
|
||||||
expressions.MappingRuleExpression(expressions.KeywordConstant(key),
|
expressions.MappingRuleExpression(expressions.KeywordConstant(key),
|
||||||
value)
|
value)
|
||||||
for key, value in six.iteritems(kwargs))
|
for key, value in kwargs.items())
|
||||||
function = expressions.Function(name, *args)
|
function = expressions.Function(name, *args)
|
||||||
return op_dot(context, receiver, function)
|
return op_dot(context, receiver, function)
|
||||||
else:
|
else:
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
import six
|
|
||||||
import yaql
|
import yaql
|
||||||
from yaql.language import contexts
|
from yaql.language import contexts
|
||||||
from yaql.language import conventions
|
from yaql.language import conventions
|
||||||
@ -132,7 +131,7 @@ def call_func(__context, __name, *args, **kwargs):
|
|||||||
return __context(__name, engine)(
|
return __context(__name, engine)(
|
||||||
*args,
|
*args,
|
||||||
**{CONVENTION.convert_parameter_name(key): value
|
**{CONVENTION.convert_parameter_name(key): value
|
||||||
for key, value in six.iteritems(kwargs)})
|
for key, value in kwargs.items()})
|
||||||
|
|
||||||
|
|
||||||
def _infer_parameter_type(name, class_name):
|
def _infer_parameter_type(name, class_name):
|
||||||
@ -330,7 +329,7 @@ def _create_basic_mpl_stub(murano_method, reserve_params, payload,
|
|||||||
i = reserve_params + 1
|
i = reserve_params + 1
|
||||||
varargs = False
|
varargs = False
|
||||||
kwargs = False
|
kwargs = False
|
||||||
for name, arg_spec in six.iteritems(murano_method.arguments_scheme):
|
for name, arg_spec in murano_method.arguments_scheme.items():
|
||||||
position = i
|
position = i
|
||||||
if arg_spec.usage == dsl_types.MethodArgumentUsages.VarArgs:
|
if arg_spec.usage == dsl_types.MethodArgumentUsages.VarArgs:
|
||||||
name = '*'
|
name = '*'
|
||||||
@ -396,7 +395,7 @@ def get_class_factory_definition(cls, murano_class):
|
|||||||
def filter_parameters(__fd, *args, **kwargs):
|
def filter_parameters(__fd, *args, **kwargs):
|
||||||
if '*' not in __fd.parameters:
|
if '*' not in __fd.parameters:
|
||||||
position_args = 0
|
position_args = 0
|
||||||
for p in six.itervalues(__fd.parameters):
|
for p in __fd.parameters.values():
|
||||||
if p.position is not None:
|
if p.position is not None:
|
||||||
position_args += 1
|
position_args += 1
|
||||||
args = args[:position_args]
|
args = args[:position_args]
|
||||||
@ -405,7 +404,7 @@ def filter_parameters(__fd, *args, **kwargs):
|
|||||||
if not utils.is_keyword(name):
|
if not utils.is_keyword(name):
|
||||||
del kwargs[name]
|
del kwargs[name]
|
||||||
if '**' not in __fd.parameters:
|
if '**' not in __fd.parameters:
|
||||||
names = {p.alias or p.name for p in six.itervalues(__fd.parameters)}
|
names = {p.alias or p.name for p in __fd.parameters.values()}
|
||||||
for name in list(kwargs.keys()):
|
for name in list(kwargs.keys()):
|
||||||
if name not in names:
|
if name not in names:
|
||||||
del kwargs[name]
|
del kwargs[name]
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
from yaql.language import specs
|
from yaql.language import specs
|
||||||
from yaql.language import yaqltypes
|
from yaql.language import yaqltypes
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ def with_original(context, **kwargs):
|
|||||||
new_context = context.create_child_context()
|
new_context = context.create_child_context()
|
||||||
|
|
||||||
original_context = context[constants.CTX_ORIGINAL_CONTEXT]
|
original_context = context[constants.CTX_ORIGINAL_CONTEXT]
|
||||||
for k, v in six.iteritems(kwargs):
|
for k, v in kwargs.items():
|
||||||
new_context['$' + k] = v(original_context)
|
new_context['$' + k] = v(original_context)
|
||||||
return new_context
|
return new_context
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class ApiPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
def load_class_package(self, class_name, version_spec):
|
def load_class_package(self, class_name, version_spec):
|
||||||
packages = self._class_cache.get(class_name)
|
packages = self._class_cache.get(class_name)
|
||||||
if packages:
|
if packages:
|
||||||
version = version_spec.select(six.iterkeys(packages))
|
version = version_spec.select(packages.keys())
|
||||||
if version:
|
if version:
|
||||||
return packages[version]
|
return packages[version]
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class ApiPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
|
|
||||||
packages = self._package_cache.get(package_name)
|
packages = self._package_cache.get(package_name)
|
||||||
if packages:
|
if packages:
|
||||||
version = version_spec.select(six.iterkeys(packages))
|
version = version_spec.select(packages.keys())
|
||||||
if version:
|
if version:
|
||||||
return packages[version]
|
return packages[version]
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ class DirectoryPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
packages = self._packages_by_class.get(class_name)
|
packages = self._packages_by_class.get(class_name)
|
||||||
if not packages:
|
if not packages:
|
||||||
raise exceptions.NoPackageForClassFound(class_name)
|
raise exceptions.NoPackageForClassFound(class_name)
|
||||||
version = version_spec.select(six.iterkeys(packages))
|
version = version_spec.select(packages.keys())
|
||||||
if not version:
|
if not version:
|
||||||
raise exceptions.NoPackageForClassFound(class_name)
|
raise exceptions.NoPackageForClassFound(class_name)
|
||||||
return packages[version]
|
return packages[version]
|
||||||
@ -497,7 +497,7 @@ class DirectoryPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
packages = self._packages_by_name.get(package_name)
|
packages = self._packages_by_name.get(package_name)
|
||||||
if not packages:
|
if not packages:
|
||||||
raise exceptions.NoPackageFound(package_name)
|
raise exceptions.NoPackageFound(package_name)
|
||||||
version = version_spec.select(six.iterkeys(packages))
|
version = version_spec.select(packages.keys())
|
||||||
if not version:
|
if not version:
|
||||||
raise exceptions.NoPackageFound(package_name)
|
raise exceptions.NoPackageFound(package_name)
|
||||||
self._fixations[package_name].add(version)
|
self._fixations[package_name].add(version)
|
||||||
@ -513,8 +513,8 @@ class DirectoryPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def packages(self):
|
def packages(self):
|
||||||
for package_versions in six.itervalues(self._packages_by_name):
|
for package_versions in self._packages_by_name.values():
|
||||||
for package in six.itervalues(package_versions):
|
for package in package_versions.values():
|
||||||
yield package
|
yield package
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -582,7 +582,7 @@ class CombinedPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
for loader in self.directory_loaders:
|
for loader in self.directory_loaders:
|
||||||
fixations = deserialize_package_fixations(
|
fixations = deserialize_package_fixations(
|
||||||
loader.export_fixation_table())
|
loader.export_fixation_table())
|
||||||
for key, value in six.iteritems(fixations):
|
for key, value in fixations.items():
|
||||||
result[key].update(value)
|
result[key].update(value)
|
||||||
return serialize_package_fixations(result)
|
return serialize_package_fixations(result)
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ def _with_to_generator(context_obj):
|
|||||||
|
|
||||||
def deserialize_package_fixations(fixations):
|
def deserialize_package_fixations(fixations):
|
||||||
result = collections.defaultdict(set)
|
result = collections.defaultdict(set)
|
||||||
for name, versions in six.iteritems(fixations):
|
for name, versions in fixations.items():
|
||||||
for version in versions:
|
for version in versions:
|
||||||
result[name].add(helpers.parse_version(version))
|
result[name].add(helpers.parse_version(version))
|
||||||
return result
|
return result
|
||||||
@ -634,5 +634,5 @@ def deserialize_package_fixations(fixations):
|
|||||||
def serialize_package_fixations(fixations):
|
def serialize_package_fixations(fixations):
|
||||||
return {
|
return {
|
||||||
name: list(str(v) for v in versions)
|
name: list(str(v) for v in versions)
|
||||||
for name, versions in six.iteritems(fixations)
|
for name, versions in fixations.items()
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import heatclient.client as hclient
|
|||||||
import heatclient.exc as heat_exc
|
import heatclient.exc as heat_exc
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.common import auth_utils
|
from murano.common import auth_utils
|
||||||
from murano.dsl import dsl
|
from murano.dsl import dsl
|
||||||
@ -146,7 +145,7 @@ class HeatStack(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _remove_system_params(parameters):
|
def _remove_system_params(parameters):
|
||||||
return dict((k, v) for k, v in six.iteritems(parameters) if
|
return dict((k, v) for k, v in parameters.items() if
|
||||||
not k.startswith('OS::'))
|
not k.startswith('OS::'))
|
||||||
|
|
||||||
def _get_status(self):
|
def _get_status(self):
|
||||||
|
@ -54,24 +54,6 @@ def no_mutable_default_args(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
def check_python3_no_iteritems(logical_line):
|
|
||||||
if re.search(r".*\.iteritems\(\)", logical_line):
|
|
||||||
msg = ("M323: Use six.iteritems() instead of dict.iteritems().")
|
|
||||||
yield(0, msg)
|
|
||||||
|
|
||||||
|
|
||||||
def check_python3_no_iterkeys(logical_line):
|
|
||||||
if re.search(r".*\.iterkeys\(\)", logical_line):
|
|
||||||
msg = ("M324: Use six.iterkeys() instead of dict.iterkeys().")
|
|
||||||
yield(0, msg)
|
|
||||||
|
|
||||||
|
|
||||||
def check_python3_no_itervalues(logical_line):
|
|
||||||
if re.search(r".*\.itervalues\(\)", logical_line):
|
|
||||||
msg = ("M325: Use six.itervalues() instead of dict.itervalues().")
|
|
||||||
yield(0, msg)
|
|
||||||
|
|
||||||
|
|
||||||
def check_no_basestring(logical_line):
|
def check_no_basestring(logical_line):
|
||||||
if re.search(r"\bbasestring\b", logical_line):
|
if re.search(r"\bbasestring\b", logical_line):
|
||||||
msg = ("M326: basestring is not Python3-compatible, use "
|
msg = ("M326: basestring is not Python3-compatible, use "
|
||||||
@ -82,7 +64,4 @@ def check_no_basestring(logical_line):
|
|||||||
def factory(register):
|
def factory(register):
|
||||||
register(assert_equal_none)
|
register(assert_equal_none)
|
||||||
register(no_mutable_default_args)
|
register(no_mutable_default_args)
|
||||||
register(check_python3_no_iteritems)
|
|
||||||
register(check_python3_no_iterkeys)
|
|
||||||
register(check_python3_no_itervalues)
|
|
||||||
register(check_no_basestring)
|
register(check_no_basestring)
|
||||||
|
@ -178,7 +178,7 @@ class HotPackage(package_base.PackageBase):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _translate_outputs(hot):
|
def _translate_outputs(hot):
|
||||||
contract = {}
|
contract = {}
|
||||||
for key in six.iterkeys(hot.get('outputs') or {}):
|
for key in (hot.get('outputs') or {}).keys():
|
||||||
contract[key] = YAQL("$.string()")
|
contract[key] = YAQL("$.string()")
|
||||||
return {
|
return {
|
||||||
'templateOutputs': {
|
'templateOutputs': {
|
||||||
@ -391,7 +391,7 @@ class HotPackage(package_base.PackageBase):
|
|||||||
|
|
||||||
rest_group = []
|
rest_group = []
|
||||||
properties = []
|
properties = []
|
||||||
for key, value in six.iteritems(hot_parameters):
|
for key, value in hot_parameters.items():
|
||||||
if key not in used_parameters:
|
if key not in used_parameters:
|
||||||
rest_group.append(HotPackage._translate_ui_parameter(
|
rest_group.append(HotPackage._translate_ui_parameter(
|
||||||
key, value))
|
key, value))
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ class ModifyActionManager(object):
|
|||||||
'"action-name: {{p1: v1, ...}}" '
|
'"action-name: {{p1: v1, ...}}" '
|
||||||
'but got "{action_spec}"'
|
'but got "{action_spec}"'
|
||||||
.format(action_spec=action_spec))
|
.format(action_spec=action_spec))
|
||||||
for name, kwargs in six.iteritems(actions):
|
for name, kwargs in actions.items():
|
||||||
LOG.debug('Executing action {name}, params {params}'
|
LOG.debug('Executing action {name}, params {params}'
|
||||||
.format(name=name, params=kwargs))
|
.format(name=name, params=kwargs))
|
||||||
# loads action class
|
# loads action class
|
||||||
|
@ -37,7 +37,7 @@ class TestCaseShell(testtools.TestCase):
|
|||||||
'project_name': 'test',
|
'project_name': 'test',
|
||||||
'auth_url': 'http://localhost:5000'}
|
'auth_url': 'http://localhost:5000'}
|
||||||
self.args = ['test-runner.py']
|
self.args = ['test-runner.py']
|
||||||
for k, v in six.iteritems(self.auth_params):
|
for k, v in self.auth_params.items():
|
||||||
k = '--os-' + k.replace('_', '-')
|
k = '--os-' + k.replace('_', '-')
|
||||||
self.args.extend([k, v])
|
self.args.extend([k, v])
|
||||||
|
|
||||||
|
@ -984,7 +984,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
|
|||||||
# pkg_to_upload into package_meta dict.
|
# pkg_to_upload into package_meta dict.
|
||||||
pkg_to_upload = mock.MagicMock(
|
pkg_to_upload = mock.MagicMock(
|
||||||
__exit__=lambda obj, type, value, tb: False)
|
__exit__=lambda obj, type, value, tb: False)
|
||||||
for k, v in six.iteritems(PKG_PARAMS_MAP):
|
for k, v in PKG_PARAMS_MAP.items():
|
||||||
if v in test_package_meta.keys():
|
if v in test_package_meta.keys():
|
||||||
val = test_package_meta[v]
|
val = test_package_meta[v]
|
||||||
setattr(pkg_to_upload.__enter__(), k, val)
|
setattr(pkg_to_upload.__enter__(), k, val)
|
||||||
|
@ -40,7 +40,7 @@ class TestContextManager(context_manager.ContextManager):
|
|||||||
context = helpers.link_contexts(
|
context = helpers.link_contexts(
|
||||||
root_context, yaql_functions.get_context(runtime_version))
|
root_context, yaql_functions.get_context(runtime_version))
|
||||||
context = context.create_child_context()
|
context = context.create_child_context()
|
||||||
for name, func in six.iteritems(self.__functions):
|
for name, func in self.__functions.items():
|
||||||
context.register_function(func, name)
|
context.register_function(func, name)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class Runner(object):
|
|||||||
if isinstance(arg, object_model.Object):
|
if isinstance(arg, object_model.Object):
|
||||||
arg = object_model.build_model(arg)
|
arg = object_model.build_model(arg)
|
||||||
final_args.append(arg)
|
final_args.append(arg)
|
||||||
for name, arg in six.iteritems(kwargs):
|
for name, arg in kwargs.items():
|
||||||
if isinstance(arg, object_model.Object):
|
if isinstance(arg, object_model.Object):
|
||||||
arg = object_model.build_model(arg)
|
arg = object_model.build_model(arg)
|
||||||
final_kwargs[name] = arg
|
final_kwargs[name] = arg
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from murano.dsl import constants
|
from murano.dsl import constants
|
||||||
from murano.dsl import murano_package
|
from murano.dsl import murano_package
|
||||||
@ -57,7 +56,7 @@ class TestPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
self._package = TestPackage(
|
self._package = TestPackage(
|
||||||
self, package_name, None, constants.RUNTIME_VERSION_1_0,
|
self, package_name, None, constants.RUNTIME_VERSION_1_0,
|
||||||
None, self._configs, meta)
|
None, self._configs, meta)
|
||||||
for name, payload in six.iteritems(self._classes):
|
for name, payload in self._classes.items():
|
||||||
self._package.register_class(payload, name)
|
self._package.register_class(payload, name)
|
||||||
super(TestPackageLoader, self).__init__()
|
super(TestPackageLoader, self).__init__()
|
||||||
|
|
||||||
@ -106,8 +105,8 @@ class TestPackageLoader(package_loader.MuranoPackageLoader):
|
|||||||
if 'Name' not in data:
|
if 'Name' not in data:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for name, method in six.iteritems(data.get('Methods') or data.get(
|
for name, method in (data.get('Methods') or data.get(
|
||||||
'Workflow') or {}):
|
'Workflow') or {}).items():
|
||||||
if name.startswith('test'):
|
if name.startswith('test'):
|
||||||
method['Scope'] = 'Public'
|
method['Scope'] = 'Public'
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class TestMockContextManager(mock_context_manager.MockContextManager):
|
|||||||
root_context = super(TestMockContextManager, self).create_root_context(
|
root_context = super(TestMockContextManager, self).create_root_context(
|
||||||
runtime_version)
|
runtime_version)
|
||||||
context = root_context.create_child_context()
|
context = root_context.create_child_context()
|
||||||
for name, func in six.iteritems(self.__functions):
|
for name, func in self.__functions.items():
|
||||||
context.register_function(func, name)
|
context.register_function(func, name)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -97,27 +97,6 @@ class HackingTestCase(base.MuranoTestCase):
|
|||||||
self.assertEqual(0, len(list(checks.no_mutable_default_args(
|
self.assertEqual(0, len(list(checks.no_mutable_default_args(
|
||||||
"defined, undefined = [], {}"))))
|
"defined, undefined = [], {}"))))
|
||||||
|
|
||||||
def test_check_python3_no_iteritems(self):
|
|
||||||
self.assertEqual(1, len(list(checks.check_python3_no_iteritems(
|
|
||||||
"{'foo': 'bar'}.iteritems()"))))
|
|
||||||
|
|
||||||
self.assertEqual(0, len(list(checks.check_python3_no_iteritems(
|
|
||||||
"six.iteritems({'foo': 'bar'}"))))
|
|
||||||
|
|
||||||
def test_check_python3_no_iterkeys(self):
|
|
||||||
self.assertEqual(1, len(list(checks.check_python3_no_iterkeys(
|
|
||||||
"{'foo': 'bar'}.iterkeys()"))))
|
|
||||||
|
|
||||||
self.assertEqual(0, len(list(checks.check_python3_no_iterkeys(
|
|
||||||
"six.iterkeys({'foo': 'bar'}"))))
|
|
||||||
|
|
||||||
def test_check_python3_no_itervalues(self):
|
|
||||||
self.assertEqual(1, len(list(checks.check_python3_no_itervalues(
|
|
||||||
"{'foo': 'bar'}.itervalues()"))))
|
|
||||||
|
|
||||||
self.assertEqual(0, len(list(checks.check_python3_no_itervalues(
|
|
||||||
"six.itervalues({'foo': 'bar'}"))))
|
|
||||||
|
|
||||||
def test_check_no_basestring(self):
|
def test_check_no_basestring(self):
|
||||||
self.assertEqual(1, len(list(checks.check_no_basestring(
|
self.assertEqual(1, len(list(checks.check_no_basestring(
|
||||||
"isinstance('foo', basestring)"))))
|
"isinstance('foo', basestring)"))))
|
||||||
@ -130,8 +109,5 @@ class HackingTestCase(base.MuranoTestCase):
|
|||||||
checks.factory(mock_register)
|
checks.factory(mock_register)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(checks.no_mutable_default_args),
|
mock.call(checks.no_mutable_default_args),
|
||||||
mock.call(checks.check_python3_no_iteritems),
|
|
||||||
mock.call(checks.check_python3_no_iterkeys),
|
|
||||||
mock.call(checks.check_python3_no_itervalues),
|
|
||||||
mock.call(checks.check_no_basestring)]
|
mock.call(checks.check_no_basestring)]
|
||||||
mock_register.assert_has_calls(expected)
|
mock_register.assert_has_calls(expected)
|
||||||
|
@ -20,7 +20,6 @@ from tempest import config
|
|||||||
from tempest.lib.common import rest_client
|
from tempest.lib.common import rest_client
|
||||||
|
|
||||||
from murano_tempest_tests import utils
|
from murano_tempest_tests import utils
|
||||||
import six
|
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ class ArtifactsClient(rest_client.RestClient):
|
|||||||
'tags': manifest.get('Tags', []),
|
'tags': manifest.get('Tags', []),
|
||||||
'class_definitions': package.classes.keys()
|
'class_definitions': package.classes.keys()
|
||||||
}
|
}
|
||||||
for k, v in six.iteritems(body):
|
for k, v in body.items():
|
||||||
package_draft[k] = v
|
package_draft[k] = v
|
||||||
|
|
||||||
inherits = utils.get_local_inheritance(package.classes)
|
inherits = utils.get_local_inheritance(package.classes)
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from tempest import config
|
from tempest import config
|
||||||
@ -60,7 +59,7 @@ class TestVersioning(base.BaseArtifactsTest):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resource_cleanup(cls):
|
def resource_cleanup(cls):
|
||||||
for pkg in six.itervalues(cls.packages):
|
for pkg in cls.packages.values():
|
||||||
cls.artifacts_client.delete_package(pkg['id'])
|
cls.artifacts_client.delete_package(pkg['id'])
|
||||||
map(os.remove, cls.abs_archive_paths)
|
map(os.remove, cls.abs_archive_paths)
|
||||||
super(TestVersioning, cls).resource_cleanup()
|
super(TestVersioning, cls).resource_cleanup()
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from tempest import config
|
from tempest import config
|
||||||
@ -54,7 +53,7 @@ class TestVersioningNegative(base.BaseArtifactsTest):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resource_cleanup(cls):
|
def resource_cleanup(cls):
|
||||||
for pkg in six.itervalues(cls.packages):
|
for pkg in cls.packages.values():
|
||||||
cls.artifacts_client.delete_package(pkg['id'])
|
cls.artifacts_client.delete_package(pkg['id'])
|
||||||
map(os.remove, cls.abs_archive_paths)
|
map(os.remove, cls.abs_archive_paths)
|
||||||
super(TestVersioningNegative, cls).resource_cleanup()
|
super(TestVersioningNegative, cls).resource_cleanup()
|
||||||
|
@ -319,8 +319,8 @@ class Package(FileWrapperMixin):
|
|||||||
def classes(self):
|
def classes(self):
|
||||||
if not hasattr(self, '_classes'):
|
if not hasattr(self, '_classes'):
|
||||||
self._classes = {}
|
self._classes = {}
|
||||||
for class_name, class_file in six.iteritems(
|
for class_name, class_file in (
|
||||||
self.manifest.get('Classes', {})):
|
self.manifest.get('Classes', {}).items()):
|
||||||
filename = "Classes/%s" % class_file
|
filename = "Classes/%s" % class_file
|
||||||
if filename not in self.contents.namelist():
|
if filename not in self.contents.namelist():
|
||||||
continue
|
continue
|
||||||
@ -431,7 +431,7 @@ class Package(FileWrapperMixin):
|
|||||||
def _get_direct_deps(package, base_url, path):
|
def _get_direct_deps(package, base_url, path):
|
||||||
result = []
|
result = []
|
||||||
if 'Require' in package.manifest:
|
if 'Require' in package.manifest:
|
||||||
for dep_name, ver in six.iteritems(package.manifest['Require']):
|
for dep_name, ver in package.manifest['Require'].items():
|
||||||
try:
|
try:
|
||||||
req_file = Package.from_location(
|
req_file = Package.from_location(
|
||||||
dep_name,
|
dep_name,
|
||||||
@ -480,7 +480,7 @@ class NamespaceResolver(object):
|
|||||||
|
|
||||||
def get_local_inheritance(classes):
|
def get_local_inheritance(classes):
|
||||||
result = {}
|
result = {}
|
||||||
for class_name, klass in six.iteritems(classes):
|
for class_name, klass in classes.items():
|
||||||
if 'Extends' not in klass:
|
if 'Extends' not in klass:
|
||||||
continue
|
continue
|
||||||
ns = klass.get('Namespaces')
|
ns = klass.get('Namespaces')
|
||||||
|
Loading…
Reference in New Issue
Block a user