<commit_before>package com.beust.kobalt.app

import com.beust.kobalt.Args
import com.beust.kobalt.internal.ActorUtils
import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.misc.log
import com.google.inject.Inject
import java.io.File
import java.io.FileOutputStream

/**
 * Invoked with --init. Generate a new project.
 */
public class ProjectGenerator @Inject constructor(val pluginInfo: PluginInfo){
    companion object {
        /**
         * Turns a dot property into a proper Kotlin identifier, e.g. common.version -> commonVersion
         */
        fun toIdentifier(key: String): String {
            fun upperFirst(s: String) = if (s.isBlank()) s else s.substring(0, 1).toUpperCase() + s.substring(1)

            return key.split('.').mapIndexed( { index, value -> if (index == 0) value else upperFirst(value) })
                    .joinToString("")
        }
    }

    fun run(args: Args) {
        val contributor = ActorUtils.selectAffinityActor(pluginInfo.initContributors, File("."))
        File(args.buildFile).parentFile.mkdirs()
        if (contributor != null) {
            contributor.generateBuildFile(FileOutputStream(File(args.buildFile)))
            log(1, "Created ${args.buildFile}")
        } else {
            log(1, "Couldn't identify project, not generating any build file")
        }
    }
}
<commit_msg>Don't overwrite build file with --init if it already exists.<commit_after>package com.beust.kobalt.app

import com.beust.kobalt.Args
import com.beust.kobalt.internal.ActorUtils
import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.misc.log
import com.google.inject.Inject
import java.io.File
import java.io.FileOutputStream

/**
 * Invoked with --init. Generate a new project.
 */
public class ProjectGenerator @Inject constructor(val pluginInfo: PluginInfo){
    companion object {
        /**
         * Turns a dot property into a proper Kotlin identifier, e.g. common.version -> commonVersion
         */
        fun toIdentifier(key: String): String {
            fun upperFirst(s: String) = if (s.isBlank()) s else s.substring(0, 1).toUpperCase() + s.substring(1)

            return key.split('.').mapIndexed( { index, value -> if (index == 0) value else upperFirst(value) })
                    .joinToString("")
        }
    }

    fun run(args: Args) {
        val contributor = ActorUtils.selectAffinityActor(pluginInfo.initContributors, File("."))
        File(args.buildFile).parentFile.mkdirs()
        if (contributor != null) {
            with(File(args.buildFile)) {
                if (exists()) {
                    log(1, "Build file $path already exists, not overwriting it")
                } else {
                    contributor.generateBuildFile(FileOutputStream(this))
                    log(1, "Created $path")
                }
            }
        } else {
            log(1, "Couldn't identify project, not generating any build file")
        }
    }
}

{'fraction_non_alphanumeric': 0.11760729976343359, 'fraction_numerical': 0.004393376140588037, 'mean_word_length': 2.453908984830805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3105418', 'n_tokens_mistral': 867, 'n_tokens_neox': 845, 'n_words': 210}