Ejemplo n.º 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
Ejemplo n.º 2
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 test_bibauthority_get_control_nos_from_recID(self):
     """bibauthority - test get_control_nos_from_recID()"""
     self.assertTrue(len(get_control_nos_from_recID(118)))
Ejemplo n.º 4
0
 def test_indexing_of_deleted_authority_record(self):
     """bibindex - no info for indexing from deleted authority record"""
     recID = 119 # deleted record
     control_nos = get_control_nos_from_recID(recID)
     info = get_index_strings_by_control_no(control_nos[0])
     self.assertEqual([], info)
 def test_bibauthority_get_control_nos_from_recID(self):
     """bibauthority - test get_control_nos_from_recID()"""
     self.assertTrue(len(get_control_nos_from_recID(118)))