Added 'inmem' command line option.
1 parent 76feb22 commit 24fe03ea4e063ca75eeae0d77e6dadc225f52b12
@tundra tundra authored on 20 Jan 2005
Showing 1 changed file
View
43
test-tc.py
# test-tc.py - A Test Driver For The 'tconfpy' Configuration File Parser
# Copyright (c) 2003-2005 TundraWare Inc. All Rights Reserved.
 
PROGNAME = "tconfpy Test Driver"
RCSID = "$Id: test-tc.py,v 1.144 2005/01/19 23:11:42 tundra Exp $"
RCSID = "$Id: test-tc.py,v 1.145 2005/01/20 09:51:33 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
# Make sure we got legit arguments
 
if len(sys.argv) < 2:
print BANNER
print "Usage: test-tc.py [symtbl] [nonewvars] [templates] [temponly] [limitns] [litvars] [nopredefs] [debug] file file ..."
print "Usage: test-tc.py [symtbl] [inmem] [nonewvars] [templates] [temponly] [limitns] [litvars] [nopredefs] [debug] file file ..."
sys.exit(1)
 
# Process all the requested configuration files,
# dumping the what tconfpy returns for each one.
 
ST = False
INMEM = False
ALLOWVAR = True
TEMPLATE = False
TEMPONLY = False
LIMITNS = False
if fn == "symtbl":
ST = True
 
elif fn == "inmem":
INMEM = True
elif fn == "nonewvars":
ALLOWVAR = False
 
elif fn == "templates":
 
# Everything else presumed to be a configuration file
else:
 
# Preserve the file name for later use
name = fn
 
# The default is no pre-defined symbols
st = SymbolTable()
 
tl = Template()
 
if TEMPLATE:
tl = BuildSymTbl(templs, istemplate=True)
 
 
# Support for in-memory parsing
 
if INMEM:
fn = []
try:
x=open(name)
fn = x.readlines()
x.close()
 
except:
print "Cannot Open File: '%s'!" % name
# Call the parser and process the results
 
retval = ParseConfig(fn,
CallingProgram="FeeFiFoFum ",
 
print "Total Lines Processed: %s " % retval.TotalLines
 
if retval.ErrMsgs:
print "Errors Were Found In '%s'!" % fn
print "Errors Were Found In '%s'!" % name
else:
print "No Errors Found In '%s'!" % fn
print "No Errors Found In '%s'!" % name
 
print
 
# Format and display the results