Skip to main content

Python library for Rich Text Format with Court Reporting Extensions (RTF/CRE) dictionaries

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

rtfcre-2.0.0-cp39-none-win_amd64.whl (571.2 kB view details)

Uploaded CPython 3.9 Windows x86-64

rtfcre-2.0.0-cp39-cp39-manylinux_2_24_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

rtfcre-2.0.0-cp39-cp39-macosx_10_7_x86_64.whl (710.8 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rtfcre-2.0.0-cp38-none-win_amd64.whl (571.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

rtfcre-2.0.0-cp38-cp38-manylinux_2_24_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

rtfcre-2.0.0-cp38-cp38-macosx_10_7_x86_64.whl (710.8 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rtfcre-2.0.0-cp37-none-win_amd64.whl (571.1 kB view details)

Uploaded CPython 3.7 Windows x86-64

rtfcre-2.0.0-cp37-cp37m-manylinux_2_24_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.24+ x86-64

rtfcre-2.0.0-cp37-cp37m-macosx_10_7_x86_64.whl (710.8 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rtfcre-2.0.0-cp36-none-win_amd64.whl (571.6 kB view details)

Uploaded CPython 3.6 Windows x86-64

rtfcre-2.0.0-cp36-cp36m-manylinux_2_24_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.24+ x86-64

rtfcre-2.0.0-cp36-cp36m-macosx_10_7_x86_64.whl (710.8 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

Details for the file rtfcre-2.0.0-cp39-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 571.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 9730cd53a0150258fd5782814f4ea69ffdf709c5585baf6a96f84f9b9ba1a671
MD5 488ea3c9b9fab179aca67800fbe174a9
BLAKE2b-256 003777ee6e6ea988e6ef537601040cc13e2aa0855243dd3ba3ef092da1cb6c6f

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 1a7626024e31f84dbfa7e318097d95a93ff99ded63c36bc6d8ab906eaba74652
MD5 d804a9c8bb1d29733e74a61ea581650f
BLAKE2b-256 5d43ad3ea54238894781c91fced0bc95e7c1983d46ebb79bc08c2942ac6ba86e

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 710.8 kB
  • Tags: CPython 3.9, macOS 10.7+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 3f66a65536be83e56c4995519d66ea01298fb7369c1e3db5cdc73a84aee66883
MD5 8a6e70bd27aa02f5cdcbd958e9e8f9e9
BLAKE2b-256 107249dc3cc308e8f166ecab3485a15ab69c80d551a22fa7ae1fe68b556eb836

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp38-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 571.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 944b30c893f9a910c4aa0160d0691a327fedc1ee8940e5e42082ac96dd55138e
MD5 54e64f8d376e6e47b7a86422bb710373
BLAKE2b-256 34f8be6e9e5d8d9655f8742fa5044f4c656913f7665a23ab7e94726e603d64ac

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e88f0cca15cb44a4caf04b85395d338e6b197302c3c2dde8525d1269eb1804f6
MD5 fe54c47214589fde6e0e21e224693560
BLAKE2b-256 5b81ac829f3ae3dc8793fd9ef8052517be408886f0e76153b67c7756b273d675

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 710.8 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5fd694fdddca41a499b33427a665bf67d6ccf80b3b402902b7c0dcef61a0a450
MD5 62f6939474c1f77860b38b4e3158c2f0
BLAKE2b-256 2c07fc582dd0b07bfb88f22e3adb189aea52603bdff9d643a35d942410c26da2

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp37-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 571.1 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 709d1556196faf500132f45a7496dcd06a54d0cfef16ee77497abc8fc456cf1e
MD5 71d687160bce25c05038be489f363dd2
BLAKE2b-256 d095949ccff85a8dbbe88609ee37b8d64c1b8f663073af9ef0de705d1a1953d5

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 53cc498cfb44c9411481d1f97150d983716f1c52b7d6a034fb5a7f839665e23d
MD5 62e6c5a01ba36e65119bd14a1b945ce7
BLAKE2b-256 a6c75f0292205547418774d4c85ed1f44cdb1b417a7e7477ff7e29a2b295a837

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 710.8 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ddda1bab39749ae7f0aa3d5aa270d88e4e5603ecbf6e7f7a8fb3599865b1b3a1
MD5 210c40b777ac36bbb5a9c367d1059e02
BLAKE2b-256 33f8015490aba8599b7abbeedd1f42f1750923f0e17d950c235ce9ce424bd2e1

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp36-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 571.6 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 02d56766d12ab8d0dbac754c285e29bba0903089fabc46112aec245119778fea
MD5 c4d0d42832551dc3ce3851da433a4eaa
BLAKE2b-256 12de9e57faec2653ce635c5fe587b854ddb236cae5b3e4e1e8cfe8d71493d28f

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp36-cp36m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 f8a842dc30159440b335d10359979ab39d283a1de5c3b9d4996e0c289b506ad1
MD5 c5823c009376934d9f0cf5323f88c72e
BLAKE2b-256 ff239b04e0ba96b08e6119c2e0a818da2702d4e47c34936e8d10112a3abd659e

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 710.8 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using 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

File hashes

Hashes for rtfcre-2.0.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 052f837dcf1628b4eb7755397cbe95dd0a00c0d50ade44b2329d96a7f123fc15
MD5 5d714e75a32261880a3c26967ceded0f
BLAKE2b-256 2dfd6ae8d1957e7d1bf9424596bb9991cd3b2c4ea7a0e1d5aa3ba5e2323e0de8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page