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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

rtfcre-1.2.0-cp39-cp39-macosx_10_7_x86_64.whl (706.0 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rtfcre-1.2.0-cp38-none-win_amd64.whl (595.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

rtfcre-1.2.0-cp38-cp38-macosx_10_7_x86_64.whl (706.0 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rtfcre-1.2.0-cp37-none-win_amd64.whl (595.0 kB view details)

Uploaded CPython 3.7 Windows x86-64

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

Uploaded CPython 3.7m

rtfcre-1.2.0-cp37-cp37m-macosx_10_7_x86_64.whl (706.0 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rtfcre-1.2.0-cp36-none-win_amd64.whl (595.2 kB view details)

Uploaded CPython 3.6 Windows x86-64

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

Uploaded CPython 3.6m

rtfcre-1.2.0-cp36-cp36m-macosx_10_7_x86_64.whl (706.0 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 595.0 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.2.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 66020eabb5b0b0d45f054be4ad7ceb83673de3521d53e3342647dc90254b469a
MD5 49b52bbe81b0653cc25179dcdb5b9a77
BLAKE2b-256 d82a149b0f373587cf1d0961adc7a09a120bf50c656d85ebe1dbb16986b72bf6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-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.2.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 435af29792aa0de1e83bcc7bd81f67ebcca889661d957c3f7ee751924561f102
MD5 e8579a606450291a267e5e1c4cb072da
BLAKE2b-256 3c89dc84d9e96f3e256bfc4f9c61a2a870efd8306d176e3e57e1162adb947d69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.0 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.2.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 88bfbb377fc0b19dc79d54135d5573887ad3d60ecee418a456ca165a5907dc52
MD5 65aec9c480f0773a138394af352d6e87
BLAKE2b-256 f15b8021356f8c50bfc848b9e6f9c7e0a2df64b4ad22ff25968b9621a00c28ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 595.0 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.2.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 724affb24f59c920d0baf24588f8a26b9ee4b59c1d291adb0ab8896c796d55a6
MD5 7601e133f3d3e6c7b4e4919bbf0fc38b
BLAKE2b-256 3ceedae11f4e80e7b25bf581c781849a2140ce51b14b60d64bbe5dd63b42f04c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-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.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 64b6ec2480abbd8c3a83aa8befc179acac04a7eba2470afb5c97deb0f1b691e5
MD5 8dacf588244197f1796da5cb3e7f1e80
BLAKE2b-256 7c077adbece491cd70c6398007e15cf2684a92104b42e6fac1a4908fdfcfa953

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.0 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.2.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 bde5c589ac055b37c946c8d691b8ae6596e861a213a8bbe010cc75535d5c1e44
MD5 adf4c60968f5b23deb29fadf82dd1083
BLAKE2b-256 b5db8ed70fab05b356c964da00ba046aa5b37fad4e9970dd59827e34c7912114

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 595.0 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.2.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 d403005da15191c61fbee284c6b9fba94ff78c41e5fca0e754624a874c0a50c8
MD5 f5f8f122a594c69583f195f106320352
BLAKE2b-256 4e78de304f4b0a1d92214699a6cb5dab29228829d6aab7f21956d5de9c43ed50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-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.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 aaf17ebbaedd7e5589f25512ba1826cf2b8b4dc4d7ca19ebff14d77745b5343f
MD5 0dfd074051691152142c46849dd4fc78
BLAKE2b-256 aea724f12ccafc504d5d11a312618d24b361043efd0b56da3646763980a07fcd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.0 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.2.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 3c93104cc0d1fae695d402aa2d9e15a827c2c4f987edeb12cc9e6771af15bef4
MD5 6abeff9160dfb3c6f583b598bbf6e2db
BLAKE2b-256 696d5ffa5fbbefe749830e363d500d36bbff241f148df52f9600379f42e05857

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 595.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.2.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 443c942b654560799d718012f8d84cda3e9c964ff05b53fba0f8b5b4519fb8f3
MD5 8e2fefacd7de021019e1580d289d2ae4
BLAKE2b-256 fc97952eabef9b6dd68b19825349fe88a89f2a3b2bc7cf2a4c3d3f3d6ba86224

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-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.2.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 24841d67aa968b2c906957818057b9dfd483d7fe1292199071d157e677f39ce4
MD5 34c5f98d98ffd63f1b371a93e3d2e85e
BLAKE2b-256 a5a10d557950631caf07a42466941903c24edf8d64ba1dbd93ea79423d50ea89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.2.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.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.2.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9cc48a13ad9945ac0b234e3d6ed0a4b88204301aec85ae4624a58790854e306e
MD5 3caa3f036b78839b6f54443710e6f860
BLAKE2b-256 d1c520a43a2b9c7598c35d5046a5286172d72d29c67dcc08f903564ac2c6f0b4

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