(store, desired_length)
return False
Trim the history animation to the desired length.
Trim the history animation to the desired length.
Trim the history animation to the desired length .
def history_trim(store, desired_length):
    """Trim the history animation to the desired length."""
    
    history = store['Applications'][store['CurrentProgramName']]['Data']['HistoryAnimation']['Tracks']
    
    #Delete all history
    if not desired_length:
        store['Applications'][store['CurrentProgramName']]['Data']['HistoryAnimation']['Tracks'] = [history[-1][0]]
        return True
    
    #No point checking if it's too long first, it will probably take just as long
    total = 0
    for count, items in enumerate(history[::-1]):
        total += len(items) - 1
        
        if total >= desired_length:
            
            #Cut off the earlier resolutions
            start_point = len(history) - count - 1
            history = history[start_point:]
            
            #Trim the first record if not exact
            if total > desired_length:
                history[0] = [history[0][0]] + history[0][total-desired_length+1:]
            
            store['Applications'][store['CurrentProgramName']]['Data']['HistoryAnimation']['Tracks'] = history
            return True
            
    return False
def history_trim ( store , desired_length ) : history = store [ 'Applications' ] [ store [ 'CurrentProgramName' ] ] [ 'Data' ] [ 'HistoryAnimation' ] [ 'Tracks' ] #Delete all history if not desired_length : store [ 'Applications' ] [ store [ 'CurrentProgramName' ] ] [ 'Data' ] [ 'HistoryAnimation' ] [ 'Tracks' ] = [ history [ - 1 ] [ 0 ] ] return True #No point checking if it's too long first, it will probably take just as long total = 0 for count , items in enumerate ( history [ : : - 1 ] ) : total += len ( items ) - 1 if total >= desired_length : #Cut off the earlier resolutions start_point = len ( history ) - count - 1 history = history [ start_point : ] #Trim the first record if not exact if total > desired_length : history [ 0 ] = [ history [ 0 ] [ 0 ] ] + history [ 0 ] [ total - desired_length + 1 : ] store [ 'Applications' ] [ store [ 'CurrentProgramName' ] ] [ 'Data' ] [ 'HistoryAnimation' ] [ 'Tracks' ] = history return True return False