def _get_self_pubs_bai(person_id):
    '''
    person's publication list.
    @param person_id: int person id
    '''
    cid = get_canonical_id_from_personid(person_id)
    try:
        cid = cid[0][0]
    except IndexError:
        cid = person_id
    return perform_request_search(rg=0, p='author:%s and authorcount:1' % cid)
def _get_self_pubs_bai(person_id):
    '''
    person's publication list.
    @param person_id: int person id
    '''
    cid = get_canonical_id_from_personid(person_id)
    try:
        cid = cid[0][0]
    except IndexError:
        cid = person_id
    return perform_request_search(rg=0, p='author:%s and authorcount:1' % cid)
def _get_institute_pub_dict_bai(recids, names_list, person_id):
    """return a dictionary consisting of institute -> list of publications"""
    try:
        cid = get_canonical_id_from_personid(person_id)[0][0]
    except IndexError:
        cid = person_id
    recids = perform_request_search(rg=0, p='author:%s' % str(cid))
    a = format_records(recids, 'WAPAFF')
    a = [pickle.loads(p) for p in a.split('!---THEDELIMITER---!') if p]
    affdict = {}
    for rec, affs in a:
        keys = affs.keys()
        for name in names_list:
            if name in keys and affs[name][0]:
                try:
                    affdict[affs[name][0]].add(rec)
                except KeyError:
                    affdict[affs[name][0]] = set([rec])
    return affdict
def _get_institute_pub_dict_bai(recids, names_list, person_id):
    """return a dictionary consisting of institute -> list of publications"""
    try:
        cid = get_canonical_id_from_personid(person_id)[0][0]
    except IndexError:
        cid = person_id
    recids = perform_request_search(rg=0, p='author:%s' % str(cid))
    a = format_records(recids, 'WAPAFF')
    a = [pickle.loads(p) for p in a.split('!---THEDELIMITER---!') if p]
    affdict = {}
    for rec, affs in a:
        keys = affs.keys()
        for name in names_list:
            if name in keys and affs[name][0]:
                try:
                    affdict[affs[name][0]].add(rec)
                except KeyError:
                    affdict[affs[name][0]] = set([rec])
    return affdict
 def canonical_name(pid):
     ret = get_canonical_id_from_personid(pid)
     if ret:
         return ret[0][0]
     else:
         return ""
 def canonical_name(pid):
     ret = get_canonical_id_from_personid(pid)
     if ret:
         return ret[0][0]
     else:
         return ""