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:16jo 3:16(enum abbreviation)
- Parsing a verse range into a
VerseRangeRef:John 3:16-17John 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
- chapter/verse separator can be
- 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)
- Arabic (
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 likeesandhe)VerseRef: single verse (book,chapter,verse)VerseRangeRef: range withstartandendVerseRefsParseVerseRefError: parse failure exception with structured diagnostics (code,details)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03752cfb67ef0d85a3acf64e3f560eaf4225a0404b5854d3447c609708404a4d
|
|
| MD5 |
411437cb52e71c2bfa406a3ffef53183
|
|
| BLAKE2b-256 |
7e7feb9742e97465d1eac91311ad0c882e50c35d9d05f6d43a9c9b990f2be621
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bible_io_references-1.0.1.tar.gz -
Subject digest:
03752cfb67ef0d85a3acf64e3f560eaf4225a0404b5854d3447c609708404a4d - Sigstore transparency entry: 1117916064
- Sigstore integration time:
-
Permalink:
m0ty/bible-io-references-py@cc16aad78c47493e5c953591cd68a073a240ce9c -
Branch / Tag:
refs/tags/Release-1.0.1 - Owner: https://github.com/m0ty
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cc16aad78c47493e5c953591cd68a073a240ce9c -
Trigger Event:
push
-
Statement type:
File details
Details for the file bible_io_references-1.0.1-py3-none-any.whl.
File metadata
- Download URL: bible_io_references-1.0.1-py3-none-any.whl
- Upload date:
- Size: 56.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85e66a43d032a2f31a5c414cd61ff5dd525b38bf534a4be7bbb5e1233f5252a
|
|
| MD5 |
bd6cd9157f248479b57b5c575f7deb5f
|
|
| BLAKE2b-256 |
954469fdb6598ebdaee600e46670807a456eceda8c0c8a6496390335190a6df4
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bible_io_references-1.0.1-py3-none-any.whl -
Subject digest:
f85e66a43d032a2f31a5c414cd61ff5dd525b38bf534a4be7bbb5e1233f5252a - Sigstore transparency entry: 1117916140
- Sigstore integration time:
-
Permalink:
m0ty/bible-io-references-py@cc16aad78c47493e5c953591cd68a073a240ce9c -
Branch / Tag:
refs/tags/Release-1.0.1 - Owner: https://github.com/m0ty
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cc16aad78c47493e5c953591cd68a073a240ce9c -
Trigger Event:
push
-
Statement type: