diff --git a/tconfpy.py b/tconfpy.py index 085a3ad..b54ac8a 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.178 2004/04/16 23:59:45 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.179 2004/04/17 01:02:04 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -276,6 +276,7 @@ Messages["dNUMLINES"] = "Processing File '%s' Resulted In %d Total Lines Parsed" Messages["dPARSEDLINE"] = FILENUM + "'%s'" + PTR + "'%s'" Messages["dREGEXMATCH"] = FILENUM + "Value '%s' Matched Regex '%s' For Variable '%s'" +Messages["dVAREXISTS"] = FILENUM + "Checking To See If Variable '%s' Exists" Messages["dVARREF"] = FILENUM + "Variable Dereference: '%s'" + PTR + "'%s'" @@ -930,13 +931,41 @@ # Iterate through all named variables to see if they exist for v in vars: + # Condition the variable name with the current namespace + # unless: + # + # 1) We are in the root namespace + # 2) We're dealing with an environment variable + # 3) We're dealing with a predefined variable + # 4) We're dealing with the NAMESPACE variable + # 5) The variable name is not escaped + + ns = SymTable[NAMESPACE].Value + + if ns and \ + v[0] != ENVIRO and \ + v not in Predefined and \ + v != NAMESPACE: + + # Convert escaped variable names to canonical form + if v[0] == NSSEP: + v = v[1:] + + # Prepend current namespace to everything else + else: + v = "%s%s%s" % (ns, NSSEP, v) + + # Produce debug ouput of actual variable name being checked + if DEBUG: + DebugMsg("dVAREXISTS", (cfgfile, linenum, v)) + # Handle environment variables if v[0] == ENVIRO: - if v in os.environ: + if v[1:] in os.environ: numexist += 1 # Handle local local variables - if v in SymTable: + elif v in SymTable: numexist += 1 # And set the conditional state accordingly