#NEWLINE# def parse_parametrs( p ) : #NEWLINE# #INDENT# '\n    Parses the parameters given from POST or websocket reqs\n    expecting the parameters as:  "11|par1=\'asd\'|6|par2=1"\n    returns a dict like {par1:\'asd\',par2:1}\n    ' #NEWLINE# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# while ( ( len ( p ) > 1 ) and ( p . count ( '|' ) > 0 ) ) : #NEWLINE# #INDENT# s = p . split ( '|' ) #NEWLINE# l = int ( s [ 0 ] ) #NEWLINE# if ( l > 0 ) : #NEWLINE# #INDENT# p = p [ ( len ( s [ 0 ] ) + 1 ) : ] #NEWLINE# field_name = p . split ( '|' ) [ 0 ] . split ( '=' ) [ 0 ] #NEWLINE# field_value = p [ ( len ( field_name ) + 1 ) : l ] #NEWLINE# p = p [ ( field_value + 1 ) : ] #NEWLINE# if ( ( field_value . count ( "'" ) == 0 ) and ( field_value . count ( '"' ) == 0 ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# field_value = int ( field_value ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# field_value = float ( field_value ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ret [ field_name ] = field_value #NEWLINE# #UNINDENT# #UNINDENT# return ret