yum.parser

yum.parser.varReplace(raw, vars)

Perform variable replacement

@param raw: String to perform substitution on. @param vars: Dictionary of variables to replace. Key is variable name

(without $ prefix). Value is replacement string.

@return: Input raw string with substituted values.

ConfigPreProcessor

class yum.parser.ConfigPreProcessor(configfile, vars=None)

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)
readline(size=0)

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

Table Of Contents

Previous topic

yum.packages

Next topic

yum.pgpmsg

This Page