Python library for Rich Text Format with Court Reporting Extensions (RTF/CRE) dictionaries
Project description
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,
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file rtfcre-1.2.2-cp39-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp39-none-win_amd64.whl
- Upload date:
- Size: 597.0 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85288102303c36255c3c529e7453f4bae3224a47ad7b0885497e46859c36f490 |
|
MD5 | 75580b09f35af4b31625651c8cab346d |
|
BLAKE2b-256 | 87917bc21723304f979510ab117b4193d55a011c5054e544e7fe341206fb75cd |
File details
Details for the file rtfcre-1.2.2-cp39-cp39-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23a0c245156e4b72a50da5713eddf917391d8a24e3a58d6263848235556510a3 |
|
MD5 | 173685b454172fd23b2ba1b00d434c37 |
|
BLAKE2b-256 | bc5a142815c4207b4b44225173b5e6ac4f6ccdb44a6883cea61a280442e2815e |
File details
Details for the file rtfcre-1.2.2-cp39-cp39-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 709.6 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9ce3354b48a746de98dd5046ae0fd0e1a4439a5c5ca1ba65a30241d06a2d534 |
|
MD5 | 744f8dfe6333bf18ce6c980be253825b |
|
BLAKE2b-256 | 123101e33e360e7ec5f99914b6677affe40996b4e09b3eb02cdaddee51e1b46b |
File details
Details for the file rtfcre-1.2.2-cp38-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp38-none-win_amd64.whl
- Upload date:
- Size: 597.0 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe3cc6edc643eeaaa343f078471d365f4dac421a4adca24ef40d96ca02366e8b |
|
MD5 | 7d5e39ff0f3f848d2eb72566ae54fc00 |
|
BLAKE2b-256 | 832d5ef312f83c997a39780519cc487603e09c3f2bb88458c3b9ad31e92dca9b |
File details
Details for the file rtfcre-1.2.2-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bc686d3a361e59bd08c081fcb88491ba3f6507f87fea31a75ef76340c41e731 |
|
MD5 | 200d71361cbbf23122d708237de96bae |
|
BLAKE2b-256 | ec1c9fd4d555844144606f5fd9b77edc723dd81750323c2a45a46d38c9aaa3e0 |
File details
Details for the file rtfcre-1.2.2-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 709.6 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ade4aafc17d184d02cff81b0e5ba3c12b6d4bb448b5b739a4c913cc1c97aada7 |
|
MD5 | a46ddb494693e1f702f2283ec88be97b |
|
BLAKE2b-256 | 55ce83a9450c1ffa5e26d688e2c32e37c41b5c62b64cec949e29b232770266a6 |
File details
Details for the file rtfcre-1.2.2-cp37-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp37-none-win_amd64.whl
- Upload date:
- Size: 597.0 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6b1ea99a4412812849b1b07c5335ac40616a53918b6c94bf32035909d05022 |
|
MD5 | 724d2d998cc851efd6d1803fe9d13d32 |
|
BLAKE2b-256 | 20601a04531f6e1596148d5f8859af4cb6a82e7fb7acd17285536baf3757cb09 |
File details
Details for the file rtfcre-1.2.2-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f284b23ec187ab3cc7dafe60253e9cc090abb66d744f1175f821a5b2c91768bb |
|
MD5 | 507024ab2cb443b68f2a6f90ff7ff990 |
|
BLAKE2b-256 | ec708da2978fee76ebf49a84836ed363b887619fb92b67446c7b49088fffaa3e |
File details
Details for the file rtfcre-1.2.2-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 709.7 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b62d9e56ffbca08ec08d0904f55f3ed135f2396e59653e593f29f3554b8c482 |
|
MD5 | 0a990e8767c41fc725019a7814b6adf5 |
|
BLAKE2b-256 | a8f210f718de787510e42d797ab3f5e4253f6753933269d67cfe241e49c0444b |
File details
Details for the file rtfcre-1.2.2-cp36-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp36-none-win_amd64.whl
- Upload date:
- Size: 597.2 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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 704518cebe817bdd3b4d4e6750498873f055f47bbb398fd49af634344f909339 |
|
MD5 | 5bcddd2019b1e7d3a380e43da53bec8e |
|
BLAKE2b-256 | ffaf8e7bc87f523b15a0dda6e9d3491a5a6e6d10c971d87260bbf0da3949e5cc |
File details
Details for the file rtfcre-1.2.2-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 440b62a018e0b6287557a72e354a6d69c36873308e6c944c1bf42ff56caf437f |
|
MD5 | 346bd6a7455e6234595886141e012907 |
|
BLAKE2b-256 | af12dafcd6b23e43adb388bf6fbb9f0379daa736e6209b269c312b4c3de19ce5 |
File details
Details for the file rtfcre-1.2.2-cp36-cp36m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.2.2-cp36-cp36m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 710.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.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85e06706a5f9f86dce4193c4f31efdb1cb4c0bacbcca774711d1e6a1b1ead81e |
|
MD5 | 2ac5800c4c01d6935509a8fac5869a64 |
|
BLAKE2b-256 | 31ca95e037b0975fdd6facc86494c629754557c924c6272c72127c3273f397a0 |