Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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

Metadata

Release files for rtfcre 2.0.0_dev1

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.0_dev1
File
rtfcre-2.0.0_dev1-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
rtfcre-2.0.0_dev1-cp39-cp39-manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64 Details
rtfcre-2.0.0_dev1-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
rtfcre-2.0.0_dev1-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
rtfcre-2.0.0_dev1-cp38-cp38-manylinux_2_24_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.24+ x86-64 Details
rtfcre-2.0.0_dev1-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
rtfcre-2.0.0_dev1-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details
rtfcre-2.0.0_dev1-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.0_dev1-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details
rtfcre-2.0.0_dev1-cp36-none-win_amd64.whl CPython 3.6 none Windows x86-64 Details
rtfcre-2.0.0_dev1-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.0_dev1-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.1 MB

Release files / rtfcre-2.0.0_dev1-cp39-none-win_amd64.whl

Download URL rtfcre-2.0.0_dev1-cp39-none-win_amd64.whl
Size 585.2 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
927cdc36841b2c49bf87fa227b5a836cebbea13b7fc47bbbeea1c137685ac0cb
BLAKE2b-256 checksum
How to use checksums
2c7dcc72c2d43c4cfe10e8f2307f22b8b55bb5b35e9cc955955d6f03bd31bb4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp39-cp39-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.0_dev1-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
fa9d2b8eee1affbec16b6e3782e8b53686c7069939eda84421acdd8a3466f19f
BLAKE2b-256 checksum
How to use checksums
01b760a63a7a4dcd45b2b3bb2ed9534717ff6911ed477a3bb794815e6a1f14b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp39-cp39-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.0_dev1-cp39-cp39-macosx_10_7_x86_64.whl
Size 726.0 kB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
6dd3560104791009f2eb5909c9edebd97110c1e8ba10b3dcf7333313f9dff1fa
BLAKE2b-256 checksum
How to use checksums
3f5cf25ff044fdd662c6478f955be0135514e4f1e412b7db12a1444465d7c214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp38-none-win_amd64.whl

Download URL rtfcre-2.0.0_dev1-cp38-none-win_amd64.whl
Size 585.2 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
93724df1b525373695036c53f7150c7921b0a21d8d399d3e7d74699ee47429a3
BLAKE2b-256 checksum
How to use checksums
7b3c446c032e13ae7d113d9b0acc02e43e4e5fb387109e2eb873a9c936ba6cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp38-cp38-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.0_dev1-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
f906d1c0c6134249364216a504efc96cf767af57c8f960665324d6f2895876ae
BLAKE2b-256 checksum
How to use checksums
bbf7f6bf4d581aaee8a3389e4e917f43293827149e75ab465f61c0f7492543f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp38-cp38-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.0_dev1-cp38-cp38-macosx_10_7_x86_64.whl
Size 726.0 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
4768c2282315d2c6c332bda8909d1249db87af2ece273a320e6ea1178c4da39f
BLAKE2b-256 checksum
How to use checksums
5d391cc207f409e994997b064397ec9a1f272c7c14741dfdec0b38a2fefc9be9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp37-none-win_amd64.whl

Download URL rtfcre-2.0.0_dev1-cp37-none-win_amd64.whl
Size 585.2 kB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
c16d4109ee2a69e561a736503a3556ebf7fee93f0cecfddab48c3e37bcc5c257
BLAKE2b-256 checksum
How to use checksums
61d59a020c2682ae28cccc00d834d500379f66766e1eb75a550d726d6efc9acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp37-cp37m-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.0_dev1-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
23e556f81e09b443c487bdca934700340ef913258bfe9fcaf75439f8a838019b
BLAKE2b-256 checksum
How to use checksums
2f39cc46ccb64da2bd176db4b9a21a3eeaede3bc56665a6489f42189b5978a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.0_dev1-cp37-cp37m-macosx_10_7_x86_64.whl
Size 726.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
cab28a349945aed0437f3e76d076e2103083c6f2b89a5f11b99efde8287ccc83
BLAKE2b-256 checksum
How to use checksums
c0b50bf6b0dd707a98aeeccbabc39a8b4098c9b76f4e037346c140eddef623d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp36-none-win_amd64.whl

Download URL rtfcre-2.0.0_dev1-cp36-none-win_amd64.whl
Size 585.6 kB
Tags CPython 3.6 Windows x86-64
SHA-256 checksum
How to use checksums
dee7e8e294b8371c0fb8661648bbd862b7cc310b9cf7c647b9d618c073cd1fbc
BLAKE2b-256 checksum
How to use checksums
7c8dcacb341b72c50b48485d967f00853bf30a524e83ed095e4159f1907c031a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp36-cp36m-manylinux_2_24_x86_64.whl

Download URL rtfcre-2.0.0_dev1-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
a832beb81aebebc46dfdd450abe1a1d2ddc4f41a6c7b01d1c62e07ac708d7f7f
BLAKE2b-256 checksum
How to use checksums
28b9cce6182d0ce0c0a9750b22fab7e26a0c6a52efe6c26254b8e530eb12c84a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / rtfcre-2.0.0_dev1-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL rtfcre-2.0.0_dev1-cp36-cp36m-macosx_10_7_x86_64.whl
Size 726.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
c9fcd1f88afe9aae27d7dcd48ed58e2131125c8d20f4e24f6d72d8f1a5477890
BLAKE2b-256 checksum
How to use checksums
b838ce9d6642e809576535cfae5ff7f4b16363744300cc0b610efc6c1d256fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
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