ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: linting fixes
Date Thu, 27 Jul 2017 08:27:28 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-174-Refactor-instantiation-phase 3a4ed87ba -> 1e7586af3


linting fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/1e7586af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1e7586af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1e7586af

Branch: refs/heads/ARIA-174-Refactor-instantiation-phase
Commit: 1e7586af3d2468d615f27b494a654fc35e85911e
Parents: 3a4ed87
Author: max-orlov <maxim@gigaspaces.com>
Authored: Thu Jul 27 11:27:22 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Thu Jul 27 11:27:22 2017 +0300

----------------------------------------------------------------------
 aria/modeling/functions.py                      |   2 +-
 aria/modeling/mixins.py                         |   2 +-
 .../execution_plugin/instantiation.py           |   8 +-
 aria/orchestrator/topology/__init__.py          |  65 ++++++-----
 aria/orchestrator/topology/common.py            |  15 +--
 aria/orchestrator/topology/instance.py          | 111 ++++++++++---------
 aria/orchestrator/topology/template.py          |  58 +++++-----
 aria/orchestrator/topology/utils.py             |   8 +-
 aria/parser/modeling/context.py                 |   2 +-
 aria/parser/reading/locator.py                  |   2 -
 aria/parser/validation/issue.py                 |   2 +-
 11 files changed, 138 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/modeling/functions.py
----------------------------------------------------------------------
diff --git a/aria/modeling/functions.py b/aria/modeling/functions.py
index 425b69b..7330268 100644
--- a/aria/modeling/functions.py
+++ b/aria/modeling/functions.py
@@ -102,7 +102,7 @@ def evaluate(value, container_holder, report_issues=False): # pylint:
disable=to
                     final = False
         except exceptions.CannotEvaluateFunctionException:
             pass
-        except InvalidValueError as e:
+        except InvalidValueError:
             if report_issues:
                 # TODO: do not use the context for "reporting"
                 pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/modeling/mixins.py
----------------------------------------------------------------------
diff --git a/aria/modeling/mixins.py b/aria/modeling/mixins.py
index fd31e3e..33f2306 100644
--- a/aria/modeling/mixins.py
+++ b/aria/modeling/mixins.py
@@ -135,7 +135,7 @@ class InstanceModelMixin(ModelMixin):
         pass
 
 
