def as_string(value):
 if six.PY2:
  buffer_types = (buffer, memoryview)
 else:
  buffer_types = memoryview
 if (value is None):
  return u''
 elif isinstance(value, buffer_types):
  return bytes(value).decode('utf-8', 'ignore')
 elif isinstance(value, bytes):
  return value.decode('utf-8', 'ignore')
 else:
  return six.text_type(value)

def as_string ( value ) : if six . PY2 : buffer_types = ( buffer , memoryview ) else : buffer_types = memoryview if ( value is None ) : return u'' elif isinstance ( value , buffer_types ) : return bytes ( value ) . decode ( 'utf-8' , 'ignore' ) elif isinstance ( value , bytes ) : return value . decode ( 'utf-8' , 'ignore' ) else : return six . text_type ( value )
convert a value to a unicode object for matching with a query .