def _recommendation(results):
 if (not results):
  return Recommendation.none
 min_dist = results[0].distance
 if (min_dist < config['match']['strong_rec_thresh'].as_number()):
  rec = Recommendation.strong
 elif (min_dist <= config['match']['medium_rec_thresh'].as_number()):
  rec = Recommendation.medium
 elif (len(results) == 1):
  rec = Recommendation.low
 elif ((results[1].distance - min_dist) >= config['match']['rec_gap_thresh'].as_number()):
  rec = Recommendation.low
 else:
  return Recommendation.none
 keys = set(min_dist.keys())
 if isinstance(results[0], hooks.AlbumMatch):
  for track_dist in min_dist.tracks.values():
   keys.update(track_dist.keys())
 max_rec_view = config['match']['max_rec']
 for key in keys:
  if (key in max_rec_view.keys()):
   max_rec = max_rec_view[key].as_choice({'strong': Recommendation.strong, 'medium': Recommendation.medium, 'low': Recommendation.low, 'none': Recommendation.none})
   rec = min(rec, max_rec)
 return rec

def _recommendation ( results ) : if ( not results ) : return Recommendation . none min_dist = results [ 0 ] . distance if ( min_dist < config [ 'match' ] [ 'strong_rec_thresh' ] . as_number ( ) ) : rec = Recommendation . strong elif ( min_dist <= config [ 'match' ] [ 'medium_rec_thresh' ] . as_number ( ) ) : rec = Recommendation . medium elif ( len ( results ) == 1 ) : rec = Recommendation . low elif ( ( results [ 1 ] . distance - min_dist ) >= config [ 'match' ] [ 'rec_gap_thresh' ] . as_number ( ) ) : rec = Recommendation . low else : return Recommendation . none keys = set ( min_dist . keys ( ) ) if isinstance ( results [ 0 ] , hooks . AlbumMatch ) : for track_dist in min_dist . tracks . values ( ) : keys . update ( track_dist . keys ( ) ) max_rec_view = config [ 'match' ] [ 'max_rec' ] for key in keys : if ( key in max_rec_view . keys ( ) ) : max_rec = max_rec_view [ key ] . as_choice ( { 'strong' : Recommendation . strong , 'medium' : Recommendation . medium , 'low' : Recommendation . low , 'none' : Recommendation . none } ) rec = min ( rec , max_rec ) return rec
given a sorted list of albummatch or trackmatch objects .