incubator-ariatosca git commit: Fixes, cleanups, more tests [Forced Update!]

2017-08-07 Thread emblemparade
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-324-refactor-ctx-access 5b95c26fd -> 1baaedf5c (forced update)


Fixes, cleanups, more tests


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

Branch: refs/heads/ARIA-324-refactor-ctx-access
Commit: 1baaedf5c42fc66ba44e360854456c7e64002b4a
Parents: 607f1dd
Author: Tal Liron 
Authored: Mon Aug 7 12:05:34 2017 -0500
Committer: Tal Liron 
Committed: Mon Aug 7 15:12:59 2017 -0500

--
 .../execution_plugin/ctx_proxy/server.py| 44 ++--
 .../execution_plugin/test_ctx_proxy_server.py   | 22 +++---
 tests/requirements.txt  |  6 +--
 tox.ini |  8 ++--
 4 files changed, 47 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1baaedf5/aria/orchestrator/execution_plugin/ctx_proxy/server.py
--
diff --git a/aria/orchestrator/execution_plugin/ctx_proxy/server.py 
b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
index b248a5d..5f4b72b 100644
--- a/aria/orchestrator/execution_plugin/ctx_proxy/server.py
+++ b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
@@ -121,7 +121,7 @@ class CtxProxy(object):
 def _process(self, request):
 try:
 with self.ctx.model.instrument(*self.ctx.INSTRUMENTATION_FIELDS):
-payload = _parse_request(self.ctx, request)
+payload = _process_request(self.ctx, request)
 result_type = 'result'
 if isinstance(payload, exceptions.ScriptException):
 payload = dict(message=str(payload))
@@ -146,41 +146,44 @@ class CtxProxy(object):
 self.close()
 
 
-class ProcessingError(RuntimeError):
+class CtxError(RuntimeError):
 pass
 
 
-class ParsingError(ProcessingError):
+class CtxParsingError(CtxError):
 pass
 
 
-def _parse_request(ctx, request):
+def _process_request(ctx, request):
 request = json.loads(request)
 args = request['args']
-return _parse_arguments(ctx, args)
+return _process_arguments(ctx, args)
 
 
-def _parse_arguments(obj, args):
+def _process_arguments(obj, args):
 # Modifying?
 try:
 # TODO: should there be a way to escape "=" in case it is needed as 
real argument?
 equals_index = args.index('=') # raises ValueError if not found
+except ValueError:
+equals_index = None
+if equals_index is not None:
 if equals_index == 0:
-raise ParsingError('The "=" argument cannot be first')
-if equals_index != len(args) - 2:
-raise ParsingError('The "=" argument must be penultimate')
+raise CtxParsingError('The "=" argument cannot be first')
+elif equals_index != len(args) - 2:
+raise CtxParsingError('The "=" argument must be penultimate')
 modifying = True
 modifying_key = args[-3]
 modifying_value = args[-1]
 args = args[:-3]
-except ValueError:
+else:
 modifying = False
 modifying_key = None
 modifying_value = None
 
 # Parse all arguments
 while len(args) > 0:
-obj, args = _parse_argument(obj, args, modifying)
+obj, args = _process_next_operation(obj, args, modifying)
 
 if modifying:
 if hasattr(obj, '__setitem__'):
@@ -192,13 +195,12 @@ def _parse_arguments(obj, args):
 # Modify object attribute
 setattr(obj, modifying_key, modifying_value)
 else:
