Skip to main content

Parse Bible verse references into structured Python objects.

Project description

bible-io-references-py

Parse Bible verse references into structured Python objects.

What this package supports

  • Parsing a single verse reference into a VerseRef:
    • John 3:16
    • jo 3:16 (enum abbreviation)
  • Parsing a verse range into a VerseRangeRef:
    • John 3:16-17
    • John 3:16-4:1 (same book, different chapter)
    • John 3:16-Acts 1:2 (cross-book range)
  • Flexible separators and spacing:
    • chapter/verse separator can be : or .
    • range separator can be hyphen, en dash, or em dash
    • extra surrounding whitespace is tolerated
  • Book name matching from:
    • English full names (for all enum books)
    • enum abbreviations (for all enum books)
    • localized names and abbreviations for:
      • Arabic (ar)
      • Chinese (zh)
      • French (fr)
      • German (de)
      • Hebrew (he)
      • Hindi (hi)
      • Indonesian (id)
      • Korean (ko)
      • Portuguese (pt)
      • Russian (ru)
      • Spanish (es)
      • Tagalog (tl)

Installation

pip install bible-io-references

Usage

Parse a single verse

from bible_io_references import VerseRef

ref = VerseRef.from_str("John 3:16")
print(ref.book.full_name)  # John
print(ref.chapter)         # 3
print(ref.verse)           # 16
print(str(ref))            # John 3:16

Parse a verse range

from bible_io_references import VerseRangeRef

rng = VerseRangeRef.from_str("John 3:16-4:1")
print(rng.start.book.full_name, rng.start.chapter, rng.start.verse)  # John 3 16
print(rng.end.book.full_name, rng.end.chapter, rng.end.verse)        # John 4 1
print(str(rng))                                                       # John 3:16-4:1

Parse either type with one helper

from bible_io_references import VerseRangeRef, VerseRef, parse_reference

parsed = parse_reference("John 3:16-17")

if isinstance(parsed, VerseRangeRef):
    print(parsed.start, parsed.end)
elif isinstance(parsed, VerseRef):
    print(parsed)

Parse localized references

from bible_io_references import BibleLanguageEnum, VerseRef

print(VerseRef.from_str("Juan 3:16"))
print(VerseRef.from_str("Mat. 5:9", language=BibleLanguageEnum.SPANISH))
print(VerseRef.from_str("Juan 3:16", language="Spanish"))

To restrict parsing to a specific language (to avoid cross-language abbreviation collisions), pass a language enum or string. BibleLanguageEnum.from_str(...) accepts full names like Spanish, short codes like es, and bible-io-json identifier prefixes like spa or spa-rva-1602. The default is AUTO, which searches all supported languages.

AUTO-mode precedence and collision diagnostics

from bible_io_references.references import AUTO_LANGUAGE_COLLISIONS, AUTO_LANGUAGE_PRECEDENCE

print(AUTO_LANGUAGE_PRECEDENCE)
print(AUTO_LANGUAGE_COLLISIONS.get("jn"))

In AUTO mode, English terms are checked first. Localized terms are then resolved using AUTO_LANGUAGE_PRECEDENCE order.

Audit language term tables (maintainers)

from bible_io_references.languages import audit_language_terms

report = audit_language_terms()
print(report.has_blocking_issues)
print(len(report.duplicate_terms))

Error handling

Invalid references raise ParseVerseRefError.

from bible_io_references import ParseVerseRefError, VerseRef

try:
    VerseRef.from_str("NotABook 3:16")
except ParseVerseRefError as exc:
    print(str(exc))      # invalid verse reference
    print(exc.code)      # machine-readable reason code
    print(exc.details)   # optional detail text
    print(exc.to_dict()) # {'code': '...', 'details': '...'}

Core types

  • BibleBookEnum: canonical Bible books (including Protestant, Catholic deuterocanonical, and Eastern Orthodox additions in the enum)
  • BibleLanguageEnum: language strategy enum (Auto, Spanish, Hebrew, etc., with code aliases like es and he)
  • VerseRef: single verse (book, chapter, verse)
  • VerseRangeRef: range with start and end VerseRefs
  • ParseVerseRefError: parse failure exception with structured diagnostics (code, details)

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

bible_io_references-1.0.1.tar.gz (70.6 kB view details)

Uploaded Source

Built Distribution

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

bible_io_references-1.0.1-py3-none-any.whl (56.5 kB view details)

Uploaded Python 3

File details

Details for the file bible_io_references-1.0.1.tar.gz.

File metadata

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

File hashes

Hashes for bible_io_references-1.0.1.tar.gz
Algorithm Hash digest
SHA256 03752cfb67ef0d85a3acf64e3f560eaf4225a0404b5854d3447c609708404a4d
MD5 411437cb52e71c2bfa406a3ffef53183
BLAKE2b-256 7e7feb9742e97465d1eac91311ad0c882e50c35d9d05f6d43a9c9b990f2be621

See more details on using hashes here.

Provenance

The following attestation bundles were made for bible_io_references-1.0.1.tar.gz:

Publisher: release.yml on m0ty/bible-io-references-py

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

File details

Details for the file bible_io_references-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bible_io_references-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f85e66a43d032a2f31a5c414cd61ff5dd525b38bf534a4be7bbb5e1233f5252a
MD5 bd6cd9157f248479b57b5c575f7deb5f
BLAKE2b-256 954469fdb6598ebdaee600e46670807a456eceda8c0c8a6496390335190a6df4

See more details on using hashes here.

Provenance

The following attestation bundles were made for bible_io_references-1.0.1-py3-none-any.whl:

Publisher: release.yml on m0ty/bible-io-references-py

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