<commit_before>require 'fileutils'

class RemoteTable
  class LocalFile #:nodoc:all
    
    attr_reader :t
    
    def initialize(t)
      @t = t
    end
    
    def path
      generate unless generated?
      @path
    end
    
    def encoded_io
      @encoded_io ||= if ::RUBY_VERSION >= '1.9'
        ::File.open path, 'rb', :internal_encoding => t.properties.internal_encoding, :external_encoding => t.properties.external_encoding
      else
        ::File.open path, 'rb'
      end
    end
    
    def cleanup
      if @encoded_io.respond_to?(:closed?) and !@encoded_io.closed?
        @encoded_io.close
      end
      @encoded_io = nil
      ::FileUtils.rm_f @path
      @path = nil
      @generated = nil
    end
    
    private
    
    def generated?
      @generated == true
    end
        
    def generate
      tmp_path = Utils.download t.properties.uri, t.properties.form_data
      if compression = t.properties.compression
        tmp_path = Utils.decompress tmp_path, compression
      end
      if packing = t.properties.packing<commit_msg>don't die if path is missing<commit_after>require 'fileutils'

class RemoteTable
  class LocalFile #:nodoc:all
    
    attr_reader :t
    
    def initialize(t)
      @t = t
    end
    
    def path
      generate unless generated?
      @path
    end
    
    def encoded_io
      @encoded_io ||= if ::RUBY_VERSION >= '1.9'
        ::File.open path, 'rb', :internal_encoding => t.properties.internal_encoding, :external_encoding => t.properties.external_encoding
      else
        ::File.open path, 'rb'
      end
    end
    
    def cleanup
      if @encoded_io.respond_to?(:closed?) and !@encoded_io.closed?
        @encoded_io.close
      end
      @encoded_io = nil
      if @path and ::File.exist?(@path)
        ::FileUtils.rm_f @path
      end
      @path = nil
      @generated = nil
    end
    
    private
    
    def generated?
      @generated == true
    end
        
    def generate
      tmp_path = Utils.download t.properties.uri, t.properties.form_data
      if compression = t.properties.compression
        tmp_path = Utils.decompress tmp_path, compression
      end
      if packing = t.properties.packing
{'fraction_non_alphanumeric': 0.08867667121418826, 'fraction_numerical': 0.0018190086402910413, 'mean_word_length': 2.064066852367688, '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': '5300068', 'n_tokens_mistral': 677, 'n_tokens_neox': 673, 'n_words': 169}