<commit_before>class Cleaner
  
  attr_reader :paths, :options
  
  VALID_OPTIONS    = [:threshold, :pretend, :verbose, :recursive]
  VALID_INTERVALS  = [:hourly, :daily, :weekly, :monthly, :yearly]
  TIME_INTERVALS   = [:hour,   :day,   :cweek, :month, :year]
  
  def initialize(paths, options = {})
    @paths = [paths].flatten
    @options = options.reverse_merge(:threshold => 30.days.ago)
    options.assert_valid_keys(VALID_OPTIONS + VALID_INTERVALS)
    given_intervals = VALID_INTERVALS & options.keys
    if given_intervals.present?
      lowest_selected_position = VALID_INTERVALS.index(given_intervals.first)
      @key_intervals = TIME_INTERVALS[lowest_selected_position..-1]
    end
  end
  
  def start
    files = files_to_delete.map(&:path)
    puts files.join("\n") if options[:verbose]
    FileUtils.rm_rf(files, :noop => !!options[:pretend])
  end
  
  def files
    @_files ||= paths.map do |file_path| 
      begin 
        File.new(file_path)
      rescue Errno::EOPNOTSUPP
        nil
      end
    end.compact.select do |file|
      file.stat.file? || (options[:recursive] && file.stat.directory?)
    end.sort_by(&:ctime)
  end<commit_msg>Nicer error message if specified file doesn't exist<commit_after>class Cleaner
  
  attr_reader :paths, :options
  
  VALID_OPTIONS    = [:threshold, :pretend, :verbose, :recursive]
  VALID_INTERVALS  = [:hourly, :daily, :weekly, :monthly, :yearly]
  TIME_INTERVALS   = [:hour,   :day,   :cweek, :month, :year]
  
  def initialize(paths, options = {})
    @paths = [paths].flatten
    @options = options.reverse_merge(:threshold => 30.days.ago)
    options.assert_valid_keys(VALID_OPTIONS + VALID_INTERVALS)
    given_intervals = VALID_INTERVALS & options.keys
    if given_intervals.present?
      lowest_selected_position = VALID_INTERVALS.index(given_intervals.first)
      @key_intervals = TIME_INTERVALS[lowest_selected_position..-1]
    end
  end
  
  def start
    files = files_to_delete.map(&:path)
    puts files.join("\n") if options[:verbose]
    FileUtils.rm_rf(files, :noop => !!options[:pretend])
  end
  
  def files
    @_files ||= paths.map do |file_path| 
      begin 
        File.new(file_path)
      rescue Errno::EOPNOTSUPP
        nil
      rescue Errno::ENOENT => e
        puts e.to_s
        exit -2
      end
    end.compact.select do |file|
      file.stat.file? || (options[:recursive] && file.stat.directory?)
    end.sort_by(&:ctime)
  end
{'fraction_non_alphanumeric': 0.12192118226600986, 'fraction_numerical': 0.0028735632183908046, 'mean_word_length': 3.290492957746479, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4067380', 'n_tokens_mistral': 872, 'n_tokens_neox': 856, 'n_words': 163}