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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

rtfcre-1.0.3-cp39-cp39-macosx_10_7_x86_64.whl (695.8 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

rtfcre-1.0.3-cp38-cp38-macosx_10_7_x86_64.whl (695.8 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

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

Uploaded CPython 3.7 Windows x86-64

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

Uploaded CPython 3.7m

rtfcre-1.0.3-cp37-cp37m-macosx_10_7_x86_64.whl (695.8 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rtfcre-1.0.3-cp36-none-win_amd64.whl (585.3 kB view details)

Uploaded CPython 3.6 Windows x86-64

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

Uploaded CPython 3.6m

rtfcre-1.0.3-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.3-cp39-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 12b60e9e6bcb726e3c6a03902d29ec6a91470f1995716186ff36454e7bcbaad7
MD5 a89f54ed79b0ab1cd7860ba4149a1a12
BLAKE2b-256 5eca2620e595e7eb3ed26c509a12377b89440dabc9cec20ed26cf254f22f1ddf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bb15177e211cd4e8ab2d42906ce8278466400f758943dcccf78d3f42fcf78976
MD5 aa79fe0188abffaa8161a77f772988e5
BLAKE2b-256 034d2a8e401ecb384b6832c6e8864dd9cf859f84d5f93f4a02b13d71aaa14021

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.8 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.3-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7d99411be597bfbfba0d7cd43f1a348184a32ef915d8067d4e0b7799b5c9fc87
MD5 764694888f8aedfeb55996555a853d13
BLAKE2b-256 6f8b717ea82f716771d3dcdc5078bbc1f3ef0018ea8f40598b542164f4747700

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 fe72038d6cc004771d79a0893b24570614dcadf5bad3d1eceb503a983faec1e9
MD5 463752304467f1b28233c0eb05ccf64b
BLAKE2b-256 75233fccc2734198ef27598040fa928dcbbb1adcdbedb8d4345ea540803570b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0a9cd26a3151baae52fda59d679a2603241cd5d87700a3a0cb446612ba0736fd
MD5 377d805eb5bde6f11617e9ffa141da55
BLAKE2b-256 3cc1c16d30d77d1f49d9f2e51c53938f55bdaf1a11c330b775bafa8e44ab86ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.8 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.3-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9e80974a3c81dd8a5c717821be09b5f24d3d9d24cf818d054bc2d1db76e58481
MD5 59e2829cb9bfdc387b182495e302b3ed
BLAKE2b-256 0a5f5e44b09977bc9bd5b9c5ec0b133627b78e92f16540be979b1a7ad91ef148

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 776f87dd24b58d1bbe679997bda804f150826ad3cec9908329f5e2d4a4e3ed70
MD5 e3ac1b7f08d9b8fead1c5330142c4186
BLAKE2b-256 4c6e34e3ed028e11e551f3c89fb3627606ea3aa837016d93cec254f02c83eff4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6d7cc304ff7431b82df4591a820fa681b220334f2cfc593136928d6b04810fa7
MD5 49f3a446986755675eacbe80ce4511f2
BLAKE2b-256 acec8251f3ad9d9b977074df963a6a0d4004e77d62446505d066d7c38a4d1abf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 695.8 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.3-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 52bf346a6fab7f2f2bfb994c6e4ecbe2655fe632f64374047661be06132d3de5
MD5 be2d3f1efb5e5ef01e55ef1301614897
BLAKE2b-256 01159621ba8994e2c37e7cef296a5aae0bb20d5d414bfda54437d70adbe5d889

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 d8fe5a01defb5ed561d9bd1dfedf6403f551cc1c4b2a11b18401e1ff197d6e4f
MD5 a874e3eeb5d63dcd9c69571d68d9dd8f
BLAKE2b-256 152c5d88a1276d2f95edd14595d7cf665706e8dafa32fbab251ed9e65bb3e697

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 452bbd4d5187920b7f7db620bed4508a5003a8e517192021db285470ae851199
MD5 ac068058279bc180f0a261d1066ed306
BLAKE2b-256 c534da5f1f5d7ce03f47b8997d060f8500ca0cf5ee0f4ad1e7aab0ce502d8355

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.0.3-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.3-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b1a6248f00cdd6a748afd98feba7bcea90d748e3e69b4d7ef1317d26d4dc20fa
MD5 e048e7e9e633c3fca18735b9a27ffbb1
BLAKE2b-256 ce6e43591298089a3d4cd7f12b1448d06a21e7027aba4e2401349ca5b4c7ed4e

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