Skip to content

Commit

Permalink
Additional defense against bad input
Browse files Browse the repository at this point in the history
  • Loading branch information
uogbuji committed Apr 22, 2019
1 parent 0480eb8 commit 1be2c54
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/py/pipeline/core_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ def _foreach(ctx):
a = [a] if _attributes is None else (_attributes if isinstance(_attributes, list) else [_attributes])
#print([(curr_o, curr_r, curr_t, curr_a) for (curr_o, curr_r, curr_t, curr_a)
# in product(o, r, t, a)])
# Assemble the possible context links, ignoring those with blank or None origins
subcontexts = [ ctx.copy(current_link=(curr_o, curr_r, curr_t, curr_a))
for (curr_o, curr_r, curr_t, curr_a)
in itertools.product(o, r, t, a) ]
in itertools.product(o, r, t, a) if curr_o ]
if action:
if not(callable(action)):
raise TypeError('foreach() action arg must be callable')
Expand Down Expand Up @@ -286,7 +287,7 @@ def _materialize(ctx):
_unique = unique(ctx) if callable(unique) else unique
(o, r, t, a) = ctx.current_link
#FIXME: On redesign implement split using function composition instead
targets = [ sub_t.strip() for sub_t in t.split(split) ] if split else [t]
targets = [ sub_t.strip() for sub_t in t.split(split) if sub_t.strip() ] if split else [t]
#Conversions to make sure we end up with a list of relationships out of it all
if _rel is None:
_rel = [r]
Expand All @@ -301,6 +302,8 @@ def _materialize(ctx):
if origin:
#Have been given enough info to derive the origin from context. Ignore origin in current link
o = origin(ctx_stem)
if not o: #Defensive coding
continue

computed_unique = [] if _unique else None
if _unique:
Expand Down

0 comments on commit 1be2c54

Please sign in to comment.