def make_query(metaquery=None, **kwargs):
 q = []
 res_q = None
 for (key, value) in sorted(kwargs.items()):
  if (value is not None):
   if (key == 'source'):
    q.append(("SingleColumnValueFilter ('f', 's_%s', =, 'binary:%s', true, true)" % (value, dump('1'))))
   else:
    q.append(("SingleColumnValueFilter ('f', '%s', =, 'binary:%s', true, true)" % (quote(key), dump(value))))
 res_q = None
 if len(q):
  res_q = ' AND '.join(q)
 if metaquery:
  meta_q = []
  for (k, v) in metaquery.items():
   meta_q.append(("SingleColumnValueFilter ('f', '%s', =, 'binary:%s', true, true)" % (('r_' + k), dump(v))))
  meta_q = ' AND '.join(meta_q)
  if (res_q is not None):
   res_q += (' AND ' + meta_q)
  else:
   res_q = meta_q
 return res_q

def make_query ( metaquery = None , ** kwargs ) : q = [ ] res_q = None for ( key , value ) in sorted ( kwargs . items ( ) ) : if ( value is not None ) : if ( key == 'source' ) : q . append ( ( "SingleColumnValueFilter ('f', 's_%s', =, 'binary:%s', true, true)" % ( value , dump ( '1' ) ) ) ) else : q . append ( ( "SingleColumnValueFilter ('f', '%s', =, 'binary:%s', true, true)" % ( quote ( key ) , dump ( value ) ) ) ) res_q = None if len ( q ) : res_q = ' AND ' . join ( q ) if metaquery : meta_q = [ ] for ( k , v ) in metaquery . items ( ) : meta_q . append ( ( "SingleColumnValueFilter ('f', '%s', =, 'binary:%s', true, true)" % ( ( 'r_' + k ) , dump ( v ) ) ) ) meta_q = ' AND ' . join ( meta_q ) if ( res_q is not None ) : res_q += ( ' AND ' + meta_q ) else : res_q = meta_q return res_q
make a query message .