<commit_before>
# vim:tabstop=2:sw=2:et:

# Copyright 2016, <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'json'
require 'systemu'
require 'tempfile'
require 'fileutils'
require 'yaml'

class Cangallo

  class Cangafile
    attr_accessor :data

    ACTIONS = {
      "copy" => {
        "action" => lambda do |input|
          add_head "copy-in #{input.gsub(" ", ":")}"
        end
      },

      "run" => {
        "type" => [Array, String],
        "action" => lambda do |input|
          if input.class == String
            commands = input.split("\n").reject {|l| l.empty? }
          else
            commands = input
          end

          commands.each do |cmd|
            add_head "run-command #{cmd}"
          end
        end
      },

      "change" => {
        "type" => Hash,
        "action" => lambda do |input|
          regexp = input["regexp"].gsub("/", "\\/")
          text = input["text"]
          file = input["file"]
          add_head "run-command sed -i 's/#{regexp}/#{text}/g' #{file}"
        end
      },

      "delete" => {
        "action" => lambda do |input|
          add_head "run-command rm -rf #{input}"
        end
      },

      "password" => {
        "type" => Hash,
        "action" => lambda do |input|
          if input["disabled"]
            password = "<PASSWORD>"
          else
            password = "password:#{input["password"]}"
          end

          add_parameter "--password '#{input["user"]}:#{password}'"
        end
      }
    }

    def initialize(file)
      text = File.read(file)
      @data = YAML.load(text)

      @params = []
      @head = []
      @tail = []
<commit_msg>Use virt-customize's delete command for delete<commit_after>
# vim:tabstop=2:sw=2:et:

# Copyright 2016, <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'json'
require 'systemu'
require 'tempfile'
require 'fileutils'
require 'yaml'

class Cangallo

  class Cangafile
    attr_accessor :data

    ACTIONS = {
      "copy" => {
        "action" => lambda do |input|
          add_head "copy-in #{input.gsub(" ", ":")}"
        end
      },

      "run" => {
        "type" => [Array, String],
        "action" => lambda do |input|
          if input.class == String
            commands = input.split("\n").reject {|l| l.empty? }
          else
            commands = input
          end

          commands.each do |cmd|
            add_head "run-command #{cmd}"
          end
        end
      },

      "change" => {
        "type" => Hash,
        "action" => lambda do |input|
          regexp = input["regexp"].gsub("/", "\\/")
          text = input["text"]
          file = input["file"]
          add_head "run-command sed -i 's/#{regexp}/#{text}/g' #{file}"
        end
      },

      "delete" => {
        "action" => lambda do |input|
          add_head "delete #{input}"
        end
      },

      "password" => {
        "type" => Hash,
        "action" => lambda do |input|
          if input["disabled"]
            password = "<PASSWORD>"
          else
            password = "password:#{input["password"]}"
          end

          add_parameter "--password '#{input["user"]}:#{password}'"
        end
      }
    }

    def initialize(file)
      text = File.read(file)
      @data = YAML.load(text)

      @params = []
      @head = []
      @tail = []

{'fraction_non_alphanumeric': 0.1392260132814289, 'fraction_numerical': 0.004579803068468056, 'mean_word_length': 1.9938313913639478, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3363109', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1268, 'n_words': 395}