diff --git a/tconfpy.3 b/tconfpy.3 index d33cbba..2b35059 100644 --- a/tconfpy.3 +++ b/tconfpy.3 @@ -11,14 +11,20 @@ sophisticated applications. This gives the end-user the ability to easily change program options by editing that file. -\fCtconfpy\fP is a Python module for parsing such configuration files. \fCtconfpy\fP -understands and parses a configuration "language" which has a rich set -of string-substitution, variable name, conditional, and validation -features. +\fCtconfpy\fP is a Python module for parsing such configuration +files. \fCtconfpy\fP understands and parses a configuration "language" +which has a rich set of string-substitution, variable name, +conditional, and validation features. -By using \fCtconfpy\fP, you relieve your program of the major responsibility -of configuration file parsing and validation, while providing your -users a rich set of configuration features. +By using \fCtconfpy\fP, you relieve your program of the major +responsibility of configuration file parsing and validation, while +providing your users a rich set of configuration features. + +.B NOTE: +Throughout this document we use the term "configuration file". However, +\fCtconfpy\fP can parse configurations both in files as well as in-memory +lists. Whenever you see the term "file", think "a file or a set of +configuration statements stored in a list". If you run \fCtconfpy\fP directly, it will dump version and copyright information, as well as the value of the current predefined @@ -95,9 +101,9 @@ .SS Core Objects -In order to use \fCtconfpy\fP effectively, you need to be familiar with the -objects used to communicate between your program and the parser. -This section provides a brief overview of these objects for +In order to use \fCtconfpy\fP effectively, you need to be familiar +with the objects used to communicate between your program and the +parser. This section provides a brief overview of these objects for reference use later in the document. .TP @@ -208,7 +214,6 @@ ReturnPredefs=True, Debug=False ) - .fi .ft \" revert @@ -230,13 +235,13 @@ .TP -.B CallingProgram (\'tconfpy\' + Version Number) +.B CallingProgram (Default: \fC\fCtconfpy\fP + Version Number\fP) Change the prompt introducer string used for Debug, Error, and Warning messages. By default, each time \fCtconfpy\fP produces an Error, Warning, or Debug -message, it prepends it with the string \'tconfpy\' followed by the +message, it prepends it with the string \fCtconfpy\fP followed by the version number. Since \fCtconfpy\fP is designed to be called from applications programs, you may wish to substitute your own program name or other information in these messages. You do so by setting the @@ -258,14 +263,12 @@ .TP .B Templates (Default: \fCTemplate()\fP) -This option is used to pass variable templates to the parser. If present, -\fCtconfpy\fP expects this option to pass a data structure in the same format as -a symbol table. i.e., You must pass a Python dictonary whose keys are the -names of the variable templates and each entry must be a \fCVarDescriptor\fP -object. See the section below entitled, +This option is used to pass variable templates to the parser. If +present, \fCtconfpy\fP expects this option to pass an object of type +\fCTemplate\fP. See the section below entitled, .B Using Variable Templates -for all the details. By default, no variable templates are passed to -the parser. +for all the details. By default, an empty template table (no templates) +is passed to the parser. .TP @@ -377,13 +380,13 @@ which is passed to \fCParseConfig()\fP. .IP \(bu 4 -You may wish to "protect" certain variable names be creating -them ahead of time and marking them as "Read Only". This is -useful when you want a variable to be available for use -within a configuration file, but you do not want users to -be able to change its value. In this case, the variable can -be referenced in a string substitution or conditional test, -but cannot be changed. +You may wish to "protect" certain variable names be creating them +ahead of time and marking them as "Read Only" +(\fCVarDescriptor.Writeable=False \fP). This is useful when you want +a variable to be available for use within a configuration file, but +you do not want users to be able to change its value. In this case, +the variable can be referenced in a string substitution or conditional +test, but cannot be changed. .IP \(bu 4 You may want to place limits on what values can be assigned to a @@ -471,6 +474,7 @@ Holds the current value for the variable. + .TP .B VarDescriptor.Writeable (Default: \fCTrue\fP) @@ -536,6 +540,61 @@ .B any value. +.B NOTE: +\fCtconfpy\fP always stores a variable's value in it native type in +the symbol table entry for that variable - i.e., You'll get the +variable's value back from the parser in the proper type. However, +when the variable is actually referenced within a configuration file, +it is converted to a +.B string +for purposes of configuration processing. + +For instance, when doing conditional comparisons, the parser coerces +the variable's value into a string for purposes of the comparsion. +Say you have the floating point variable \fCmyfloat\fP whose value is +\fC6.023\fP and the configuration file contains a statement like: + +.ft C \" Courier +.nf + .if myfloat == 6.023 +.fi +.ft \" revert + +When doing this conditional check, the parser will convert the current +value of \fCmyfloat\fP into a string and compare it to the +.B string +\fC"6.023"\fP on the Right Hand Side. + +This can be tricky when dealing with Boolean variables. As described +later in this document, you can do conditional tests based on the +.B state +of a Boolean, but if you do this: + +.ft C \" Courier +.nf + .if myboolean == whatever... +.fi +.ft \" revert + +The parser converts \fCmyboolean\fP to a +.B string +of either \fC"True"\fP or \fC"False"\fP, so watch out for this. As a +general matter, you're more likely to need the boolean tests that +check the state of the variable, but the above construct is handy if +you want to use regular string variables to control conditional +bodies: + +.ft C \" Courier +.nf + MYCONTROL = True + .if myboolean == MYCONTROL +.fi +.ft \" revert + +Where, \fCMYCONTROL\fP is a regular old string variable - i.e., It has not +been defined to be a boolean by either a Template or Initial Symbol table +passed to the parser. + .TP .B VarDescriptor.Default (Default: \fCEmpty String\fP) @@ -3142,4 +3201,4 @@ .ft \" revert .SH DOCUMENT REVISION INFORMATION -$Id: tconfpy.3,v 1.151 2005/01/18 08:45:17 tundra Exp $ +$Id: tconfpy.3,v 1.152 2005/01/19 08:31:33 tundra Exp $