6.15.2. Convenience commands

These functions are conveniences for creating filter chains. The function chain_filters chains a sequence of filters together, the first filter is called first, and calls the second filter, etc.

the function create filters takes a sequence of triples as an argument, and returns a sequence of filters: each triple should consist of a regexp, start method name, and end method name. The filters are not connected.

The function create_filter_chain combines these two functions, it takes a sequence of triples and constructs a filter chain. Such a connected chain is also known as a pipe.

Start python section to interscript/weavers/filter.py[2 /2 ] Prev First
    69: #line 99 "weaver_filters.ipk"
    70: def chain_filters(filters):
    71:   for i in range(0,len(filters)-1):
    72:     filters[i].base = [filters[i+1]]
    73: 
    74: def create_filters(triples):
    75:   filters = []
    76:   for regexp,startmethod,endmethod in triples:
    77:     filters.append(markup_filter(regexp,startmethod,endmethod))
    78:   return filters
    79: 
    80: def create_filter_chain(triples):
    81:   return chain_filters(create_filters(triples))
    82: 
End python section to interscript/weavers/filter.py[2]