USFMTC Module
Introduction
The USFMTC module is a module for reading and writing USFM scripture files in all their formats: USFM, USX and USJ. It is designed to be a reference implementation of the standard. It also has support for Scripture References.
import sys, usfmtc
from usfmtc.versification import cached_versification
from usfmtc.reference import Ref, RefList
engvrs = cached_versification("eng") # can also be a path to a .vrs file
usxdoc = usfmtc.readFile(sys.argv[1])
usxdoc.canonicalise()
# usxdoc.reversify(engvrs, None)
usxdoc.saveAs(sys.argv[2])
r = Ref("ISA 9:1-4") # returns a RefRange
canr = engvrs.remap(r, None) # one way conversion
print(canr) # prints "ISA 8:23-9:3"
rlist = RefList("JHN 3:16, GEN 1:1, PSA 23, ISA 53, PSA 23:1")
print(rlist.simplify()) # GEN 1:1; PSA 23; ISA 53; JHN 3:16
print(Ref("PSA 23").end()) # PSA 23:6
print(Ref("PSA 23:10").isvalid()) # False
newdoc = usxdoc.getrefs(Ref("PSA 23:2-4"))
print(newdoc.outUsfm(None)) # A new doc of just PSA 23:2-4
The internal representation of the data is as an ElementTree structure conforming to the USX standard.
See the tests/test_\*.py files for more examples. See also pydoc usfmtc.
Utilities
usfmtc comes with a few utilities:
- usfmconv: Converts from one serialisation to another
- usfmreversify: Change the versification of a file to something different
- urnc2rng: Convert to relax-NG
Installation
python3 -m venv venv
source venv/bin/activate
pip install .
To install the dev profile with extra optional dependencies:
pip install .[dev]
Release files for usfmtc 0.4.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| usfmtc-0.4.8.tar.gz | 122.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| usfmtc-0.4.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 234.1 kB
Release files / usfmtc-0.4.8.tar.gz
| Download URL | usfmtc-0.4.8.tar.gz |
|---|---|
| Size | 122.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e835b845bd0a541272c87522461f9316cc627251940fd9b586be532d6d64537
|
|
BLAKE2b-256 checksum How to use checksums |
fc90214ef93e2f7e2306a1323be60898a2c5317c0df5d8686b7c8d9ebb19e04b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / usfmtc-0.4.8-py3-none-any.whl
| Download URL | usfmtc-0.4.8-py3-none-any.whl |
|---|---|
| Size | 111.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86729c119c443b31457989f31fe500abae3956308736dd18982b6141cfc2e7f7
|
|
BLAKE2b-256 checksum How to use checksums |
54dbd1c4c7300f3ba860b5fe2df0fda59049611876e1694a0ca6ebaeaab21c8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|