-class TemplateModelMixin(InstanceModelMixin):
+class TemplateModelMixin(InstanceModelMixin):                                           
           # pylint: disable=abstract-method
     """
     Mix-in for service template models.
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/orchestrator/execution_plugin/instantiation.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/execution_plugin/instantiation.py b/aria/orchestrator/execution_plugin/instantiation.py
index 0e3a441..49605b9 100644
--- a/aria/orchestrator/execution_plugin/instantiation.py
+++ b/aria/orchestrator/execution_plugin/instantiation.py
@@ -120,10 +120,10 @@ def _configure_remote(operation):
         # TODO: fix
         pass
         # context = ConsumptionContext.get_thread_local()
-        # context.validation.report('must configure "ssh.password", "ssh.key", or "ssh.key_filename"
'
-        #                           'for "{0}"'
-        #                           .format(operation.implementation),
-        #                           level=validation.Issue.BETWEEN_TYPES)
+        # context.validation.report(
+        # 'must configure "ssh.password", "ssh.key", or "ssh.key_filename" for "{0}"'.format(
+        #     operation.implementation),
+        # level=validation.Issue.BETWEEN_TYPES)
 
     operation.arguments['fabric_env'] = Argument.wrap('fabric_env', fabric_env,
                                                       'Fabric configuration.')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/orchestrator/topology/__init__.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/__init__.py b/aria/orchestrator/topology/__init__.py
index afa5334..afb7d22 100644
--- a/aria/orchestrator/topology/__init__.py
+++ b/aria/orchestrator/topology/__init__.py
@@ -17,7 +17,7 @@ from StringIO import StringIO
 from ...parser.validation import issue
 from ...parser.consumption.style import Style
 from ...modeling import models
-from ...utils import console
+from ...utils import console as console_utils
 from . import (
     template,
     instance,
@@ -58,7 +58,7 @@ class Handler(issue.Reporter):
             self._str = StringIO()
 
         def write(self, str_):
-            console.puts(str_, stream=self._str)
+            console_utils.puts(str_, stream=self._str)
 
         def __repr__(self):
             return self._str.getvalue()
@@ -103,9 +103,9 @@ class Handler(issue.Reporter):
         elif isinstance(model, list):
             return list(self.instantiate(value, **kwargs) for value in model)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
+            _handler = self._handlers.get(model.__class__)
             instance_cls = self._init_map.get(model.__class__)
-            return handler(self, model).instantiate(instance_cls, **kwargs)
+            return _handler(self, model).instantiate(instance_cls, **kwargs)
 
     def validate(self, model, **kwargs):
         if isinstance(model, dict):
@@ -113,8 +113,8 @@ class Handler(issue.Reporter):
         elif isinstance(model, list):
             return all(self.validate(value) for value in model)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
-            return handler(self, model).validate(**kwargs)
+            _handler = self._handlers.get(model.__class__)
+            return _handler(self, model).validate(**kwargs)
 
     def dump(self, model, console=None, section_name=None, **kwargs):
         console = console or self.TopologyStylizer()
@@ -130,34 +130,33 @@ class Handler(issue.Reporter):
                 for value in model:
                     self.dump(value, console=console, **kwargs)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
-            handler(self, model).dump(console=console, **kwargs)
+            _handler = self._handlers.get(model.__class__)
+            _handler(self, model).dump(console=console, **kwargs)
         return str(console)
 
-    def dump_graph(self, context, service, **kwargs):
-        context = self.TopologyStylizer(context.style)
+    def dump_graph(self, service, **kwargs):
+        console = self.TopologyStylizer()
         for node in service.nodes.itervalues():
             if not node.inbound_relationships:
-                self._dump_graph_node(context, node)
+                self._dump_graph_node(console, node)
 
-    def _dump_graph_node(self, context, node, capability=None):
-        context.write(context.style.node(node.name))
+    def _dump_graph_node(self, console, node, capability=None):
+        console.write(console.style.node(node.name))
         if capability is not None:
-            context.write('{0} ({1})'.format(context.style.property(capability.name),
-                                             context.style.type(capability.type.name)))
+            console.write('{0} ({1})'.format(console.style.property(capability.name),
+                                             console.style.type(capability.type.name)))
         if node.outbound_relationships:
-            with context.style.indent:
+            with console.style.indent:
                 for relationship_model in node.outbound_relationships:
-                    relationship_name = context.style.property(relationship_model.name)
+                    relationship_name = console.style.property(relationship_model.name)
                     if relationship_model.type is not None:
-                        context.write('-> {0} ({1})'.format(
-                            relationship_name, context.style.type(relationship_model.type.name)))
+                        console.write('-> {0} ({1})'.format(
+                            relationship_name, console.style.type(relationship_model.type.name)))
                     else:
-                        context.write('-> {0}'.format(relationship_name))
-                    # TODO: this needs to be fixed
-                    # with console.indent(3):
-                    #     self._dump_graph_node(relationship_model.target_node,
-                    #                           relationship_model.target_capability)
+                        console.write('-> {0}'.format(relationship_name))
+                    with console.indent(3):
+                        self._dump_graph_node(relationship_model.target_node,
+                                              relationship_model.target_capability)
 
     def coerce(self, model, **kwargs):
         if isinstance(model, dict):
@@ -165,11 +164,11 @@ class Handler(issue.Reporter):
         elif isinstance(model, list):
             return all(self.validate(value) for value in model)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
-            return handler(self, model).coerce(**kwargs)
+            _handler = self._handlers.get(model.__class__)
+            return _handler(self, model).coerce(**kwargs)
 
     def dump_types(self, service_template, console=None):
-        console = console or self.TopologyStylizer(console.style)
+        console = console or self.TopologyStylizer()
         console.write(self.dump(service_template.node_types, console))
         console.write(self.dump(service_template.group_types, console))
         console.write(self.dump(service_template.capability_types, console))
@@ -186,8 +185,8 @@ class Handler(issue.Reporter):
         elif isinstance(model, list):
             return all(self.satisfy_requirements(value) for value in model)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
-            return handler(self, model).satisfy_requirements(**kwargs)
+            _handler = self._handlers.get(model.__class__)
+            return _handler(self, model).satisfy_requirements(**kwargs)
 
     def validate_capabilities(self, model, **kwargs):
         if isinstance(model, dict):
@@ -195,8 +194,8 @@ class Handler(issue.Reporter):
         elif isinstance(model, list):
             return all(self.validate_capabilities(value) for value in model)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
-            return handler(self, model).validate_capabilities(**kwargs)
+            _handler = self._handlers.get(model.__class__)
+            return _handler(self, model).validate_capabilities(**kwargs)
 
     def _find_host(self, node):
         if node.type.role == 'host':
@@ -227,8 +226,8 @@ class Handler(issue.Reporter):
         elif isinstance(model, list):
             return all(self.configure_operations(value) for value in model)
         elif model is not None:
-            handler = self._handlers.get(model.__class__)
-            return handler(self, model).configure_operations(**kwargs)
+            _handler = self._handlers.get(model.__class__)
+            return _handler(self, model).configure_operations(**kwargs)
 
 
 handler = Handler()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/orchestrator/topology/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/common.py b/aria/orchestrator/topology/common.py
index 2be38cd..e788b4a 100644
--- a/aria/orchestrator/topology/common.py
+++ b/aria/orchestrator/topology/common.py
@@ -24,7 +24,7 @@ class _Handler(object):
             self._topology.coerce(template)
 
     def coerce(self):
-        raise NotImplementedError
+        pass
 
     def validate(self, **kwargs):
         pass
@@ -34,22 +34,19 @@ class _Handler(object):
             self._topology.validate(template)
 
     def dump(self, console):
-        raise NotImplementedError
+        pass
 
 
-class _TemplateHandler(_Handler):
+class _TemplateHandlerMixin(_Handler):
 
-    def instantiate(self, **kwargs):
+    def instantiate(self, instance_cls, **kwargs):
         raise NotImplementedError
 
-    def coerce(self, **kwargs):
-        pass
-
 
-class _InstanceHandler(_Handler):
+class _InstanceHandlerMixin(_Handler):
     pass
 
 
-class _OperatorHolderHandler(_Handler):
+class _OperatorHolderHandlerMixin(_Handler):
     def configure_operations(self):
         raise NotImplementedError

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/orchestrator/topology/instance.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/instance.py b/aria/orchestrator/topology/instance.py
index e160d2b..9dea932 100644
--- a/aria/orchestrator/topology/instance.py
+++ b/aria/orchestrator/topology/instance.py
@@ -21,7 +21,7 @@ from .. import decorators
 from . import common
 
 
-class Artifact(common._InstanceHandler):
+class Artifact(common._InstanceHandlerMixin):
 
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
@@ -47,9 +47,9 @@ class Artifact(common._InstanceHandler):
                 console.write('Repository credential: {0}'.format(
                     console.literal(self._model.repository_credential)))
             self._topology.dump(self._model.properties, console, 'Properties')
-            
 
-class Capability(common._InstanceHandler):
+
+class Capability(common._InstanceHandlerMixin):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
 
@@ -69,7 +69,7 @@ class Capability(common._InstanceHandler):
             self._topology.dump(self._model.properties, console, 'Properties')
 
 
-class Group(common._OperatorHolderHandler):
+class Group(common._OperatorHolderHandlerMixin):
 
     def coerce(self, **kwargs):
         self._coerce(self._model.properties, self._model.interfaces, **kwargs)
@@ -95,7 +95,7 @@ class Group(common._OperatorHolderHandler):
             self._topology.configure_operations(interface)
 
 
-class Interface(common._OperatorHolderHandler):
+class Interface(common._OperatorHolderHandlerMixin):
     def coerce(self, **kwargs):
         self._coerce(self._model.inputs, self._model.operations, **kwargs)
 
@@ -117,7 +117,7 @@ class Interface(common._OperatorHolderHandler):
             self._topology.configure_operations(operation)
 
 
-class Node(common._OperatorHolderHandler):
+class Node(common._OperatorHolderHandlerMixin):
     def coerce(self, **kwargs):
         self._coerce(self._model.properties,
                      self._model.attributes,
@@ -129,10 +129,9 @@ class Node(common._OperatorHolderHandler):
 
     def validate(self, **kwargs):
         if len(self._model.name) > context.ID_MAX_LENGTH:
-            pass
-            self._topology.report('"{0}" has an ID longer than the limit of {1:d} characters:
'
-                                  '{2:d}'.format(
-                self._model.name, context.ID_MAX_LENGTH, len(self._model.name)),
+            self._topology.report(
+                '"{0}" has an ID longer than the limit of {1:d} characters: {2:d}'.format(
+                    self._model.name, context.ID_MAX_LENGTH, len(self._model.name)),
                 level=self._topology.Issue.BETWEEN_INSTANCES)
 
         self._validate(self._model.properties,
@@ -164,9 +163,12 @@ class Node(common._OperatorHolderHandler):
         satisfied = False
         for capability in self._model.capabilities.itervalues():
             if not capability.has_enough_relationships:
-                self._topology.report('capability "{0}" of node "{1}" requires at least {2:d}
'
-                                      'relationships but has {3:d}'.format(
-                    capability.name, self._model.name, capability.min_occurrences, capability.occurrences),
+                self._topology.report(
+                    'capability "{0}" of node "{1}" requires at least {2:d} '
+                    'relationships but has {3:d}'.format(capability.name,
+                                                         self._model.name,
+                                                         capability.min_occurrences,
+                                                         capability.occurrences),
                     level=self._topology.Issue.BETWEEN_INSTANCES)
                 satisfied = False
         return satisfied
@@ -220,31 +222,35 @@ class Node(common._OperatorHolderHandler):
                 self._model.outbound_relationships.append(relationship_model)
                 return True
             else:
-                self._topology.report('requirement "{0}" of node "{1}" targets node '
-                                      'template "{2}" but its instantiated nodes do not '
-                                      'have enough capacity'.format(
-                    requirement_template.name, self._model.name, target_node_template.name),
+                self._topology.report(
+                    'requirement "{0}" of node "{1}" targets node '
+                    'template "{2}" but its instantiated nodes do not '
+                    'have enough capacity'.format(
+                        requirement_template.name, self._model.name, target_node_template.name),
                     level=self._topology.Issue.BETWEEN_INSTANCES)
                 return False
         else:
-            self._topology.report('requirement "{0}" of node "{1}" targets node template
'
-                                  '"{2}" but it has no instantiated nodes'.format(
-                requirement_template.name, self._model.name, target_node_template.name),
+            self._topology.report(
+                'requirement "{0}" of node "{1}" targets node template '
+                '"{2}" but it has no instantiated nodes'.format(
+                    requirement_template.name, self._model.name, target_node_template.name),
                 level=self._topology.Issue.BETWEEN_INSTANCES)
             return False
 
     def _find_target(self, requirement_template):
         # We might already have a specific node template, so we'll just verify it
         if requirement_template.target_node_template is not None:
-            if not self._model.node_template.is_target_node_template_valid(requirement_template.target_node_template):
-                self._topology.report('requirement "{0}" of node template "{1}" is for node
'
-                                      'template "{2}" but it does not match constraints'.format(
-                    requirement_template.name,
-                    requirement_template.target_node_template.name,
-                    self._model.node_template.name),
+            if not self._model.node_template.is_target_node_template_valid(
+                    requirement_template.target_node_template):
+                self._topology.report(
+                    'requirement "{0}" of node template "{1}" is for node '
+                    'template "{2}" but it does not match constraints'.format(
+                        requirement_template.name,
+                        requirement_template.target_node_template.name,
+                        self._model.node_template.name),
                     level=self._topology.Issue.BETWEEN_TYPES)
             if (requirement_template.target_capability_type is not None or
-                requirement_template.target_capability_name is not None):
+                    requirement_template.target_capability_name is not None):
                 target_node_capability = self._get_capability(requirement_template)
                 if target_node_capability is None:
                     return None, None
@@ -257,10 +263,12 @@ class Node(common._OperatorHolderHandler):
         elif requirement_template.target_node_type is not None:
             for target_node_template in \
                     self._model.node_template.service_template.node_templates.itervalues():
-                if requirement_template.target_node_type.get_descendant(target_node_template.type.name)
is None:
+                if requirement_template.target_node_type.get_descendant(
+                        target_node_template.type.name) is None:
                     continue
 
-                if not self._model.node_template.is_target_node_template_valid(target_node_template):
+                if not self._model.node_template.is_target_node_template_valid(
+                        target_node_template):
                     continue
 
                 target_node_capability = self._get_capability(requirement_template,
@@ -283,11 +291,12 @@ class Node(common._OperatorHolderHandler):
 
         return None
 
-    def _satisfies_requirement(self, capability_template, requirement_template, target_node_template):
+    def _satisfies_requirement(
+            self, capability_template, requirement_template, target_node_template):
         # Do we match the required capability type?
         if (requirement_template.target_capability_type and
-            requirement_template.target_capability_type.get_descendant(
-                capability_template.type.name) is None):
+                requirement_template.target_capability_type.get_descendant(
+                    capability_template.type.name) is None):
             return False
 
         # Are we in valid_source_node_types?
@@ -307,7 +316,7 @@ class Node(common._OperatorHolderHandler):
         return True
 
 
-class Operation(common._OperatorHolderHandler):
+class Operation(common._OperatorHolderHandlerMixin):
     def coerce(self, **kwargs):
         self._coerce(self._model.inputs,
                      self._model.configurations,
@@ -352,8 +361,8 @@ class Operation(common._OperatorHolderHandler):
             return
 
         if (self._model.interface is not None and
-            self._model.plugin is None and
-            self._model.function is None):
+                self._model.plugin is None and
+                self._model.function is None):
             # ("interface" is None for workflow operations, which do not currently use "plugin")
             # The default (None) plugin is the execution plugin
             execution_plugin.instantiation.configure_operation(self._model)
@@ -377,15 +386,16 @@ class Operation(common._OperatorHolderHandler):
             self._model.arguments[key] = self._topology.instantiate(input.as_argument())
 
         # Check for reserved arguments
-        used_reserved_names = decorators.OPERATION_DECORATOR_RESERVED_ARGUMENTS.intersection(
+        used_reserved_names = set(decorators.OPERATION_DECORATOR_RESERVED_ARGUMENTS).intersection(
             self._model.arguments.keys())
         if used_reserved_names:
-            self._topology.report('using reserved arguments in operation "{0}": {1}'.format(
-                self._model.name, formatting.string_list_as_string(used_reserved_names)),
+            self._topology.report(
+                'using reserved arguments in operation "{0}": {1}'.format(
+                    self._model.name, formatting.string_list_as_string(used_reserved_names)),
                 level=self._topology.Issue.EXTERNAL)
 
 
-class Policy(common._InstanceHandler):
+class Policy(common._InstanceHandlerMixin):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
 
@@ -409,7 +419,7 @@ class Policy(common._InstanceHandler):
                         console.write(console.node(group.name))
 
 
-class Relationship(common._OperatorHolderHandler):
+class Relationship(common._OperatorHolderHandlerMixin):
     def coerce(self, **kwargs):
         self._coerce(self._model.properties,
                      self._model.interfaces,
@@ -433,7 +443,7 @@ class Relationship(common._OperatorHolderHandler):
                 console.write('Relationship type: {0}'.format(
                     console.type(self._model.type.name)))
             if (self._model.relationship_template is not None and
-                self._model.relationship_template.name):
+                    self._model.relationship_template.name):
                 console.write('Relationship template: {0}'.format(
                     console.node(self._model.relationship_template.name)))
             self._topology.dump(self._model.properties, console, 'Properties')
@@ -444,7 +454,7 @@ class Relationship(common._OperatorHolderHandler):
             self._topology.configure_operations(interface)
 
 
-class Service(common._OperatorHolderHandler):
+class Service(common._OperatorHolderHandlerMixin):
     def coerce(self, **kwargs):
         self._coerce(self._model.meta_data,
                      self._model.nodes,
@@ -498,7 +508,7 @@ class Service(common._OperatorHolderHandler):
                    for node in self._model.nodes.values())
 
 
-class Substitution(common._InstanceHandler):
+class Substitution(common._InstanceHandlerMixin):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.mappings, **kwargs)
 
@@ -512,13 +522,14 @@ class Substitution(common._InstanceHandler):
             self._topology.dump(self._model.mappings, console, 'Mappings')
 
 
-class SubstitutionMapping(common._InstanceHandler):
+class SubstitutionMapping(common._InstanceHandlerMixin):
 
     def validate(self, **kwargs):
         if (self._model.capability is None) and (self._model.requirement_template is None):
-            self._topology.report('mapping "{0}" refers to neither capability nor a requirement'
-                                  ' in node: {1}'.format(
-                                  self._model.name, formatting.safe_repr(self._model.node.name)),
+            self._topology.report(
+                'mapping "{0}" refers to neither capability nor a requirement'
+                ' in node: {1}'.format(
+                    self._model.name, formatting.safe_repr(self._model.node.name)),
                 level=self._topology.Issue.BETWEEN_TYPES)
 
     def dump(self, console):
@@ -534,7 +545,7 @@ class SubstitutionMapping(common._InstanceHandler):
                 console.node(self._model.requirement_template.name)))
 
 
-class Metadata(common._InstanceHandler):
+class Metadata(common._InstanceHandlerMixin):
 
     def dump(self, console):
         console.write('{0}: {1}'.format(
@@ -551,7 +562,7 @@ class Metadata(common._InstanceHandler):
         pass
 
 
-class _Parameter(common._InstanceHandler):
+class _Parameter(common._InstanceHandlerMixin):
 
     def dump(self, console):
         if self._model.type_name is not None:
@@ -602,7 +613,7 @@ class Configuration(_Parameter):
     pass
 
 
-class Type(common._InstanceHandler):
+class Type(common._InstanceHandlerMixin):
     def coerce(self):
         pass
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/orchestrator/topology/template.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/template.py b/aria/orchestrator/topology/template.py
index 917f7a8..8f06ba0 100644
--- a/aria/orchestrator/topology/template.py
+++ b/aria/orchestrator/topology/template.py
@@ -20,7 +20,7 @@ from ...modeling import utils as modeling_utils
 from . import utils, common
 
 
-class ServiceTemplate(common._TemplateHandler):
+class ServiceTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         if self._model.description is not None:
             console.write(console.meta(self._model.description))
@@ -44,7 +44,7 @@ class ServiceTemplate(common._TemplateHandler):
                      self._model.workflow_templates,
                      **kwargs)
 
-    def instantiate(self, instance_cls, inputs=None):
+    def instantiate(self, instance_cls, inputs=None):                                   
           # pylint: disable=arguments-differ
         now = datetime.now()
         service = instance_cls(
             created_at=now,
@@ -118,11 +118,11 @@ class ServiceTemplate(common._TemplateHandler):
         # Validate
         # pylint: disable=too-many-boolean-expressions
         if (scaling['min_instances'] < 0 or
-            scaling['max_instances'] < 0 or
-            scaling['default_instances'] < 0 or
-            scaling['max_instances'] < scaling['min_instances'] or
-            scaling['default_instances'] < scaling['min_instances'] or
-            scaling['default_instances'] > scaling['max_instances']):
+                scaling['max_instances'] < 0 or
+                scaling['default_instances'] < 0 or
+                scaling['max_instances'] < scaling['min_instances'] or
+                scaling['default_instances'] < scaling['min_instances'] or
+                scaling['default_instances'] > scaling['max_instances']):
             self._topology.report(
                 'invalid scaling parameters for node template "{0}": min={min_instances},
max='
                 '{max_instances}, default={default_instances}'.format(self._model.name, **scaling),
@@ -130,7 +130,6 @@ class ServiceTemplate(common._TemplateHandler):
 
         return scaling
 
-
     def validate(self):
         self._topology.validate(self._model.meta_data)
         self._topology.validate(self._model.node_templates)
@@ -149,7 +148,7 @@ class ServiceTemplate(common._TemplateHandler):
         self._topology.validate(self._model.artifact_types)
 
 
-class ArtifactTemplate(common._TemplateHandler):
+class ArtifactTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         console.write(console.node(self._model.name))
         if self._model.description:
@@ -185,7 +184,7 @@ class ArtifactTemplate(common._TemplateHandler):
         self._topology.validate(self._model.properties)
 
 
-class CapabilityTemplate(common._TemplateHandler):
+class CapabilityTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         console.write(console.node(self._model.name))
         if self._model.description:
@@ -219,7 +218,7 @@ class CapabilityTemplate(common._TemplateHandler):
         self._topology.validate(self._model.properties)
 
 
-class RequirementTemplate(common._TemplateHandler):
+class RequirementTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         if self._model.name:
             console.write(console.node(self._model.name))
@@ -263,7 +262,7 @@ class RequirementTemplate(common._TemplateHandler):
         self._topology.validate(self._model.relationship_template)
 
 
-class GroupTemplate(common._TemplateHandler):
+class GroupTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         console.write('Group template: {0}'.format(console.node(self._model.name)))
         if self._model.description:
@@ -299,7 +298,7 @@ class GroupTemplate(common._TemplateHandler):
                        self._model.interface_templates)
 
 
-class InterfaceTemplate(common._TemplateHandler):
+class InterfaceTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         console.write(console.node(self._model.name))
         if self._model.description:
@@ -329,7 +328,7 @@ class InterfaceTemplate(common._TemplateHandler):
                        self._model.operation_templates)
 
 
-class NodeTemplate(common._TemplateHandler):
+class NodeTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         console.write('Node template: {0}'.format(console.node(self._model.name)))
         if self._model.description:
@@ -382,7 +381,7 @@ class NodeTemplate(common._TemplateHandler):
                        self._model.requirement_templates)
 
 
-class PolicyTemplate(common._TemplateHandler):
+class PolicyTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         console.write('Policy template: {0}'.format(console.node(self._model.name)))
         if self._model.description:
@@ -420,7 +419,7 @@ class PolicyTemplate(common._TemplateHandler):
         self._topology.validate(self._model.properties)
 
 
-class SubstitutionTemplate(common._TemplateHandler):
+class SubstitutionTemplate(common._TemplateHandlerMixin):
 
     def dump(self, console):
         console.write('Substitution template:')
@@ -439,7 +438,7 @@ class SubstitutionTemplate(common._TemplateHandler):
         self._topology.validate(self._model.mappings)
 
 
-class SubstitutionTemplateMapping(common._TemplateHandler):
+class SubstitutionTemplateMapping(common._TemplateHandlerMixin):
 
     def dump(self, console):
         if self._topology.capability_template is not None:
@@ -450,8 +449,8 @@ class SubstitutionTemplateMapping(common._TemplateHandler):
             console.node(self._topology.name),
             console.node(node_template.name),
             console.node(self._topology.capability_template.name
-                               if self._topology.capability_template
-                               else self._topology.requirement_template.name)))
+                         if self._topology.capability_template
+                         else self._topology.requirement_template.name)))
 
     def coerce(self):
         pass
@@ -469,8 +468,7 @@ class SubstitutionTemplateMapping(common._TemplateHandler):
         if len(nodes) == 0:
             self._topology.report(
                 'mapping "{0}" refers to node template "{1}" but there are no node instances'.
-                    format(self._model.mapped_name,
-                           self._model.node_template.name),
+                format(self._model.mapped_name, self._model.node_template.name),
                 level=self._topology.Issue.BETWEEN_INSTANCES)
             return None
         # The TOSCA spec does not provide a way to choose the node,
@@ -485,17 +483,15 @@ class SubstitutionTemplateMapping(common._TemplateHandler):
         return substitution_mapping
 
     def validate(self):
-        if all([
-                    self._model.capability_template is None,
-                    self._model.requirement_template is None
-        ]):
-            self._topology.report('mapping "{0}" refers to neither capability nor a requirement
'
-                                  'in node template: {1}'.format(
-                self._model.name, formatting.safe_repr(self._model.node_template.name)),
+        if self._model.capability_template is None and self._model.requirement_template is
None:
+            self._topology.report(
+                'mapping "{0}" refers to neither capability nor a requirement '
+                'in node template: {1}'.format(
+                    self._model.name, formatting.safe_repr(self._model.node_template.name)),
                 level=self._topology.Issue.BETWEEN_TYPES)
 
 
-class RelationshipTemplate(common._TemplateHandler):
+class RelationshipTemplate(common._TemplateHandlerMixin):
     def dump(self, console):
         if self._model.type is not None:
             console.write('Relationship type: {0}'.format(console.type(self._model.type.name)))
@@ -525,7 +521,7 @@ class RelationshipTemplate(common._TemplateHandler):
         self._validate(self._model.properties, self._model.interface_templates)
 
 
-class OperationTemplate(common._TemplateHandler):
+class OperationTemplate(common._TemplateHandlerMixin):
 
     def dump(self, console):
         console.write(console.node(self._model.name))
@@ -585,7 +581,7 @@ class OperationTemplate(common._TemplateHandler):
                        self._model.configurations)
 
 
-class PluginSpecification(common._TemplateHandler):
+class PluginSpecification(common._TemplateHandlerMixin):
     def instantiate(self, **kwargs):
         pass
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/orchestrator/topology/utils.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/utils.py b/aria/orchestrator/topology/utils.py
index ce81f30..47396a5 100644
--- a/aria/orchestrator/topology/utils.py
+++ b/aria/orchestrator/topology/utils.py
@@ -54,10 +54,10 @@ def resolve_plugin_specification(plugin_specification, plugins):
     matching_plugins = []
     if plugins:
         for plugin in plugins:
-            if all([plugin.name == plugin_specification.name,
-                    any([plugin_specification.version is None,
-                         VersionString(plugin.package_version) >= plugin_specification.version])
-                    ]):
+            if (plugin.name == plugin_specification.name and
+                    (plugin_specification.version is None or
+                     VersionString(plugin.package_version) >= plugin_specification.version)
+               ):
                 matching_plugins.append(plugin)
     plugin_specification.plugin = None
     if matching_plugins:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/parser/modeling/context.py
----------------------------------------------------------------------
diff --git a/aria/parser/modeling/context.py b/aria/parser/modeling/context.py
index 286ab60..d8a1f7a 100644
--- a/aria/parser/modeling/context.py
+++ b/aria/parser/modeling/context.py
@@ -22,7 +22,7 @@ from ...utils.uuid import generate_uuid
 # See: http://www.faqs.org/rfcs/rfc1035.html
 ID_MAX_LENGTH = 63
 
-1
+
 class IdType(object):
     LOCAL_SERIAL = 0
     """

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/parser/reading/locator.py
----------------------------------------------------------------------
diff --git a/aria/parser/reading/locator.py b/aria/parser/reading/locator.py
index 8bbb178..57b4d50 100644
--- a/aria/parser/reading/locator.py
+++ b/aria/parser/reading/locator.py
@@ -117,5 +117,3 @@ class Locator(object):
     def __str__(self):
         # Should be in same format as Issue.locator_as_str
         return '"%s":%d:%d' % (self.location, self.line, self.column)
-
-

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e7586af/aria/parser/validation/issue.py
----------------------------------------------------------------------
diff --git a/aria/parser/validation/issue.py b/aria/parser/validation/issue.py
index f4304b7..17e488f 100644
--- a/aria/parser/validation/issue.py
+++ b/aria/parser/validation/issue.py
@@ -183,4 +183,4 @@ class Reporter(object):
                         with console.indent(3):
                             exceptions.print_exception(issue.exception)
             return True
-        return False
\ No newline at end of file
+        return False



Mime
View raw message