/slacklog-java

Java bindings for Python slacklog module

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

Slacklog Java

Java wrapper for Python slacklog module.

slacklog-java provides a library to convert a Slackware ChangeLog into other formats. Currently, RSS, Atom, JSON and PyBlosxom formats are supported.

Example usage

import fi.linuxbox.slacklog.formatters.SlackLogJsonFormatter;
import fi.linuxbox.slacklog.models.SlackLog;
import fi.linuxbox.slacklog.parsers.SlackLogParser;
import org.python.core.Py;
import org.python.core.PySystemState;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;

import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;

public class Example {

    public static void main(String... args) throws IOException {
        // Initialize Jython
        PySystemState.initialize();

        // Read the source ChangeLog.txt
        final String changelog = read("src/test/resources/ChangeLog.txt", ISO_8859_1);

        // Parse the ChangeLog.txt
        final SlackLog slacklog = new SlackLogParser().parse(changelog);

        // Convert the ChangeLog to JSON
        final SlackLogJsonFormatter formatter = new SlackLogJsonFormatter();
        formatter.setIndent(4);
        final String json = formatter.format(slacklog);

        // Write the output
        write("src/test/resources/ChangeLog.json", json.getBytes(UTF_8));

        // Close the resources
        Py.getSystemState().close();
    }

    private static String read(final String path, final Charset charset) throws IOException {
        return new String(Files.readAllBytes(Paths.get(path)), charset);
    }

    private static void write(final String path, final byte[] data) throws IOException {
        Files.write(Paths.get(path), data);
    }
}

Requirements

Slacklog Java requires Java 8. This library is available at The Central Repository and jcenter

Authors

Original author and current maintainer is Mikko Värri (vmj@linuxbox.fi).

License

slacklog-java is Free Software, licensed under GNU General Public License (GPL), version 3 or later. See LICENSE.txt file for details.