Added ability to pass name of calling program to the API via the
'CallingProgram' keyword parameter.  This allows the calling program
to change the default program ID string used in messages produced
during the parse.
1 parent cca703f commit 02bb3bfe0f8b5296504dbb3046c85198b8861791
@tundra tundra authored on 13 Jan 2005
Showing 1 changed file
View
14
tconfpy.py
#!/usr/bin/env python
# tconfpy.py
# Copyright (c) 2003-2004 TundraWare Inc. All Rights Reserved.
# Copyright (c) 2003-2005 TundraWare Inc. All Rights Reserved.
# For Updates See: http://www.tundraware.com/Software/tconfpy
 
# Program Information
 
PROGNAME = "tconfpy"
RCSID = "$Id: tconfpy.py,v 1.185 2004/05/02 08:06:07 tundra Exp $"
RCSID = "$Id: tconfpy.py,v 1.186 2005/01/13 10:36:24 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
CPRT = chr(169)
DATE = "2003-2004"
DATE = "2003-2005"
OWNER = "TundraWare Inc."
RIGHTS = "All Rights Reserved"
COPYRIGHT = "Copyright %s %s %s, %s." % (CPRT, DATE, OWNER, RIGHTS)
PROGINFO = PROGNAME + " " + VERSION
def mkmsg(msg, msgtype):
 
pad = " " * (MAXMSG - len(msgtype) + 2)
 
return "%s %s%s%s" % (PROGINFO, MSGPROMPT % msgtype, pad, msg)
return "%s %s%s%s" % (mkmsg.proginfo, MSGPROMPT % msgtype, pad, msg)
 
 
# End of 'mkmsg()'
 
# Public API To Module #
#----------------------------------------------------------#
 
def ParseConfig(cfgfile,
CallingProgram=PROGINFO,
InitialSymTable={},
AllowNewVars=True,
Templates={},
TemplatesOnly=False,
 
CondStack = [["", True],] # Always has one entry as a sentinel
TotalLines = 0
 
# Set the name of the calling program for output messages
mkmsg.proginfo = CallingProgram
# Setup container to return parsing results
 
retobj = RetObj()