Skip to main content

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

Project description

rtfcre

pypi python build

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-1.0.6-cp39-none-win_amd64.whl (585.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

rtfcre-1.0.6-cp39-cp39-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9

rtfcre-1.0.6-cp39-cp39-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rtfcre-1.0.6-cp38-none-win_amd64.whl (585.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

rtfcre-1.0.6-cp38-cp38-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8

rtfcre-1.0.6-cp38-cp38-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rtfcre-1.0.6-cp37-none-win_amd64.whl (585.1 kB view details)

Uploaded CPython 3.7 Windows x86-64

rtfcre-1.0.6-cp37-cp37m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m

rtfcre-1.0.6-cp37-cp37m-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rtfcre-1.0.6-cp36-none-win_amd64.whl (585.2 kB view details)

Uploaded CPython 3.6 Windows x86-64

rtfcre-1.0.6-cp36-cp36m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.6m

rtfcre-1.0.6-cp36-cp36m-macosx_10_7_x86_64.whl (696.0 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 585.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 1e40b7986f209c480233106be9d06c799b958114b5c95528c6484cb01edba32c
MD5 674054f564a6293d8baed64c0701beeb
BLAKE2b-256 93e496a639e54fe6338edc3b7ef6eeeab82c29e55c868b26edd18fbe29cfe302

See more details on using hashes here.

File details

Details for the file rtfcre-1.0.6-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.0.6-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 46f986c78b56e46ef090c35a5026aa3008df6532d66d8d0160e758ccfa2aa31c
MD5 92d249aa071ae251a79747188337a1b9
BLAKE2b-256 ab4d207d5756fc437c3ac6ea35682066819a2985ef9ade9a97d8dd524a6c1c1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.9 kB
  • Tags: CPython 3.9, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f9f95d257d97cf2b9fd0e8f3e3d03a832dab978b97fb3ce2e801579f94e7122d
MD5 725ad3a88e3ce32c1b046f74f4610f42
BLAKE2b-256 af042904d127aafc678c18985c936d16d71bef5c68f6094bff1d8d40a0da7879

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 585.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 8b45d26592c8f628b236a534c74978731e17a550abd76bc975d752265567ab57
MD5 843ab526b10450062c8b162ed139908e
BLAKE2b-256 09187edbfe2669c7c987cd1553f7a377584fd81ea9c7f2bde5ce56841995c4c2

See more details on using hashes here.

File details

Details for the file rtfcre-1.0.6-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.0.6-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4db55c8a7c34e6143281550a576cb634ef8d0daf8242235882970f02de23c785
MD5 e2ccd476837587e0ccb7e53ab841a0f9
BLAKE2b-256 2a34554a66c26885a740c96a18e4092017319dc48b6871abdc324fd409deb762

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.9 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 72ece999b3fcd63403757784b321696ef7945acf445d023a530f7b13448aa0a1
MD5 3fe80f2b9037fdbcd6669c2bedca2f4e
BLAKE2b-256 92ea1cea15b7d3d455c6663fd1a730b5528e1807c0fe7b65681ae9b111bda4f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 585.1 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 18f69df1a6df40766221db43265670be2e047a5317ee7ba5ae9760facd4b6cee
MD5 0b133218a5d493e2e569a12be0ed08be
BLAKE2b-256 c23f3a97b430af73eceece2f28d8b0bea4a2f90dd623b73b3919fd55039104e9

See more details on using hashes here.

File details

Details for the file rtfcre-1.0.6-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.0.6-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2daca973505630e9d4d45d79b01b7f8c749d1f741a5a6c73be2153eafc38b63b
MD5 85218423ab19b0ed590ea7f7a0054311
BLAKE2b-256 81d928f9fc95aa08cbcdcbcae7e59c68965554dedc461e7f70a16f5fc4c6adf4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.9 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 487ec09800fbdae572d232913e2c5ac4d208f3e8fbff7b06c4ef7d092ed973dd
MD5 a0cff820d044d00727b3dc10e7332e6a
BLAKE2b-256 948f5ddcf8379fa3998280c53758f8a6fea115bef73c4975781148cf2784d6dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 585.2 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 299e15769608733445e4c27970dd26bb7b44de2a0f4d912c92d56ca4201881a8
MD5 9ce089d77478ed377305b2723227ac96
BLAKE2b-256 88dfde4b8141a97caf88e0102641a1ff8c17c54cdb390c4083c8956606a423c4

See more details on using hashes here.

File details

Details for the file rtfcre-1.0.6-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.0.6-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4fe194c44be6bb54a87c10f7851243649e31171cf3ccc2c26dbac64cca3dd840
MD5 52d1e49831ecd98eb14eb808a760d400
BLAKE2b-256 6b2264519e59f270c9a83600876bf9694c8ba694cbdf7cc3e213e5bcaf664f9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.6-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 696.0 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7

File hashes

Hashes for rtfcre-1.0.6-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 393ca9f925f62fa4aa4e1ef57995bc52c49692b074d66ab6abd69cacca2d20c3
MD5 8b89a6f6891d1c9ab808d280878974a5
BLAKE2b-256 d069cecb1ce879b90bb6c071bbb685d732f00a85ecbaa497df7712366ab62a5d

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