ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tliron <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #60: Aria 44 merge parser and storage model...
Date Wed, 01 Feb 2017 16:13:43 GMT
Github user tliron commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/60#discussion_r98929538
  
    --- Diff: aria/storage/modeling/elements.py ---
    @@ -0,0 +1,102 @@
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +
    +from sqlalchemy import (
    +    Column,
    +    Text
    +)
    +
    +from ...parser.modeling import utils
    +from ...utils.collections import OrderedDict
    +from ...utils.console import puts
    +
    +from . import structure
    +from . import type
    +
    +# pylint: disable=no-self-argument, no-member, abstract-method
    +
    +
    +class ParameterBase(structure.ModelMixin):
    +    """
    +    Represents a typed value.
    +
    +    This class is used by both service model and service instance elements.
    +    """
    +    __tablename__ = 'parameter'
    +    name = Column(Text, nullable=False)
    +    type = Column(Text, nullable=False)
    +
    +    # Check: value type
    +    value = Column(Text)
    +    description = Column(Text)
    +
    +    @property
    +    def as_raw(self):
    +        return OrderedDict((
    +            ('name', self.name),
    +            ('type_name', self.type),
    +            ('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)
    --- End diff --
    
    All these castings might throw exceptions. I think we should catch them and raise better
exceptions.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message