pyexpander (version 1.5.11)
index
/net/elbe.acc.bessy.de/srv/projects/ctl/pfeiffer/project-elbe/pyexpander/pyexpander.py

# pylint: disable=C0302

 
Modules
       
expanderparser
inspect
os
sys

 
Classes
       
__builtin__.object
Block
BeginBlock
ForBlock
IfBlock
IncludeBlock
PatternBlock
SubstBlock
WhileBlock

 
class BeginBlock(Block)
    implements a $begin .. $end block.
 
This block is simply a variable scope, so it is derived from Block where
the constructor is called with new_scope=True.
 
 
Method resolution order:
BeginBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, filename=None)
__str__(self)

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Block(__builtin__.object)
    class that represents a block in the expander language.
 
Each block has a parent-pointer, which may be None. Blocks are used to
represent syntactical blocks in the expander language. They manage the
global variable dictionary and some more properties that are needed during
execution of the program.
 
  Methods defined here:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__init__(self, previous=None, new_scope=False, filename=None, parse_list=None, external_definitions=None)
The Block constructor.
 
Properties of a Block:
    parse_list    -- the list with parse objects
    lst_pos       -- the position in the parse_list
    start_pos     -- the start position of the block in the parse_list
    previous      -- the previous block
    new_scope     -- True if the block is also a new scope with
                     respect to global variables.
    skip          -- if True, skip a block in the text when the code
                     is interpreted
    globals_      -- a dictionary with the current global variables of
                     the interpreter.
    exported_syms -- a list of symbols (names in globals_) that are
                     copied to the globals_ dictionary of the parent
                     block when the pop() method is called.
    filename      -- name of the interpreted file, may be None
    template      -- name of the file that "$subst" would include,
                     usually None
    template_path -- complete path of template
                     usually None
    template_parselist_cache --
                     parselist of the template, usually None.
                     This is a kind of optimization
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True,parse_list=[])
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
__str__(self)
returns a string representation of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class ForBlock(Block)
    implements a $for .. $endfor block.
 
 
Method resolution order:
ForBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, new_scope=False, value_list=None, var_expr='')
constructor of the block.
 
var_expr -- the expression that contains the loop variable or the
            tuple with the loop variables.
__str__(self)
next_loop(self)
performs next loop.
 
returns:
  True when the loop is not yet finished.
set_loop_var(self)
set the loop variable to a new value.

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IfBlock(Block)
    implements a $if .. $else .. $endif block.
 
An $if block never has a variable scope, so the base Block object is
called with new_scope=False.
 
 
Method resolution order:
IfBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, condition=True)
constructs the $if block.
 
condition is the boolean value of the $if condition.
__str__(self)
enter_elif(self, condition)
enter the "elif" part in the if..endif block.
enter_else(self)
this should be called when $else is encountered.

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IncludeBlock(Block)
    implements a $include(filename) block.
 
This block is simply a variable scope, so it is derived from Block where
the constructor is called with new_scope=True.
 
 
Method resolution order:
IncludeBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, new_scope=False, filename=None, include_paths=None)
__str__(self)

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class PatternBlock(Block)
    implements a $pattern(parameters) block.
 
This block is simply a variable scope, so it is derived from Block where
the constructor is called with new_scope=True.
 
 
Method resolution order:
PatternBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, filename=None, include_paths=None, heading=None, lines=None)
# pylint: disable=R0913
__str__(self)
def_vars(self)
define all the given variables in the PatternBlock.
pop(self)
# pylint: enable=R0913

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class SubstBlock(Block)
    implements a $subst(parameters) block.
 
This block is simply a variable scope, so it is derived from Block where
the constructor is called with new_scope=True.
 
 
Method resolution order:
SubstBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, filename=None, include_paths=None, external_definitions=None)
__str__(self)

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class WhileBlock(Block)
    implements a $while .. $endwhile block.
 
 
Method resolution order:
WhileBlock
Block
__builtin__.object

Methods defined here:
__init__(self, previous=None, new_scope=False, while_expr='')
constructor of the block.
 
while_expr -- the expression that contains the loop variable or the
              tuple with the loop variables.
__str__(self)
next_loop(self)
performs next loop.
 
returns:
  True when the loop is not yet finished.

Methods inherited from Block:
__delitem__(self, name)
deletes a value in the globals_ dictionary of the block.
 
Here is an example:
 
>>> import pprint
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'a']
>>> b["a"]
5
>>> del b["a"]
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__']
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> del b["c"]
Traceback (most recent call last):
    ...
NameError: name 'c' is not defined at unknown position
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b= Block(parse_list=[])
>>> os.path.myvar=200
>>> b["os"]= os
>>> b["os.path.myvar"]
200
>>> del b["os.path.myvar"]
>>> b["os.path.myvar"]
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
>>> os.path.myvar
Traceback (most recent call last):
    ...
