<commit_before>#encoding: utf-8

module CommandExec
  class Process
    attr_accessor :executable 
    attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid

    def initialize(options={})
      @options = {
        logger: Logger.new($stderr),
        stderr: [],
        stdout: [],
        output: [],
        pid: nil,
        return_code: nil,
        reason_for_failure: [],
        status: :success,
      }.merge options

      @logger = @options[:logger]

      @stderr = @options[:stderr]
      @stdout = @options[:stdout]
      @status = @options[:status]
      @pid = @options[:pid]
      @reason_for_failure = @options[:reason_for_failure]
      @return_code = @options[:return_code]

      @output = @options[:output]
    end

    def log_file=(filename=nil)
        if filename.blank?
          file = StringIO.new 
          @logger.debug "No file name for log file given. Using empty String"
        else
          begin
            file = File.open(filename)
            @logger.debug "read logfile \"#{file}\" "
          rescue Errno::ENOENT
            file = StringIO.new
            @logger.warn "Logfile #{filename} not found!"
          rescue Exception => e
            file = StringIO.new
            @logger.warn "An error happen while reading log_file \"#{filename}\": #{e.message}"
          end
        end

      @log_file = file.readlines
    end

    def pid=(value)
      @pid = value.to_s
    end<commit_msg>mmh, I don't like doubled newlines<commit_after>#encoding: utf-8

module CommandExec
  class Process
    attr_accessor :executable 
    attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid

    def initialize(options={})
      @options = {
        logger: Logger.new($stderr),
        stderr: [],
        stdout: [],
        output: [],
        pid: nil,
        return_code: nil,
        reason_for_failure: [],
        status: :success,
      }.merge options

      @logger = @options[:logger]

      @stderr = @options[:stderr]
      @stdout = @options[:stdout]
      @status = @options[:status]
      @pid = @options[:pid]
      @reason_for_failure = @options[:reason_for_failure]
      @return_code = @options[:return_code]

      @output = @options[:output]
    end

    def log_file=(filename=nil)
        if filename.blank?
          file = StringIO.new 
          @logger.debug "No file name for log file given. Using empty String"
        else
          begin
            file = File.open(filename)
            @logger.debug "read logfile \"#{file}\" "
          rescue Errno::ENOENT
            file = StringIO.new
            @logger.warn "Logfile #{filename} not found!"
          rescue Exception => e
            file = StringIO.new
            @logger.warn "An error happen while reading log_file \"#{filename}\": #{e.message}"
          end
        end

      @log_file = file.readlines.map(&:chomp)
    end

    def pid=(value)
      @pid = value.to_s
    end
{'fraction_non_alphanumeric': 0.11990647962591851, 'fraction_numerical': 0.0006680026720106881, 'mean_word_length': 2.0655066530194475, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '6245411', 'n_tokens_mistral': 885, 'n_tokens_neox': 866, 'n_words': 220}