Skip to content

Commit

Permalink
First pass
Browse files Browse the repository at this point in the history
  • Loading branch information
minchinweb committed May 6, 2021
0 parents commit 0dc912a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 14 additions & 0 deletions jrnl/contrib/exporter/rot13.py
Original file line number Diff line number Diff line change
@@ -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")
35 changes: 35 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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
)

0 comments on commit 0dc912a

Please sign in to comment.