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.0.2-cp39-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-cp39-none-win_amd64.whl
- Upload date:
- Size: 585.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3980098c31d925b6ff500a72846aa0afb5ce7a08c15a6e4991ac8053779fa94a |
|
MD5 | e272399f1b96fdcdbb8c458aa4aae00d |
|
BLAKE2b-256 | d0d774997f11a5cc011bd5542cd20b3fd88473679315acfc2921607466f99ead |
File details
Details for the file rtfcre-1.0.2-cp39-cp39-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.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.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb3f1f0cba1685f940a6b6cf877bbd1cff8e7c47da6569d23d5161957ece399 |
|
MD5 | 5cabfebed32a7a9d55736eaec3dd3ee1 |
|
BLAKE2b-256 | a5d3ea9e3309158e5ecea6e11ef2f73c0ef66f1a130620b6cf0e278bfbab7d27 |
File details
Details for the file rtfcre-1.0.2-cp39-cp39-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 695.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca59c149f1dc86d696cfea0c0b7099bc3b72144963c3c34035d1ee8ee868e839 |
|
MD5 | af745122c72f088d503e48c24226497b |
|
BLAKE2b-256 | 48abed7eed678753c699d349f946946d9e000653c8c3b71195a4dbd12d401e2b |
File details
Details for the file rtfcre-1.0.2-cp38-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-cp38-none-win_amd64.whl
- Upload date:
- Size: 585.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d828be38563799480a9c37c9096c385ae5cc383e6e1400df029eda120f8e0baf |
|
MD5 | d098ff1301bd35346d588d87593d24eb |
|
BLAKE2b-256 | a51e5e8ff3238a015d1c743ac01626d0e8eac775d10f86663deeb018de9f9ce2 |
File details
Details for the file rtfcre-1.0.2-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.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.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 211465533d2c6c2a8c673dc59b855ecddf3fcd60bb3da951723b25aeec373ffa |
|
MD5 | a2b1c9cac05054cd56eaee1f611481d9 |
|
BLAKE2b-256 | 4bdab1ea47edd01c39697f90f43220cb30d3efbcf89dbcb882c0df583f2ac9ba |
File details
Details for the file rtfcre-1.0.2-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 695.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b50d280f3fe48357c0cd06f895463bf9bbdd3ff17169a2f5f22fb5abbdf74dc6 |
|
MD5 | 612aa64bc0eec49e6487e443745349df |
|
BLAKE2b-256 | c4a7ee2779b454efab83d2cf0edd58e85b73b56c5d29f57259992866a81e28db |
File details
Details for the file rtfcre-1.0.2-cp37-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6c4bd32eaa86613cd72e92930e3ddbd67d64579ccf677480d1cc47cace80bc0 |
|
MD5 | e8c721cccf4681e4a5a59034d99ea82f |
|
BLAKE2b-256 | 31644dbe1b328609242258a07378408ad6d956fe9294a78d6fb5b7419b395533 |
File details
Details for the file rtfcre-1.0.2-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.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.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d898517413b96f934352a2783793dfcf4d9f2ee3d08dbeee89118b8544c699a |
|
MD5 | c0fc3645928d7b6d0eea3b676eb8eba3 |
|
BLAKE2b-256 | cdcf6ceb78886feb24bd20e1be4569b3420db6f89a736cde046ee4644d11e34c |
File details
Details for the file rtfcre-1.0.2-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 695.6 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1649c3a776f05cdcec11c9bb987bce434fc7e5258e36cbceabe51df7a67eb4bf |
|
MD5 | 62452e7a88b6a0e1108bc0350cbe4bd3 |
|
BLAKE2b-256 | 812e995ac96323c6d59756641e75ce30ac510999ce9de45e5db927cdd4dc30b9 |
File details
Details for the file rtfcre-1.0.2-cp36-none-win_amd64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c4ef3f42539c3eac36ec1af08dbecd2842fc6a96ee2a171da32743d02e8cecb |
|
MD5 | bae8898f0a9ca41dd0c330bc9736a3b8 |
|
BLAKE2b-256 | fcbd5b48097fc840ac13942574f6c8bfaa8c1a918c7044695ff938ef1c4707e6 |
File details
Details for the file rtfcre-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.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.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6496943f28d9a7552e825aa5ba37005c4bc811bef3c7534129e9d59118b968f |
|
MD5 | 360a6865a59e9c8dbfb3747ff08578aa |
|
BLAKE2b-256 | 9f42b62ac39b9fbcf428fb1a20f01bf7d35ba97991f055414cc286fc57504330 |
File details
Details for the file rtfcre-1.0.2-cp36-cp36m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: rtfcre-1.0.2-cp36-cp36m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 695.7 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ef32cff4db225239c7fa2623ccfd607052b38088519442a01c9c6de8e90d04 |
|
MD5 | 7fed3727cb40caff539888a8d333fbb1 |
|
BLAKE2b-256 | ea41143aea4fea1278cb53f656e95d65935fe8011f9af309769e111312462430 |