Error-tolerant USFM 3.x parser
Project description
usfm3
An error-tolerant USFM 3.x parser for Python. Outputs USJ (JSON), USX (XML), normalized USFM, and verse-reference maps.
Built in Rust for speed, with native Python bindings via PyO3.
Also available as a Rust crate and npm package (WebAssembly).
Installation
pip install usfm3
Requires Python 3.9+.
Usage
import usfm3
result = usfm3.parse(open("GEN.usfm").read())
# Output formats
usj = result.to_usj() # dict
usx = result.to_usx() # XML string
usfm = result.to_usfm() # USFM string
vref = result.to_vref() # {"GEN 1:1": "In the beginning...", ...}
# Diagnostics
for d in result.diagnostics:
print(f"[{d.severity}] {d.message} ({d.start}..{d.end})")
if result.has_errors():
print("Document has errors")
# Skip semantic validation
result = usfm3.parse(text, validate=False)
API
usfm3.parse(usfm: str, validate: bool = True) -> ParseResult
Parse a USFM string. Returns a ParseResult with lazy output methods and diagnostics.
ParseResult
| Method / Property | Returns | Description |
|---|---|---|
to_usj() |
dict |
USJ (Unified Scripture JSON) |
to_usx() |
str |
USX (Unified Scripture XML) |
to_usfm() |
str |
Normalized USFM |
to_vref() |
dict |
Verse reference to plain text map |
has_errors() |
bool |
True if any error-severity diagnostics |
diagnostics |
list[Diagnostic] |
Parser and validation diagnostics |
Diagnostic
| Property | Type | Description |
|---|---|---|
severity |
str |
"error", "warning", or "info" |
code |
str |
Machine-readable code (e.g. "UnknownMarker") |
message |
str |
Human-readable message |
start |
int |
Start byte offset in source |
end |
int |
End byte offset in source |
License
MIT
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 Distributions
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 usfm3-0.1.6.tar.gz.
File metadata
- Download URL: usfm3-0.1.6.tar.gz
- Upload date:
- Size: 64.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3cfba26b4533eddb01782fe0cbc1baeaf8c9013067a7f9bd5a483eeeed418e7
|
|
| MD5 |
122d8bac6528268c63231f90c251a872
|
|
| BLAKE2b-256 |
860f30c933905b2df58f240c3b6fcf1c0e6ebe05b4bc0662a54c378db459008e
|
Provenance
The following attestation bundles were made for usfm3-0.1.6.tar.gz:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.1.6.tar.gz -
Subject digest:
f3cfba26b4533eddb01782fe0cbc1baeaf8c9013067a7f9bd5a483eeeed418e7 - Sigstore transparency entry: 1084139005
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.1.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: usfm3-0.1.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 221.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2efdb8df5724790fae98285fbe0482f3010a726efdea97ef5509001a5dc72a2
|
|
| MD5 |
b3e36059a3813569611508236dad3595
|
|
| BLAKE2b-256 |
c79f992fe41af510f7bea664bd266025f74734523cc094bc9fdb8f633512fc7f
|
Provenance
The following attestation bundles were made for usfm3-0.1.6-cp313-cp313-win_amd64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.1.6-cp313-cp313-win_amd64.whl -
Subject digest:
e2efdb8df5724790fae98285fbe0482f3010a726efdea97ef5509001a5dc72a2 - Sigstore transparency entry: 1084139141
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: usfm3-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 377.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77a61f7404e374cfdb60fbd4c7362501c73b249afd7983727b1801b807a85de4
|
|
| MD5 |
7f73610f363d085c4eb38133b1a5eda3
|
|
| BLAKE2b-256 |
acc906682be27f266f8f48d9f645012c5af98033b51ac180ed33e31235bc6691
|
Provenance
The following attestation bundles were made for usfm3-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
77a61f7404e374cfdb60fbd4c7362501c73b249afd7983727b1801b807a85de4 - Sigstore transparency entry: 1084139073
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: usfm3-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 368.8 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c457f331462a6eb05f63ad2a53239d4b6531db9de452cf4f55a8c4063529877
|
|
| MD5 |
0a6428e053abc9108ac1d5b59fe2efe4
|
|
| BLAKE2b-256 |
d7b2596a43ce2781438e09bed267df202fe712017590a335ca4811f2d76f7b17
|
Provenance
The following attestation bundles were made for usfm3-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
1c457f331462a6eb05f63ad2a53239d4b6531db9de452cf4f55a8c4063529877 - Sigstore transparency entry: 1084139223
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.1.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: usfm3-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 328.9 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c074bc93c47eb7222e93e0d2024e5e44c0c734fd2ece8865871da1c574f01f8
|
|
| MD5 |
928641fe4487132daa30c4a6d4444236
|
|
| BLAKE2b-256 |
470ded50a095dd44528bad06ee65ca71109aac4348de314ea8394160d804975b
|
Provenance
The following attestation bundles were made for usfm3-0.1.6-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.1.6-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
2c074bc93c47eb7222e93e0d2024e5e44c0c734fd2ece8865871da1c574f01f8 - Sigstore transparency entry: 1084139276
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1de3dbfaac49d6d89b1f8f229cdf53226b315167 -
Trigger Event:
push
-
Statement type: