djdb/search.py
def _enforce_results_limit_on_matches(segmented_matches, max_num_results):
    """If necessary, throw away results to avoid returning too many items.

    Args:
      segmented_matches: A dictionary mapping entity type strings to
        lists of matching entities.  This dict is modified in-place.
      max_num_results: The maximum number of items that may be returned.
        This function does nothing is max_num_results is None.
    
    If the dict contains too many items, they are thrown away
    semi-randomly: Track objects are discarded first, then Albums,
    and finally Artists.
    """
    if max_num_results is None:
        return
    num_results = sum([len(x) for x in segmented_matches.itervalues()])
    num_to_discard = num_results - max_num_results
    for kind in ("Track", "Album", "Artist"):
        these_matches = segmented_matches.get(kind)
        num_to_discard -= _discard_items(these_matches, num_to_discard)
        if these_matches is not None and len(these_matches) == 0:
            del segmented_matches[kind]
If necessary, throw away results to avoid returning too many items.

    Args:
      segmented_matches: A dictionary mapping entity type strings to
        lists of matching entities.  This dict is modified in-place.
      max_num_results: The maximum number of items that may be returned.
        This function does nothing is max_num_results is None.
    
    If the dict contains too many items, they are thrown away
    semi-randomly: Track objects are discarded first, then Albums,
    and finally Artists.
    
If necessary, throw away results to avoid returning too many items.
If necessary throw away results to avoid returning too many items .
def _enforce_results_limit_on_matches(segmented_matches, max_num_results):
    if max_num_results is None:
        return
    num_results = sum([len(x) for x in segmented_matches.itervalues()])
    num_to_discard = num_results - max_num_results
    for kind in ("Track", "Album", "Artist"):
        these_matches = segmented_matches.get(kind)
        num_to_discard -= _discard_items(these_matches, num_to_discard)
        if these_matches is not None and len(these_matches) == 0:
            del segmented_matches[kind]
def _enforce_results_limit_on_matches ( segmented_matches , max_num_results ) : if max_num_results is None : return num_results = sum ( [ len ( x ) for x in segmented_matches . itervalues ( ) ] ) num_to_discard = num_results - max_num_results for kind in ( "Track" , "Album" , "Artist" ) : these_matches = segmented_matches . get ( kind ) num_to_discard -= _discard_items ( these_matches , num_to_discard ) if these_matches is not None and len ( these_matches ) == 0 : del segmented_matches [ kind ]
If necessary, throw away results to avoid returning too many items.
If necessary throw away results to avoid returning too many items .
"""If necessary, throw away results to avoid returning too many items.

    Args:
      segmented_matches: A dictionary mapping entity type strings to
        lists of matching entities.  This dict is modified in-place.
      max_num_results: The maximum number of items that may be returned.
        This function does nothing is max_num_results is None.
    
    If the dict contains too many items, they are thrown away
    semi-randomly: Track objects are discarded first, then Albums,
    and finally Artists.
    """
segmented_matches
A dictionary mapping entity type strings to
lists of matching entities.  This dict is modified in-place.
A dictionary mapping entity type strings to lists of matching entities . This dict is modified in - place .
max_num_results
The maximum number of items that may be returned.
This function does nothing is max_num_results is None.
The maximum number of items that may be returned . This function does nothing is max_num_results is None .