diff --git a/tconfpy.py b/tconfpy.py index f1e263d..3cabc1b 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.124 2004/03/20 01:04:36 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.125 2004/03/21 13:07:50 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -74,14 +74,16 @@ CONDINTRO = '.' # Conditional introducer token INCLUDE = CONDINTRO + "include" -ENDIF = CONDINTRO + "endif" IF = CONDINTRO + "if" IFALL = IF + "all" IFANY = IF + "any" IFNONE = IF + "none" +ENDIF = CONDINTRO + "endif" +LITERAL = CONDINTRO + "literal" +ENDLITERAL = CONDINTRO + "endliteral" -Reserved = ["DELIML", "DELIMR", "DOLLAR", "EQUAL", "EQUIV", "NOTEQUIV", - "HASH", "INCLUDE", "ENDIF", "IF", "IFALL", "IFANY", "IFNONE"] +Reserved = ["HASH", "DELIML", "DELIMR", "DOLLAR", "EQUAL", "EQUIV", "NOTEQUIV", + "INCLUDE", "IF", "IFALL", "IFANY", "IFNONE", "ENDIF", "LITERAL", "ENDLITERAL"] # Regular Expressions @@ -96,12 +98,11 @@ # String Representations Of Booleans -sFALSE = "False" -sNO = "No" -sOFF = "Off" -sON = "On" -sTRUE = "True" -sYES = "Yes" +Booleans = (("1", True), ("0", False), + ("True", True), ("False", False), + ("Yes", True), ("No", False), + ("On", True), ("Off", False)) + #----------------------------------------------------------# @@ -115,6 +116,7 @@ DebugMsg = [] # Place to store and return debug info ErrMsgs = [] # Place to store and return errors WarnMsgs = [] # Place to store and return warnings +LiteralLines = [] # Place to store and return unprocessed lines CondStack = [True,] # Conditional stack @@ -333,9 +335,9 @@ # Public API To Module # #----------------------------------------------------------# -def ParseConfig(cfgfile, symtbl={}, IgnoreCase=False, debug=False): +def ParseConfig(cfgfile, InitialSymTbl={}, IgnoreCase=False, debug=False, LiteralVars=False): - global DebugMsgs, ErrMsgs, WarnMsgs + global DebugMsgs, ErrMsgs, WarnMsgs, LiteralLines global CondStack, DEBUG, IGNORECASE, SymTable, TotalLines # Initialize the globals @@ -347,14 +349,15 @@ DebugMsgs = [] ErrMsgs = [] WarnMsgs = [] + LiteralLines = [] CondStack = [True,] TotalLines = 0 # Add any passed symbols to the SymbolTable - for sym in symtbl: - SymTable[sym] = symtbl[sym] + for sym in InitialSymTbl: + SymTable[sym] = InitialSymTbl[sym] # Parse the file @@ -365,7 +368,7 @@ if DEBUG: DebugMsg("dNUMLINES", (cfgfile, TotalLines)) - return (SymTable, ErrMsgs, WarnMsgs, DebugMsgs) + return (SymTable, ErrMsgs, WarnMsgs, DebugMsgs, LiteralLines) # End of 'ParseConfig()'