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]

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)

Source distribution for usfmtc 0.4.8
File Size Uploaded
usfmtc-0.4.8.tar.gz 122.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for usfmtc 0.4.8
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.4.8 This release

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2

2 release files

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