Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.15.2] - 2025-12-31

### Fixed

- Fixed the pythonbible package README file to, for now, be a copy of the main project README file so that it displays in PyPI correctly.

## [0.15.1] - 2025-12-31

### Added
Expand Down Expand Up @@ -214,9 +220,10 @@ The goal of this release was to address [Issue #90], and to make things related

## [0.0.1] - 2020-10-08

[unreleased]: https://github.com/avendesora/pythonbible/compare/v0.15.1...HEAD
[0.15.1]: https://github.com/avendesora/pythonbible/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/avendesora/pythonbible/compare/v0.14.0...v0.15.0
[unreleased]: https://github.com/avendesora/pythonbible/compare/v0.15.2...HEAD
[0.15.2]: https://github.com/avendesora/pythonbible/compare/v0.15.1...v0.15.2
[0.15.1]: https://github.com/avendesora/pythonbible/compare/v0.14.0...v0.15.1
[0.15.0]: https://github.com/avendesora/pythonbible/compare/v0.14.0...v0.15.1
[0.14.0]: https://github.com/avendesora/pythonbible/compare/v0.13.1...v0.14.0
[0.13.1]: https://github.com/avendesora/pythonbible/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/avendesora/pythonbible/compare/v0.12.0...v0.13.0
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "Nathan Patton"

# The full version, including alpha/beta/rc tags
release = "0.15.1"
release = "0.15.2"


# -- General configuration ---------------------------------------------------
Expand Down
203 changes: 203 additions & 0 deletions pythonbible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
![Image](https://github.com/avendesora/pythonbible/raw/main/pythonbible.png)

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

<table>
<tr>
<td>Latest Version</td>
<td>
<a href="https://pypi.org/project/pythonbible/"><img src="https://img.shields.io/pypi/v/pythonbible?color=gold&logo=pypi&logoColor=lightgray"></a><br />
<img src="https://img.shields.io/pypi/dm/pythonbible?color=gold">
</td>
</tr>
<tr>
<td>License</td>
<td><a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-orange.svg"></a></td>
</tr>
<tr>
<td>Workflows</td>
<td>
<img src="https://github.com/avendesora/pythonbible/actions/workflows/python-package.yml/badge.svg"><br/>
<img src="https://github.com/avendesora/pythonbible/workflows/CodeQL/badge.svg"><br />
<img src="https://github.com/avendesora/pythonbible/actions/workflows/tests.yml/badge.svg">
</td>
</tr>
<tr>
<td>Code Quality</td>
<td>
<a href="https://www.codacy.com/gh/avendesora/pythonbible/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=avendesora/pythonbible&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/dc1333c64b434f7bb813d08750462921"></a><br/>
<a href="https://app.codacy.com/gh/avendesora/pythonbible/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage"><img src="https://app.codacy.com/project/badge/Coverage/dc1333c64b434f7bb813d08750462921"></a><br />
<a href="https://results.pre-commit.ci/latest/github/avendesora/pythonbible/main"><img src="https://results.pre-commit.ci/badge/github/avendesora/pythonbible/main.svg"></a><br />
<a href="https://sourcery.ai"><img src="https://img.shields.io/badge/Sourcery-enabled-brightgreen"></a>
</td>
</tr>
<tr>
<td>Supported Python Versions</td>
<td><a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue?logo=python&logoColor=lightgray"></a></td>
</tr>
</table>

## Documentation

The full documentation for pythonbible can be found at [docs.python.bible](https://docs.python.bible).

## Installation

```shell script
python3 -m pip install pythonbible
```

## Features

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

For example, given the following text:

```python
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 references:

```python
[
NormalizedReference(
book=<Book.MATTHEW: 40>,
start_chapter=18,
start_verse=12,
end_chapter=18,
end_verse=14,
end_book=<Book.MATTHEW: 40>
),
NormalizedReference(
book=<Book.LUKE: 42>,
start_chapter=15,
start_verse=3,
end_chapter=15,
end_verse=7,
end_book=<Book.LUKE: 42>
)
]
```

### 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:

```python
1001001
```

"John 3:16" would be represented as:

```python
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 into a list of verse id integers.

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

```python
import pythonbible as bible

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

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

```python
(1001001, 1001002, 1001003, 1001004)
```

### Converting a list of verse id integers into a list of normalized scripture references
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 references.

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

```python
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 references.

```python
[
NormalizedReference(
book=<Book.MATTHEW: 40>,
start_chapter=18,
start_verse=12,
end_chapter=18,
end_verse=14,
end_book=<Book.MATTHEW: 40>
),
NormalizedReference(
book=<Book.LUKE: 42>,
start_chapter=15,
start_verse=3,
end_chapter=15,
end_verse=7,
end_book=<Book.LUKE: 42>
)
]
```

### Converting a list of normalized scripture references 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:

```python
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:

```python
'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.)

### Formatting Biblical text for print or web display in one or more open-source or public domain versions

This is still a work in progress, but there is some existing functionality related to this.

The related [pythonbible-parser](https://github.com/avendesora/pythonbible-parser/) library includes a parser to parse [OSIS](https://ebible.org/osis/) formatted XML files and convert them into a more efficient format for use in Python. The King James and American Standard OSIS files have been converted into python classes and have been included in the **pythonbible** library and can be currently used to retrieve the text for a single verse:

```python
import pythonbible as bible

verse_text = bible.get_verse_text(1001001, version=bible.Version.KING_JAMES)
```

The resulting verse_text would be:

```python
'In the beginning God created the heaven and the earth.'
```

The version argument is optional and currently defaults to ``AMERICAN_STANDARD``. Ideally, that default will be configurable in a future release.
2 changes: 1 addition & 1 deletion pythonbible/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module-name = "pythonbible"

[project]
name = "pythonbible"
version = "0.15.1"
version = "0.15.2"
description-file = "README.md"
requires-python = ">=3.10"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion pythonbible/pythonbible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from __future__ import annotations

__version__ = "0.15.1"
__version__ = "0.15.2"

from .bible import add_bible
from .bible import get_bible
Expand Down
Loading
Loading