<commit_before>module CloudfilesCli
  class Transactions
    attr_reader :config

    def initialize(config)
      @config = config
    end

    def connection
      @cf ||= Fog::Storage.new(config.hash.merge(:provider => 'Rackspace'))
    end

    def upload(container_name, localfile, remotefile)
      container = connection.directories.get(container_name)
      object = container.files.create(
        :key => remotefile, :body => File.open(localfile)
      )
    end

    def download(container_name, remotefile, localfile)
      container = connection.directories.get(container_name)
      object = container.files.get(remotefile)
      IO.binwrite(localfile, object.body)
    end
  end
end<commit_msg>Better error message when file is missing<commit_after>module CloudfilesCli
  class Transactions
    attr_reader :config

    def initialize(config)
      @config = config
    end

    def connection
      @cf ||= Fog::Storage.new(config.hash.merge(:provider => 'Rackspace'))
    end

    def upload(container_name, localfile, remotefile)
      container = connection.directories.get(container_name)
      object = container.files.create(
        :key => remotefile, :body => File.open(localfile)
      )
    end

    def download(container_name, remotefile, localfile)
      container = connection.directories.get(container_name)
      object = container.files.get(remotefile)
      if object.nil?
        STDERR.puts "File #{remotefile} not found on cloudfiles"
        exit 1
      else
        IO.binwrite(localfile, object.body)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0929936305732484, 'fraction_numerical': 0.0006369426751592356, 'mean_word_length': 3.028205128205128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1766244', 'n_tokens_mistral': 472, 'n_tokens_neox': 462, 'n_words': 104}