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

Uploaded CPython 3.9 Windows x86-64

rtfcre-1.3.0-cp39-cp39-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

rtfcre-1.3.0-cp39-cp39-macosx_10_7_x86_64.whl (719.5 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rtfcre-1.3.0-cp38-none-win_amd64.whl (586.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

rtfcre-1.3.0-cp38-cp38-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

rtfcre-1.3.0-cp38-cp38-macosx_10_7_x86_64.whl (719.5 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rtfcre-1.3.0-cp37-none-win_amd64.whl (586.1 kB view details)

Uploaded CPython 3.7 Windows x86-64

rtfcre-1.3.0-cp37-cp37m-manylinux2010_x86_64.whl (1.5 MB view details)

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

rtfcre-1.3.0-cp37-cp37m-macosx_10_7_x86_64.whl (719.4 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rtfcre-1.3.0-cp36-none-win_amd64.whl (586.3 kB view details)

Uploaded CPython 3.6 Windows x86-64

rtfcre-1.3.0-cp36-cp36m-manylinux2010_x86_64.whl (1.5 MB view details)

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

rtfcre-1.3.0-cp36-cp36m-macosx_10_7_x86_64.whl (719.9 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 586.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 d8beff35909e097312a176dc17ae43522169c065af0a7b0ce771780229528cd9
MD5 cfd492e7572efc992fe4af00d51eb39c
BLAKE2b-256 6e5110f88485ce04f0aeda8ccf978b6cf4803119d2546497aabe2fb6f3ba890b

See more details on using hashes here.

File details

Details for the file rtfcre-1.3.0-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.3.0-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3e3ad4af7fc2fc8e0440d03703da765d38229fb78713d6d2a386d3a13b212247
MD5 8a875bb814a27f0609e422f566b65a44
BLAKE2b-256 b4144a170f2dba69d6a8b7cd6ae83a99197e82395d9fa059ee1c2798a6a35a1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 719.5 kB
  • Tags: CPython 3.9, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ee46f21da544e8e15a87d99ea26a2292667537e2c7ae2b28cc26a88f5af5da74
MD5 6f567c7629da2ebb37efa8f23d5d9d03
BLAKE2b-256 5a81065cb134e905bad8ecb8fd36fa45b74266ed671352c8760be3f4e4bab9e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 586.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 fcf8c74b5df3eb591d612778b5ec1d200b6d97aad957fbd5b6311c0697761231
MD5 ded2853dcae0b9f3eafb43395d039ed5
BLAKE2b-256 491f9dfb65115f4a629d014d9fb58d0297f8ca21e9b906f32c0e9fd58aab4564

See more details on using hashes here.

File details

Details for the file rtfcre-1.3.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.3.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0a877dccca8943201c7d88bc4f9792a542b138ba2c2ceeade4177c2da05ce7d5
MD5 f77e9f95eb22d0a66e589eb3325d18ec
BLAKE2b-256 ee132b8477680581cb54506843e708d91a7d07de06ca5d895f962942ab0b0752

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 719.5 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 70e6fdacd938cc55e7ceddfda271fba67d0f20b43ee1e18074357a11cafe115b
MD5 7e30d95bcc4e27df8894151360b87cd0
BLAKE2b-256 fec47f5c537430631b371df0356d3d5467f44c5b9687bb922f5bff4245c87c0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 586.1 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 b65a1d7cb1461d23c5f1e610b7c41a7598bd9b9db975189007013ee4ec85afaf
MD5 821d6f6a37b5cc9ebec1f17df5087b72
BLAKE2b-256 880f2d5a8687a9f851410145e130a11d70a3a36ac6208d336faa20c3817de47a

See more details on using hashes here.

File details

Details for the file rtfcre-1.3.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.3.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 414fe8de77c375f0bba2846318a718013a9884865142c9cf9b26d293b9933bc2
MD5 1ebae6e1d4fc2ab182f1ac4b88900229
BLAKE2b-256 3b1e7ccc55efd30c25fe773366007b73da4e046fff82643bdb6728b35af7d00c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 719.4 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7dce4ac0391a59b69d5bb607eaa9edc3c79e79002e882d8aa2858eb298447562
MD5 f20c41d17861d5b1fc1e0afa01e022c3
BLAKE2b-256 7398dfb19af965b371f4313a782deff6370eed6a37af11fee95f5dcc4df341cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 586.3 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 4c1d7e1c4d41eda2e98801d0b72a954c7f2309d78df3215699adfbe17309857e
MD5 df7faba45b6b6dceb035b3b910142fea
BLAKE2b-256 9fa5fabcfdcee33029ae76835f55c3b8d65f9bf872a7ff786c87250856d07ed4

See more details on using hashes here.

File details

Details for the file rtfcre-1.3.0-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rtfcre-1.3.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 57394053550ad135e71cbd708f9980c5bc7e8738719dc4220d6edfac7a1cdd8d
MD5 ee86e7d263eb65d748b873767bf33175
BLAKE2b-256 cef1dbc7805792aa77d86447ccd0e8df223729529bb5ee4be6af009ab23a7d2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.3.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 719.9 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for rtfcre-1.3.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7df5e2df9b29a17b369ae95f46f301a9b6fe8404c0d0448975117ce02bc25e1d
MD5 133c10016eb21c3d3e76f11aea26c66f
BLAKE2b-256 94641b5bd8b78c808ce4c200dd4bf891e6c6075476cb389588d7b8d893b6c433

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