@frappe.whitelist()
def get_contact_list(txt):
 txt = txt.replace(u'%', u'')
 def get_users():
  return filter(None, frappe.db.sql_list(u'select email from tabUser where email like %s', ((u'%' + txt) + u'%')))
 try:
  out = filter(None, frappe.db.sql_list(u'select email_id from `tabContact`\n DCTB  DCTB  DCTB where `email_id` like %(txt)s order by\n DCTB  DCTB  DCTB if (locate( %(_txt)s, email_id), locate( %(_txt)s, email_id), 99999)', {u'txt': (u'%%%s%%' % frappe.db.escape(txt)), u'_txt': txt.replace(u'%', u'')}))
  if (not out):
   out = get_users()
 except Exception as e:
  if (e.args[0] == 1146):
   out = get_users()
  else:
   raise
 return out

@ frappe . whitelist ( ) def get_contact_list ( txt ) : txt = txt . replace ( u'%' , u'' ) def get_users ( ) : return filter ( None , frappe . db . sql_list ( u'select email from tabUser where email like %s' , ( ( u'%' + txt ) + u'%' ) ) ) try : out = filter ( None , frappe . db . sql_list ( u'select email_id from `tabContact`\n DCTB  DCTB  DCTB where `email_id` like %(txt)s order by\n DCTB  DCTB  DCTB if (locate( %(_txt)s, email_id), locate( %(_txt)s, email_id), 99999)' , { u'txt' : ( u'%%%s%%' % frappe . db . escape ( txt ) ) , u'_txt' : txt . replace ( u'%' , u'' ) } ) ) if ( not out ) : out = get_users ( ) except Exception as e : if ( e . args [ 0 ] == 1146 ) : out = get_users ( ) else : raise return out
returns contacts .