This release is a pre-release and may not be stable for production use.
rtfcre
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,
rtfcrealso 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
Metadata
Release files for rtfcre 2.0.0_dev2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 11.1 MB
Release files / rtfcre-2.0.0_dev2-cp39-none-win_amd64.whl
| Download URL | rtfcre-2.0.0_dev2-cp39-none-win_amd64.whl |
|---|---|
| Size | 586.7 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
aa5a836ec64d9e1037d03e44d4dbdc2f054ca37d5bbc0579d8e612a6c6010b2c
|
|
BLAKE2b-256 checksum How to use checksums |
46cab0a8f7c08f9357d847ba70a21650ed6a9af09239f5f1b68bbe72edc5d2d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp39-cp39-manylinux_2_24_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp39-cp39-manylinux_2_24_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.9 Linux glibc 2.24+ x86-64 |
|
SHA-256 checksum How to use checksums |
cf571926f23ed5c5712bada6bd4fd50cfae52536e2784f9a722f7ce153b9e40e
|
|
BLAKE2b-256 checksum How to use checksums |
746c989722378013dd325a5fcc8f4fd432ea1faf8c6b423c1145cd0c7ba036bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp39-cp39-macosx_10_7_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp39-cp39-macosx_10_7_x86_64.whl |
|---|---|
| Size | 727.2 kB |
| Tags | CPython 3.9 macOS 10.7+ x86-64 |
|
SHA-256 checksum How to use checksums |
5bd6d7ac0e28c45a1e65eb33a4ecfdacb8b41cb0c0d8d7469fb2631e74e66ca0
|
|
BLAKE2b-256 checksum How to use checksums |
a07f1a1adc9d4c2ae1a35db7b0557c4b9cc35da31250edffdddffcca1bc73892
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp38-none-win_amd64.whl
| Download URL | rtfcre-2.0.0_dev2-cp38-none-win_amd64.whl |
|---|---|
| Size | 586.7 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fa140964bcdf56f046a8497d871e6e4358bb8d42145dee5ec8d6d3037e514355
|
|
BLAKE2b-256 checksum How to use checksums |
20227defe606d12d4e5d1805badbb7aee7a52b8638f2636b337e3972d379116f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp38-cp38-manylinux_2_24_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp38-cp38-manylinux_2_24_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.8 Linux glibc 2.24+ x86-64 |
|
SHA-256 checksum How to use checksums |
0c09f8bb1fd382ce33fc5b2f41ccfdb0f88281820a99b729fed4abd8584a8b9a
|
|
BLAKE2b-256 checksum How to use checksums |
e2e445c8ef5376362f500ca1a74eea1dd54a0b880fea27ded3ebeef0d0e3b4b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp38-cp38-macosx_10_7_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp38-cp38-macosx_10_7_x86_64.whl |
|---|---|
| Size | 727.2 kB |
| Tags | CPython 3.8 macOS 10.7+ x86-64 |
|
SHA-256 checksum How to use checksums |
5d63e54b3f137b56b2e95facd99561d93c0515868d710b7d541d9822e6d7e9b9
|
|
BLAKE2b-256 checksum How to use checksums |
b1effec0f7dae124e8a9d7922dcfc6ab7b2462d0719b675650db7841bc3a93df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp37-none-win_amd64.whl
| Download URL | rtfcre-2.0.0_dev2-cp37-none-win_amd64.whl |
|---|---|
| Size | 586.7 kB |
| Tags | CPython 3.7 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c1d1b67e0f1466f6733fa3aeaa36a7cc5b098de1eba8a4d7514e47c561cbbd22
|
|
BLAKE2b-256 checksum How to use checksums |
86d1d39c4f05adc58eca267563c280654af65c37775d0802fda0724045f60a11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp37-cp37m-manylinux_2_24_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp37-cp37m-manylinux_2_24_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64 |
|
SHA-256 checksum How to use checksums |
bdea49a27254bb45239ff2bb72416a60fb1d32af2ba541d86bb528d63115583d
|
|
BLAKE2b-256 checksum How to use checksums |
4c3b1bef7f46aeb6bfb3959e8cca20d0741a2c762f16bfd47a37026166cde15b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp37-cp37m-macosx_10_7_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp37-cp37m-macosx_10_7_x86_64.whl |
|---|---|
| Size | 727.2 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 |
|
SHA-256 checksum How to use checksums |
10f13313685de65a7098eca3b2d1b7f1d0e412c796b06b0b9676861b334d0ced
|
|
BLAKE2b-256 checksum How to use checksums |
27bf8e25aa1dbd6d0fba045e0022bdb1ca32b42a3976a6926a66399b934c8d16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp36-none-win_amd64.whl
| Download URL | rtfcre-2.0.0_dev2-cp36-none-win_amd64.whl |
|---|---|
| Size | 587.1 kB |
| Tags | CPython 3.6 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4eeebb2ec5e7256d612cc3ba21017abd6f33033814dd04d1e328b57cdb47a7f9
|
|
BLAKE2b-256 checksum How to use checksums |
01c0ed470cf849c8a2baf96df2fc196ca06870ea896183ed8b048befb5c6e964
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp36-cp36m-manylinux_2_24_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp36-cp36m-manylinux_2_24_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.24+ x86-64 |
|
SHA-256 checksum How to use checksums |
5d0013d11fb21d1eea1b1441acb588dd674cb114b34d6a7e2708f6a90a6bcf96
|
|
BLAKE2b-256 checksum How to use checksums |
abc4cceb406aa2a1ba8ba8c27e818ab2cc280086b88ef505f1addefcf4ec6eb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / rtfcre-2.0.0_dev2-cp36-cp36m-macosx_10_7_x86_64.whl
| Download URL | rtfcre-2.0.0_dev2-cp36-cp36m-macosx_10_7_x86_64.whl |
|---|---|
| Size | 727.5 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 |
|
SHA-256 checksum How to use checksums |
face92faceb6f9615fd3e4e6004ef337bd171eb0fc254f4963c36983160b0019
|
|
BLAKE2b-256 checksum How to use checksums |
94117627bfd3d8c8ac650049e60241d46f80bc04742357138d9c9dce921e4aac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|