#NEWLINE# def parse( script , line , filename = '' , linenumber = 0 ) : #NEWLINE# #INDENT# if ( not ( line . count ( '[' ) == line . count ( ']' ) ) ) : #NEWLINE# #INDENT# raise Exception ( ( 'BRACE mismatch (%s, line %s): %s' % ( filename , linenumber , line ) ) ) #NEWLINE# #UNINDENT# bracket_data = [ entry . strip ( '[' ) . strip ( ']' ) for entry in re . findall ( '\\[[\\w]*\\]' , line ) ] #NEWLINE# if line . startswith ( '[' ) : #NEWLINE# #INDENT# create_section ( script , bracket_data [ 0 ] ) #NEWLINE# set_active_section ( script , bracket_data [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( identifier [ 'section' ] and line . count ( ':' ) ) : #NEWLINE# #INDENT# _split = line . split ( ':' ) #NEWLINE# identifier = _split [ 0 ] #NEWLINE# arguments = [ ] #NEWLINE# for _argument_group in _split [ 1 ] . split ( '|' ) : #NEWLINE# #INDENT# if _argument_group . rpartition ( '{' ) [ 2 ] . rpartition ( '}' ) [ 0 ] . count ( ',' ) : #NEWLINE# #INDENT# arguments . append ( [ _argument_group ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arguments . append ( _argument_group . split ( ',' ) ) #NEWLINE# #UNINDENT# #UNINDENT# add_action ( script , create_action ( script , identifier , arguments ) )