<commit_before>package com.github.lunatrius.configpatcher;

import com.github.lunatrius.configpatcher.patch.Generate;
import com.github.lunatrius.configpatcher.patch.Patch;
import com.github.lunatrius.configpatcher.reference.Reference;
import com.github.lunatrius.configpatcher.util.FileHelper;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkCheckHandler;
import cpw.mods.fml.relauncher.Side;

import java.io.File;
import java.util.Map;

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-before:*")
public class ConfigPatcher {
    private File directoryMain = null;
    private File directoryOverride = null;
    private File directoryBase = null;
    private File directoryDiff = null;
    private boolean generatePatches = false;

    @NetworkCheckHandler
    public boolean checkModList(final Map<String, String> versions, final Side side) {
        return true;
    }

    @Mod.EventHandler
    public void preInit(final FMLPreInitializationEvent event) {
        this.directoryMain = FileHelper.getCanonicalFile(event.getModConfigurationDirectory());
        this.directoryOverride = FileHelper.getCanonicalFile(this.directoryMain.getParentFile(), this.directoryMain.getName() + "-override");
        this.generatePatches = new File(this.directoryMain.getParentFile(), "generate_patches.txt").exists();
        if (this.generatePatches) {
            this.directoryBase = FileHelper.getCanonicalFile(this.directoryMain.getParentFile(), this.directoryMain.getName() + "-base");
            this.directoryDiff = FileHelper.getCanonicalFile(this.directoryOverride, "auto-generated");
        }

        new Patch(this.directoryMain, this.directoryOverride).execute();
    }

    @Mod.EventHandler
    public void init(final FMLInitializationEvent event) {
        if (this.generatePatches) {
            new Generate(this.directoryMain, this.directoryBase, this.directoryDiff).execute();
        }
    }

    @Mod.EventHandler
    public void postInit(final FMLPostInitializationEvent event) {
    }
}<commit_msg>Do not apply patches if they are going to be generated.<commit_after>package com.github.lunatrius.configpatcher;

import com.github.lunatrius.configpatcher.patch.Generate;
import com.github.lunatrius.configpatcher.patch.Patch;
import com.github.lunatrius.configpatcher.reference.Reference;
import com.github.lunatrius.configpatcher.util.FileHelper;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkCheckHandler;
import cpw.mods.fml.relauncher.Side;

import java.io.File;
import java.util.Map;

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-before:*")
public class ConfigPatcher {
    private File directoryMain = null;
    private File directoryOverride = null;
    private File directoryBase = null;
    private File directoryDiff = null;
    private boolean generatePatches = false;

    @NetworkCheckHandler
    public boolean checkModList(final Map<String, String> versions, final Side side) {
        return true;
    }

    @Mod.EventHandler
    public void preInit(final FMLPreInitializationEvent event) {
        this.directoryMain = FileHelper.getCanonicalFile(event.getModConfigurationDirectory());
        this.directoryOverride = FileHelper.getCanonicalFile(this.directoryMain.getParentFile(), this.directoryMain.getName() + "-override");
        this.generatePatches = new File(this.directoryMain.getParentFile(), "generate_patches.txt").exists();
        if (this.generatePatches) {
            this.directoryBase = FileHelper.getCanonicalFile(this.directoryMain.getParentFile(), this.directoryMain.getName() + "-base");
            this.directoryDiff = FileHelper.getCanonicalFile(this.directoryOverride, "auto-generated");
        } else {
            new Patch(this.directoryMain, this.directoryOverride).execute();
        }
    }

    @Mod.EventHandler
    public void init(final FMLInitializationEvent event) {
        if (this.generatePatches) {
            new Generate(this.directoryMain, this.directoryBase, this.directoryDiff).execute();
        }
    }

    @Mod.EventHandler
    public void postInit(final FMLPostInitializationEvent event) {
    }
}
{'fraction_non_alphanumeric': 0.10155911650064964, 'fraction_numerical': 0.0, 'mean_word_length': 4.2728310502283104, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4627571', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1304, 'n_words': 241}