Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nielslaukens committed Oct 17, 2018
1 parent 57a673e commit ab6190c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions stacker/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def resolve(self, context, provider):

def dependencies(self):
"""
:return: list of stack names that this variable depends on
:rtype: Set[str]
Returns:
Set[str]: Stack names that this variable depends on
"""
return self._value.dependencies()

Expand All @@ -153,8 +153,8 @@ def __iter__(self):

def resolved(self):
"""
:return: Whether value() will not raise an error
:rtype: bool
Returns:
bool: Whether value() will not raise an error
"""
return NotImplementedError()

Expand All @@ -169,7 +169,9 @@ def simplified(self):
Return a simplified version of the Value.
This can be used to e.g. concatenate two literals in to one literal, or
to flatten nested Concatenations
:rtype: VariableValue
Returns:
VariableValue
"""
return self

Expand All @@ -188,24 +190,27 @@ def parse(cls, input_object):
for t in re.split(r'(\$\{|\}|\s+)', input_object)
])

opener = '${'
closer = '}'

while True:
last_open = None
next_close = None
for i, t in enumerate(tokens):
if not isinstance(t, VariableValueLiteral):
continue

if t.value() == '${':
if t.value() == opener:
last_open = i
next_close = None
if last_open is not None and \
t.value() == '}' and \
t.value() == closer and \
next_close is None:
next_close = i

if next_close is not None:
lookup_data = VariableValueConcatenation(
tokens[(last_open + 3):next_close]
tokens[(last_open + len(opener) + 1):next_close]
)
lookup = VariableValueLookup(
lookup_name=tokens[last_open + 1],
Expand Down Expand Up @@ -395,10 +400,9 @@ def simplified(self):
class VariableValueLookup(VariableValue):
def __init__(self, lookup_name, lookup_data, handler=None):
"""
:param lookup_name: Name of the invoked lookup
:type lookup_name: basestring
:param lookup_data: Data portion of the lookup
:type lookup_data: VariableValue
Args:
lookup_name (basestring): Name of the invoked lookup
lookup_data (VariableValue): Data portion of the lookup
"""
self._resolved = False
self._value = None
Expand Down

0 comments on commit ab6190c

Please sign in to comment.