示例#1
0
def get_child_htmls(this_recID, cc_val, c_val, record_url_pattern,
                    link_pattern):
    """children aren'r referenced by parents, so we need special treatment to find
    them"""
    control_nos = get_control_nos_from_recID(this_recID)
    for control_no in control_nos:
        url = ''
        p_val = '510%4:"' + control_no + '" and 510%w:t'
        # find a first, fuzzy result set
        # narrowing down on a few possible recIDs
        recIDs = perform_request_search(cc=cc_val,
                                        c=c_val,
                                        p=p_val)
        # now filter to find the ones where the subfield conditions of p_val
        # are both true within the exact same field
        sf_req = [('w', 't'), ('4', control_no)]
        recIDs = filter(lambda x:
                            match_all_subfields_for_tag(x, '510', sf_req),
                        recIDs)
        # proceed with assembling the html link
        child_htmls = []
        for recID in recIDs:
            url = record_url_pattern % str(recID)
            display = guess_main_name_from_authority_recID(recID) or str(recID)
            out_html = link_pattern % (url, display)
            child_htmls.append(out_html)
        return child_htmls
def get_child_htmls(this_recID, cc_val, c_val, record_url_pattern,
                    link_pattern):
    """children aren'r referenced by parents, so we need special treatment to find
    them"""
    control_nos = get_control_nos_from_recID(this_recID)
    for control_no in control_nos:
        url = ''
        p_val = '510%4:"' + control_no + '" and 510%w:t'
        # find a first, fuzzy result set
        # narrowing down on a few possible recIDs
        recIDs = perform_request_search(cc=cc_val,
                                        c=c_val,
                                        p=p_val)
        # now filter to find the ones where the subfield conditions of p_val
        # are both true within the exact same field
        sf_req = [('w', 't'), ('4', control_no)]
        recIDs = filter(lambda x:
                            match_all_subfields_for_tag(x, '510', sf_req),
                        recIDs)
        # proceed with assembling the html link
        child_htmls = []
        for recID in recIDs:
            url = record_url_pattern % str(recID)
            display = guess_main_name_from_authority_recID(recID) or str(recID)
            out_html = link_pattern % (url, display)
            child_htmls.append(out_html)
        return child_htmls
 def test_bibauthority_guess_main_name(self):
     """bibauthority - test guess_main_name_from_authority_recID()"""
     recID = 118
     main_name = 'Ellis, John'
     self.assertEqual(guess_main_name_from_authority_recID(recID),
                      main_name)
 def test_bibauthority_guess_main_name(self):
     """bibauthority - test guess_main_name_from_authority_recID()"""
     recID = 118
     main_name = 'Ellis, John'
     self.assertEqual(guess_main_name_from_authority_recID(recID),
                      main_name)