def trim_dir(directory):
 def access_time(f):
  return os.stat(os.path.join(directory, f)).st_atime
 files = sorted(os.listdir(directory), key=access_time)
 file_name = os.path.join(directory, files[0])
 log.debug(u'removing least accessed file: %s', file_name)
 os.remove(file_name)

def trim_dir ( directory ) : def access_time ( f ) : return os . stat ( os . path . join ( directory , f ) ) . st_atime files = sorted ( os . listdir ( directory ) , key = access_time ) file_name = os . path . join ( directory , files [ 0 ] ) log . debug ( u'removing least accessed file: %s' , file_name ) os . remove ( file_name )
removed the least accessed file on a given dir .