diff --git a/tconfpy.py b/tconfpy.py index 272ce6b..b358df5 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 2.110 2005/01/19 23:39:29 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 2.111 2005/01/20 00:31:24 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -167,11 +167,19 @@ class SymbolTable(object): def __init__(self): + + # Returned by the parser + self.Symbols = {} self.DebugMsgs = [] self.ErrMsgs = [] self.WarnMsgs = [] self.LiteralLines = [] + self.TotalLines = 0 + self.Visited = [] + + # Anything below here is used interally and not returned + self.Templates = Template() self.ALLOWNEWVAR = True self.TEMPONLY = False @@ -179,7 +187,6 @@ self.INLITERAL = False self.DEBUG = False self.CondStack = [["", True],] # Always has one entry as a sentinel - self.TotalLines = 0 # End of class 'SymbolTable' @@ -255,6 +262,7 @@ 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'" +Messages["dVISITED"] = "Configuration Files Processed: '%s'" ########### @@ -294,6 +302,7 @@ Messages["eIFEXTRATXT"] = FILENUM + "Extra Text On Line. '%s' Only Accepts Variable References As Arguments" Messages["eNOTLEGALVAL"] = FILENUM + "'%s' Not Found In List Of Legal Values For Variable '%s'" Messages["eNOTSTRING"] = FILENUM + "%s Is Not A String Type - Ignoring" +Messages["eRECURSIVE"] = FILENUM + "Recursive .includes Forbidden" Messages["eSTRINGLONG"] = FILENUM + "'%s' Too Long For Variable '%s'. Maximum Length Is %s" Messages["eSTRINGSHORT"] = FILENUM + "'%s' Too Short For Variable '%s'. Minimum Length is %s" Messages["eSYMBADCHAR"] = FILENUM + "Symbol '%s' Contains Illegal Character '%s'" @@ -510,6 +519,7 @@ if SymTable.DEBUG: DebugMsg("dNUMLINES", (configname, SymTable.TotalLines)) + DebugMsg("dVISITED", (SymTable.Visited)) # Strip out Prefefined Variables if user does not want them @@ -657,6 +667,18 @@ global SymTable + linenum = 0 + + # Inhbit recursive includes + + if cfgfile in SymTable.Visited: + + ErrorMsg("eRECURSIVE", (current_cfg, current_linenum)) + return + + else: + SymTable.Visited.append(cfgfile) + try: cf = open(cfgfile) @@ -664,9 +686,10 @@ for line in cf.read().splitlines(): SymTable.TotalLines += 1 + linenum +=1 # Parse this line - ParseLine(line, cfgfile, SymTable.TotalLines) + ParseLine(line, cfgfile, linenum) # Close the config file cf.close() @@ -686,21 +709,26 @@ global SymTable + linenum = 0 + + SymTable.Visited.append(configname) + # Process and massage the configuration file for line in cfglist: SymTable.TotalLines += 1 + linenum += 1 # The entry must be a string if type(line) == TYPE_STRING: # Parse this line - ParseLine(line, configname, SymTable.TotalLines) + ParseLine(line, configname, linenum) # Anything else is a problem else: - ErrorMsg("eNOTSTRING", (configname, SymTable.TotalLines, str(line))) + ErrorMsg("eNOTSTRING", (configname, linenum, str(line))) # End of 'ParseInMemory()'