Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f11674b
support other OSIS files
avendesora May 15, 2024
b540ead
update supported Python versions
avendesora May 15, 2024
e83cf7c
test all available public domain en OSIS versions and tweak parsers t…
avendesora May 21, 2024
0286508
upgrade pythonbible
avendesora May 24, 2024
dd6c68c
Merge branch 'main' into issue-66-parsing-additional-translations
avendesora May 24, 2024
27fb50b
fix merge
avendesora May 24, 2024
e6d30f2
skip mypy and sourcery in ci (non-local) runs of pre-commit
avendesora May 24, 2024
85f9d0c
fix type hints for Python 3.8
avendesora May 24, 2024
7647a4d
upgrade pythonbible version
avendesora May 28, 2024
db2ed83
remove ds_store
avendesora May 28, 2024
ae26b50
upgrade pythonbible version
avendesora May 28, 2024
37f5990
Merge branch 'main' into issue-66-parsing-additional-translations
avendesora May 28, 2024
b00cc51
escape backslash and use default titles if OSIS file doesn't contain …
avendesora May 31, 2024
3f897cf
add max verses to bible output
avendesora Aug 8, 2024
cd2738e
WIP related to RVA (Spanish) version
avendesora Aug 20, 2024
f2d9b28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
2aed3c8
Merge branch 'main' into issue-66-parsing-additional-translations
avendesora Aug 20, 2024
c3a5795
comment out reference to REINA_VALERA_1989 since it doesn't exist in …
avendesora Aug 20, 2024
9779cd4
Merge remote-tracking branch 'origin/issue-66-parsing-additional-tran…
avendesora Aug 20, 2024
7a4ac2f
Merge branch 'main' into issue-66-parsing-additional-translations
avendesora Dec 30, 2025
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
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ci:
skip: [mypy,sourcery]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
Expand All @@ -14,3 +17,17 @@ repos:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
args: ["--config-file", "pyproject.toml", "--ignore-missing-imports"]
#args: [--strict, --ignore-missing-imports]
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.18.0
hooks:
- id: sourcery
# The best way to use Sourcery in a pre-commit hook:
# * review only changed lines:
# * omit the summary
args: [--diff=git diff HEAD, --no-summary]
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
]
requires = [
"defusedxml >=0.7.1",
"pythonbible ==0.10.0",
"pythonbible ==0.13.1",
]
description-file = "README.md"
requires-python = ">=3.8"
Expand All @@ -48,12 +48,7 @@ dev = [
all = [
]

[tool.isort]
profile = "black"
add_imports = "from __future__ import annotations"
force_single_line = true

[tool.ruff]
[tool.ruff.lint]
select = [
"A",
"ANN",
Expand Down Expand Up @@ -101,6 +96,7 @@ select = [
]
ignore = [
"ANN401",
"COM812", # causes conflicts with the formmatter
"D100",
"D101",
"D102",
Expand All @@ -112,15 +108,19 @@ ignore = [
"FBT001",
"FBT002",
"FBT003",
"ISC001", # causes conflicts with the formmatter
]
fix = true

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"pythonbible_parser/osis/old_osis_parser.py" = ["B019", "PLR0913"]
"pythonbible_parser/osis/osis_book_parser.py" = ["C901", "PLR0913"]
"pythonbible_parser/osis/osis_parser.py" = ["PLR0913"]
"tests/*.py" = ["S101"]
"tests/bible_data_test.py" = ["ERA001"]
"tests/conftest.py" = ["E501", "RUF"]
"tests/public_domain_versions_test.py" = ["ERA001"]
# TODO - remove this once code is fully implemented
"pythonbible_parser/usfm/usfm_parser.py" = ["ANN001", "ANN101", "D105", "D107", "T201"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-single-line = true
4 changes: 3 additions & 1 deletion pythonbible_parser/bible_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class BibleParser:
parsers (e.g. OSIS, USFM, USFX, etc.) for parsing scripture text.
"""

version: Version

def __init__(self: BibleParser, version: Version) -> None:
"""Initialize the Bible parser with the version.

:param version:
"""
self.version: Version = version
self.version = version

@abstractmethod
def get_book_title(self: BibleParser, book: Book) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pythonbible_parser/osis/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pythonbible as bible

# noinspection SpellCheckingInspection
BOOK_IDS: dict[bible.Book, str] = MappingProxyType(
BOOK_IDS: MappingProxyType[bible.Book, str] = MappingProxyType(
{
bible.Book.GENESIS: "Gen",
bible.Book.EXODUS: "Exod",
Expand Down
14 changes: 9 additions & 5 deletions pythonbible_parser/osis/old_osis_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

import os
import ast
from functools import lru_cache
from pathlib import Path
from typing import Any
Expand All @@ -25,7 +25,7 @@
from pythonbible_parser.osis.osis_utilities import parse_osis_id
from pythonbible_parser.osis.osis_utilities import strip_namespace_from_tag

XML_FOLDER: str = Path(Path(os.path.realpath(__file__)).parent / "versions")
XML_FOLDER: Path = Path(__file__).parent / "versions"

XPATH_BOOK: str = ".//xmlns:div[@osisID='{}']"
XPATH_BOOK_TITLE: str = f"{XPATH_BOOK}/xmlns:title"
Expand All @@ -51,7 +51,7 @@ def __init__(self: OldOSISParser, version: Version) -> None:
super().__init__(version)

self.tree: ElementTree = ElementTree.parse(
Path(XML_FOLDER / f"{self.version.value.lower()}.xml"),
XML_FOLDER / f"{self.version.value.lower()}.xml",
)
self.namespaces: dict[str, str] = {
"xmlns": get_namespace(self.tree.getroot().tag),
Expand Down Expand Up @@ -103,7 +103,9 @@ def get_scripture_passage_text(
verse_ids_tuple: tuple[int, ...] = tuple(verse_ids)

# keyword arguments
include_verse_number: bool = kwargs.get("include_verse_number", True)
include_verse_number: bool = ast.literal_eval(
str(kwargs.get("include_verse_number", True))
)

return self._get_scripture_passage_text_memoized(
verse_ids_tuple,
Expand Down Expand Up @@ -131,7 +133,9 @@ def verse_text(
raise InvalidVerseError(msg)

# keyword arguments
include_verse_number: bool = kwargs.get("include_verse_number", True)
include_verse_number: bool = ast.literal_eval(
str(kwargs.get("include_verse_number", True))
)

return self._get_verse_text_memoized(verse_id, include_verse_number)

Expand Down
Loading
Loading