Skip to content

Commit c044b79

Browse files
authored
Move Bible XML parser functionality into separate library (#86)
* initial gutting of parser code. tests expected to fail. * remove defusedxml references * made readme prettier * added Bible output from pythonbible-parser for KJV and ASV and updated formatter to fix several tests * refactoring / tidying up * refactoring / tidying up * refactoring / tidying up * updated asv bibles * updated kjv bibles * support for version book titles * exclude large bible files from pre-commit checks * updated sourcery config to ignore large bible files and to support python 3.7 * update asv bibles * update asv bibles * update kjv bibles * improve test coverage * gotta support python 3.7 for a couple more months :) * attempt to tell codacy to ignore the large bible files * test coverage
1 parent fc5d175 commit c044b79

50 files changed

Lines changed: 775735 additions & 536722 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codacy.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
exclude_paths:
3+
- "pythonbible/bible/asv/*.py"
4+
- "pythonbible/bible/kjv/*.py"

.pre-commit-config.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ repos:
88
- id: debug-statements
99
- id: name-tests-test
1010
- id: requirements-txt-fixer
11-
- id: check-added-large-files
1211
- repo: https://github.com/psf/black
1312
rev: 23.3.0
1413
hooks:
@@ -42,3 +41,19 @@ repos:
4241
- flake8-tidy-imports
4342
- flake8-warnings
4443
- wemake-python-styleguide
44+
45+
exclude: |
46+
(?x)^(
47+
pythonbible/bible/asv/html.py|
48+
pythonbible/bible/asv/html_notes.py|
49+
pythonbible/bible/asv/html_readers.py|
50+
pythonbible/bible/asv/plain_text.py|
51+
pythonbible/bible/asv/plain_text_notes.py|
52+
pythonbible/bible/asv/plain_text_readers.py|
53+
pythonbible/bible/kjv/html.py|
54+
pythonbible/bible/kjv/html_notes.py|
55+
pythonbible/bible/kjv/html_readers.py|
56+
pythonbible/bible/kjv/plain_text.py|
57+
pythonbible/bible/kjv/plain_text_notes.py|
58+
pythonbible/bible/kjv/plain_text_readers.py
59+
)$