-raise ProcessingError('Cannot modify `{0}` of `{1!r}`'
-  .format(modifying_key, obj))
+raise CtxError('Cannot modify `{0}` of 
`{1!r}`'.format(modifying_key, obj))
 
 return obj
 
 
-def _parse_argument(obj, args, modifying):
+def _process_next_operation(obj, args, modifying):
 args = list(args)
 arg = args.pop(0)
 
@@ -207,22 +209,22 @@ def _parse_argument(obj, args, modifying):
 # TODO: should there be a way to escape "[" and "]" in case they are 
needed as real
 # arguments?
 try:
-closing_index = args.index(']')
+closing_index = args.index(']') # raises ValueError if not found
 except ValueError:
-raise ParsingError('Opening "[" without a closing "]')
+raise CtxParsingError('Opening "[" without a closing "]')
 callable_args = args[:closing_index]
 args = args[closing_index + 1:]
 if not callable(obj):
-raise Process

incubator-ariatosca git commit: Fixes, cleanups, more tests

2017-08-07 Thread emblemparade
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-324-refactor-ctx-access 607f1dd1b -> 5b95c26fd


Fixes, cleanups, more tests


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

Branch: refs/heads/ARIA-324-refactor-ctx-access
Commit: 5b95c26fdaf7784808dad52036c0cb66a0397a4f
Parents: 607f1dd
Author: Tal Liron 
Authored: Mon Aug 7 12:05:34 2017 -0500
Committer: Tal Liron 
Committed: Mon Aug 7 12:05:34 2017 -0500

--
 .../execution_plugin/ctx_proxy/server.py| 44 ++--
 .../execution_plugin/test_ctx_proxy_server.py   | 22 +++---
 2 files changed, 40 insertions(+), 26 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5b95c26f/aria/orchestrator/execution_plugin/ctx_proxy/server.py
--
diff --git a/aria/orchestrator/execution_plugin/ctx_proxy/server.py 
b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
index b248a5d..5f4b72b 100644
--- a/aria/orchestrator/execution_plugin/ctx_proxy/server.py
+++ b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
@@ -121,7 +121,7 @@ class CtxProxy(object):
 def _process(self, request):
 try:
 with self.ctx.model.instrument(*self.ctx.INSTRUMENTATION_FIELDS):
-payload = _parse_request(self.ctx, request)
+payload = _process_request(self.ctx, request)
 result_type = 'result'
 if isinstance(payload, exceptions.ScriptException):
 payload = dict(message=str(payload))
@@ -146,41 +146,44 @@ class CtxProxy(object):
 self.close()
 
 
-class ProcessingError(RuntimeError):
+class CtxError(RuntimeError):
 pass
 
 
-class ParsingError(ProcessingError):
+class CtxParsingError(CtxError):
 pass
 
 
-def _parse_request(ctx, request):
+def _process_request(ctx, request):
 request = json.loads(request)
 args = request['args']
-return _parse_arguments(ctx, args)
+return _process_arguments(ctx, args)
 
 
-def _parse_arguments(obj, args):
+def _process_arguments(obj, args):
 # Modifying?
 try:
 # TODO: should there be a way to escape "=" in case it is needed as 
real argument?
 equals_index = args.index('=') # raises ValueError if not found
+except ValueError:
+equals_index = None
+if equals_index is not None:
 if equals_index == 0:
-raise ParsingError('The "=" argument cannot be first')
-if equals_index != len(args) - 2:
-raise ParsingError('The "=" argument must be penultimate')
+raise CtxParsingError('The "=" argument cannot be first')
+elif equals_index != len(args) - 2:
+raise CtxParsingError('The "=" argument must be penultimate')
 modifying = True
 modifying_key = args[-3]
 modifying_value = args[-1]
 args = args[:-3]
-except ValueError:
+else:
 modifying = False
 modifying_key = None
 modifying_value = None
 
 # Parse all arguments
 while len(args) > 0:
-obj, args = _parse_argument(obj, args, modifying)
+obj, args = _process_next_operation(obj, args, modifying)
 
 if modifying:
 if hasattr(obj, '__setitem__'):
@@ -192,13 +195,12 @@ def _parse_arguments(obj, args):
 # Modify object attribute
 setattr(obj, modifying_key, modifying_value)
 else:
-raise ProcessingError('Cannot modify `{0}` of `{1!r}`'
-  .format(modifying_key, obj))
+raise CtxError('Cannot modify `{0}` of 
`{1!r}`'.format(modifying_key, obj))
 
 return obj
 
 
-def _parse_argument(obj, args, modifying):
+def _process_next_operation(obj, args, modifying):
 args = list(args)
 arg = args.pop(0)
 
@@ -207,22 +209,22 @@ def _parse_argument(obj, args, modifying):
 # TODO: should there be a way to escape "[" and "]" in case they are 
needed as real
 # arguments?
 try:
-closing_index = args.index(']')
+closing_index = args.index(']') # raises ValueError if not found
 except ValueError:
-raise ParsingError('Opening "[" without a closing "]')
+raise CtxParsingError('Opening "[" without a closing "]')
 callable_args = args[:closing_index]
 args = args[closing_index + 1:]
 if not callable(obj):
-raise ProcessingError('Used "[" and "] on an object that is not 
callable')
+raise CtxError('Used "[" and "] on an object that is not 

[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131703940
  
--- Diff: aria/orchestrator/execution_plugin/ctx_proxy/server.py ---
@@ -170,101 +178,59 @@ def _process_ctx_request(ctx, args): # pylint: 
disable=too-many-branches,too-man
 modifying_key = None
 modifying_value = None
 
-num_args = len(args)
-
-while index < num_args:
-arg = args[index]
-
-# Object attribute
-attr = _desugar_attr(current, arg)
-if attr is not None:
-current = getattr(current, attr)
-
-# List entry
-elif isinstance(current, list) and _is_int(arg):
-current = current[int(arg)]
-
-# Dict (or dict-like object) value
-elif hasattr(current, '__getitem__'):
-if modifying and (not arg in current):
-current[arg] = {}
-current = current[arg]
-
-# Call
-elif callable(current):
-if isinstance(current, functools.partial):
-argspec = inspect.getargspec(current.func)
-# Don't count initial args fulfilled by the partial
-spec_args = argspec.args[len(current.args):]
-# Don't count keyword args fulfilled by the partial
-spec_args = tuple(a for a in spec_args if a not in 
current.keywords)
-else:
-argspec = inspect.getargspec(current)
-spec_args = argspec.args
-
-callable_kwargs = {}
-if isinstance(arg, dict):
-# If the first arg is a dict, treat it as our kwargs
-# TODO: what if the first argument really needs to be a 
dict?
-callable_kwargs = arg
-index += 1
-
-if argspec.varargs is not None:
-# Gobble the rest of the args
-callable_args = args[index:]
-else:
-# Take only what we need
-spec_args = tuple(a for a in spec_args if a not in 
callable_kwargs)
-spec_args_count = len(spec_args)
-if inspect.ismethod(current):
-# Don't count "self" argument
-spec_args_count -= 1
-callable_args = args[index:index + spec_args_count]
-# Note: we might actually have fewer args than the 
args_count, but that could be OK
-# if the user expects subsequent args to have default 
values
-
-args_count = len(callable_args)
-if args_count > 1:
-index += args_count - 1
-
-current = current(*callable_args, **callable_kwargs)
-
-else:
-raise RuntimeError('`{0}` cannot be processed in 
{1}'.format(arg, args))
-
-index += 1
-
-if callable(current):
-current = current()
+# Parse all arguments
+while len(args) > 0:
+obj, args = _parse_argument(obj, args, modifying)
 
 if modifying:
-if hasattr(current, '__setitem__'):
-# Modify dict value
-current[modifying_key] = modifying_value
-else:
+if hasattr(obj, '__setitem__'):
+# Modify item value (dict, list, and similar)
+if isinstance(obj, (list, tuple)):
+modifying_key = int(modifying_key)
+obj[modifying_key] = modifying_value
+elif hasattr(obj, modifying_key):
 # Modify object attribute
-setattr(current, modifying_key, modifying_value)
-
-return current
+setattr(obj, modifying_key, modifying_value)
+else:
+raise ProcessingError('Cannot modify `{0}` of `{1!r}`'
+  .format(modifying_key, obj))
 
+return obj
 
-def _desugar_attr(obj, attr):
-if not isinstance(attr, basestring):
-return None
-if hasattr(obj, attr):
-return attr
-attr = attr.replace('-', '_')
-if hasattr(obj, attr):
-return attr
-return None
 
+def _parse_argument(obj, args, modifying):
+args = list(args)
+arg = args.pop(0)
 
-def _is_int(arg):
-try:
-int(arg)
-except ValueError:
-return False
-return True
+# Call?
+if arg == '[':
+# TODO: should there be a way to escape "[" and "]" in case they 
are needed as real
+# arguments?
+try:
+closing_index = args.index(']')
+

[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131703163
  
--- Diff: aria/orchestrator/execution_plugin/ctx_proxy/server.py ---
@@ -170,101 +178,59 @@ def _process_ctx_request(ctx, args): # pylint: 
disable=too-many-branches,too-man
 modifying_key = None
 modifying_value = None
 
-num_args = len(args)
-
-while index < num_args:
-arg = args[index]
-
-# Object attribute
-attr = _desugar_attr(current, arg)
-if attr is not None:
-current = getattr(current, attr)
-
-# List entry
-elif isinstance(current, list) and _is_int(arg):
-current = current[int(arg)]
-
-# Dict (or dict-like object) value
-elif hasattr(current, '__getitem__'):
-if modifying and (not arg in current):
-current[arg] = {}
-current = current[arg]
-
-# Call
-elif callable(current):
-if isinstance(current, functools.partial):
-argspec = inspect.getargspec(current.func)
-# Don't count initial args fulfilled by the partial
-spec_args = argspec.args[len(current.args):]
-# Don't count keyword args fulfilled by the partial
-spec_args = tuple(a for a in spec_args if a not in 
current.keywords)
-else:
-argspec = inspect.getargspec(current)
-spec_args = argspec.args
-
-callable_kwargs = {}
-if isinstance(arg, dict):
-# If the first arg is a dict, treat it as our kwargs
-# TODO: what if the first argument really needs to be a 
dict?
-callable_kwargs = arg
-index += 1
-
-if argspec.varargs is not None:
-# Gobble the rest of the args
-callable_args = args[index:]
-else:
-# Take only what we need
-spec_args = tuple(a for a in spec_args if a not in 
callable_kwargs)
-spec_args_count = len(spec_args)
-if inspect.ismethod(current):
-# Don't count "self" argument
-spec_args_count -= 1
-callable_args = args[index:index + spec_args_count]
-# Note: we might actually have fewer args than the 
args_count, but that could be OK
-# if the user expects subsequent args to have default 
values
-
-args_count = len(callable_args)
-if args_count > 1:
-index += args_count - 1
-
-current = current(*callable_args, **callable_kwargs)
-
-else:
-raise RuntimeError('`{0}` cannot be processed in 
{1}'.format(arg, args))
-
-index += 1
-
-if callable(current):
-current = current()
+# Parse all arguments
+while len(args) > 0:
+obj, args = _parse_argument(obj, args, modifying)
 
 if modifying:
-if hasattr(current, '__setitem__'):
-# Modify dict value
-current[modifying_key] = modifying_value
-else:
+if hasattr(obj, '__setitem__'):
+# Modify item value (dict, list, and similar)
+if isinstance(obj, (list, tuple)):
+modifying_key = int(modifying_key)
+obj[modifying_key] = modifying_value
+elif hasattr(obj, modifying_key):
 # Modify object attribute
-setattr(current, modifying_key, modifying_value)
-
-return current
+setattr(obj, modifying_key, modifying_value)
+else:
+raise ProcessingError('Cannot modify `{0}` of `{1!r}`'
+  .format(modifying_key, obj))
 
+return obj
 
-def _desugar_attr(obj, attr):
-if not isinstance(attr, basestring):
-return None
-if hasattr(obj, attr):
-return attr
-attr = attr.replace('-', '_')
-if hasattr(obj, attr):
-return attr
-return None
 
+def _parse_argument(obj, args, modifying):
+args = list(args)
+arg = args.pop(0)
 
-def _is_int(arg):
-try:
-int(arg)
-except ValueError:
-return False
-return True
+# Call?
+if arg == '[':
+# TODO: should there be a way to escape "[" and "]" in case they 
are needed as real
+# arguments?
+try:
+closing_index = args.index(']')
+

[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131702731
  
--- Diff: aria/orchestrator/execution_plugin/ctx_proxy/server.py ---
@@ -170,101 +178,59 @@ def _process_ctx_request(ctx, args): # pylint: 
disable=too-many-branches,too-man
 modifying_key = None
 modifying_value = None
 
-num_args = len(args)
-
-while index < num_args:
-arg = args[index]
-
-# Object attribute
-attr = _desugar_attr(current, arg)
-if attr is not None:
-current = getattr(current, attr)
-
-# List entry
-elif isinstance(current, list) and _is_int(arg):
-current = current[int(arg)]
-
-# Dict (or dict-like object) value
-elif hasattr(current, '__getitem__'):
-if modifying and (not arg in current):
-current[arg] = {}
-current = current[arg]
-
-# Call
-elif callable(current):
-if isinstance(current, functools.partial):
-argspec = inspect.getargspec(current.func)
-# Don't count initial args fulfilled by the partial
-spec_args = argspec.args[len(current.args):]
-# Don't count keyword args fulfilled by the partial
-spec_args = tuple(a for a in spec_args if a not in 
current.keywords)
-else:
-argspec = inspect.getargspec(current)
-spec_args = argspec.args
-
-callable_kwargs = {}
-if isinstance(arg, dict):
-# If the first arg is a dict, treat it as our kwargs
-# TODO: what if the first argument really needs to be a 
dict?
-callable_kwargs = arg
-index += 1
-
-if argspec.varargs is not None:
-# Gobble the rest of the args
-callable_args = args[index:]
-else:
-# Take only what we need
-spec_args = tuple(a for a in spec_args if a not in 
callable_kwargs)
-spec_args_count = len(spec_args)
-if inspect.ismethod(current):
-# Don't count "self" argument
-spec_args_count -= 1
-callable_args = args[index:index + spec_args_count]
-# Note: we might actually have fewer args than the 
args_count, but that could be OK
-# if the user expects subsequent args to have default 
values
-
-args_count = len(callable_args)
-if args_count > 1:
-index += args_count - 1
-
-current = current(*callable_args, **callable_kwargs)
-
-else:
-raise RuntimeError('`{0}` cannot be processed in 
{1}'.format(arg, args))
-
-index += 1
-
-if callable(current):
-current = current()
+# Parse all arguments
+while len(args) > 0:
+obj, args = _parse_argument(obj, args, modifying)
 
 if modifying:
-if hasattr(current, '__setitem__'):
-# Modify dict value
-current[modifying_key] = modifying_value
-else:
+if hasattr(obj, '__setitem__'):
+# Modify item value (dict, list, and similar)
+if isinstance(obj, (list, tuple)):
+modifying_key = int(modifying_key)
+obj[modifying_key] = modifying_value
+elif hasattr(obj, modifying_key):
 # Modify object attribute
-setattr(current, modifying_key, modifying_value)
-
-return current
+setattr(obj, modifying_key, modifying_value)
+else:
+raise ProcessingError('Cannot modify `{0}` of `{1!r}`'
+  .format(modifying_key, obj))
 
+return obj
 
-def _desugar_attr(obj, attr):
-if not isinstance(attr, basestring):
-return None
-if hasattr(obj, attr):
-return attr
-attr = attr.replace('-', '_')
-if hasattr(obj, attr):
-return attr
-return None
 
+def _parse_argument(obj, args, modifying):
--- End diff --

But you wouldn't know in advance which function to call until you start 
parsing. I renamed it and did some little cleanups to add clarity.


---
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 infrastruct

[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131700894
  
--- Diff: aria/orchestrator/execution_plugin/ctx_proxy/server.py ---
@@ -150,17 +146,29 @@ def __exit__(self, *args, **kwargs):
 self.close()
 
 
-def _process_ctx_request(ctx, args): # pylint: 
disable=too-many-branches,too-many-statements
-current = ctx
-index = 0
+class ProcessingError(RuntimeError):
+pass
+
 
+class ParsingError(ProcessingError):
+pass
+
+
+def _parse_request(ctx, request):
+request = json.loads(request)
+args = request['args']
+return _parse_arguments(ctx, args)
+
+
+def _parse_arguments(obj, args):
+# Modifying?
 try:
 # TODO: should there be a way to escape "=" in case it is needed 
as real argument?
-equals_index = args.index('=')
+equals_index = args.index('=') # raises ValueError if not found
--- End diff --

It looks more awkward, but +1.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131700830
  
--- Diff: aria/orchestrator/execution_plugin/ctx_proxy/server.py ---
@@ -170,101 +178,59 @@ def _process_ctx_request(ctx, args): # pylint: 
disable=too-many-branches,too-man
 modifying_key = None
 modifying_value = None
 
-num_args = len(args)
-
-while index < num_args:
-arg = args[index]
-
-# Object attribute
-attr = _desugar_attr(current, arg)
-if attr is not None:
-current = getattr(current, attr)
-
-# List entry
-elif isinstance(current, list) and _is_int(arg):
-current = current[int(arg)]
-
-# Dict (or dict-like object) value
-elif hasattr(current, '__getitem__'):
-if modifying and (not arg in current):
-current[arg] = {}
-current = current[arg]
-
-# Call
-elif callable(current):
-if isinstance(current, functools.partial):
-argspec = inspect.getargspec(current.func)
-# Don't count initial args fulfilled by the partial
-spec_args = argspec.args[len(current.args):]
-# Don't count keyword args fulfilled by the partial
-spec_args = tuple(a for a in spec_args if a not in 
current.keywords)
-else:
-argspec = inspect.getargspec(current)
-spec_args = argspec.args
-
-callable_kwargs = {}
-if isinstance(arg, dict):
-# If the first arg is a dict, treat it as our kwargs
-# TODO: what if the first argument really needs to be a 
dict?
-callable_kwargs = arg
-index += 1
-
-if argspec.varargs is not None:
-# Gobble the rest of the args
-callable_args = args[index:]
-else:
-# Take only what we need
-spec_args = tuple(a for a in spec_args if a not in 
callable_kwargs)
-spec_args_count = len(spec_args)
-if inspect.ismethod(current):
-# Don't count "self" argument
-spec_args_count -= 1
-callable_args = args[index:index + spec_args_count]
-# Note: we might actually have fewer args than the 
args_count, but that could be OK
-# if the user expects subsequent args to have default 
values
-
-args_count = len(callable_args)
-if args_count > 1:
-index += args_count - 1
-
-current = current(*callable_args, **callable_kwargs)
-
-else:
-raise RuntimeError('`{0}` cannot be processed in 
{1}'.format(arg, args))
-
-index += 1
-
-if callable(current):
-current = current()
+# Parse all arguments
+while len(args) > 0:
+obj, args = _parse_argument(obj, args, modifying)
 
 if modifying:
-if hasattr(current, '__setitem__'):
-# Modify dict value
-current[modifying_key] = modifying_value
-else:
+if hasattr(obj, '__setitem__'):
--- End diff --

Cannot, because it wouldn't support dict-like objects like instrumented 
wrapper classes. This is generally better because it would support anything 
that supported __get_item__ and __set_item__, which allows for any kind of 
classes.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131693627
  
--- Diff: tests/orchestrator/execution_plugin/test_ctx_proxy_server.py ---
@@ -55,61 +55,32 @@ def test_dict_prop_access_set(self, server, ctx):
 assert ctx.node.properties['prop3'][2]['value'] == 'new_value_2'
 assert ctx.node.properties['prop4']['some']['new']['path'] == 
'some_new_value'
 
+def test_dict_prop_access_set_with_list_index(self, server, ctx):
--- End diff --

+1


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #188: ARIA-324 Refactor ctx proxy access

2017-08-07 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/188#discussion_r131693585
  
--- Diff: examples/hello-world/scripts/stop.sh ---
@@ -16,14 +16,13 @@
 
 set -e
 
-TEMP_DIR="/tmp"
-PYTHON_FILE_SERVER_ROOT=${TEMP_DIR}/python-simple-http-webserver
-PID_FILE="server.pid"
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="${TEMP_DIR}/python-simple-http-webserver"
+PID_FILE=server.pid
+PID=$(cat "$PYTHON_FILE_SERVER_ROOT/$PID_FILE")
 
-PID=`cat ${PYTHON_FILE_SERVER_ROOT}/${PID_FILE}`
+ctx logger info [ "Shutting down web server, pid = ${PID}." ]
+kill -9 "$PID" || exit $?
 
-ctx logger info "Shutting down web server, pid = ${PID}."
-kill -9 ${PID} || exit $?
-
-ctx logger info "Removing web server root folder: 
${PYTHON_FILE_SERVER_ROOT}."
-rm -rf ${PYTHON_FILE_SERVER_ROOT}
+ctx logger info [ "Removing web server root folder: 
$PYTHON_FILE_SERVER_ROOT." ]
--- End diff --

Heh, not 100% sure I agree with that, but it does look clear. :)


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---