Skip to main content

Utilities for working with metadata for Bible books, references, pericopes, and other units.

Project description

Biblelib

Release Build status codecov Commit activity Docs Code style with black Imports with isort License

Utilities for working with Bible books, references, pericopes, and other units. Note this does not include any actual Bible texts.

Installation

$ pip install biblelib

Usage

Book metadata

from biblelib.book import Books

books = Books()
books["MRK"]           # <Book: MRK>
books["MRK"].name      # 'Mark'
books["MRK"].osisID    # 'Mark'
books.fromosis("Matt").name      # 'Matthew'
books.frombiblia("Mk").usfmname  # 'MRK'
books.findbook("Ge")             # <Book: GEN>  (searches all schemes)

Rendering Bible references

BCVID (book-chapter-verse) and BCVIDRange are the primary reference types. Several rendering methods are available:

from biblelib.word import BCVID, BCVIDRange

ref = BCVID("41004003")      # Mark 4:3
ref.to_usfm()                # 'MRK 4:3'
ref.to_nameref()             # 'Mark 4:3'    (full English name)
ref.to_abbrevref()           # 'Mk 4:3'      (biblia abbreviation)
ref.to_osisID()              # 'Mark 4:3'
ref.to_biblia()              # 'Mk 4:3'

rng = BCVIDRange(BCVID("41004003"), BCVID("41004008"))
rng.to_nameref()             # 'Mark 4:3-4:8'
rng.to_abbrevref()           # 'Mk 4:3-4:8'

Localized rendering

to_nameref() and to_abbrevref() accept an optional lang parameter using ISO 639-3 three-letter codes. French (fra) is currently bundled; see Adding a language below for others.

from biblelib.word import BCVID, BCVIDRange

ref = BCVID("01001001")
ref.to_nameref(lang="fra")    # 'Genèse 1.1'
ref.to_abbrevref(lang="fra")  # 'Gn 1.1'

rng = BCVIDRange(BCVID("41004003"), BCVID("41004008"))
rng.to_nameref(lang="fra")    # 'Marc 4.3-4.8'
rng.to_abbrevref(lang="fra")  # 'Mc 4.3-4.8'

Note that the chapter-verse separator is language-specific (English uses :, French uses .).

You can also work with LocalizedBooks directly:

from biblelib.book import get_localized_books

fra = get_localized_books("fra")
fra.get_name("GEN")    # 'Genèse'
fra.get_abbrev("GEN")  # 'Gn'
fra.cv_sep             # '.'

Adding a language

Create biblelib/book/books_<lang>.tsv (e.g. books_spa.tsv for Spanish) with three tab-separated columns and optional metadata comments:

# cv_sep: .
usfmname	name	abbrev
GEN	Génesis	Gn
EXO	Éxodo	Éx
...

Supported metadata comments:

Key Description Default
cv_sep Chapter-verse separator character :

No code changes are required. The new language is available immediately via lang="spa" (or whatever code you used).

Acknowledgements

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

biblelib-0.4.0.tar.gz (470.2 kB view details)

Uploaded Source

Built Distribution

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

biblelib-0.4.0-py3-none-any.whl (478.1 kB view details)

Uploaded Python 3

File details

Details for the file biblelib-0.4.0.tar.gz.

File metadata

  • Download URL: biblelib-0.4.0.tar.gz
  • Upload date:
  • Size: 470.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/25.3.0

File hashes

Hashes for biblelib-0.4.0.tar.gz
Algorithm Hash digest
SHA256 03736952f2381642baf11c55a547befd9066e3779ae7b7bb6b8f595e4abf90b4
MD5 f491746d58030bb98aaef377b2f3d936
BLAKE2b-256 cf37f942b68f38095603d1a823ad418df027f6de655f13b5f890bc52f9ae3d93

See more details on using hashes here.

File details

Details for the file biblelib-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: biblelib-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 478.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/25.3.0

File hashes

Hashes for biblelib-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39e6f1b96d58262cbe59d293bea2b23d8a9610c9a0b36099379e5184a83c9e32
MD5 ace557e16122c65bfc0683d62e70f81f
BLAKE2b-256 33a0ddb8f5ea088b6743e3b5681b523a2dcd4ca946dfa8370f48c7b5bfa22967

See more details on using hashes here.

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