Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usfm3-0.1.4.tar.gz (60.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

usfm3-0.1.4-cp313-cp313-win_amd64.whl (213.8 kB view details)

Uploaded CPython 3.13Windows x86-64

usfm3-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (370.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

usfm3-0.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

usfm3-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (323.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file usfm3-0.1.4.tar.gz.

File metadata

  • Download URL: usfm3-0.1.4.tar.gz
  • Upload date:
  • Size: 60.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for usfm3-0.1.4.tar.gz
Algorithm Hash digest
SHA256 548ce8b84ebba31532e542243a14485b448404e87cce340da6710ac5a8e60bbf
MD5 4c953aecb06ac5153f3082c33aa1243d
BLAKE2b-256 dbe12900a3160d379f0b915c50dc2989e4e0cfa243cd05b6474e3d1ad69f0738

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.4.tar.gz:

Publisher: publish-pypi.yml on jcuenod/usfm3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file usfm3-0.1.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: usfm3-0.1.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 213.8 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

Hashes for usfm3-0.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d29e926271aadb78841dcaf58d246b21a50302d77f34045766a494983cad9cd4
MD5 e844c50d1778f7751f163e81574f2923
BLAKE2b-256 6f69929cdf5f22659d95ba00d025c3e8131fe8b381597d39fabea0547e7dcb2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.4-cp313-cp313-win_amd64.whl:

Publisher: publish-pypi.yml on jcuenod/usfm3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file usfm3-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3713c0da3c8bce80c9a4d959fac284d39989a93882b61187aa2065029dfc2cf8
MD5 c98dd9f5043e860a4d37acb4fd785117
BLAKE2b-256 dc924c91d55b9bb0e02248ab160cfb1ce78756f8b1c06038c3cdd8d21f7f85d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on jcuenod/usfm3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file usfm3-0.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 43c85d2893764527cef8effcac46c6437f0702d739b0e28c0f686bb3a930e644
MD5 e7c7010c03d43be3e3a655a04a56d657
BLAKE2b-256 c688ad1a245fe353a3f2c875bdfa2ae54c6c843d98ed48c3054f2c6781206335

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on jcuenod/usfm3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file usfm3-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90a2cb5e30a4dd0541ca9361ccfa91c910d578ef244abfeafed04895ef1f4836
MD5 c82e4452c92afb2e1e482447eeac28a8
BLAKE2b-256 c903a1afb4b6e119f9fa69b4153fdc4079fac3fa8c6ef78cb51d8758ae4268fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.4-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on jcuenod/usfm3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page