<commit_before>package org.horrgs.twitterbot.api;

import com.google.gson.Gson;
import com.google.gson.JsonElement;

import java.io.*;

/**
 * Created by horrgs on 9/17/15.
 */
public class FileManager {
    private static FileManager instance = new FileManager();
    public static FileManager getInstance() { return instance; }
    String username1, password1, oAuthConsumerKey1, oAuthConsumerSecret1,
            oAuthAccessToken1, oAuthAccessTokenSecret1, weatherApiKey1, pasteBinKey1;
    private File keys;
    private BufferedWriter keysWriter;

    private BufferedReader keysReader;

    public BufferedWriter getKeysWriter() {
        return keysWriter;
    }

    public void setKeysWriter(BufferedWriter keysWriter) {
        this.keysWriter = keysWriter;
    }

    public BufferedReader getKeysReader() {
        return keysReader;
    }

    public void setKeysReader(BufferedReader keysReader) {
        this.keysReader = keysReader;
    }

    public void createFiles() {
        keys = new File("keys.json");
        if(!keys.exists()) {
            try {
                keys.createNewFile();
                keysWriter = new BufferedWriter(new FileWriter(keys));
                keysReader = new BufferedReader(new FileReader(keys));

                FileLayout fileLayout = new FileLayout("", "", "", "", "", "", "", "");
                Gson gson = new Gson();
                String json = gson.toJson(fileLayout);
                keysWriter.write(json);
                keysWriter.flush();
                keysWriter.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    public FileManager() {
        keys = new File("keys.json");
        if(keys.exists()) {
            try {
                keysWriter = new BufferedWriter(new FileWriter(keys));
                keysReader = new BufferedReader(new FileReader(keys));
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        } else {
            createFiles();
        }
    }

    public String getWeatherApiKey() {
        return weatherApiKey1;
    }

    public String getUsername() {
        return username1;
    }

    public String getPassword() {
        return <PASSWORD>;
    }

    public String getoAuthConsumeyKey() {
        return oAuthConsumerKey1;
    }

    public String getoAuthConsumerSecret() {
        return oAuthConsumerSecret1;
    }

    public String getoAuthAccessToken() {
        return oAuthAccessToken1;
    }

    public String getoAuthAccessTokenSecret() {
        return oAuthAccessTokenSecret1;
    }

    public String getPasteBinKey() {
        return pasteBinKey1;
    }

    private class FileLayout {

        public FileLayout(String username, String password, String oAuthConsumerKey,
                          String oAuthConsumerSecret, String oAuthAccessToken, String oAuthAccessTokenSecret, String weatherApiKey, String pasteBinKey) {
            username1 = username;
            password1 = password;
            oAuthConsumerKey1 = oAuthConsumerKey;
            oAuthConsumerSecret1 = oAuthConsumerSecret;
            oAuthAccessToken1 = oAuthAccessToken;
            oAuthAccessTokenSecret1 = oAuthAccessTokenSecret;
            weatherApiKey1 = weatherApiKey;
            pasteBinKey1 = pasteBinKey;
        }

        public void setUsername(String username) {
            username1 = username;
        }

        public void setPassword(String password) {
            password1 = password;
        }

        public void setoAuthConsumeyKey(String oAuthConsumeyKey) {
            oAuthConsumerKey1 = oAuthConsumeyKey;
        }

        public void setoAuthConsumerSecret(String oAuthConsumerSecret) {
            oAuthConsumerSecret1 = oAuthConsumerSecret;
        }

        public void setoAuthAccessToken(String oAuthAccessToken) {
            oAuthAccessToken1 = oAuthAccessToken;<commit_msg>FileManager better formatting + uses.<commit_after>package org.horrgs.twitterbot.api;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.json.JSONArray;

import java.io.*;
import java.util.Date;

/**
 * Created by horrgs on 9/17/15.
 */
public class FileManager {
    private static FileManager instance = new FileManager();
    public static FileManager getInstance() { return instance; }
    String username1, password1, oAuthConsumerKey1, oAuthConsumerSecret1,
            oAuthAccessToken1, oAuthAccessTokenSecret1, weatherApiKey1, pasteBinKey1;
    private File keys;
    private BufferedWriter keysWriter;

    private BufferedReader keysReader;

    public BufferedWriter getKeysWriter() {
        return keysWriter;
    }

    public void setKeysWriter(BufferedWriter keysWriter) {
        this.keysWriter = keysWriter;
    }

    public BufferedReader getKeysReader() {
        return keysReader;
    }

    public void setKeysReader(BufferedReader keysReader) {
        this.keysReader = keysReader;
    }

    private JsonArray miscArray;
    public void createFiles() {
        keys = new File("keys.json");
        if(!keys.exists()) {
            try {
                keys.createNewFile();
                keysWriter = new BufferedWriter(new FileWriter(keys));
                keysReader = new BufferedReader(new FileReader(keys));

                KeysLayout keysLayout = new KeysLayout("", "", "", "", "", "", "", "");
                Gson gson = new Gson();
                JsonObject jsonObject = new JsonObject();
                JsonArray jsonArray = new JsonArray();
                jsonObject.add("keys", jsonArray);
                jsonArray.add(gson.toJsonTree(keysLayout));
                miscArray = new JsonArray();
                JsonObject jsonObject1 = new JsonObject();
                jsonObject1.addProperty("wordOfTheDay", "");
                Date d = new Date();
                String s = String.format("%s/%s/%s", d.getMonth(), d.getDay(), d.getYear());
                jsonObject1.addProperty("lastTimeAssigned", s);
                jsonObject.add("misc", miscArray);
                keysWriter.write(jsonObject.toString());
                keysWriter.flush();
                keysWriter.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    public FileManager() {
        keys = new File("keys.json");
        if(keys.exists()) {
            try {
                keysWriter = new BufferedWriter(new FileWriter(keys));
                keysReader = new BufferedReader(new FileReader(keys));
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        } else {
            createFiles();
        }
    }

    public String getWeatherApiKey() {
        return weatherApiKey1;
    }

    public String getUsername() {
        return username1;
    }

    public String getPassword() {
        return <PASSWORD>;
    }

    public String getoAuthConsumeyKey() {
        return oAuthConsumerKey1;
    }

    public String getoAuthConsumerSecret() {
        return oAuthConsumerSecret1;
    }

    public String getoAuthAccessToken() {
        return oAuthAccessToken1;
    }

    public String getoAuthAccessTokenSecret() {
        return oAuthAccessTokenSecret1;
    }

    public String getPasteBinKey() {
        return pasteBinKey1;
    }

    private class KeysLayout {

        public KeysLayout(String username, String password, String oAuthConsumerKey,
                          String oAuthConsumerSecret, String oAuthAccessToken, String oAuthAccessTokenSecret, String weatherApiKey, String pasteBinKey) {
            username1 = username;
            password1 = password;
            oAuthConsumerKey1 = oAuthConsumerKey;
            oAuthConsumerSecret1 = oAuthConsumerSecret;
            oAuthAccessToken1 = oAuthAccessToken;
            oAuthAccessTokenSecret1 = oAuthAccessTokenSecret;
            weatherApiKey1 = weatherApiKey;
            pasteBinKey1 = pasteBinKey;
        }

        public void setUsername(String username) {
            username1 = username;
        }

        public void setPassword(String password) {
            password1 = password;
        }

        public void setoAuthConsumeyKey(String oAuthConsumeyKey) {
            oAuthConsumerKey1 = oAuthConsumeyKey;
        }

        public void setoAuthConsumerSecret(String oAuthConsumerSecret) {
            oAuthConsumerSecret1 = oAuthConsumerSecret;
        }

        public void setoAuthAccessToken(String oAuthAccessToken) {
            oAuthAccessToken1 = oAuthAccessToken;
{'fraction_non_alphanumeric': 0.08279370952821462, 'fraction_numerical': 0.007978723404255319, 'mean_word_length': 2.1716171617161715, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2004273', 'n_tokens_mistral': 2284, 'n_tokens_neox': 2196, 'n_words': 503}