#NEWLINE# def parse( elementstr ) : #NEWLINE# #INDENT# "Transform 'token;key=val' to ('token', {'key': 'val'})." #NEWLINE# atoms = [ x . strip ( ) for x in elementstr . split ( ';' ) if x . strip ( ) ] #NEWLINE# if ( not atoms ) : #NEWLINE# #INDENT# initial_value = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# initial_value = atoms . pop ( 0 ) . strip ( ) #NEWLINE# #UNINDENT# params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for atom in atoms : #NEWLINE# #INDENT# atom = [ x . strip ( ) for x in atom . split ( '=' , 1 ) if x . strip ( ) ] #NEWLINE# key = atom . pop ( 0 ) #NEWLINE# if atom : #NEWLINE# #INDENT# val = atom [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# val = '' #NEWLINE# #UNINDENT# params [ key ] = val #NEWLINE# #UNINDENT# return ( initial_value , params )