Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-44-Merge-parser-and-storage-models bc49c55a4 -> b2b05ed21 (forced update)
review fixups - unicode support, clearer exceptions and doc fixups Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/b2b05ed2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/b2b05ed2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/b2b05ed2 Branch: refs/heads/ARIA-44-Merge-parser-and-storage-models Commit: b2b05ed21810ce3698abca5b829db2aa60765074 Parents: c5fb0ab Author: mxmrlv <[email protected]> Authored: Tue Feb 7 17:27:41 2017 +0200 Committer: mxmrlv <[email protected]> Committed: Tue Feb 7 17:29:11 2017 +0200 ---------------------------------------------------------------------- aria/storage/modeling/elements.py | 27 ++++++++++++++----------- aria/storage/modeling/instance_elements.py | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b2b05ed2/aria/storage/modeling/elements.py ---------------------------------------------------------------------- diff --git a/aria/storage/modeling/elements.py b/aria/storage/modeling/elements.py index 699a511..6850201 100644 --- a/aria/storage/modeling/elements.py +++ b/aria/storage/modeling/elements.py @@ -21,6 +21,7 @@ from sqlalchemy import ( from ...parser.modeling import utils from ...utils.collections import OrderedDict from ...utils.console import puts +from .. import exceptions from . import structure from . import type @@ -50,21 +51,23 @@ class ParameterBase(structure.ModelMixin): ('value', self._cast_value()), ('description', self.description))) - # TODO: change name def _cast_value(self): if self.type is None: return - - if self.type.lower() == 'str': - return str(self.value) - elif self.type.lower() == 'int': - return int(self.value) - elif self.type.lower() == 'bool': - return bool(self.value) - elif self.type.lower() == 'float': - return float(self.value) - else: - raise Exception('No supported type_name was provided') + try: + if self.type.lower() == ['str', 'unicode']: + return self.value.decode('utf-8') + elif self.type.lower() == 'int': + return int(self.value) + elif self.type.lower() == 'bool': + return bool(self.value) + elif self.type.lower() == 'float': + return float(self.value) + else: + raise exceptions.StorageError('No supported type_name was provided') + except ValueError: + raise exceptions.StorageError('Trying to cast {0} to {1} failed'.format(self.value, + self.type)) def instantiate(self, context, container): return ParameterBase(self.type, self.value, self.description) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b2b05ed2/aria/storage/modeling/instance_elements.py ---------------------------------------------------------------------- diff --git a/aria/storage/modeling/instance_elements.py b/aria/storage/modeling/instance_elements.py index faa4c48..9c5e750 100644 --- a/aria/storage/modeling/instance_elements.py +++ b/aria/storage/modeling/instance_elements.py @@ -818,7 +818,7 @@ class NodeBase(structure.ModelMixin): * :code:`interfaces`: Dict of :class:`Interface` * :code:`artifacts`: Dict of :class:`Artifact` * :code:`capabilities`: Dict of :class:`CapabilityTemplate` - * :code:`relationship`: List of :class:`Relationship` + * :code:`relationships`: List of :class:`Relationship` """ __tablename__ = 'node'
