Skip to main content

rtfcre

pypi python tests

rtfcre is a Python library for reading and writing steno dictionaries in the RTF/CRE (Rich Text Format with Court Reporting Extensions) format. The library provides an API similar to that of the json module for reading and writing dictionaries.

rtfcre also comes with a little command-line utility that you can use to convert your dictionaries between Plover's native JSON format and RTF. See CLI for more information.

Features

  • Speed: The parsing logic is written in Rust using parser combinators, making it much faster than practically any pure-Python implementation.

  • Comments: Rather than just exposing translations, rtfcre also reads the comments embedded in each entry ({\*\cxcomment like this}).

  • Unicode: Full Unicode support -- while the dictionary files are not encoded in UTF-8, Unicode characters in translations are still fully supported. Translations can be in any language and they will seamlessly be converted to escapes when writing.

  • Plover support: Translations are converted automatically to Plover's native syntax (e.g. fingerspelling is represented with {&a} rather than {\cxfing a}) and converted back when writing.

Installation

To install the library:

pip install rtfcre

If you just want to use this with Plover, install the plover-better-rtf plugin instead, since that plugin uses this library under the hood.

If you want the command-line utility, go to the Releases page and download the binary for your system.

Usage

Library

To read an RTF dictionary:

import rtfcre

# Reading directly from a file (make sure to open binary)
with open("dict.rtf", "rb") as file:
  dic = rtfcre.load(file)

# Reading from a string
rtf = r"""
{\rtf1\ansi{\*\cxrev100}\cxdict{\*\cxsystem KittyCAT}
{\*\cxs KAT}cat
{\*\cxs KOU}cow
}
""".lstrip()
dic = rtfcre.loads(rtf)

To write the RTF dictionary:

# Writing to a file (make sure to open binary)
with open("dict.rtf", "wb") as file:
  dic.dump(file)

# Writing to a string
rtf = dic.dumps()

The dictionary object itself also supports the standard dict API:

dic["KAT"] = "cat"

"KAT" in dic  # True
dic["KAT"]  # "cat"

del dic["KAT"]

dic["TKOG"]  # KeyError
dic["TKOG"] = "dog"
dic["TKOG"]  # "dog"

as well as a reverse lookup API for mapping from translations to steno strokes:

dic.reverse_lookup("cat")  # ["KAT"]

To access comments:

dic.lookup("TKOG")  # ("dog", None)

dic.add_comment("TKOG", "TK means D")
dic.lookup("TKOG")  # ("dog", "TK means D")

dic.remove_comment("TKOG")

CLI

To convert an existing Plover JSON dictionary to RTF:

rtfcre path/to/input.json path/to/output.rtf

To convert an existing RTF dictionary back to Plover JSON:

rtfcre path/to/input.rtf path/to/output.json

Release files for rtfcre 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for rtfcre 2.0.1
File
rtfcre-2.0.1-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
rtfcre-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64 Details
rtfcre-2.0.1-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
rtfcre-2.0.1-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
rtfcre-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.24+ x86-64 Details
rtfcre-2.0.1-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
rtfcre-2.0.1-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details
rtfcre-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64 Details
rtfcre-2.0.1-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details
rtfcre-2.0.1-cp36-none-win_amd64.whl CPython 3.6 none Windows x86-64 Details
rtfcre-2.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.24+ x86-64 Details
rtfcre-2.0.1-cp36-cp36m-macosx_10_7_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 Details

Total release size: 11.0 MB

Release files / rtfcre-2.0.1-cp39-none-win_amd64.whl

