Removed reference to deprecated AllowNewNamespaces.
Changed command line option to to limitns.
Changed order of options to reflect API order.
1 parent 5d07ad4 commit 7d50791054e8108a9614c98a658c66e72281b9e8
@tundra tundra authored on 16 Apr 2004
Showing 1 changed file
View
95
test-tc.py
# test-tc.py - A Test Driver For The 'tconfpy' Configuration File Parser
# Copyright (c) 2003-2004 TundraWare Inc. All Rights Reserved.
 
PROGNAME = "tconfpy Test Driver"
RCSID = "$Id: test-tc.py,v 1.130 2004/04/08 17:15:41 tundra Exp $"
RCSID = "$Id: test-tc.py,v 1.131 2004/04/16 05:47:29 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
# Where 'None' appears, the init code just uses the default established
# by the VarDescriptor base class.
 
 
syms = [ ["foo", 1, True, TYPE_INT, 0, [1, 2, 23], 1, 30 ],
["fox", 1.0, None, TYPE_FLOAT, 0.5, [3.14, 2.73], None, None ],
["bar", "stringy", None, None, None, [r'^box$', r'^Bax', r'a+bc'], 3, 8 ],
["baz", 4+5j, None, TYPE_COMPLEX, 0-0j, [], None, None ],
["boo", True, None, TYPE_BOOL, None, None, None, None ],
["read", "ReadVar", False, None, None, None, None, None ],
syms = [ ["int1", 1, True, TYPE_INT, 0, [1, 2, 23], None, None ],
["int2", 1, True, TYPE_INT, 0, [], 1, 30 ],
["float1", 1.0, None, TYPE_FLOAT, 0.5, [3.14, 2.73], None, None ],
["float2", 1.0, None, TYPE_FLOAT, 0.5, [], -1.2, 0.5 ],
["str1" , "stringy", None, None, None, [r'^box$', r'^Bax', r'a+bc'], 3, 8 ],
["cmplx1", 4+5j, None, TYPE_COMPLEX, 0-0j, [], None, None ],
["cmplx2", 4+5j, None, TYPE_COMPLEX, 0-0j, [1-1j, 1+1j], None, None ],
["bool1", True, None, TYPE_BOOL, None, None, None, None ],
["ro1", "ReadVar", False, None, None, None, None, None ],
]
 
# Another way to add pre-defined symbols is to explicitly load
 
# And stuff them into the symbol table
symtbl["MyComplex1"] = mc1
symtbl["MyComplex2"] = mc2
 
# Just for fun, define an initial namespace and
# some other "legal" namespaces for use in testing
# the AllowNewNamespaces option of the API
 
des = VarDescriptor()
des.Value = "" # This is the initial namespace
des.LegalVals = ["NS1", "NS2"]
symtbl["NAMESPACE"] = des
 
 
#---------------------------------------------------------------------------#
# Nothing Else Should Need Changing Below Here
# Make sure we got legit arguments
 
if len(sys.argv) < 2:
print BANNER
print "Usage: test-tc.py [symtbl] [nonewvar] [nonewns] [debug] [litvars] file file ..."
print "Usage: test-tc.py [symtbl] [nonewvar] [limitns] [debug] [litvars] file file ..."
sys.exit(1)
 
# Process all the requested configuration files,
# dumping the what tconfpy returns for each one.
 
ALLOWVAR = True
ALLOWNS = True
DEBUG = False
LIMITNS = False
LITVARS = False
 
 
# The default is no pre-defined symbols
st = {}
ST = False
 
 
for fn in sys.argv[files:]:
 
# Handle inline options
if fn == "debug":
DEBUG = True
if fn == "symtbl":
ST = True
 
elif fn == "nonewvar":
ALLOWVAR = False
 
elif fn == "limitns":
LIMITNS = True
 
elif fn == "litvars":
LITVARS = True
 
elif fn == "symtbl":
st = symtbl
 
elif fn == "nonewvar":
ALLOWVAR = False
elif fn == "nonewns":
ALLOWNS = False
elif fn == "debug":
DEBUG = True
 
# Everything else presumed to be a configuration file
else:
 
# The default is no pre-defined symbols
st = {}
 
if ST:
st = symtbl
 
if LIMITNS:
# Limit the number of namespaces the user can use
des = VarDescriptor()
des.Value = "NS0" # This is the initial namespace
des.LegalVals = [r"^NS.*", ]
des.Min = 3
des.Max = 8
st["NAMESPACE"] = des
 
retval = ParseConfig(fn, InitialSymTable=st,
AllowNewVars=ALLOWVAR,
AllowNewNamespaces=ALLOWNS,
Debug=DEBUG,
LiteralVars=LITVARS
LiteralVars=LITVARS,
Debug=DEBUG
)
 
if retval.Errors:
print "Errors Were Found In '%s'!" % fn