#NEWLINE# def parse_condition_string( condition_str ) : #NEWLINE# #INDENT# pattern = re . compile ( "{(?P<type>[\\w-]+?)\\.(?P<id>[\\w-]+?)}=(?P<equals>true|false|'[\\w-]+')" ) #NEWLINE# match = pattern . match ( condition_str ) . groupdict ( ) #NEWLINE# if ( match [ 'equals' ] == 'true' ) : #NEWLINE# #INDENT# match [ 'equals' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( match [ 'equals' ] == 'false' ) : #NEWLINE# #INDENT# match [ 'equals' ] = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( len ( match [ 'equals' ] ) > 1 ) and ( match [ 'equals' ] [ 0 ] is "'" ) and ( pattern [ 'equals' ] [ ( - 1 ) ] is "'" ) ) : #NEWLINE# #INDENT# match [ 'equals' ] = match [ 'equals' ] [ 1 : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Error parsing contingent condition' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return match