def tag_item(item, search_artist=None, search_title=None,
             search_ids=[]):
    # Holds candidates found so far: keys are MBIDs; values are
    # (distance, TrackInfo) pairs.
    candidates = {}

    # First, try matching by MusicBrainz ID.
    trackids = search_ids or filter(None, [item.mb_trackid])
    if trackids:
        for trackid in trackids:
            log.debug(u'Searching for track ID: {0}', trackid)
            for track_info in hooks.tracks_for_id(trackid):
                dist = track_distance(item, track_info, incl_artist=True)
                candidates[track_info.track_id] = \
                    hooks.TrackMatch(dist, track_info)
                # If this is a good match, then don't keep searching.
                rec = _recommendation(sorted(candidates.itervalues()))
                if rec == Recommendation.strong and \
                        not config['import']['timid']:
                    log.debug(u'Track ID match.')
                    return sorted(candidates.itervalues()), rec

    # If we're searching by ID, don't proceed.
    if search_ids:
        if candidates:
            return sorted(candidates.itervalues()), rec
        else:
            return [], Recommendation.none

    # Search terms.
    if not (search_artist and search_title):
        search_artist, search_title = item.artist, item.title
    log.debug(u'Item search terms: {0} - {1}', search_artist, search_title)

    # Get and evaluate candidate metadata.
    for track_info in hooks.item_candidates(item, search_artist, search_title):
        dist = track_distance(item, track_info, incl_artist=True)
        candidates[track_info.track_id] = hooks.TrackMatch(dist, track_info)

    # Sort by distance and return with recommendation.
    log.debug(u'Found {0} candidates.', len(candidates))
    candidates = sorted(candidates.itervalues())
    rec = _recommendation(candidates)
    return candidates, rec
Record.__getitem__ redirects to getattr()
dataset/ETHPy150Open beetbox/beets/beets/autotag/match.py/tag_item--crossover with--dataset/ETHPy150Open numba/numba/numba/targets/arrayobj.py/record_getitem