def Query(sorted=0, **kwarg):
 cmd = []
 keys = kwarg.keys()
 if sorted:
  keys.sort()
 for k in keys:
  v = kwarg[k]
  k = k.upper()
  if ((k in _SIMPLE_BOOL) and v):
   cmd.append(k)
  elif (k == 'HEADER'):
   cmd.extend([k, v[0], ('"%s"' % (v[1],))])
  elif (k not in _NO_QUOTES):
   cmd.extend([k, ('"%s"' % (v,))])
  else:
   cmd.extend([k, ('%s' % (v,))])
 if (len(cmd) > 1):
  return ('(%s)' % ' '.join(cmd))
 else:
  return ' '.join(cmd)

def Query ( sorted = 0 , ** kwarg ) : cmd = [ ] keys = kwarg . keys ( ) if sorted : keys . sort ( ) for k in keys : v = kwarg [ k ] k = k . upper ( ) if ( ( k in _SIMPLE_BOOL ) and v ) : cmd . append ( k ) elif ( k == 'HEADER' ) : cmd . extend ( [ k , v [ 0 ] , ( '"%s"' % ( v [ 1 ] , ) ) ] ) elif ( k not in _NO_QUOTES ) : cmd . extend ( [ k , ( '"%s"' % ( v , ) ) ] ) else : cmd . extend ( [ k , ( '%s' % ( v , ) ) ] ) if ( len ( cmd ) > 1 ) : return ( '(%s)' % ' ' . join ( cmd ) ) else : return ' ' . join ( cmd )
create a query string among the accepted keywords are:: all : if set to a true value .