aboutsummaryrefslogtreecommitdiff
path: root/steuermann/nodes.py
diff options
context:
space:
mode:
authorcslocum <cslocum@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2014-09-10 14:44:10 -0400
committercslocum <cslocum@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2014-09-10 14:44:10 -0400
commit7eae6c96bdec6ad1a5dadbd4cd0c07231dcca179 (patch)
tree612204f11614676af059e97cdcae4f2c185c9a3f /steuermann/nodes.py
parentbc68f11a5fc3d4132676068d91eccf0652e715fb (diff)
downloadsteuermann-7eae6c96bdec6ad1a5dadbd4cd0c07231dcca179.tar.gz
some changes to how CONDITIONS block is processed; incrememnt N to 20
git-svn-id: https://svn.stsci.edu/svn/ssb/etal/steuermann/trunk@1318 d34015c8-bcbb-4646-8ac8-8ba5febf221d
Diffstat (limited to 'steuermann/nodes.py')
-rw-r--r--steuermann/nodes.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/steuermann/nodes.py b/steuermann/nodes.py
index 871b7c6..17b73ab 100644
--- a/steuermann/nodes.py
+++ b/steuermann/nodes.py
@@ -3,6 +3,8 @@ Stuff related to the tree structure of the command set
'''
import fnmatch
+from run_all import allowed_flags
+import sys
#import exyapps.runtime
@@ -366,6 +368,21 @@ def read_file_list( file_list ) :
saved_conditions = { 'True' : True, 'False' : False }
+# find any unknown arguments like --something=whatever, set as conditions
+arguments = sys.argv[1:]
+for a in arguments:
+ if '--' in a and '=' in a:
+ not_allowed_flag = True
+ for f in allowed_flags.keys():
+ if a.startswith(f):
+ not_allowed_flag = False
+ break
+ if not_allowed_flag:
+ a = a.lstrip('--')
+ k, v = a.split('=')
+ saved_conditions[k] = eval(v)
+
+
def declare_conditions( text, filename ) :
# the parameter "text" is the token that begins "CONDITION\n"
# and ends "\nEND\n", with a block of python code in the middle.
@@ -377,22 +394,13 @@ def declare_conditions( text, filename ) :
text = text.split('\n',1)[1] # tear off "CONDITION\n"
text = text.rsplit('\n',2)[0] # tear off "END\n"
- # if it is indented at all, compensate for the indent so the
- # exec will work
- if text.startswith(' ') or text.startswith('\t') :
- text = 'if 1 :\n' + text
-
- # exec it into cond first, and then move any entries that are unique
- # into saved_conditions; this allows us to specify conditions on the
- # command line and not have them overwritten by the same variable in
- # a CONDITIONS block
- cond = {}
- exec text in cond
- for k, v in cond.items():
- if k not in saved_conditions:
- saved_conditions[k] = v
-
-
+ for ln in text.split('\n'):
+ ln = ln.strip()
+ cond = saved_conditions.copy()
+ exec ln in cond
+ for k, v in cond.items():
+ if k not in saved_conditions:
+ saved_conditions[k] = v
def check_condition( name, filename ) :