.sourcery.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ignore:
2+
- .git
3+
- venv
4+
- .venv
5+
- env
6+
- .env
7+
- .tox
8+
- node_modules
9+
- vendor
10+
- pythonbible/bible/asv/*.py
11+
- pythonbible/bible/kjv/*.py
12+
13+
rule_settings:
14+
python_version: '3.7'

README.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,39 @@
22

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

5-
[![PyPI version](https://img.shields.io/pypi/v/pythonbible?color=blue&logo=pypi&logoColor=lightgray)](https://pypi.org/project/pythonbible/)
6-
[![license MIT](https://img.shields.io/badge/license-MIT-orange.svg)](https://opensource.org/licenses/MIT)
7-
8-
![Test](https://github.com/avendesora/pythonbible/workflows/Test/badge.svg)
9-
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/dc1333c64b434f7bb813d08750462921)](https://www.codacy.com/gh/avendesora/pythonbible/dashboard?utm_source=github.com&utm_medium=referral&utm_content=avendesora/pythonbible&utm_campaign=Badge_Coverage)
10-
11-
![CodeQL](https://github.com/avendesora/pythonbible/workflows/CodeQL/badge.svg)
12-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc1333c64b434f7bb813d08750462921)](https://www.codacy.com/gh/avendesora/pythonbible/dashboard?utm_source=github.com&utm_medium=referral&utm_content=avendesora/pythonbible&utm_campaign=Badge_Grade)
13-
14-
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/avendesora/pythonbible/main.svg)](https://results.pre-commit.ci/latest/github/avendesora/pythonbible/main)
15-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
16-
17-
[![Python 3.11](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20dev-blue?logo=python&logoColor=lightgray)](https://www.python.org/downloads/)
5+
<table>
6+
<tr>
7+
<td>Latest Version</td>
8+
<td>
9+
<a href="https://pypi.org/project/pythonbible/"><img src="https://img.shields.io/pypi/v/pythonbible?color=gold&logo=pypi&logoColor=lightgray"></a>
10+
<img src="https://img.shields.io/pypi/dm/pythonbible?color=gold">
11+
</td>
12+
</tr>
13+
<tr>
14+
<td>License</td>
15+
<td><a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-orange.svg"></a></td>
16+
</tr>
17+
<tr>
18+
<td>Tests</td>
19+
<td>
20+
<img src="https://github.com/avendesora/pythonbible/workflows/Test/badge.svg">
21+
<a href="https://www.codacy.com/gh/avendesora/pythonbible/dashboard?utm_source=github.com&utm_medium=referral&utm_content=avendesora/pythonbible&utm_campaign=Badge_Coverage"><img src="https://app.codacy.com/project/badge/Coverage/dc1333c64b434f7bb813d08750462921"></a>
22+
</td>
23+
</tr>
24+
<tr>
25+
<td>Code Quality</td>
26+
<td>
27+
<img src="https://github.com/avendesora/pythonbible/workflows/CodeQL/badge.svg">
28+
<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/>
29+
<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>
30+
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
31+
</td>
32+
</tr>
33+
<tr>
34+
<td>Supported Python Versions</td>
35+
<td><a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20dev-blue?logo=python&logoColor=lightgray"></a></td>
36+
</tr>
37+
</table>
1838

1939
## Documentation
2040

@@ -26,16 +46,6 @@ The full documentation for pythonbible can be found at [docs.python.bible](https
2646
pip install pythonbible
2747
```
2848

29-
### Optional Dependencies
30-
31-
If the [defusedxml](https://github.com/tiran/defusedxml) library is installed, pythonbible will use it to parse XML files rather than the builtin xml.etree library.
32-
33-
To install pythonbible with all optional dependencies, use the following command.
34-
35-
```shell script
36-
pip install pythonbible[all]
37-
```
38-
3949
## Features
4050

4151
### Searching text for scripture references

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ doc = [
4444
dev = [
4545
"pre-commit >=2.20.0",
4646
]
47-
all = [
48-
"defusedxml >=0.7.1",
49-
]
5047

5148
[tool.isort]
5249
profile = "black"
5350
add_imports = "from __future__ import annotations"
51+
force_single_line = true

pythonbible/__init__.py

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,40 @@
1111

1212
__version__ = "0.8"
1313

14-
from .bible.osis.parser import OSISParser
15-
from .book_groups import BOOK_GROUPS, BookGroup
14+
from .bible.bible import Bible
15+
from .book_groups import BOOK_GROUPS
16+
from .book_groups import BookGroup
1617
from .books import Book
17-
from .converter import (
18-
convert_reference_to_verse_ids,
19-
convert_references_to_verse_ids,
20-
convert_verse_ids_to_references,
21-
)
18+
from .converter import convert_reference_to_verse_ids
19+
from .converter import convert_references_to_verse_ids
20+
from .converter import convert_verse_ids_to_references
2221
from .counters.book_counter import count_books
2322
from .counters.chapter_counter import count_chapters
2423
from .counters.verse_counter import count_verses
25-
from .errors import (
26-
InvalidBibleParserError,
27-
InvalidBookError,
28-
InvalidChapterError,
29-
InvalidVerseError,
30-
MissingBookFileError,
31-
MissingVerseFileError,
32-
)
33-
from .formatter import (
34-
format_scripture_references,
35-
format_scripture_text,
36-
format_single_reference,
37-
get_book_titles,
38-
get_parser,
39-
get_verse_text,
40-
)
24+
from .errors import InvalidBibleParserError
25+
from .errors import InvalidBookError
26+
from .errors import InvalidChapterError
27+
from .errors import InvalidVerseError
28+
from .errors import MissingBookFileError
29+
from .errors import MissingVerseFileError
30+
from .formatter import format_scripture_references
31+
from .formatter import format_scripture_text
32+
from .formatter import format_single_reference
33+
from .formatter import get_book_titles
34+
from .formatter import get_verse_text
4135
from .normalized_reference import NormalizedReference
42-
from .parser import get_references, normalize_reference
43-
from .validator import (
44-
is_valid_book,
45-
is_valid_chapter,
46-
is_valid_reference,
47-
is_valid_verse,
48-
is_valid_verse_id,
49-
)
50-
from .verses import (
51-
get_book_chapter_verse,
52-
get_book_number,
53-
get_chapter_number,
54-
get_number_of_chapters,
55-
get_number_of_verses,
56-
get_verse_id,
57-
get_verse_number,
58-
)
36+
from .parser import get_references
37+
from .parser import normalize_reference
38+
from .validator import is_valid_book
39+
from .validator import is_valid_chapter
40+
from .validator import is_valid_reference
41+
from .validator import is_valid_verse
42+
from .validator import is_valid_verse_id
43+
from .verses import get_book_chapter_verse
44+
from .verses import get_book_number
45+
from .verses import get_chapter_number
46+
from .verses import get_number_of_chapters
47+
from .verses import get_number_of_verses
48+
from .verses import get_verse_id
49+
from .verses import get_verse_number
5950
from .versions import Version

pythonbible/bible/asv/html.py

Lines changed: 62220 additions & 0 deletions
Large diffs are not rendered by default.

pythonbible/bible/asv/html_notes.py

Lines changed: 62220 additions & 0 deletions
Large diffs are not rendered by default.

pythonbible/bible/asv/html_readers.py

Lines changed: 62220 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)