Trees | Indices | Help |
|
---|
|
ConfigParser Include Pre-Processor
File-like Object capable of pre-processing include= lines for a ConfigParser.
The readline function expands lines matching include=(url) into lines from the url specified. Includes may occur in included files as well.
Suggested Usage:
cfg = ConfigParser.ConfigParser() fileobj = confpp( fileorurl ) cfg.readfp(fileobj)
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Implementation of File-Like Object readline function. This should be the only function called by ConfigParser according to the python docs. We maintain a stack of real FLOs and delegate readline calls to the FLO on top of the stack. When EOF occurs on the topmost FLO, it is popped off the stack and the next FLO takes over. include= lines found anywhere cause a new FLO to be opened and pushed onto the top of the stack. Finally, we return EOF when the bottom-most (configfile arg to __init__) FLO returns EOF. Very Technical Pseudo Code: def confpp.readline() [this is called by ConfigParser] open configfile, push on stack while stack has some stuff on it line = readline from file on top of stack pop and continue if line is EOF if line starts with 'include=' then error if file is recursive or duplicate otherwise open file, push on stack continue else return line return EOF |
Returns an absolute url for the (possibly) relative url specified. The base url used to resolve the missing bits of url is the url of the file currently being included (i.e. the top of the stack). |
Opens the url specified, pushes it on the stack, and returns a file like object. Returns None if the url has previously been included. If the file can not be opened this function exits. |
Checks if the tuple describes an include that was already done. This does not necessarily have to be recursive |
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 28 11:38:43 2010 | http://epydoc.sourceforge.net |