AttributeError: 'module' object has no attribute 'myvar'
__getitem__(self, name)
looks up a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_["a"]= 5
>>> b["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse
os.path to create a variable os.path.myvar and store a
reference to the module "os" in the Block "globals_"
dictionary:
 
>>> import os.path
>>> os.path.myvar=100
>>> b.globals_["os"]= os
>>> b["os.path.myvar"]
100
__len__(self)
returns the number of items in the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.globals_.keys()
[]
>>> b["a"]= 5
>>> b["b"]= 6
>>> b.globals_.keys()
['__pyexpander_buffer', '__builtins__', 'b', 'a']
>>> len(b)
4
__setitem__(self, name, val)
sets a value in the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]= 5
>>> b.globals_["a"]
5
 
Here we show how symbols with dots '.' are treated. We misuse os.path
to create a variable os.path.myvar and store a reference to the module
"os" in the Block "globals_" dictionary:
 
>>> import os.path
>>> b["os"]= os
>>> b["os.path.myvar"]= 200
>>> os.path.myvar
200
>>> b["os.path.myvar"]
200
eval_(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.eval_("3*a")
6
exec_(self, st)
perform exec with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=1")
>>> b["a"]
1
>>> b= Block(b,True)
>>> b["a"]
1
>>> b.exec_("a=2")
>>> b["a"]
2
>>> b.previous["a"]
1
export_symbols(self, lst)
appends items to the export_symbols list.
 
This list is used by the pop() method in order to copy values from the
current globals_ dictionary to the globals_ dictionary of the previous
block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.export_symbols(["a","b"])
>>> b.exported_syms
['a', 'b']
>>> b.export_symbols(["d","e"])
>>> b.exported_syms
['a', 'b', 'd', 'e']
extend(self, lst)
adds items to the list of expander functions or variables.
 
Here is an example:
>>> a=1
>>> b=2
>>> def t(x):
...   return x+1
...
>>> block= Block(parse_list=[],external_definitions=globals())
>>> block.extend(["a","b","t"])
>>> _pr_set(block.direct_vars)
set(['a', 'b'])
>>> _pr_set(block.direct_funcs)
set(['t'])
get_block_list(self)
returns all blocks of the list.
 
The list is returned with the oldest block first.
parse_elm(self)
get the current parse element.
parse_loop(self)
loop across the items in the Block.
 
returns False if there is nothing more to parse in the current block.
pop(self)
removes the current block and returns the previous one.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b["a"]=1
>>> b["b"]=2
>>> b= Block(b,True)
>>> b["a"]=10
>>> b["b"]=20
>>> b.export_symbols(["a"])
>>> b= b.pop()
>>> b["a"]
10
>>> b["b"]
2
posmsg(self, msg=None, pos=None)
return a message together with a position.
 
This method is mainly used for error messages. We usually want to print
filename and the line and column number together with a message. This
method returns the given message string <msg> together with this
additional information.
print_block_list(self)
print all blocks in the list.
 
The list is returned with the oldest block first.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> print b
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
>>> b= Block(b,True)
>>> print b
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
>>> b.print_block_list()
Block{
    has parent          : False
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = False
    skip                = False
    new_parse_list      = True
    lst_pos             = -1
    start_pos           = 0
}
Block{
    has parent          : True
    filename            = None
    template            = None
    template_path       = None
    has template_parselist_cache: False
    exported_syms       = []
    direct_vars         = set([])
    direct_funcs        = set([])
    new_scope           = True
    skip                = False
    new_parse_list      = False
    lst_pos             = -1
    start_pos           = 0
}
set_substfile(self, filename, tp)
set substitution filename.
 
Used for the "$subst", "$template" and "$pattern" commands.
setdefault(self, name, val)
return a value from globals, set to a default if it's not defined.
 
Here are some examples:
>>> b= Block(parse_list=[])
>>> b["a"]
Traceback (most recent call last):
    ...
NameError: name 'a' is not defined at unknown position
>>> b.setdefault("a",10)
10
>>> b["a"]
10
>>> b["a"]=11
>>> b.setdefault("a",10)
11
str_block_list(self)
returns a string representation of all blocks in the list.
 
The list is returned with the oldest block first.
str_eval(self, st)
perform eval with the globals_ dictionary of the block.
 
Here is an example:
>>> b= Block(parse_list=[])
>>> b.exec_("a=2")
>>> b.str_eval("3*a")
'6'
substfile_parselist(self, include_paths)
return the parselist for a given file.
 
This method manages a cache of that assigns filenames to parselists.
This can speed things up if a file is included several times.

Data descriptors inherited from Block:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
expand(st, filename=None, external_definitions=None, allow_nobracket_vars=False, include_paths=None)
returns the global dict.
expandFile(filename, external_definitions=None, allow_nobracket_vars=False, include_paths=None)
returns the global dict.
find_file(filename, include_paths)
find a file in a list of include paths.
 
include_paths MUST CONTAIN "" in order to search the
local directory.
parseFile(filename)
parse a file.
parseString(st)
parse a string.
processToList(parse_list, filename=None, external_definitions=None, allow_nobracket_vars=False, include_paths=None)
run pyexpander, return a list of strings.
processToPrint(parse_list, filename=None, external_definitions=None, allow_nobracket_vars=False, include_paths=None)
returns the global dict.

 
Data
        __version__ = '1.5.11'