<commit_before>package toGit

import org.codehaus.groovy.control.CompilerConfiguration
import org.slf4j.LoggerFactory
import toGit.migration.MigrationManager

public class Executor {

    final static log = LoggerFactory.getLogger(this.class)

    GroovyShell execute(String[] args) {
        File commandFile = null
        if (!args) {
            log.error("Missing command file parameter")
            System.exit(1)
        } else {
            commandFile = new File(args[0])
            if (!commandFile.exists() || commandFile.isDirectory()) {
                log.error("Cannot find command file '$commandFile'")
                System.exit(1)
            }
        }

        def scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent
        def config = new CompilerConfiguration()
        config.setClasspath(scriptDir)
        config.scriptBaseClass = 'toGit.ScriptBase'
        def binding = new Binding(args as String[])
        if (args.length > 1) {
            parseParameters(binding, args[1..-1] as String[])
        }

        MigrationManager.instance.reset()
        def shell = new GroovyShell(binding, config)
        shell.evaluate(commandFile)
        return shell
    }

    static def parseParameters(Binding binding, String[] args) {
        args.each {
            if (!it.contains('=')) return
            def split = it.split('=')
            binding.setVariable(split[0], split[1..-1].join('='))
        }
    }
}<commit_msg>Fix 127. Add script location to classpath.<commit_after>package toGit

import org.codehaus.groovy.control.CompilerConfiguration
import org.slf4j.LoggerFactory
import toGit.migration.MigrationManager

public class Executor {

    final static log = LoggerFactory.getLogger(this.class)

    GroovyShell execute(String[] args) {
        if (!args) {
            log.error("Missing migration script parameter")
            System.exit(1)
        }

        File migrationScript = new File(args[0])

        if (!migrationScript.exists() || migrationScript.isDirectory()) {
            log.error("Cannot find migration script '$migrationScript'")
            System.exit(1)
        }

        def config = new CompilerConfiguration(
                scriptBaseClass: 'toGit.ScriptBase',
                classpath: migrationScript.absoluteFile.parent
        )

        def binding = new Binding(args as String[])
        if (args.length > 1) {
            parseParameters(binding, args[1..-1] as String[])
        }

        MigrationManager.instance.reset()
        def shell = new GroovyShell(this.class.classLoader, binding, config)
        shell.evaluate(migrationScript)
        return shell
    }

    static def parseParameters(Binding binding, String[] args) {
        args.each {
            if (!it.contains('=')) return
            def split = it.split('=')
            binding.setVariable(split[0], split[1..-1].join('='))
        }
    }
}
{'fraction_non_alphanumeric': 0.10982264665757162, 'fraction_numerical': 0.007844474761255117, 'mean_word_length': 2.28076062639821, 'pattern_counts': {'":': 0, '<': 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': '7043114', 'n_tokens_mistral': 811, 'n_tokens_neox': 773, 'n_words': 179}