From 0dc912af8265ef4ef4743fdc439d89025259d8b2 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Wed, 5 May 2021 22:27:17 -0600 Subject: [PATCH] First pass --- README.md | 9 +++++++++ jrnl/contrib/exporter/rot13.py | 14 ++++++++++++++ setup.py | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 README.md create mode 100644 jrnl/contrib/exporter/rot13.py create mode 100644 setup.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6674f4 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Rot13 Custom Exporter for Jrnl + +This is a custom exporter to demostrate how to write customer exporters for +[jrnl](https://github.com/jrnl-org/jrnl). It is also used by *jrnl* in its +tests to ensure the feature works as expected. + +This plugin applies a [Caeser +cipher](https://en.wikipedia.org/wiki/Caesar_cipher) (specifically the +[ROT13](https://en.wikipedia.org/wiki/ROT13)) to output text. diff --git a/jrnl/contrib/exporter/rot13.py b/jrnl/contrib/exporter/rot13.py new file mode 100644 index 0000000..508a8f4 --- /dev/null +++ b/jrnl/contrib/exporter/rot13.py @@ -0,0 +1,14 @@ +import codecs + +from jrnl.plugins.base import BaseExporter + +__version__ = "1.0.0" + +class Exporter(BaseExporter): + names = ["rot13"] + extension = "txt" + version = __version__ + + @classmethod + def export_entry(cls, entry): + return codecs.encode(str(entry), "rot_13") diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c8b0c58 --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +import os +import re + +try: + from setuptools import find_packages, setup +except ImportError: + from distutils.core import find_packages, setup + +base_dir = os.path.dirname(os.path.abspath(__file__)) + + +def get_version(filename="jrnl/contrib/exporter/rot13.py"): + with open(os.path.join(base_dir, filename), encoding="utf-8") as initfile: + for line in initfile.readlines(): + m = re.match("__version__ *= *['\"](.*)['\"]", line) + if m: + return m.group(1) + + +setup( + name="jrnl-rot13", + version=get_version(), + description="Demonstration custom exporter for jrnl", + long_description="\n\n".join([open(os.path.join(base_dir, "README.md")).read()]), + long_description_content_type="text/markdown", + author="W. Minchin", + author_email="w_minchin@hotmail.com", + url="https://github.com/MinchinWeb/jrnl-rot13-exporter", + packages=["jrnl", "jrnl.contrib", "jrnl.contrib.exporter"], + include_package_data=True, + install_requires=[ + "jrnl", + ], + zip_safe=False, # use wheels instead +)