Merge "Drop types module usage"
This commit is contained in:
commit
93db3555ca
@ -13,8 +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 types
|
|
||||||
|
|
||||||
|
|
||||||
class TokenSanitizer(object):
|
class TokenSanitizer(object):
|
||||||
"""Helper class for cleaning some object from different passwords/tokens.
|
"""Helper class for cleaning some object from different passwords/tokens.
|
||||||
@ -48,16 +46,16 @@ class TokenSanitizer(object):
|
|||||||
|
|
||||||
def sanitize(self, obj):
|
def sanitize(self, obj):
|
||||||
"""Replaces each token found in object by message.
|
"""Replaces each token found in object by message.
|
||||||
:param obj: types.DictType, types.ListType, types.Tuple, object
|
:param obj: dict, list, tuple, object
|
||||||
:return: Sanitized object
|
:return: Sanitized object
|
||||||
"""
|
"""
|
||||||
if isinstance(obj, types.DictType):
|
if isinstance(obj, dict):
|
||||||
return dict([self.sanitize(item) for item in obj.iteritems()])
|
return dict([self.sanitize(item) for item in obj.iteritems()])
|
||||||
elif isinstance(obj, types.ListType):
|
elif isinstance(obj, list):
|
||||||
return [self.sanitize(item) for item in obj]
|
return [self.sanitize(item) for item in obj]
|
||||||
elif isinstance(obj, types.TupleType):
|
elif isinstance(obj, tuple):
|
||||||
k, v = obj
|
k, v = obj
|
||||||
if self._contains_token(k) and isinstance(v, types.StringTypes):
|
if self._contains_token(k) and isinstance(v, basestring):
|
||||||
return k, self.message
|
return k, self.message
|
||||||
return k, self.sanitize(v)
|
return k, self.sanitize(v)
|
||||||
else:
|
else:
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import functools as func
|
import functools as func
|
||||||
import types
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
import jsonschema
|
import jsonschema
|
||||||
@ -27,8 +26,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class TraverseHelper(object):
|
class TraverseHelper(object):
|
||||||
value_type = (types.StringTypes, types.IntType, types.FloatType,
|
value_type = (basestring, int, float, bool)
|
||||||
types.BooleanType)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get(path, source):
|
def get(path, source):
|
||||||
@ -60,7 +58,7 @@ class TraverseHelper(object):
|
|||||||
while len(queue):
|
while len(queue):
|
||||||
path = queue.popleft()
|
path = queue.popleft()
|
||||||
|
|
||||||
if isinstance(source, types.ListType):
|
if isinstance(source, list):
|
||||||
idx_source = source
|
idx_source = source
|
||||||
iterator = (
|
iterator = (
|
||||||
i for i in source
|
i for i in source
|
||||||
@ -69,7 +67,7 @@ class TraverseHelper(object):
|
|||||||
source = next(iterator, None)
|
source = next(iterator, None)
|
||||||
if source is None and path.isdigit():
|
if source is None and path.isdigit():
|
||||||
source = idx_source[int(path)]
|
source = idx_source[int(path)]
|
||||||
elif isinstance(source, types.DictionaryType):
|
elif isinstance(source, dict):
|
||||||
source = source[path]
|
source = source[path]
|
||||||
elif isinstance(source, TraverseHelper.value_type):
|
elif isinstance(source, TraverseHelper.value_type):
|
||||||
break
|
break
|
||||||
@ -126,14 +124,14 @@ class TraverseHelper(object):
|
|||||||
node = TraverseHelper.get(parent_path, source)
|
node = TraverseHelper.get(parent_path, source)
|
||||||
key = path[1:].split('/')[-1]
|
key = path[1:].split('/')[-1]
|
||||||
|
|
||||||
if isinstance(node, types.ListType):
|
if isinstance(node, list):
|
||||||
iterator = (i for i in node if i.get('?', {}).get('id') == key)
|
iterator = (i for i in node if i.get('?', {}).get('id') == key)
|
||||||
item = next(iterator, None)
|
item = next(iterator, None)
|
||||||
if item is None and key.isdigit():
|
if item is None and key.isdigit():
|
||||||
del node[int(key)]
|
del node[int(key)]
|
||||||
else:
|
else:
|
||||||
node.remove(item)
|
node.remove(item)
|
||||||
elif isinstance(node, types.DictionaryType):
|
elif isinstance(node, dict):
|
||||||
del node[key]
|
del node[key]
|
||||||
else:
|
else:
|
||||||
raise ValueError(_('Source object or path is malformed'))
|
raise ValueError(_('Source object or path is malformed'))
|
||||||
@ -197,12 +195,12 @@ def is_different(obj1, obj2):
|
|||||||
|
|
||||||
def build_entity_map(value):
|
def build_entity_map(value):
|
||||||
def build_entity_map_recursive(value, id_map):
|
def build_entity_map_recursive(value, id_map):
|
||||||
if isinstance(value, types.DictionaryType):
|
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 value.itervalues():
|
for v in value.itervalues():
|
||||||
build_entity_map_recursive(v, id_map)
|
build_entity_map_recursive(v, id_map)
|
||||||
if isinstance(value, types.ListType):
|
if isinstance(value, list):
|
||||||
for item in value:
|
for item in value:
|
||||||
build_entity_map_recursive(item, id_map)
|
build_entity_map_recursive(item, id_map)
|
||||||
|
|
||||||
|
@ -12,8 +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 types
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from webob import exc
|
from webob import exc
|
||||||
@ -119,7 +117,7 @@ class CoreServices(object):
|
|||||||
temp_description['services'] = []
|
temp_description['services'] = []
|
||||||
|
|
||||||
if path == '/services':
|
if path == '/services':
|
||||||
if isinstance(data, types.ListType):
|
if isinstance(data, list):
|
||||||
utils.TraverseHelper.extend(path, data, temp_description)
|
utils.TraverseHelper.extend(path, data, temp_description)
|
||||||
else:
|
else:
|
||||||
utils.TraverseHelper.insert(path, data, temp_description)
|
utils.TraverseHelper.insert(path, data, temp_description)
|
||||||
@ -149,7 +147,7 @@ class CoreServices(object):
|
|||||||
temp_description['services'] = []
|
temp_description['services'] = []
|
||||||
|
|
||||||
if path == '/services':
|
if path == '/services':
|
||||||
if isinstance(data, types.ListType):
|
if isinstance(data, list):
|
||||||
utils.TraverseHelper.extend(path, data, temp_description)
|
utils.TraverseHelper.extend(path, data, temp_description)
|
||||||
else:
|
else:
|
||||||
utils.TraverseHelper.insert(path, data, temp_description)
|
utils.TraverseHelper.insert(path, data, temp_description)
|
||||||
@ -175,7 +173,7 @@ class CoreServices(object):
|
|||||||
env_description['services'] = []
|
env_description['services'] = []
|
||||||
|
|
||||||
if path == '/services':
|
if path == '/services':
|
||||||
if isinstance(data, types.ListType):
|
if isinstance(data, list):
|
||||||
utils.TraverseHelper.extend(path, data, env_description)
|
utils.TraverseHelper.extend(path, data, env_description)
|
||||||
else:
|
else:
|
||||||
utils.TraverseHelper.insert(path, data, env_description)
|
utils.TraverseHelper.insert(path, data, env_description)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import os.path
|
import os.path
|
||||||
import types
|
|
||||||
|
|
||||||
from yaql.language import expressions as yaql_expressions
|
from yaql.language import expressions as yaql_expressions
|
||||||
from yaql.language import utils
|
from yaql.language import utils
|
||||||
@ -51,7 +50,7 @@ class MuranoType(yaqltypes.PythonType):
|
|||||||
if value is None or isinstance(value, yaql_expressions.Expression):
|
if value is None or isinstance(value, yaql_expressions.Expression):
|
||||||
return True
|
return True
|
||||||
murano_class = self.murano_class
|
murano_class = self.murano_class
|
||||||
if isinstance(murano_class, types.StringTypes):
|
if isinstance(murano_class, basestring):
|
||||||
murano_class_name = murano_class
|
murano_class_name = murano_class
|
||||||
else:
|
else:
|
||||||
murano_class_name = murano_class.name
|
murano_class_name = murano_class.name
|
||||||
@ -94,7 +93,7 @@ class MuranoTypeName(yaqltypes.LazyParameterType, yaqltypes.PythonType):
|
|||||||
def __init__(self, nullable=False, context=None):
|
def __init__(self, nullable=False, context=None):
|
||||||
self._context = context
|
self._context = context
|
||||||
super(MuranoTypeName, self).__init__(
|
super(MuranoTypeName, self).__init__(
|
||||||
(dsl_types.MuranoClassReference,) + types.StringTypes, nullable)
|
(dsl_types.MuranoClassReference, basestring), nullable)
|
||||||
|
|
||||||
def convert(self, value, sender, context, function_spec, engine,
|
def convert(self, value, sender, context, function_spec, engine,
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
@ -103,7 +102,7 @@ class MuranoTypeName(yaqltypes.LazyParameterType, yaqltypes.PythonType):
|
|||||||
value = value(utils.NO_VALUE, context, engine)
|
value = value(utils.NO_VALUE, context, engine)
|
||||||
value = super(MuranoTypeName, self).convert(
|
value = super(MuranoTypeName, self).convert(
|
||||||
value, sender, context, function_spec, engine)
|
value, sender, context, function_spec, engine)
|
||||||
if isinstance(value, types.StringTypes):
|
if isinstance(value, basestring):
|
||||||
murano_type = helpers.get_type(context)
|
murano_type = helpers.get_type(context)
|
||||||
value = dsl_types.MuranoClassReference(
|
value = dsl_types.MuranoClassReference(
|
||||||
helpers.get_class(
|
helpers.get_class(
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import itertools
|
import itertools
|
||||||
import types
|
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@ -184,7 +183,7 @@ class MuranoDslExecutor(object):
|
|||||||
return tuple(), parameter_values
|
return tuple(), parameter_values
|
||||||
|
|
||||||
def load(self, data):
|
def load(self, data):
|
||||||
if not isinstance(data, types.DictionaryType):
|
if not isinstance(data, dict):
|
||||||
raise TypeError()
|
raise TypeError()
|
||||||
self._attribute_store.load(data.get(constants.DM_ATTRIBUTES) or [])
|
self._attribute_store.load(data.get(constants.DM_ATTRIBUTES) or [])
|
||||||
result = self._object_store.load(data.get(constants.DM_OBJECTS), None)
|
result = self._object_store.load(data.get(constants.DM_OBJECTS), None)
|
||||||
@ -216,16 +215,16 @@ class MuranoDslExecutor(object):
|
|||||||
'on {0}: {1}').format(obj, e), exc_info=True)
|
'on {0}: {1}').format(obj, e), exc_info=True)
|
||||||
|
|
||||||
def _list_potential_object_ids(self, data):
|
def _list_potential_object_ids(self, data):
|
||||||
if isinstance(data, types.DictionaryType):
|
if isinstance(data, dict):
|
||||||
sys_dict = data.get('?')
|
sys_dict = data.get('?')
|
||||||
if (isinstance(sys_dict, types.DictionaryType) and
|
if (isinstance(sys_dict, dict) and
|
||||||
sys_dict.get('id') and sys_dict.get('type')):
|
sys_dict.get('id') and sys_dict.get('type')):
|
||||||
yield sys_dict['id']
|
yield sys_dict['id']
|
||||||
for val in data.itervalues():
|
for val in data.itervalues():
|
||||||
for res in self._list_potential_object_ids(val):
|
for res in self._list_potential_object_ids(val):
|
||||||
yield res
|
yield res
|
||||||
elif isinstance(data, collections.Iterable) and not isinstance(
|
elif isinstance(data, collections.Iterable) and not isinstance(
|
||||||
data, types.StringTypes):
|
data, basestring):
|
||||||
for val in data:
|
for val in data:
|
||||||
for res in self._list_potential_object_ids(val):
|
for res in self._list_potential_object_ids(val):
|
||||||
yield res
|
yield res
|
||||||
|
@ -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 types
|
|
||||||
|
|
||||||
from murano.dsl import dsl_exception
|
from murano.dsl import dsl_exception
|
||||||
from murano.dsl import helpers
|
from murano.dsl import helpers
|
||||||
@ -45,7 +44,7 @@ class Statement(DslExpression):
|
|||||||
if isinstance(statement, yaql_expression.YaqlExpression):
|
if isinstance(statement, yaql_expression.YaqlExpression):
|
||||||
key = None
|
key = None
|
||||||
value = statement
|
value = statement
|
||||||
elif isinstance(statement, types.DictionaryType):
|
elif isinstance(statement, dict):
|
||||||
if len(statement) != 1:
|
if len(statement) != 1:
|
||||||
raise SyntaxError()
|
raise SyntaxError()
|
||||||
key = statement.keys()[0]
|
key = statement.keys()[0]
|
||||||
@ -81,7 +80,7 @@ def parse_expression(expr):
|
|||||||
result = None
|
result = None
|
||||||
if isinstance(expr, yaql_expression.YaqlExpression):
|
if isinstance(expr, yaql_expression.YaqlExpression):
|
||||||
result = Statement(expr)
|
result = Statement(expr)
|
||||||
elif isinstance(expr, types.DictionaryType):
|
elif isinstance(expr, dict):
|
||||||
kwds = {}
|
kwds = {}
|
||||||
for key, value in expr.iteritems():
|
for key, value in expr.iteritems():
|
||||||
if isinstance(key, yaql_expression.YaqlExpression):
|
if isinstance(key, yaql_expression.YaqlExpression):
|
||||||
|
@ -18,7 +18,6 @@ import functools
|
|||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
import types
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import eventlet.greenpool
|
import eventlet.greenpool
|
||||||
@ -83,15 +82,15 @@ def merge_dicts(dict1, dict2, max_levels=0):
|
|||||||
if key in dict2:
|
if key in dict2:
|
||||||
value2 = dict2[key]
|
value2 = dict2[key]
|
||||||
if type(value2) != type(value1):
|
if type(value2) != type(value1):
|
||||||
if (isinstance(value1, types.StringTypes) and
|
if (isinstance(value1, basestring) and
|
||||||
isinstance(value2, types.StringTypes)):
|
isinstance(value2, basestring)):
|
||||||
continue
|
continue
|
||||||
raise TypeError()
|
raise TypeError()
|
||||||
if max_levels != 1 and isinstance(value2, types.DictionaryType):
|
if max_levels != 1 and isinstance(value2, dict):
|
||||||
result[key] = merge_dicts(
|
result[key] = merge_dicts(
|
||||||
value1, value2,
|
value1, value2,
|
||||||
0 if max_levels == 0 else max_levels - 1)
|
0 if max_levels == 0 else max_levels - 1)
|
||||||
elif max_levels != 1 and isinstance(value2, types.ListType):
|
elif max_levels != 1 and isinstance(value2, list):
|
||||||
result[key] = merge_lists(value1, value2)
|
result[key] = merge_lists(value1, value2)
|
||||||
else:
|
else:
|
||||||
result[key] = value2
|
result[key] = value2
|
||||||
@ -285,7 +284,7 @@ def cast(obj, murano_class, pov_or_version_spec=None):
|
|||||||
obj = obj.object
|
obj = obj.object
|
||||||
if isinstance(pov_or_version_spec, dsl_types.MuranoClass):
|
if isinstance(pov_or_version_spec, dsl_types.MuranoClass):
|
||||||
pov_or_version_spec = pov_or_version_spec.package
|
pov_or_version_spec = pov_or_version_spec.package
|
||||||
elif isinstance(pov_or_version_spec, types.StringTypes):
|
elif isinstance(pov_or_version_spec, basestring):
|
||||||
pov_or_version_spec = parse_version_spec(pov_or_version_spec)
|
pov_or_version_spec = parse_version_spec(pov_or_version_spec)
|
||||||
if isinstance(murano_class, dsl_types.MuranoClass):
|
if isinstance(murano_class, dsl_types.MuranoClass):
|
||||||
if pov_or_version_spec is None:
|
if pov_or_version_spec is None:
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import types
|
|
||||||
|
|
||||||
from yaql.language import specs
|
from yaql.language import specs
|
||||||
from yaql.language import utils
|
from yaql.language import utils
|
||||||
@ -109,7 +108,7 @@ class LhsExpression(object):
|
|||||||
if utils.is_sequence(src):
|
if utils.is_sequence(src):
|
||||||
src_property.set(src[:index] + (value,) + src[index + 1:])
|
src_property.set(src[:index] + (value,) + src[index + 1:])
|
||||||
|
|
||||||
if isinstance(index, types.IntType):
|
if isinstance(index, int):
|
||||||
return LhsExpression.Property(
|
return LhsExpression.Property(
|
||||||
lambda: getter(this.get()),
|
lambda: getter(this.get()),
|
||||||
lambda value: setter(this, value))
|
lambda value: setter(this, value))
|
||||||
|
@ -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 types
|
|
||||||
|
|
||||||
from murano.dsl import constants
|
from murano.dsl import constants
|
||||||
from murano.dsl import dsl_exception
|
from murano.dsl import dsl_exception
|
||||||
@ -24,7 +23,7 @@ from murano.dsl import yaql_expression
|
|||||||
|
|
||||||
class CodeBlock(expressions.DslExpression):
|
class CodeBlock(expressions.DslExpression):
|
||||||
def __init__(self, body):
|
def __init__(self, body):
|
||||||
if not isinstance(body, types.ListType):
|
if not isinstance(body, list):
|
||||||
body = [body]
|
body = [body]
|
||||||
self.code_block = map(expressions.parse_expression, body)
|
self.code_block = map(expressions.parse_expression, body)
|
||||||
|
|
||||||
@ -140,7 +139,7 @@ class WhileDoMacro(expressions.DslExpression):
|
|||||||
|
|
||||||
class ForMacro(expressions.DslExpression):
|
class ForMacro(expressions.DslExpression):
|
||||||
def __init__(self, For, In, Do):
|
def __init__(self, For, In, Do):
|
||||||
if not isinstance(For, types.StringTypes):
|
if not isinstance(For, basestring):
|
||||||
raise exceptions.DslSyntaxError(
|
raise exceptions.DslSyntaxError(
|
||||||
'For value must be of string type')
|
'For value must be of string type')
|
||||||
self._code = CodeBlock(Do)
|
self._code = CodeBlock(Do)
|
||||||
@ -180,7 +179,7 @@ class RepeatMacro(expressions.DslExpression):
|
|||||||
|
|
||||||
class MatchMacro(expressions.DslExpression):
|
class MatchMacro(expressions.DslExpression):
|
||||||
def __init__(self, Match, Value, Default=None):
|
def __init__(self, Match, Value, Default=None):
|
||||||
if not isinstance(Match, types.DictionaryType):
|
if not isinstance(Match, dict):
|
||||||
raise exceptions.DslSyntaxError(
|
raise exceptions.DslSyntaxError(
|
||||||
'Match value must be of dictionary type')
|
'Match value must be of dictionary type')
|
||||||
self._switch = Match
|
self._switch = Match
|
||||||
@ -199,7 +198,7 @@ class MatchMacro(expressions.DslExpression):
|
|||||||
|
|
||||||
class SwitchMacro(expressions.DslExpression):
|
class SwitchMacro(expressions.DslExpression):
|
||||||
def __init__(self, Switch, Default=None):
|
def __init__(self, Switch, Default=None):
|
||||||
if not isinstance(Switch, types.DictionaryType):
|
if not isinstance(Switch, dict):
|
||||||
raise exceptions.DslSyntaxError(
|
raise exceptions.DslSyntaxError(
|
||||||
'Switch value must be of dictionary type')
|
'Switch value must be of dictionary type')
|
||||||
self._switch = Switch
|
self._switch = Switch
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import types
|
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from yaql.language import specs
|
from yaql.language import specs
|
||||||
@ -59,12 +58,12 @@ class MuranoMethod(dsl_types.MuranoMethod):
|
|||||||
self._body = macros.MethodBlock(payload.get('Body') or [], name)
|
self._body = macros.MethodBlock(payload.get('Body') or [], name)
|
||||||
self._usage = payload.get('Usage') or MethodUsages.Runtime
|
self._usage = payload.get('Usage') or MethodUsages.Runtime
|
||||||
arguments_scheme = payload.get('Arguments') or []
|
arguments_scheme = payload.get('Arguments') or []
|
||||||
if isinstance(arguments_scheme, types.DictionaryType):
|
if isinstance(arguments_scheme, dict):
|
||||||
arguments_scheme = [{key: value} for key, value in
|
arguments_scheme = [{key: value} for key, value in
|
||||||
arguments_scheme.iteritems()]
|
arguments_scheme.iteritems()]
|
||||||
self._arguments_scheme = collections.OrderedDict()
|
self._arguments_scheme = collections.OrderedDict()
|
||||||
for record in arguments_scheme:
|
for record in arguments_scheme:
|
||||||
if (not isinstance(record, types.DictionaryType) or
|
if (not isinstance(record, dict) or
|
||||||
len(record) > 1):
|
len(record) > 1):
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
name = record.keys()[0]
|
name = record.keys()[0]
|
||||||
|
@ -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 types
|
|
||||||
|
|
||||||
from yaql import utils
|
from yaql import utils
|
||||||
|
|
||||||
@ -86,8 +85,7 @@ def _pass12_serialize(value, parent, serialized_objects,
|
|||||||
designer_attributes_getter):
|
designer_attributes_getter):
|
||||||
if isinstance(value, dsl.MuranoObjectInterface):
|
if isinstance(value, dsl.MuranoObjectInterface):
|
||||||
value = value.object
|
value = value.object
|
||||||
if isinstance(value, (types.StringTypes, types.IntType, types.FloatType,
|
if isinstance(value, (basestring, int, float, bool)) or value is None:
|
||||||
types.BooleanType, types.NoneType)):
|
|
||||||
return value, False
|
return value, False
|
||||||
if isinstance(value, dsl_types.MuranoObject):
|
if isinstance(value, dsl_types.MuranoObject):
|
||||||
if value.owner is not parent or value.object_id in serialized_objects:
|
if value.owner is not parent or value.object_id in serialized_objects:
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import types
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from yaql.language import specs
|
from yaql.language import specs
|
||||||
@ -175,7 +174,7 @@ class TypeScheme(object):
|
|||||||
|
|
||||||
obj = object_store.load(
|
obj = object_store.load(
|
||||||
value, owner, root_context, defaults=default)
|
value, owner, root_context, defaults=default)
|
||||||
elif isinstance(value, types.StringTypes):
|
elif isinstance(value, basestring):
|
||||||
obj = object_store.get(value)
|
obj = object_store.get(value)
|
||||||
if obj is None:
|
if obj is None:
|
||||||
if not object_store.initializing:
|
if not object_store.initializing:
|
||||||
@ -255,10 +254,10 @@ class TypeScheme(object):
|
|||||||
shift = 0
|
shift = 0
|
||||||
max_length = sys.maxint
|
max_length = sys.maxint
|
||||||
min_length = 0
|
min_length = 0
|
||||||
if isinstance(spec[-1], types.IntType):
|
if isinstance(spec[-1], int):
|
||||||
min_length = spec[-1]
|
min_length = spec[-1]
|
||||||
shift += 1
|
shift += 1
|
||||||
if len(spec) >= 2 and isinstance(spec[-2], types.IntType):
|
if len(spec) >= 2 and isinstance(spec[-2], int):
|
||||||
max_length = min_length
|
max_length = min_length
|
||||||
min_length = spec[-2]
|
min_length = spec[-2]
|
||||||
shift += 1
|
shift += 1
|
||||||
@ -317,6 +316,6 @@ class TypeScheme(object):
|
|||||||
|
|
||||||
|
|
||||||
def format_scalar(value):
|
def format_scalar(value):
|
||||||
if isinstance(value, types.StringTypes):
|
if isinstance(value, basestring):
|
||||||
return "'{0}'".format(value)
|
return "'{0}'".format(value)
|
||||||
return unicode(value)
|
return unicode(value)
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import types
|
|
||||||
|
|
||||||
from yaql.language import exceptions as yaql_exceptions
|
from yaql.language import exceptions as yaql_exceptions
|
||||||
from yaql.language import expressions
|
from yaql.language import expressions
|
||||||
@ -26,7 +25,7 @@ from murano.dsl import yaql_integration
|
|||||||
class YaqlExpression(dsl_types.YaqlExpression):
|
class YaqlExpression(dsl_types.YaqlExpression):
|
||||||
def __init__(self, expression, version):
|
def __init__(self, expression, version):
|
||||||
self._version = version
|
self._version = version
|
||||||
if isinstance(expression, types.StringTypes):
|
if isinstance(expression, basestring):
|
||||||
self._expression = unicode(expression)
|
self._expression = unicode(expression)
|
||||||
self._parsed_expression = yaql_integration.parse(
|
self._parsed_expression = yaql_integration.parse(
|
||||||
self._expression, version)
|
self._expression, version)
|
||||||
@ -66,7 +65,7 @@ class YaqlExpression(dsl_types.YaqlExpression):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_expression(expression, version):
|
def is_expression(expression, version):
|
||||||
if not isinstance(expression, types.StringTypes):
|
if not isinstance(expression, basestring):
|
||||||
return False
|
return False
|
||||||
if re.match('^[\s\w\d.:]*$', expression):
|
if re.match('^[\s\w\d.:]*$', expression):
|
||||||
return False
|
return False
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import types
|
|
||||||
import urlparse
|
import urlparse
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -207,7 +206,7 @@ class Agent(object):
|
|||||||
|
|
||||||
def build_execution_plan(self, template, resources):
|
def build_execution_plan(self, template, resources):
|
||||||
template = copy.deepcopy(template)
|
template = copy.deepcopy(template)
|
||||||
if not isinstance(template, types.DictionaryType):
|
if not isinstance(template, dict):
|
||||||
raise ValueError('Incorrect execution plan ')
|
raise ValueError('Incorrect execution plan ')
|
||||||
format_version = template.get('FormatVersion')
|
format_version = template.get('FormatVersion')
|
||||||
if not format_version or format_version.startswith('1.'):
|
if not format_version or format_version.startswith('1.'):
|
||||||
|
@ -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 types
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
@ -35,7 +34,7 @@ class StatusReporter(object):
|
|||||||
StatusReporter.transport,
|
StatusReporter.transport,
|
||||||
publisher_id=uuidutils.generate_uuid(),
|
publisher_id=uuidutils.generate_uuid(),
|
||||||
topic='murano')
|
topic='murano')
|
||||||
if isinstance(environment, types.StringTypes):
|
if isinstance(environment, basestring):
|
||||||
self._environment_id = environment
|
self._environment_id = environment
|
||||||
else:
|
else:
|
||||||
self._environment_id = environment.id
|
self._environment_id = environment.id
|
||||||
|
@ -19,7 +19,6 @@ import random
|
|||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
import time
|
import time
|
||||||
import types
|
|
||||||
|
|
||||||
import jsonpatch
|
import jsonpatch
|
||||||
import jsonpointer
|
import jsonpointer
|
||||||
@ -59,7 +58,7 @@ def pselect(collection, composer):
|
|||||||
@specs.parameter('mappings', collections.Mapping)
|
@specs.parameter('mappings', collections.Mapping)
|
||||||
@specs.extension_method
|
@specs.extension_method
|
||||||
def bind(obj, mappings):
|
def bind(obj, mappings):
|
||||||
if isinstance(obj, types.StringTypes) and obj.startswith('$'):
|
if isinstance(obj, basestring) and obj.startswith('$'):
|
||||||
value = _convert_macro_parameter(obj[1:], mappings)
|
value = _convert_macro_parameter(obj[1:], mappings)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return value
|
return value
|
||||||
@ -70,7 +69,7 @@ def bind(obj, mappings):
|
|||||||
for key, value in obj.iteritems():
|
for key, value in obj.iteritems():
|
||||||
result[bind(key, mappings)] = bind(value, mappings)
|
result[bind(key, mappings)] = bind(value, mappings)
|
||||||
return result
|
return result
|
||||||
elif isinstance(obj, types.StringTypes) and obj.startswith('$'):
|
elif isinstance(obj, basestring) and obj.startswith('$'):
|
||||||
value = _convert_macro_parameter(obj[1:], mappings)
|
value = _convert_macro_parameter(obj[1:], mappings)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return value
|
return value
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import types
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -249,7 +248,7 @@ class HotPackage(package_base.PackageBase):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _format_value(value):
|
def _format_value(value):
|
||||||
if isinstance(value, types.StringTypes):
|
if isinstance(value, basestring):
|
||||||
return str("'" + value + "'")
|
return str("'" + value + "'")
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import types
|
|
||||||
|
|
||||||
from murano.dsl import context_manager
|
from murano.dsl import context_manager
|
||||||
from murano.dsl import dsl
|
from murano.dsl import dsl
|
||||||
@ -48,7 +47,7 @@ class Runner(object):
|
|||||||
class DslObjectWrapper(object):
|
class DslObjectWrapper(object):
|
||||||
def __init__(self, obj, runner):
|
def __init__(self, obj, runner):
|
||||||
self._runner = runner
|
self._runner = runner
|
||||||
if isinstance(obj, types.StringTypes):
|
if isinstance(obj, basestring):
|
||||||
self._object_id = obj
|
self._object_id = obj
|
||||||
elif isinstance(obj, (object_model.Object, object_model.Ref)):
|
elif isinstance(obj, (object_model.Object, object_model.Ref)):
|
||||||
self._object_id = obj.id
|
self._object_id = obj.id
|
||||||
@ -68,7 +67,7 @@ class Runner(object):
|
|||||||
return call
|
return call
|
||||||
|
|
||||||
def __init__(self, model, package_loader, functions):
|
def __init__(self, model, package_loader, functions):
|
||||||
if isinstance(model, types.StringTypes):
|
if isinstance(model, basestring):
|
||||||
model = object_model.Object(model)
|
model = object_model.Object(model)
|
||||||
model = object_model.build_model(model)
|
model = object_model.build_model(model)
|
||||||
if 'Objects' not in model:
|
if 'Objects' not in model:
|
||||||
|
@ -12,8 +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 types
|
|
||||||
|
|
||||||
from murano.dsl import dsl
|
from murano.dsl import dsl
|
||||||
from murano.dsl import exceptions
|
from murano.dsl import exceptions
|
||||||
from murano.tests.unit.dsl.foundation import object_model as om
|
from murano.tests.unit.dsl.foundation import object_model as om
|
||||||
@ -36,12 +34,12 @@ class TestContracts(test_case.DslTestCase):
|
|||||||
|
|
||||||
def test_string_contract(self):
|
def test_string_contract(self):
|
||||||
result = self._runner.testStringContract('qwerty')
|
result = self._runner.testStringContract('qwerty')
|
||||||
self.assertIsInstance(result, types.StringTypes)
|
self.assertIsInstance(result, basestring)
|
||||||
self.assertEqual('qwerty', result)
|
self.assertEqual('qwerty', result)
|
||||||
|
|
||||||
def test_string_from_number_contract(self):
|
def test_string_from_number_contract(self):
|
||||||
result = self._runner.testStringContract(123)
|
result = self._runner.testStringContract(123)
|
||||||
self.assertIsInstance(result, types.StringTypes)
|
self.assertIsInstance(result, basestring)
|
||||||
self.assertEqual('123', result)
|
self.assertEqual('123', result)
|
||||||
|
|
||||||
def test_string_null_contract(self):
|
def test_string_null_contract(self):
|
||||||
|
@ -12,8 +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 types
|
|
||||||
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
from yaql.language import exceptions as yaql_exceptions
|
from yaql.language import exceptions as yaql_exceptions
|
||||||
|
|
||||||
@ -161,8 +159,8 @@ class TestEngineYaqlFunctions(test_case.DslTestCase):
|
|||||||
name1 = self._runner.testRandomName()
|
name1 = self._runner.testRandomName()
|
||||||
name2 = self._runner.testRandomName()
|
name2 = self._runner.testRandomName()
|
||||||
|
|
||||||
self.assertIsInstance(name1, types.StringTypes)
|
self.assertIsInstance(name1, basestring)
|
||||||
self.assertIsInstance(name2, types.StringTypes)
|
self.assertIsInstance(name2, basestring)
|
||||||
self.assertThat(len(name1), matchers.GreaterThan(12))
|
self.assertThat(len(name1), matchers.GreaterThan(12))
|
||||||
self.assertThat(len(name2), matchers.GreaterThan(12))
|
self.assertThat(len(name2), matchers.GreaterThan(12))
|
||||||
self.assertThat(name1, matchers.NotEquals(name2))
|
self.assertThat(name1, matchers.NotEquals(name2))
|
||||||
|
@ -12,9 +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 types
|
|
||||||
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from murano.dsl import serializer
|
from murano.dsl import serializer
|
||||||
@ -89,7 +86,7 @@ class TestResultsSerializer(test_case.DslTestCase):
|
|||||||
serialized['Objects']['?'].get('_actions'), dict)
|
serialized['Objects']['?'].get('_actions'), dict)
|
||||||
for action in serialized['Objects']['?']['_actions'].values():
|
for action in serialized['Objects']['?']['_actions'].values():
|
||||||
self.assertIsInstance(action.get('enabled'), bool)
|
self.assertIsInstance(action.get('enabled'), bool)
|
||||||
self.assertIsInstance(action.get('name'), types.StringTypes)
|
self.assertIsInstance(action.get('name'), basestring)
|
||||||
self.assertThat(
|
self.assertThat(
|
||||||
action['name'],
|
action['name'],
|
||||||
matchers.StartsWith('test'))
|
matchers.StartsWith('test'))
|
||||||
|
Loading…
Reference in New Issue
Block a user