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.5.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.5-cp313-cp313-win_amd64.whl (215.2 kB view details)

Uploaded CPython 3.13Windows x86-64

usfm3-0.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (370.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

usfm3-0.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

usfm3-0.1.5-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.5.tar.gz.

File metadata

  • Download URL: usfm3-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 b40b29cb9306909e767050e484a6d84468d5c94607d21edb82c237d83d01fef6
MD5 233d4c57d4e6b83156858a30607d41fb
BLAKE2b-256 3b57f56b2f856c1431119804ac4e94bb60c3e3d02f96d5d21dcfb0d3a4a4bb06

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.5.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.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: usfm3-0.1.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 215.2 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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fb7f969cec1d95f566e360889a82f529840422ee7a2bfb2cb11cffc024cf0380
MD5 8572fc38f0f120874254c56b1c5e1389
BLAKE2b-256 ba47d7c2da415506aa3321d2bc735b24305e68557680b503b9cb9ef64a2c4c72

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.5-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.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c577cc74dca8670d121d5384a4cb0eb597f353f3408a8cbbffcd9d3a4be422ca
MD5 9402bba8eed51c60c05ca373c746407d
BLAKE2b-256 3899c0ee7d7aa2c57a7825e3d6ea573ebc6b2662c74fe338bff049147a5154a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.5-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.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 43ff5d6a1a629b1db19384a3d358dbfa9c894d56c7cce5e5f64f03dd8cb356ae
MD5 f75b10d1de88c18be1008b4bf4e12df4
BLAKE2b-256 a665e12c3d8d8c2532fd1037428b359a3ccdba38804d6c915fd418e76402fb08

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.5-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.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb1ce1eb5e6b98b5166664407c1b81f37e9a8776bbcdf5ff44035f75ec4008ea
MD5 75b1071ea98035eb74e284f84dd268e7
BLAKE2b-256 459d7500537b3f9b7459012aae58d8e945a01824719610241d2fe6d65d43b7e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for usfm3-0.1.5-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