Download URL rtfcre-2.0.1-cp39-none-win_amd64.whl
Size 571.2 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
f8070a9a9d016e4d318d3c31db30b09619d6f4548a98094c00a60f7ffc555f23
BLAKE2b-256 checksum
How to use checksums
0fe4b2e79264b29f0dc028d4949bd7435a4dc5b33253221d43dd055d055d06b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl
Size 1.5 MB
Tags CPython 3.9 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
3cc1984a643182808ea9d336eeee45e47f06ce04a08c12e54a50373a5a7d3587
BLAKE2b-256 checksum
How to use checksums
0b5b08bddd8c33ca2dae829c42b2af6dc7cdac3a6ec365ee8ba9e7cf1609b17f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp39-cp39-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.1-cp39-cp39-macosx_10_7_x86_64.whl
Size 710.7 kB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
ca0b3a1e43ac8e556565b15aaa034a2d8bd7826dfc4261be39cd0b48830a2e64
BLAKE2b-256 checksum
How to use checksums
21bfaaa6154b18f8361dfae81b8338e8233673d23e447d41dbbff4289524a6ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp38-none-win_amd64.whl

Download URL rtfcre-2.0.1-cp38-none-win_amd64.whl
Size 571.2 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b48bac7c69ed2de40d3919df268fc8a5d2cb95d6bb4a7564f258930d0b0529e5
BLAKE2b-256 checksum
How to use checksums
b5c77dcdaea412cf0996fe07b8b6bca71179a536347e509f386d94bff86aacc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl
Size 1.5 MB
Tags CPython 3.8 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
0fd2014458f9513d07b6ed50f0d7b1205b84833499117436020a49268fc42a17
BLAKE2b-256 checksum
How to use checksums
da5dc1967849d2aee4ed3ae7bbe000eb4fa02ce1496f9fec7c64689e48f1fe81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp38-cp38-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.1-cp38-cp38-macosx_10_7_x86_64.whl
Size 710.7 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
7dc5ecafeb96fc5e179f907c10cd8a2769726a860dae57ac18b74ee79c1a57e4
BLAKE2b-256 checksum
How to use checksums
39ee351c8bd5319664e18cae2b93a3bdef6adb314f9730e57a05cf3b73beca79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp37-none-win_amd64.whl

Download URL rtfcre-2.0.1-cp37-none-win_amd64.whl
Size 571.2 kB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
076eb7d5f528ba52161df64b73929a9f09d3a759bb3d8be4b36e629b915989c5
BLAKE2b-256 checksum
How to use checksums
dcb47a3b843b56324d4e48472482dd7fbf79c799975213e8193ed184768daca6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl
Size 1.5 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
87e6bcbe1d9b13b8b2dad297c2c00de769f909ce8a80f0712355792b09347d8c
BLAKE2b-256 checksum
How to use checksums
9b41fbcaee49428b072ab9419201e36936d73f408fb78fba969e964682bccde8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.1-cp37-cp37m-macosx_10_7_x86_64.whl
Size 710.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
fe2a790c9c4cd3e0bc10514a583660c33d78ed277161362b2a9a5438f09bcb44
BLAKE2b-256 checksum
How to use checksums
526570d1a43acd5e6c8595421e2239d2c90a04dc824947ce3779bba1a1d7649e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp36-none-win_amd64.whl

Download URL rtfcre-2.0.1-cp36-none-win_amd64.whl
Size 571.6 kB
Tags CPython 3.6 Windows x86-64
SHA-256 checksum
How to use checksums
79bf050f3ed7adba53143b9eabe2e8ef205e6e47b819de261845fde6c8c0501f
BLAKE2b-256 checksum
How to use checksums
52a0a23a23db12553ce68b6b099d96652f065249b082c4a155b8fb6c6951880e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl
Size 1.5 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
7c07d71aa82b8a9a2f041ba7e97986bd9d60aab61f6c7e1d2d9dcf96ab38edb4
BLAKE2b-256 checksum
How to use checksums
375a49f5e8198d56347bc8df31d99f506301fd68be76e2f2c8b0384b1694f3b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rtfcre-2.0.1-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.1-cp36-cp36m-macosx_10_7_x86_64.whl
Size 710.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
e56a9a8935af0c96cb3fc648bebec392a38c077358c17618f469b8ef25650a18
BLAKE2b-256 checksum
How to use checksums
e10b95e814654f0399a84aa267bbee871024fe06723c876953e70f814526882d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page