Skip to content

Commit

Permalink
Fix the last (hopefully) case of catching used variables #1225
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Mar 1, 2019
1 parent f345a86 commit 34977e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sos/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _load_group(group: str) -> None:
import re
from ._version import __version__
from pkg_resources import parse_version
m = re.search("Requirement.parse\('sos>=([^)]*)'\)", str(e))
m = re.search(r"Requirement.parse\('sos>=([^)]*)'\)", str(e))
if m:
if parse_version(__version__) < parse_version(m.group(1)):
logger.warning(
Expand Down
21 changes: 21 additions & 0 deletions src/sos/section_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@ def get_all_used_vars(section):
all_used_vars |= accessed_vars(statement[1])
elif statement[0] == ':':
all_used_vars |= accessed_vars(statement[2])
if statement[1] != 'input':
continue
if 'paired_with' in statement[2]:
try:
pws = get_names_of_param('paired_with', statement[2], extra_dict=env.sos_dict.dict())
all_used_vars |= set(pws)
except Exception as e:
raise ValueError(f'Failed to parse parameter paired_with: {e}')
if 'group_with' in statement[2]:
try:
pws = get_names_of_param('group_with', statement[2], extra_dict=env.sos_dict.dict())
all_used_vars |= set(pws)
except Exception as e:
raise ValueError(f'Failed to parse parameter group_with: {e}')
if 'for_each' in statement[2]:
try:
pws = get_names_of_param('for_each', statement[2], extra_dict=env.sos_dict.dict())
for pw in pws:
all_used_vars |= set(pw.split(','))
except Exception as e:
raise ValueError(f'Failed to parse parameter for_each: {e}')
return all_used_vars

def get_signature_vars(section):
Expand Down

0 comments on commit 34977e7

Please sign in to comment.