Skip to main content

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]

Metadata

Release files for usfmtc 0.4.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usfmtc 0.4.9
File Size Uploaded Provenance Actions
usfmtc-0.4.9.tar.gz 134.2 kB Without provenance Details for usfmtc-0.4.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for usfmtc 0.4.9
File Interpreter ABI Platform Actions
usfmtc-0.4.9-py3-none-any.whl Python 3 none any Details for usfmtc-0.4.9-py3-none-any.whl

Total release size: 252.7 kB

Release files / usfmtc-0.4.9.tar.gz

Download URL usfmtc-0.4.9.tar.gz
Size 134.2 kB
Tags Source
SHA-256 checksum
How to use checksums
909c6e39adb3886a7377b8871a72072ce2bae89b8dbf3bbefba4ee15708277dd
BLAKE2b-256 checksum
How to use checksums
4bacb0a61b3589b499e679927c641fe0832e2c777f21ca23b1bec4025c9472e0
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.9-py3-none-any.whl

Download URL usfmtc-0.4.9-py3-none-any.whl
Size 118.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13968a58e089088cad258b462b92747f8a9cebcb6ef5e14e8239478865483f83
BLAKE2b-256 checksum
How to use checksums
cf09b924bbbbd238f69486a206fe17375d1c11e2c0a3284d704946bd8b0bf251
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for usfmtc 0.4.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.9 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page