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-2.0.0_dev4-cp39-none-win_amd64.whl (569.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

rtfcre-2.0.0_dev4-cp39-cp39-manylinux_2_24_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

rtfcre-2.0.0_dev4-cp39-cp39-macosx_10_7_x86_64.whl (706.8 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rtfcre-2.0.0_dev4-cp38-none-win_amd64.whl (569.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

rtfcre-2.0.0_dev4-cp38-cp38-manylinux_2_24_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

rtfcre-2.0.0_dev4-cp38-cp38-macosx_10_7_x86_64.whl (706.8 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rtfcre-2.0.0_dev4-cp37-none-win_amd64.whl (569.7 kB view details)

Uploaded CPython 3.7 Windows x86-64

rtfcre-2.0.0_dev4-cp37-cp37m-manylinux_2_24_x86_64.whl (1.4 MB view details)

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

rtfcre-2.0.0_dev4-cp37-cp37m-macosx_10_7_x86_64.whl (706.8 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rtfcre-2.0.0_dev4-cp36-none-win_amd64.whl (570.2 kB view details)

Uploaded CPython 3.6 Windows x86-64

rtfcre-2.0.0_dev4-cp36-cp36m-manylinux_2_24_x86_64.whl (1.4 MB view details)

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

rtfcre-2.0.0_dev4-cp36-cp36m-macosx_10_7_x86_64.whl (706.9 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

Details for the file rtfcre-2.0.0_dev4-cp39-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 569.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 10d2d7e01cde593b3243bc61796a4e538710a94cdee015057a4c9f5fd304d133
MD5 06fc90558a25288bd5cf3df2ce82307c
BLAKE2b-256 1fa056eaf758e0390c6940cb66ed95b6c818ff60a38ac3ad1335c63115850dc7

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 7acbae45a8a8f1adcd9a8520308232542a22d0161f45f8cdb117b4f3d92a8999
MD5 ee7cec25c4e83882cb66419235c43812
BLAKE2b-256 f84bf86b617f37a2827ddbef994d0441d5885c9a34845559410bcac4c533b599

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.8 kB
  • Tags: CPython 3.9, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 96b2f56f5bb0026169a83d9e9afef749c0ba06f9bb32adeaf16729c5a810e453
MD5 c8956c1d2a0c9717d81951aee679e092
BLAKE2b-256 2124d6da82ca1efd00fe7da2fdda3f0082e461d98eed4c5a168e965e9a6e1801

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp38-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 569.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 d23cbb5cad3a9f720d43425ba4807b2093e76ec9486e9f37620fe7a4481f1a46
MD5 b6d55ffb193109a274231c33e7e207c4
BLAKE2b-256 cb08d37804a66db4a84c3e4daae8cda9a5a4fb21104f41a5c6fd546c221175a6

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 232bfdf09922bf3782dc69c458cd0966288917e225ad20583569a6d3818c86f4
MD5 ac3596f945f00a64f128d2216ddd12f9
BLAKE2b-256 c56d2fae889addebc95cca74e9e84a8d615170d3286670dab2660e17e7593991

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.8 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 158037003ec6b76c56d3c128bc59e393437a16e742948b6146f1ed1772862274
MD5 c0e731c4a9c1d70158879ea38ca34749
BLAKE2b-256 6811681a0a7485eb3a54fca36f13441b5963f923669c1b65208a1d1cbde3ed19

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp37-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 569.7 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 498dcbe76502e956ca7e9a5ec2f5f42692ff2f1b7f9fb459f58270cbe407d5c3
MD5 86318750cd95513431bb842f2655a330
BLAKE2b-256 bdec956bf89b4debf44ed1db6bfcf937f655653e487607622dd1a4946e617ffe

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 8f9ec94396a9baadaabd80bef4ed0729fe8f6a0ac740a7ce6081211adb9ccce0
MD5 ed1399151d56a82590ca763f9ad4dcdb
BLAKE2b-256 6b8e748cc2b013c48cf254e7daa887a6e70ee53396ea097042278c1e7e127404

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.8 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 45aeb02472ab56273daf6227c8d11c3455e8b4fa51b142613f9aa34b9837785a
MD5 5949d98e28497660fea0cf148ae64d60
BLAKE2b-256 3c5362f73ae4b6a58e85e1704595388e579e3a3af1643650408ca0a59666065e

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp36-none-win_amd64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 570.2 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 a24306db89b75dbad187bf0394190e17291daa3d76433f6cdc2e91800fb6d339
MD5 579f56ad5b7c0b4b9afa565ae9493557
BLAKE2b-256 dbe0f2ffcba6b96f914e1f63c7bb098c4e137176c69e282c4da9a1cad17dd75b

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp36-cp36m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e3a84b9c13542847a154b1e7a77b7dd26781ad05158eb8efe83da1e1446808fe
MD5 8c21fe2d25f1a0db78e401723c796547
BLAKE2b-256 7852334edb5d99142b4c77c892d33eb7fd49ed775145edf7f3c46be696379b72

See more details on using hashes here.

File details

Details for the file rtfcre-2.0.0_dev4-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: rtfcre-2.0.0_dev4-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 706.9 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for rtfcre-2.0.0_dev4-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 fdfdd2feb62f942ef4aaf087cd41d15bf36b982a19e423b82a98f5d38fb4ce27
MD5 a5ab33fe46a61d1907b815037d389cf2
BLAKE2b-256 d5cccefd3a393c2a85a824a52fe7f41bf948f72796c8c8e28f5eb8c482271a71

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