| |
---|
| | |
---|
| | # Program Information |
---|
| | |
---|
| | PROGNAME = "tconfpy" |
---|
| | RCSID = "$Id: tconfpy.py,v 1.105 2004/03/12 00:58:52 tundra Exp $" |
---|
| | RCSID = "$Id: tconfpy.py,v 1.106 2004/03/12 08:32:35 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | # Debug Messages |
---|
| | ########## |
---|
| | |
---|
| | dDEBUG = "DEBUG" |
---|
| | dLINEIGNORE = "%s Line %d Ignored/Not Included" |
---|
| | dNUMLINES = "Processing '%s' Resulted In %d Total Lines Parsed" |
---|
| | dPARSEDLINE = "%s Line %d Parses To: %s" |
---|
| | |
---|
| | ########### |
---|
| | # Error Messages |
---|
| | ########### |
---|
| | |
---|
| | eCONFOPEN = "Cannot Open The File '%s'" |
---|
| | eERROR = "ERROR" |
---|
| | eCONFOPEN = "Cannot Open The File '%s'" |
---|
| | eENDIFEXTRA = "%s Line %d: " + ENDIF + " Without Matching Condition" |
---|
| | eERROR = "ERROR" |
---|
| | |
---|
| | |
---|
| | ########### |
---|
| | # Prompts |
---|
| |
---|
| | ########### |
---|
| | # Warning Messages |
---|
| | ########### |
---|
| | |
---|
| | wWARNING = "WARNING" |
---|
| | wENDIFBAD = "%s Line %d: Text After " + ENDIF + " Ignored" |
---|
| | wWARNING = "WARNING" |
---|
| | |
---|
| | |
---|
| | #--------------------------- Code Begins Here ---------------------------------# |
---|
| | |
---|
| |
---|
| | |
---|
| | # Only attempt on non-blank lines |
---|
| | if line: |
---|
| | |
---|
| | # Process .endif statements before checking state since |
---|
| | # these potentially change the state. |
---|
| | |
---|
| | if line.startswith(ENDIF): |
---|
| | |
---|
| | # This should be the only thing on the line |
---|
| | if line != ENDIF: |
---|
| | WarningMsg(wENDIFBAD % (cfgfile, linenum)) |
---|
| | |
---|
| | # Remove one level of nesting |
---|
| | CondStack.pop() |
---|
| | |
---|
| | # Error, if there are more .endifs than conditionals |
---|
| | if not CondStack: |
---|
| | ErrorMsg(eENDIFEXTRA % (cfgfile, linenum)) |
---|
| | CondStack.append(False) # Inhibit further parsing |
---|
| | |
---|
| | # If we are in a False conditional block, this line |
---|
| | # is ignored. |
---|
| | |
---|
| | print linenum, CondStack, line |
---|
| | if not CondStack[-1]: |
---|
| | if DEBUG: |
---|
| | DebugMsg(dLINEIGNORE %(cfgfile, linenum)) |
---|
| | return |
---|
| | |
---|
| | # Process .include statements |
---|
| | |
---|
| | if line.startswith(INCLUDE): |
---|
| | |
---|
| | ParseFile(line.split(INCLUDE)[1].strip()) |
---|
| | return |
---|
| | |
---|
| | # Substitute references to reserved symbols |
---|
| | |
---|
| | for ref in Reserved.keys(): |
---|
| | line = line.replace("%s%s%s" % (DELIML, ref, DELIMR), Reserved[ref]) |
---|
| | |
---|
| | # Process .include statements |
---|
| | |
---|
| | if line.startswith(INCLUDE): |
---|
| | ParseFile(line.split(INCLUDE)[1].strip()) |
---|
| | |
---|
| | |
---|
| | ########## |
---|
| | # End Of Line Parser |
---|
| |
---|
| | |