diff --git a/twander.py b/twander.py index 9fa3597..7987266 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.167 2005/01/24 23:53:24 tundra Exp $" +RCSID = "$Id: twander.py,v 3.168 2005/01/25 00:57:17 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -559,6 +559,7 @@ COMMENT = r"#" # Comment introducer string ENVVBL = r'$' # Symbol denoting an environment variable FAKEFIELD = r'#FAKEFIELD' # Unsplittable field used to preserve PROMPT/YESNO content +STARTUP = r'Starting Up' # Used when doing parse of first config file VAREXECUTE = r'`' # Indicate we want content of variable name to be executed @@ -736,6 +737,7 @@ wBADSORTFLD = "Don't Know How To Sort By: %s\n\nWill Sort By %s Instead." wBADVAREXEC = "Ignoring Line %s.\nExecution Of Variable %s Failed:\n\n%s" wBADYESNODFLT = "Bad Default Argument For Yes/No Prompt: '%s'\nCommand '%s' Aborted" +wCIRCULARREF = "Circular .include Reference In '%s', Line '%s'!\n.include Not Processed!" wCONFOPEN = "Cannot Open Configuration File:\n%s" wEXTRAENDIF = "Ignoring Line %s!\nNo Conditional Block To End:\n\n%s" wLINKBACK = "%s Points Back To Own Directory" @@ -1091,7 +1093,7 @@ CONF = os.path.join(HOME, "." + PROGNAME) # Actually read and parse the configuration file. - ReadConfFile(CONF) + ReadConfFile(CONF, STARTUP, 0) MissingEndIfs = len(ConditionalStack) - 1 @@ -1136,13 +1138,26 @@ # A '.include' Is Encountered Within A Configuration File ##### -def ReadConfFile(file): +def ReadConfFile(newfile, currentfile, linenum): + + # Keep track of every configuration file processed + + fqfilename = os.path.abspath(newfile) + + if fqfilename not in UI.ConfigVisited: + UI.ConfigVisited.append(fqfilename) + + # And prevent circular references + + else: + WrnMsg(wCIRCULARREF % (currentfile, linenum)) + return # Keep track of the line number on a per-file basis linenum = 0 try: - cf = open(file) + cf = open(newfile) # Successful open of config file - Begin processing it # Process and massage the configuration file @@ -1151,13 +1166,13 @@ # Parse this line if line: - ParseLine(line, file, linenum) + ParseLine(line, newfile, linenum) # Close the config file cf.close() except: - WrnMsg(wCONFOPEN % file) + WrnMsg(wCONFOPEN % newfile) # End of 'ReadConfFile()' @@ -1406,7 +1421,7 @@ ##### elif fields[0] == DIRECTINC: - ReadConfFile(cleanline.split(DIRECTINC)[1].strip()) + ReadConfFile(cleanline.split(DIRECTINC)[1].strip(), file, num) ### @@ -4807,6 +4822,9 @@ # Initialize the refresh timers UI.LastRefresh = 0 +# Initialize storage for list of configuration files processed +UI.ConfigVisited = [] + # Start in detailed mode UI.SetDetailedView(TRUE)