USFM reference parser
Project description
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
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usfmtc-0.3.19.tar.gz.
File metadata
- Download URL: usfmtc-0.3.19.tar.gz
- Upload date:
- Size: 117.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
078fbb3ee58578a37a4f64ec148e5c6ad0257dd21094b554deb4bb4eddb95723
|
|
| MD5 |
b1ab9981d9712d1c152dd00a9cff2332
|
|
| BLAKE2b-256 |
ca8fabad189b74688f69b5a74396545c9bba5bb1d9f2daa6a4aa61353533da23
|
File details
Details for the file usfmtc-0.3.19-py3-none-any.whl.
File metadata
- Download URL: usfmtc-0.3.19-py3-none-any.whl
- Upload date:
- Size: 109.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eaaaee091df05cd32fd20305e83cd8679abdcf8f33fd211f90d557128e653bb
|
|
| MD5 |
84eaa3dd2e06c0223882d695fdffe788
|
|
| BLAKE2b-256 |
4d7367769f6f2ea02c609e3a8e5ac2eeba3900b27c610e378caf59b8ac3d757a
|