def query_from_params(params):
 try:
  query = params.pop('q')
 except KeyError:
  return []
 try:
  return [(([neg] + pval.split(':', 1)) if (':' in pval) else [neg, pval, None]) for (neg, pval) in (((True, x[1:]) if (x[:1] in '!-') else (False, x)) for x in shlex.split(query))]
 except ValueError as exc:
  sys.stdout.write(js_alert('param-parsing', 'warning', "Parameter parsing error. Check the server's logs for more information."))
  sys.stderr.write(('IVRE: WARNING: parameter parsing error [%s (%r)]\n' % (exc.message, exc)))
  sys.exit(0)

def query_from_params ( params ) : try : query = params . pop ( 'q' ) except KeyError : return [ ] try : return [ ( ( [ neg ] + pval . split ( ':' , 1 ) ) if ( ':' in pval ) else [ neg , pval , None ] ) for ( neg , pval ) in ( ( ( True , x [ 1 : ] ) if ( x [ : 1 ] in '!-' ) else ( False , x ) ) for x in shlex . split ( query ) ) ] except ValueError as exc : sys . stdout . write ( js_alert ( 'param-parsing' , 'warning' , "Parameter parsing error. Check the server's logs for more information." ) ) sys . stderr . write ( ( 'IVRE: WARNING: parameter parsing error [%s (%r)]\n' % ( exc . message , exc ) ) ) sys . exit ( 0 )
this function *consumes* the q parameter and returns the query as a list of three elements list: [boolean neg .