diff --git a/tconfpy.py b/tconfpy.py index 0e948c1..3037776 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.169 2004/04/13 23:06:01 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.170 2004/04/14 02:26:08 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -76,18 +76,6 @@ NSSEP = '.' # Namespace separator character NOTEQUIV = r"!=" # Used in conditional tests -# Pre-Defined System Symbols - -PREDEFINTRO = '.' - -Predefined = {PREDEFINTRO + "PLATFORM" : sysplat, - PREDEFINTRO + "OSDETAILS" : platform.platform(), - PREDEFINTRO + "OSNAME" : platform.system(), - PREDEFINTRO + "OSRELEASE" : platform.release(), - PREDEFINTRO + "PYTHONVERSION" : platform.python_version(), - PREDEFINTRO + "MACHINENAME" : platform.node() - } - # Control and conditional symbols CONDINTRO = '.' # Conditional introducer token @@ -101,9 +89,34 @@ LITERAL = CONDINTRO + "literal" ENDLITERAL = CONDINTRO + "endliteral" -Reserved = ["HASH", "DELIML", "DELIMR", "DOLLAR", "EQUAL", "EQUIV", "NOTEQUIV", "NSSEP", - "INCLUDE", "IF", "IFALL", "IFANY", "IFNONE", "ELSE", "ENDIF", "LITERAL", "ENDLITERAL"] +# Pre-Defined System Symbols +PREDEFINTRO = '.' + +Predefined = {"DELIML" : DELIML, + "DELIMR" : DELIMR, + "DOLLAR" : DOLLAR, + "ELSE" : ELSE, + "ENDIF" : ENDIF, + "ENDLITERAL" : ENDLITERAL, + "EQUAL" : EQUAL, + "EQUIV" : EQUIV, + "HASH" : HASH, + "IF" : IF, + "IFALL" : IFALL, + "IFANY" : IFANY, + "IFNONE" : IFNONE, + "INCLUDE" : INCLUDE, + "LITERAL" : LITERAL, + "NOTEQUIV" : NOTEQUIV, + "NSSEP" : NSSEP, + PREDEFINTRO + "MACHINENAME" : platform.node(), + PREDEFINTRO + "OSDETAILS" : platform.platform(), + PREDEFINTRO + "OSNAME" : platform.system(), + PREDEFINTRO + "OSRELEASE" : platform.release(), + PREDEFINTRO + "PLATFORM" : sysplat, + PREDEFINTRO + "PYTHONVERSION" : platform.python_version() + } # Regular Expressions @@ -212,20 +225,10 @@ # End of class 'VarDescriptor' -# Initialize the table using the builtin symbols +# Initialize the table using the predefined symbols SymTable = {} -for sym in Reserved: - - descript = VarDescriptor() - descript.Value = eval(sym) - descript.Writeable = False - - SymTable[sym] = descript - -# Add the predefined symbols - for var in Predefined.keys(): d = VarDescriptor() @@ -610,10 +613,10 @@ return line, ref_ok # By default, all variable names assumed to be relative to - # current namespace unless escaped with NSSEP. - # However, environment variables and predefined variables - # are always presumed to be relative to the top-level - # namespace and are left untouched here. + # current namespace unless escaped with NSSEP. However, + # environment variables and predefined variables are always + # presumed to be relative to the top-level namespace and are + # left untouched here. if sym not in Predefined and sym[0] != ENVIRO: @@ -1119,14 +1122,13 @@ # # This test needs to happen here before any of the # namespace stuff below. Doing it here guarantees we - # catch an attempt to modify one of the Predefined or - # Reserved variables, which are always marked RO and are - # always relative to the top-level namespace. This way, - # we don't have to put in an explicit check to ignore - # Predefined and Reserved variables in the namespace - # munging below. IOW, Don't move this test down into the - # body of the variable name processing where namespace - # fiddling takes place. + # catch an attempt to modify one of the Predefined + # variables, which are always marked RO and are always + # relative to the top-level namespace. This way, we don't + # have to put in an explicit check to ignore Predefined + # variables in the namespace munging below. IOW, Don't + # move this test down into the body of the variable name + # processing where namespace fiddling takes place. elif l in SymTable and not SymTable[l].Writeable: ErrorMsg("eVARREADONLY", (cfgfile, linenum, l)) @@ -1367,8 +1369,8 @@ pk.sort() for var in pk: - val = Predefined[var] - print "%s%s%s" % (var, (20-len(var)) * " ", val) + if var[0] == PREDEFINTRO: + val = Predefined[var] + print "%s%s%s" % (var, (20-len(var)) * " ", val) - - +