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.6.tar.gz (64.4 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.6-cp313-cp313-win_amd64.whl (221.6 kB view details)

Uploaded CPython 3.13Windows x86-64

usfm3-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (377.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

usfm3-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (368.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

usfm3-0.1.6-cp313-cp313-macosx_11_0_arm64.whl (328.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Hashes for usfm3-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f3cfba26b4533eddb01782fe0cbc1baeaf8c9013067a7f9bd5a483eeeed418e7
MD5 122d8bac6528268c63231f90c251a872
BLAKE2b-256 860f30c933905b2df58f240c3b6fcf1c0e6ebe05b4bc0662a54c378db459008e

See more details on using hashes here.

Provenance

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

Hashes for usfm3-0.1.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e2efdb8df5724790fae98285fbe0482f3010a726efdea97ef5509001a5dc72a2
MD5 b3e36059a3813569611508236dad3595
BLAKE2b-256 c79f992fe41af510f7bea664bd266025f74734523cc094bc9fdb8f633512fc7f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for usfm3-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77a61f7404e374cfdb60fbd4c7362501c73b249afd7983727b1801b807a85de4
MD5 7f73610f363d085c4eb38133b1a5eda3
BLAKE2b-256 acc906682be27f266f8f48d9f645012c5af98033b51ac180ed33e31235bc6691

See more details on using hashes here.

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

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.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1c457f331462a6eb05f63ad2a53239d4b6531db9de452cf4f55a8c4063529877
MD5 0a6428e053abc9108ac1d5b59fe2efe4
BLAKE2b-256 d7b2596a43ce2781438e09bed267df202fe712017590a335ca4811f2d76f7b17

See more details on using hashes here.

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

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.6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for usfm3-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c074bc93c47eb7222e93e0d2024e5e44c0c734fd2ece8865871da1c574f01f8
MD5 928641fe4487132daa30c4a6d4444236
BLAKE2b-256 470ded50a095dd44528bad06ee65ca71109aac4348de314ea8394160d804975b

See more details on using hashes here.

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

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