<s> """<STR_LIT>""" <EOL> from exabgp . configuration . core import Section <EOL> from exabgp . configuration . flow . route import ParseFlowRoute <EOL> from exabgp . configuration . flow . route import ParseFlowMatch <EOL> from exabgp . configuration . flow . route import ParseFlowThen <EOL> from exabgp . rib . change import Change <EOL> from exabgp . bgp . message . update . nlri import Flow <EOL> from exabgp . bgp . message . update . attribute import Attributes <EOL> class ParseFlow ( Section ) : <EOL> syntax = '<STR_LIT>' '<STR_LIT>' '<STR_LIT:}>' % '<STR_LIT>' . join ( ParseFlowRoute . syntax . split ( '<STR_LIT:\n>' ) ) <EOL> name = '<STR_LIT>' <EOL> known = dict ( ParseFlowMatch . known ) <EOL> known . update ( ParseFlowThen . known ) <EOL> action = dict ( ParseFlowMatch . action ) <EOL> action . update ( ParseFlowThen . action ) <EOL> def __init__ ( self , tokeniser , scope , error , logger ) : <EOL> Section . __init__ ( self , tokeniser , scope , error , logger ) <EOL> def clear ( self ) : <EOL> pass <EOL> def pre ( self ) : <EOL> self . scope . to_context ( self . name ) <EOL> return True <EOL> def post ( self ) : <EOL> self . scope . to_context ( self . name ) <EOL> self . scope . set ( '<STR_LIT>' , self . scope . pop ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' , [ ] ) ) <EOL> self . scope . extend ( '<STR_LIT>' , self . scope . pop ( '<STR_LIT>' , [ ] ) ) <EOL> return True <EOL> def check ( self ) : <EOL> return True <EOL> @ ParseFlow . register ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def route ( tokeniser ) : <EOL> change = Change ( <EOL> Flow ( ) , <EOL> Attributes ( ) <EOL> ) <EOL> while True : <EOL> command = tokeniser ( ) <EOL> if not command : <EOL> break <EOL> action = ParseFlow . action [ command ] <EOL> if action == '<STR_LIT>' : <EOL> for adding in ParseFlow . known [ command ] ( tokeniser ) : <EOL> change . nlri . add ( adding ) <EOL> elif action == '<STR_LIT>' : <EOL> change . attributes . add ( ParseFlow . known [ command ] ( tokeniser ) ) <EOL> elif action == '<STR_LIT>' : <EOL> nexthop , attribute = ParseFlow . known [ command ] ( tokeniser ) <EOL> change . nlri . nexthop = nexthop <EOL> change . attributes . add ( attribute ) <EOL> elif action == '<STR_LIT>' : <EOL> pass <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' % command ) <EOL> return [ change ] </s>
