Skip to main content

pythonbible

The pythonbible library serves several purposes related to the Christian Bible and Scripture references.

PyPI version license MIT

Test CodeQL Codacy Badge Codacy Badge Code style: black

Python 3.8

Installation

pip install pythonbible

Optional Dependencies

If the defusedxml library is installed, pythonbible will use it to parse XML files rather than the builtin xml.etree library.

To install pythonbible with all optional dependencies, use the following command.

pip install pythonbible[all]

Features

Searching text for scripture references

Given a text, search for scripture references and return any that are found in a list of tuples.

For example, given the following text:

import pythonbible as bible

text = "The parable of the lost sheep is told in Matthew 18:12-14 and Luke 15:3-7."
references = bible.get_references(text)

The search functionality should return the following list of scripture reference tuples:

[(<Book.MATTHEW: 40>, 18, 12, 18, 14), (<Book.LUKE: 42>, 15, 3, 15, 7)]

Converting a normalized scripture reference into a list of integer verse ids

Any single verse can be identified by an integer that contains the book, chapter, and verse information. The first 1-2 digits of the integer id represent the book, the next 3 digits represent the chapter, and the last 3 digits represent the verse.

For example, "Genesis 1:1" would be represented as:

1001001

"John 3:16" would be represented as:

43003016

The book of John is the 43rd book of the Bible, "003" represents the 3rd chapter, and "016" represents the sixteenth verse.

Since the book, chapter, and verses are standardized and unlikely to change, this allows us to reference verses in a very efficient way.

Given a normalized scripture reference, which can contain one or more verses, the conversion functionality will convert that normalized scripture reference tuple into a list of verse id integers.

For example, given the following normalized scripture reference for Genesis 1:1-4:

import pythonbible as bible

reference = (bible.Book.GENESIS, 1, 1, 1, 4)
verse_ids = bible.convert_reference_to_verse_ids(reference)

The conversion functionality would return the following list of verse id integers:

[1001001, 1001002, 1001003, 1001004]

Converting a list of verse id integers into a list of normalized scripture reference tuples

The reverse of the above feature, we can take a list of integer verse ids and convert it back into a list of normalized scripture reference tuples.

For example, the following list of verse ids represent the references Matthew 18:12-14 and Luke 15:3-7.

import pythonbible as bible

verse_ids = [40018012, 40018013, 40018014, 42015003, 42015004, 42015005, 42015006, 42015007, ]
references = bible.convert_verse_ids_to_references(verse_ids)

The conversion functionality would return the following list of normalized scripture reference tuples.

[(<Book.MATTHEW: 40>, 18, 12, 18, 14), (<Book.LUKE: 42>, 15, 3, 15, 7)]

Converting a list of normalized scripture reference tuples into a formatted string scripture reference

Given a list of normalized references, this feature formats them into a human-readable scripture reference string.

It sorts the list so that the references appear in the order they would in the Bible. It also combines verses into ranges when possible.

For example:

import pythonbible as bible

text = "My favorite verses are Philippians 4:8, Isaiah 55:13, and Philippians 4:4-7."
references = bible.get_references(text)
formatted_reference = bible.format_scripture_references(references)

The resulting formatted reference should be:

'Isaiah 55:13;Philippians 4:4-8'

There are a couple of reference formatting features not yet implemented:

  • Smarter pluralization of the book of Psalms (i.e. If just one Psalm is referenced, the singular "Psalm" should be used, but if more than one Psalm is referenced, the plural "Psalms" should be used.)
  • Optional exclusion of the chapter number for books that contain only one chapter (e.g. Some prefer references like Obadiah 1-4 rather than Obadiah 1:1-4, since Obadiah contains only one chapter.)

Given a list of verse id integers, formatting the related Biblical text for print or web display in one or more open source or public domain versions

coming soon...

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythonbible-0.1.3.tar.gz (7.2 MB view details)

Uploaded Source

Built Distribution

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

pythonbible-0.1.3-py3-none-any.whl (7.4 MB view details)

Uploaded Python 3

File details

Details for the file pythonbible-0.1.3.tar.gz.

File metadata

  • Download URL: pythonbible-0.1.3.tar.gz
  • Upload date:
  • Size: 7.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for pythonbible-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9d5b43119df9e10fb6eccd93753777dd5492c85887b5a8a5cc864fe3033c7c51
MD5 fba8380964e7a5c2ffa073ddc0e3430c
BLAKE2b-256 51052f9d0bdf51a1eff96c6c6aef4abcb812d1b773b31eefcdcab657be7d1868

See more details on using hashes here.

File details

Details for the file pythonbible-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pythonbible-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for pythonbible-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4ab4c39712f8259f254c73e6aecdc47cac2b200dbd6059de5d64c38b9014341
MD5 5ceedd8763b2adabcc2e8a6d51e25f48
BLAKE2b-256 e014418071d710d58b75058fefd217142e997d059e4f1fde0bfaa0e5be3ba031

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 Sentry Error logging StatusPage Status page