def getUsernameByUid(uid): if not uid: return None user = xapian_search_user.search_by_id(int(uid), fields=['name']) if user: name = user['name'] return name return None
def getFriendship(uid, schema='friends'): if uid: user = xapian_search_user.search_by_id(int(uid), fields=[schema]) if user: return user[schema] else: return [] else: return []
def getUserByUid(uid): user = xapian_search_user.search_by_id(int(uid), fields=user_fields) user_dict = {} if user: for field in user_fields: user_dict[field] = _utf_8_decode(user[field]) else: user_dict['name'] = str(uid) user_dict['location'] = u'未知' user_dict['profile_image_url'] = u'' result_dict = {} for k, v in user_dict.iteritems(): result_dict[k] = v result_dict['id'] = int(uid) return result_dict
def thumbnail_user_info(uid): user = {} item = xapian_search_user.search_by_id(int(uid), fields=thumbnail_user_fields) if item: for f in thumbnail_user_fields: if f == 'verified': user[f] = u'是' if item[f] == True else u'否' elif f == 'created_at': try: user[f] = ts2HMS(item[f]) except: user[f] = '' elif f == 'gender': if item[f] == 'f': user[f] = u'女' elif item[f] == 'm': user[f] = u'男' else: user[f] = u'未知' else: user[f] = item[f] return user
def getUserNameById(uid): user = xapian_search_user.search_by_id(int(uid), fields=['name']) if user: return user['name'] return uid