Newer
Older
tconfpy / test-tc.py
#!/usr/bin/env python
# Copyright (c) 2003-2004 TundraWare Inc.  All Rights Reserved.

PROGNAME = "tconfpy Test Driver"
RCSID = "$Id: test-tc.py,v 1.110 2004/03/14 01:35:23 tundra Exp $"
VERSION = RCSID.split()[2]

# Copyright Information

CPRT         = chr(169)
DATE         = "2004"
OWNER        = "TundraWare Inc."
RIGHTS       = "All Rights Reserved"
COPYRIGHT    = "Copyright %s %s %s,  %s." % (CPRT, DATE, OWNER, RIGHTS)
PROGINFO     = PROGNAME + " " + VERSION
BANNER       = "%s\n%s\n%s\n" % (PROGINFO, COPYRIGHT, RCSID)

import tconfpy
import sys

##########
# Routine to dump returned values
##########


def dumpreturn(name, data, isdict=False):

    print name
    print len(name) * '=' + '\n'


    items = data
    if isdict:
        items = data.keys()
        items.sort()

    for val in items:
        if isdict:
            print val + (15-len(val)) * " " + str(data[val])
        else:
            print val

    print '\n'
    

# End of 'dumpreturn()'


#---------------------------------------------------------------------------#

##########
# Beginning of test driver
##########

files = 1
DEBUG = False

symtbl  = {"foo" : ["val1", True, "s", None, None, None, None],
           "baz" : [3,      True, "i", None, None, None, None]
          }

#symtbl = {}

if len(sys.argv) < 2:
    print BANNER
    print "Usage: test-tc.py [debug] file file ..."
    sys.exit(1)

if sys.argv[1].lower() == "debug":
    files = 2
    DEBUG = True

for fn in sys.argv[files:]:

    retval = tconfpy.ParseConfig(fn, symtbl, debug=DEBUG)

    if retval[1]:
        print "Errors Were Found In '%s'!" % fn
    else:
        print "No Errors Found In '%s'!" % fn

    print
    
    dumpreturn("SYMBOL TABLE", retval[0], isdict=True)
    dumpreturn("ERRORS", retval[1])
    dumpreturn("WARNINGS", retval[2])
    dumpreturn("DEBUG", retval[3])