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.
-
Source code: https://github.com/vmj/slacklog-java
-
Builds status: https://travis-ci.org/vmj/slacklog-java
-
Docs: https://www.javadoc.io/doc/fi.linuxbox.slacklog/slacklog-java
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);
}
}
Slacklog Java requires Java 8. This library is available at The Central Repository and jcenter
Original author and current maintainer is Mikko Värri (vmj@linuxbox.fi).