Example #1
0
  private static BoardSettings getBoardSettings(Settings settings, String boardName) {
    BoardSettings defaults = settings.getBoardSettings().get("default");
    BoardSettings bSet = settings.getBoardSettings().get(boardName);

    bSet.initSetting("path", defaults.getPath() + "/" + boardName + "/");
    bSet.initSetting("table", boardName);

    // set everything that isn't set already to their defaults
    bSet.initSettings(defaults);

    return bSet;
  }
Example #2
0
  public static void main(String[] args) {
    Settings fullSettings;
    String settingsJson;
    Gson gson = new Gson();
    String settingsFileName = SETTINGS_FILE;

    for (int i = 0; i < args.length; ++i) {
      if (args[i].equals("--config") && ++i < args.length) {
        settingsFileName = args[i];
      }
    }

    File debugFile = new File(DEBUG_FILE);
    try {
      debugOut =
          new BufferedWriter(Files.newWriterSupplier(debugFile, Charsets.UTF_8, true).getOutput());
    } catch (IOException e1) {
      System.err.println("WARN: Cannot write to debug file");
    }

    BufferedReader settingsReader;
    if (settingsFileName.equals("-")) {
      settingsReader = new BufferedReader(new InputStreamReader(System.in, Charsets.UTF_8));
    } else {
      File settingsFile = new File(settingsFileName);
      try {
        settingsReader = Files.newReader(settingsFile, Charsets.UTF_8);
      } catch (FileNotFoundException e) {
        System.err.println("ERROR: Can't find settings file (" + settingsFile + ")");
        return;
      }
    }

    try {
      settingsJson = CharStreams.toString(settingsReader);
    } catch (IOException e) {
      System.err.println("ERROR: Error while reading settings file");
      return;
    }

    OuterSettings outerSettings;
    try {
      outerSettings = gson.fromJson(settingsJson, OuterSettings.class);
    } catch (JsonSyntaxException e) {
      System.err.println("ERROR: Settings file is malformed!");
      return;
    }

    fullSettings = outerSettings.getSettings();

    dumperEngine = fullSettings.getDumperEngine();
    sourceEngine = fullSettings.getSourceEngine();
    if (dumperEngine == null) dumperEngine = "DumperJSON";
    if (sourceEngine == null) sourceEngine = "YotsubaJSON";

    for (String boardName : fullSettings.getBoardSettings().keySet()) {
      if ("default".equals(boardName)) continue;
      try {
        spawnBoard(boardName, fullSettings);
      } catch (BoardInitException e) {
        System.err.println("ERROR: Error initializing dumper for /" + boardName + "/:");
        System.err.println("  " + e.getMessage());
      }
    }
  }