diff --git a/tconfpy.py b/tconfpy.py index 3f025ed..2e4eba1 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.122 2004/03/19 22:41:17 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.123 2004/03/20 00:02:09 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -28,15 +28,6 @@ #------------------- Nothing Below Here Should Need Changing -----------------# #----------------------------------------------------------# -# Public Features Of This Module # -#----------------------------------------------------------# - - -__all__ = ["ParseConfig"] - - - -#----------------------------------------------------------# # Imports # #----------------------------------------------------------# @@ -138,32 +129,35 @@ # # {varname : descriptor} # -# where the descriptor is a list: +# where the descriptor is an object with the following attributes # -# [value, iswriteable, type, default value, [list of legal vals], min, max] +# Value, Writeable, Type, Default, LegalVals = [list of legal vals], Min, Max] -# Indexes Into Symbol Table Variable Descriptor - -SYM_VALUE = 0 -SYM_WRITE = 1 -SYM_TYPE = 2 -SYM_DEFAULT = 3 -SYM_VALUES = 4 -SYM_MIN = 5 -SYM_MAX = 6 - +# # Legal Variable Types -TYP_BOOL = 'b' -TYPE_CMPLX = 'x' -TYP_FLOAT = 'f' -TYP_INT = 'i' -TYP_STRING = 's' +TYPE_BOOL = type(True) +TYPE_COMPLEX = type(1-1j) +TYPE_FLOAT = type(3.14) +TYPE_INT = type(1) +TYPE_STRING = type('s') -# Boolean Flags +# Object to hold full description and options for a given variable -SYM_WRITEABLE = True +class VarDescriptor: + + # Default variable type is a writeable string with no constraints + def __init__(self): + self.Value = "" + self.Writeable = True + self.Type = TYPE_STRING + self.Default = "" + self.LegalVals = None + self.Min = None + self.Max = None + +# End of class 'VarDescriptor' # Initialize the table using the builtin symbols @@ -172,15 +166,11 @@ for sym in Reserved: - SymTable[sym] = [eval(sym), - not SYM_WRITEABLE, - TYP_STRING, - eval(sym), - None, - None, - None - ] - + descript = VarDescriptor() + descript.Value = eval(sym) + + SymTable[sym] = descript + ########## # Error, Warning, And Debug Message Strings Stored In A Global Dictionary @@ -417,7 +407,7 @@ # Handle variables in symbol table elif sym in SymTable: - line = line.replace(var, str(SymTable[sym][SYM_VALUE])) + line = line.replace(var, str(SymTable[sym].Value)) # Reference to undefined variable else: