def get_index_strings_by_control_no(control_no):
    """extracts the index-relevant strings from the authority record referenced by
    the 'control_no' parameter and returns it as a list of strings

    @param control_no: a (INVENIO) MARC internal control_no to an authority record
    @type control_no: string (e.g. 'author:(ABC)1234')

    @param expected_type: the type of authority record expected
    @type expected_type: string, e.g. 'author', 'journal' etc.

    @return: list of index-relevant strings from the referenced authority record

    """

    from invenio.bibindex_engine import list_union

    #return value
    string_list = []
    #1. get recID and authority type corresponding to control_no
    rec_IDs = get_low_level_recIDs_from_control_no(control_no)
    #2. concatenate and return all the info from the interesting fields for this record
    for rec_id in rec_IDs: # in case we get multiple authority records
        for tag in CFG_BIBAUTHORITY_AUTHORITY_SUBFIELDS_TO_INDEX.get(get_type_from_control_no(control_no)):
            new_strings = get_fieldvalues(rec_id, tag)
            string_list = list_union(new_strings, string_list)
    #return
    return string_list
Exemple #2
0
def get_index_strings_by_control_no(control_no):
    """extracts the index-relevant strings from the authority record referenced by
    the 'control_no' parameter and returns it as a list of strings

    :param control_no: a (INVENIO) MARC internal control_no to an authority record
    :type control_no: string (e.g. 'author:(ABC)1234')

    :param expected_type: the type of authority record expected
    :type expected_type: string, e.g. 'author', 'journal' etc.

    :return: list of index-relevant strings from the referenced authority record

    """

    from invenio.bibindex_engine import list_union

    #return value
    string_list = []
    #1. get recID and authority type corresponding to control_no
    rec_IDs = get_low_level_recIDs_from_control_no(control_no)
    #2. concatenate and return all the info from the interesting fields for this record
    for rec_id in rec_IDs:  # in case we get multiple authority records
        for tag in CFG_BIBAUTHORITY_AUTHORITY_SUBFIELDS_TO_INDEX.get(
                get_type_from_control_no(control_no), []):
            new_strings = get_fieldvalues(rec_id, tag)
            string_list = list_union(new_strings, string_list)
    #return
    return string_list
 def test_list_union(self):
     """bibindex engine - list union"""
     self.assertEqual([1, 2, 3, 4],
                      bibindex_engine.list_union([1, 2, 3],
                                                 [1, 3, 4]))
 def test_list_union(self):
     """bibindex engine - list union"""
     self.assertEqual([1, 2, 3, 4],
                      bibindex_engine.list_union([1, 2, 3], [1, 3, 4]))