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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

rtfcre-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rtfcre-1.1.0-cp38-none-win_amd64.whl (585.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

rtfcre-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

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

Uploaded CPython 3.7 Windows x86-64

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

Uploaded CPython 3.7m

rtfcre-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl (695.9 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

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

Uploaded CPython 3.6 Windows x86-64

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

Uploaded CPython 3.6m

rtfcre-1.1.0-cp36-cp36m-macosx_10_7_x86_64.whl (696.0 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 585.2 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.1.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 52f1ef69f5aa2aa9d63898c78641c4d9107ca7a4595cef8c7819f839996348fd
MD5 d1c97a8b1c89e20e3beb0099a03e8f93
BLAKE2b-256 985cf17c6762039615e75f664b267a09147bccb0a59632f2402ce41b2b3d3be7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.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.1.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ad606aa83c15eeab31b45be394c3cabacb409ec58a93f516e1defd2ef47a8f37
MD5 5aec258b6179b564dd0df3e9fc5c1024
BLAKE2b-256 e08f2898e01faadd23d1fa86959ab93cb9170b1f526748d292c497bf84565104

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-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.1.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ae05a7d028f7d814cfa24090234d489d90d67462fd5b91f4f8b690064b2bc2e4
MD5 78ef1d170adf9025d597f18883d06983
BLAKE2b-256 c6ce8ef2618a730095c0868482966ee094f6e50d42468a7e0a8cf82b0c521c37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 585.2 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.1.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 9f19e6132ea0a7bbab23a68f32fd377927645fea821ae5d0814b88495e079d64
MD5 662aab67f2b34375ecff1fa334648dba
BLAKE2b-256 c234eb56435c03cd5a3f219427cb01a002145cf3878d091819502e0859da7c5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.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.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 696c83abb55caa22c7d906d115d9dc79c461f342781587dce5857ae4cb4ac6e3
MD5 c79b1af982846ee385262e0776e72425
BLAKE2b-256 396880b4e2cc9adb0682e7a02c0af9594d153c12088cb46d3a44146ac3f840ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-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.1.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f85e7ce2de199eba49014cae3f7f56ea71f16aeea760ea484c89c4bb30af1876
MD5 6477545a791fe061f1d871ac42ef1887
BLAKE2b-256 3aec8dd516454c65463c09c7006ecd304225f02b699b9bfa81f34b8024a6349c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-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.1.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 1caf95fd4816f1293379355b8535232802f0ca9719ed42526a18e82a0ba9906a
MD5 bfc9b0a99701057aa60e8de6e94eb7c1
BLAKE2b-256 d3980066586bc10b330274cece37d4185353d3a6039cd1b1318fa062e9e2cb96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.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.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 762391d45acdb3f64580dd76fa93189748d59401960d17adebed722c8bb9bc91
MD5 36a1d62d91df6dd3f4ea12763e29a22e
BLAKE2b-256 4da0f9b77ab962cd87546700495b1d5115f10022ca83e9d73d86a1b28ae8d9bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-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.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f80027fb3d2e483fe1560722bb20e509c9692141c0e870ce962caed18d75ff8b
MD5 6486605786b2d1f902aa6034ea02938b
BLAKE2b-256 f073290f205bc9090a86b7c4d37bba626de3b958856f9cbd2acd344ac81277db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-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.1.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 62290f6653944216301884c394332241e3d69023ce09c5f2a4b5effccd6c9b70
MD5 b3f94ba6e950bf80b74badba2b44146b
BLAKE2b-256 d597fdcc08be5aac51eedf717d06c93ed40743b60d911878a72af4323a4077a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.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.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cf738ce58c21976e98b10e66e24e7683757243a78338d5fb4c0cf7b3515a1eb1
MD5 47d6e441bef10ea4b6331919cf09e7bd
BLAKE2b-256 531a52c50ba27a488527ff17ba7a0ec9ad3d54f1cf8556bf3bfa4a2e532611b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtfcre-1.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 696.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.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9ea2eb531807c84f78e0f604a3a2f0e852f4e329b9133be571297c2d803bc375
MD5 7cde5f24852bc92eb99b1a5d11e689ff
BLAKE2b-256 e32e1e13b07bc62a7b0f46cbecbac52871ed31d12f36a307dd31221edcb107e4

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