diff --git a/tconfpy.py b/tconfpy.py index 7e29081..7c0cd67 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.111 2004/03/14 01:39:00 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.112 2004/03/14 04:43:53 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -91,7 +91,7 @@ # Regular Expressions reVARREF = r"\%s.+?\%s" % (DELIML, DELIMR) # Variable reference -VARREF = re.compile(reVARREF) +VarRef = re.compile(reVARREF) ########### @@ -126,7 +126,7 @@ # # where the descriptor is a list: # -# [value, isbuiltin, iswriteable, type, default value, [list of legal vals], min, max] +# [value, iswriteable, type, default value, [list of legal vals], min, max] # Indexes Into Symbol Table Variable Descriptor @@ -354,14 +354,19 @@ # Dereference Variables ########## -def DeRefVar(line, cfgfile, linenum): +def DerefVar(line, cfgfile, linenum): - for sym in Reserved: - line = line.replace("%s%s%s" % (DELIML, sym, DELIMR), SymTable[sym][SYM_VALUE]) + # Find all symbols refrences and replace w/sym table entry if present + + for var in VarRef.findall(line): + + sym = var[1:-1] # Strip delimiters + if sym in SymTable: + line = line.replace(var, str(SymTable[sym][SYM_VALUE])) return line -# End of 'DeRefVar()' +# End of 'DerefVar()' ########## @@ -458,18 +463,35 @@ # # Must be one of the following forms - # - # .if [var] - # .if [var] == string - # .if [var] != string + # .if string + # .if string == string + # .if string != string # ##### if line.startswith(IF): - line = line.split(IF)[1].strip() - else: - line = DeRefVar(line, cfgfile, linenum) + # Handle .if string == string form + if line.count(EQUIV): + pass + + # Handle .if string != string form + elif line.count(NOTEQUIV): + pass + + # Handle .if string + # FIXXXXXXX THIS TO CHECK FOR CORRECT FORM FIRST + else: + line = DerefVar(line, cfgfile, linenum) + + # See if all the variable references were resolved + + if not VarRef.match(line): + CondStack.append(True) + else: + CondStack.append(False) + ########## @@ -483,6 +505,6 @@ line = dBLANKLINE DebugMsg(dPARSEDLINE %(cfgfile, linenum, orig, line)) - + # End of 'ParseLine'