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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

rtfcre-1.0.5-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.5-cp38-none-win_amd64.whl (585.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

rtfcre-1.0.5-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.5-cp37-none-win_amd64.whl (585.1 kB view details)

Uploaded CPython 3.7 Windows x86-64

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

Uploaded CPython 3.7m

rtfcre-1.0.5-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.5-cp36-none-win_amd64.whl (585.3 kB view details)

Uploaded CPython 3.6 Windows x86-64

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

Uploaded CPython 3.6m

rtfcre-1.0.5-cp36-cp36m-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 165b15649cbcb7727e1c7c5c5fb273df2fe2a6c2438e7cc86a3104e6380b9f48
MD5 edf8d08edd9daefaa2e250eca7b91e02
BLAKE2b-256 7eb9b21c7429a0ff61305edae288b6341c0ce477017c854fbbfab381124773cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0166e6875be704d025d426850719b81382f0e49f2621350512769b3f25b86e00
MD5 563848fb9b85ddeb18a9f73c1e829a68
BLAKE2b-256 8881ede0999ff6050d2a34133ad70490a274da47d0142a3b6876f7feb6208caa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ba527058ef8d8982d4a1509f570bf2cb3801b72be0c1b2a8d8c15669d2f3e729
MD5 b69101d6e3dbe82c01699d680ae076d2
BLAKE2b-256 8bb3eef041600e648fea3c8b9d10918e33f85cd755d8fa54fe6dd73ab35a876f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 1d0c0106ade74578ea2861308afc362b044007fed1354c75945789dda471eb74
MD5 1e8b7b767a068205cb81b2be68896407
BLAKE2b-256 ed247f98ae1c7e5366e56de79c876611d34c5d907a137cf29045d4daf0737077

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2d0bc313931c37fa2f6e805126f4fd76d979547ffb27dcda05418394c1a69bcf
MD5 5761927f57344a87773104b5fec43a06
BLAKE2b-256 809622442c8fab1850c88d1f004b814bbc2375667f39e46c2bc0c13431ffbd9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 08e8532989165a94d22398978e15fbdff05d64dcc75390cdc5774ed483dcda4d
MD5 ab46c257dd9bf3ba2be8ac06dc9558b5
BLAKE2b-256 256dc35d75febdcdc94e65f3847736eeedb84c74c80e6b744dbc07e5d6997659

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 180d28aec2337b420171c79f1fa938e5dc40f6bf9bc1ed20e445515b103c2a64
MD5 f59443aadc0336ca6cc4734f47a8b27d
BLAKE2b-256 c1add9849b0e9e7e9e2d5c72b581a65cc64f835874da25f8d3eb6e407bbb7188

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 93bec30362c4e9f03d29564ed9a6bfd2dab1f177368dacff44811dc4b78e3154
MD5 2365f894e56ada24996c12decbc5464d
BLAKE2b-256 0b6f282b2aae2b290130e049ee9c6f54d6031c32dba8476e1fa021a1ab337e71

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f0f3dd652fc67ff8289e770bf2e870083eed0d3662bfa8d45ff11738d7f4a6d7
MD5 fcd08fac877641d3e262da69181d03f9
BLAKE2b-256 6b29ec709b326cd078af3263009ea3d48eefa077dbe771b2ce30848a1c8985f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 585.3 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.5-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 cd0e5a3b44834895202c65a24584293811a3ff3aafffabfea2aac8a4662c5589
MD5 ab0b0f070fba6c6ff164b98931bd8a3d
BLAKE2b-256 b54a9a85fd462c33642d637eb23b76d26a45b36991c6b5b9b07ff1dc6741ae27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-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.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0b459006b7c3e8bd800670d5283a6c3b2d75e15b8af64308e2a02fa7311880f1
MD5 281a606bc91d54ed1cb18923eb3ed11d
BLAKE2b-256 addf38ef7fa77a22fc8d4b0ccaec8414374e0f3952be303e0d1863ed4f617612

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.5-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.9 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.5-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9bbaf134a57e621d2a3ac93284466bd45db31019069cb3a3dfc7c5cea56245f1
MD5 9bc3a7a746f276c675a47d7122ba5c0b
BLAKE2b-256 3e088c1df35c77245df0f61ad6739af44599f8e75912d45ccd599e151d963786

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