HWRF  trunk@4391
Classes | Functions | Variables
produtil.atparse Namespace Reference

ATParser is a text parser that replaces strings with variables and function output. More...

Detailed Description

ATParser is a text parser that replaces strings with variables and function output.

Classes

class  ATParser
 Takes input files or other data, and replaces certain strings with variables or functions. More...
 
class  NoSuchVariable
 Raised when a script requests an unknown variable. More...
 
class  ParserSyntaxError
 Raised when the parser encounters a syntax error. More...
 
class  ScriptAbort
 Raised when an "@** abort" directive is reached in a script. More...
 
class  ScriptAssertion
 Raised when a script @[VARNAME:?message] is encountered, and the variable does not exist. More...
 

Functions

def replace_backslashed (text)
 Turns \t to tab, \n to end of line, \r to carriage return, \b to backspace and \(octal) to other characters. More...
 

Variables

tuple functions
 List of functions recognized. More...
 
tuple outer = dict(active=True,in_if_block=False,in_ifelse_block=False,used_if=False,ignore=False)
 Parser state for the portion of the file outside @[] and @** blocks.
 
tuple if_unused_if = dict(active=False,in_if_block=True,in_ifelse_block=False,used_if=False,ignore=False)
 @ var if_unused_if Parser state for within @**if blocks that are inactive
 
tuple if_active_if = dict(active=True,in_if_block=True,in_ifelse_block=False,used_if=True,ignore=False)
 Parser state for within @** if blocks that are active.
 
tuple if_used_if = dict(active=False,in_if_block=True,in_ifelse_block=True,used_if=True,ignore=False)
 Parser state for after the end of an @** if block.
 
tuple if_active_else = dict(active=True,in_if_block=False,in_ifelse_block=True,used_if=True,ignore=False)
 Parser state for inside an "else" block.
 
tuple if_inactive_else = dict(active=False,in_if_block=False,in_ifelse_block=True,used_if=True,ignore=False)
 Parser state for inside an "else" block that was not used.
 
tuple ignore_if_block = dict(active=False,in_if_block=True,in_ifelse_block=False,used_if=False,ignore=True)
 Parser state for an "if" block that was skipped.
 
tuple ignore_else_block = dict(active=False,in_if_block=False,in_ifelse_block=True,used_if=False,ignore=True)
 Parser state for an "else" block that was skipped.
 

Function Documentation

def produtil.atparse.replace_backslashed (   text)

Turns \t to tab, \n to end of line, \r to carriage return, \b to backspace and \(octal) to other characters.

Parameters
textthe text to scan

Definition at line 47 of file atparse.py.

Referenced by produtil.atparse.ATParser.replace_vars().

Variable Documentation

produtil.atparse.functions
Initial value:
1 = dict(lc=lambda x:str(x).lower(),
2  uc=lambda x:str(x).upper(),
3  len=lambda x:str(len(x)),
4  trim=lambda x:str(x).strip())

List of functions recognized.

Definition at line 9 of file atparse.py.