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.10

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.10
File Size Uploaded Provenance Actions
usfmtc-0.4.10.tar.gz 134.2 kB Without provenance Details for usfmtc-0.4.10.tar.gz

Built distribution (wheel)

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

Total release size: 252.8 kB

Release files / usfmtc-0.4.10.tar.gz

Download URL usfmtc-0.4.10.tar.gz
Size 134.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d1b63f0462727cf121e7ed701c617f926fd6a57c211f628ee4a2756dee2afb58
BLAKE2b-256 checksum
How to use checksums
f32c69ed9c9cf93d6bd6d4b785a74af4199cb98f1ca4d488d96c461fe780027c
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.10-py3-none-any.whl

Download URL usfmtc-0.4.10-py3-none-any.whl
Size 118.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43c38b4c3c5612ff1526b6af4f0d5a44194523de4177cb4d9336f62fa70de832
BLAKE2b-256 checksum
How to use checksums
b06f9578d158fd40fb7e3a340a332ec6961ee2b99f9ef7422af312a8446d3ab2
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.10

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.10 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