djangobible 0.1.1__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
djangobible/__init__.py CHANGED
@@ -1,5 +1,4 @@
1
- """
2
- djangobible python library.
1
+ """djangobible python library.
3
2
 
4
3
  djangobible lets you easily associate Django models with Bible Scripture references and
5
4
  search accordingly.
@@ -7,6 +6,6 @@ search accordingly.
7
6
 
8
7
  from __future__ import annotations
9
8
 
10
- __version__ = "0.1.1"
9
+ __version__ = "0.3.0"
11
10
 
12
11
  from pythonbible import *
djangobible/fields.py CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Any, Callable
5
+ from typing import Any
6
+ from typing import Callable
6
7
 
7
8
  import pythonbible as bible
8
9
  from django import forms
@@ -24,7 +25,8 @@ class VerseField(models.Field):
24
25
  bible.get_references(value),
25
26
  )[0]
26
27
  elif isinstance(value, int) and not bible.is_valid_verse_id(value):
27
- raise ValidationError(f"{value} is not a valid verse id.")
28
+ error_message = f"{value} is not a valid verse id."
29
+ raise ValidationError(error_message)
28
30
 
29
31
  return super().get_prep_value(value)
30
32
 
@@ -56,8 +58,8 @@ class VerseField(models.Field):
56
58
 
57
59
  def formfield(
58
60
  self: VerseField,
59
- form_class: Any = None,
60
- choices_form_class: Any = None,
61
+ form_class: type[forms.Field] | None = None,
62
+ choices_form_class: type[forms.Field] | None = None,
61
63
  **kwargs: Any,
62
64
  ) -> forms.Field:
63
65
  """Make sure the form field is a CharField."""
@@ -70,7 +72,7 @@ class VerseField(models.Field):
70
72
 
71
73
  def get_db_prep_save(
72
74
  self: VerseField,
73
- value: Any,
75
+ value: int | str | None,
74
76
  **kwargs: Any,
75
77
  ) -> int | None:
76
78
  """Validate and convert the value to a verse id int before saving to the DB."""
@@ -83,12 +85,12 @@ class VerseField(models.Field):
83
85
  if verse_ids := bible.convert_references_to_verse_ids(references):
84
86
  value = verse_ids[0]
85
87
  else:
86
- raise ValidationError(
87
- f"{value} does not contain a valid Scripture reference.",
88
- )
88
+ error_message = f"{value} does not contain a valid Scripture reference."
89
+ raise ValidationError(error_message)
89
90
 
90
91
  if not bible.is_valid_verse_id(value):
91
- raise ValidationError(f"{value} is not a valid verse id.")
92
+ error_message = f"{value} is not a valid verse id."
93
+ raise ValidationError(error_message)
92
94
 
93
95
  return int(value)
94
96
 
djangobible/models.py CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Any
6
-
7
5
  import pythonbible as bible
8
- from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
6
+ from django.contrib.contenttypes.fields import GenericForeignKey
7
+ from django.contrib.contenttypes.fields import GenericRelation
9
8
  from django.contrib.contenttypes.models import ContentType
10
9
  from django.db import models
11
10
 
@@ -29,8 +28,8 @@ class VerseRelation(models.Model):
29
28
  self: VerseRelation,
30
29
  force_insert: bool = False,
31
30
  force_update: bool = False,
32
- using: Any = None,
33
- update_fields: Any = None,
31
+ using: str | None = None,
32
+ update_fields: list[str] | None = None,
34
33
  ) -> None:
35
34
  """Save the instance to the DB."""
36
35
  if not bible.is_valid_verse_id(self.verse):
@@ -45,7 +44,7 @@ class ScriptureIndexedModelManager(models.Manager):
45
44
  def filter_by_verse_ids(
46
45
  self: ScriptureIndexedModelManager,
47
46
  verse_ids: list[int] | None,
48
- ) -> Any:
47
+ ) -> models.QuerySet:
49
48
  """Return the Query Set for the objects related to the given verse ids."""
50
49
  content_type = ContentType.objects.get_for_model(self.model)
51
50
  verse_relations = VerseRelation.objects.filter(
@@ -13,8 +13,7 @@ register = template.Library()
13
13
 
14
14
  @register.simple_tag
15
15
  def verse_reference(verse_id: int, **kwargs: Any) -> str:
16
- """
17
- For a given verse id return the formatted scripture reference string.
16
+ """For a given verse id return the formatted scripture reference string.
18
17
 
19
18
  :param verse_id:
20
19
  :return: the scripture reference string for the given verse id
@@ -25,7 +24,7 @@ def verse_reference(verse_id: int, **kwargs: Any) -> str:
25
24
  book, chapter, verse = bible.get_book_chapter_verse(verse_id)
26
25
 
27
26
  if version_id := kwargs.get("version"):
28
- kwargs["version"] = _get_version(version_id)
27
+ kwargs["version"] = _get_version(version_id) # type: ignore[arg-type,assignment]
29
28
 
30
29
  reference = bible.NormalizedReference(book, chapter, verse, chapter, verse)
31
30
 
@@ -34,19 +33,18 @@ def verse_reference(verse_id: int, **kwargs: Any) -> str:
34
33
 
35
34
  @register.simple_tag
36
35
  def verse_text(verse_id: int, **kwargs: Any) -> str:
37
- """
38
- For a given verse id and version, return the verse text string.
36
+ """For a given verse id and version, return the verse text string.
39
37
 
40
38
  :param verse_id:
41
39
  :return: the verse text for the given verse id and version
42
40
  """
43
- version_id: str | None = kwargs.get("version")
41
+ version_id: str | None = kwargs.get("version") # type: ignore[assignment]
44
42
  text: str = (
45
43
  bible.get_verse_text(verse_id, _get_version(version_id))
46
44
  if version_id
47
45
  else bible.get_verse_text(verse_id)
48
46
  )
49
- include_verse_numbers: bool = kwargs.get("include_verse_numbers", False)
47
+ include_verse_numbers: bool = kwargs.get("include_verse_numbers", False) # type: ignore[assignment]
50
48
 
51
49
  return (
52
50
  f"{bible.get_verse_number(verse_id)}. {text}" if include_verse_numbers else text
djangobible/validators.py CHANGED
@@ -3,11 +3,9 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from django.core.exceptions import ValidationError
6
- from pythonbible import (
7
- NormalizedReference,
8
- convert_references_to_verse_ids,
9
- get_references,
10
- )
6
+ from pythonbible import NormalizedReference
7
+ from pythonbible import convert_references_to_verse_ids
8
+ from pythonbible import get_references
11
9
 
12
10
 
13
11
  def validate_verse(verse_value: str | None) -> None:
@@ -18,12 +16,15 @@ def validate_verse(verse_value: str | None) -> None:
18
16
  references: list[NormalizedReference] = get_references(verse_value)
19
17
 
20
18
  if not references:
21
- raise ValidationError("Not a valid reference.")
19
+ error_message = "Not a valid reference."
20
+ raise ValidationError(error_message)
22
21
 
23
22
  if len(references) > 1:
24
- raise ValidationError("Only single verse references allowed.")
23
+ error_message = "Only single verse references allowed."
24
+ raise ValidationError(error_message)
25
25
 
26
26
  verse_ids: list[int] = convert_references_to_verse_ids(references)
27
27
 
28
28
  if len(verse_ids) > 1:
29
- raise ValidationError("Only single verse references allowed.")
29
+ error_message = "Only single verse references allowed."
30
+ raise ValidationError(error_message)
@@ -1,24 +1,30 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: djangobible
3
- Version: 0.1.1
4
- Summary: djangobible python library.
5
- Home-page: https://github.com/avendesora/djangobible
3
+ Version: 0.3.0
6
4
  Author: Nathan Patton
7
- Author-email: npatton@gmail.com
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
5
+ Author-email: Nathan Patton <npatton@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Framework :: Django
8
+ Classifier: Intended Audience :: Information Technology
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Classifier: Topic :: Software Development
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
10
22
  Classifier: License :: OSI Approved :: MIT License
11
- Requires-Dist: Django >=3.2.0
12
- Requires-Dist: pythonbible >=0.11.1
13
- Requires-Dist: defusedxml >=0.7.1 ; extra == "all"
14
- Requires-Dist: pre-commit >=2.20.0 ; extra == "dev"
15
- Requires-Dist: coverage >=6.4.2 ; extra == "test"
16
- Requires-Dist: factory-boy >=3.2.1 ; extra == "test"
17
- Requires-Dist: playwright >=1.23.1 ; extra == "test"
18
- Provides-Extra: all
19
- Provides-Extra: dev
20
- Provides-Extra: doc
21
- Provides-Extra: test
23
+ Requires-Dist: django>=4.2.0
24
+ Requires-Dist: pythonbible==0.14.0
25
+ Requires-Python: >=3.10
26
+ Project-URL: Source, https://github.com/avendesora/djangobible
27
+ Description-Content-Type: text/markdown
22
28
 
23
29
  # djangobible
24
30
 
@@ -39,8 +45,9 @@ The djangobible library is a Django app that wraps the [pythonbible](https://git
39
45
  <tr>
40
46
  <td>Tests</td>
41
47
  <td>
42
- <img src="https://github.com/avendesora/djangobible/workflows/Django%20CI/badge.svg">
43
- <a href="https://www.codacy.com/gh/avendesora/djangobible/dashboard?utm_source=github.com&utm_medium=referral&utm_content=avendesora/djangobible&utm_campaign=Badge_Coverage"><img src="https://app.codacy.com/project/badge/Coverage/83a28131bf6642ed9e439344122686fc"></a>
48
+ <img src="https://github.com/avendesora/djangobible/actions/workflows/tests.yml/badge.svg">
49
+ <img src="https://github.com/avendesora/djangobible/workflows/Django%20CI/badge.svg"><br/>
50
+ <a href="https://app.codacy.com/gh/avendesora/djangobible/coverage/dashboard"><img src="https://app.codacy.com/project/badge/Coverage/83a28131bf6642ed9e439344122686fc"></a>
44
51
  </td>
45
52
  </tr>
46
53
  <tr>
@@ -55,8 +62,8 @@ The djangobible library is a Django app that wraps the [pythonbible](https://git
55
62
  <tr>
56
63
  <td>Supported Python/Django Versions</td>
57
64
  <td>
58
- <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue?logo=python&logoColor=lightgray"></a><br />
59
- <a href="https://www.djangoproject.com/download/"><img src="https://img.shields.io/badge/Django-3.2%20%7C%204.0%20%7C%204.1%20%7C%204.2-blue"></a>
65
+ <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><br />
66
+ <a href="https://www.djangoproject.com/download/"><img src="https://img.shields.io/badge/Django-4.2%20%7C%205.0%20%7C%205.1%20%7C%205.2-blue"></a><br />
60
67
  </td>
61
68
  </tr>
62
69
  </table>
@@ -261,4 +268,3 @@ Then you could add, remove, and reference those verses with something like:
261
268
  ```
262
269
 
263
270
  Ideally, the form field would be a text field where the user could enter a list of Scripture references (e.g. "Genesis 1:1,3-10;Psalm 119;Luke 2:1-18;John 3:16")
264
-
@@ -0,0 +1,12 @@
1
+ djangobible/__init__.py,sha256=y0MkH-8--IsNMjbM6ftQqFHZA7J9R-Z0NXc07iRKURI,230
2
+ djangobible/apps.py,sha256=lJgCh5Hj0i-nuTS_1s9HmwMNgVX-i1nFEIJkVsUbOfs,244
3
+ djangobible/fields.py,sha256=i8KYKQY1K6ZJm2FSFmirutwBWM5Xfbtnp7pDC8dLUFw,3189
4
+ djangobible/migrations/0001_initial.py,sha256=5lNyBJtwuZSchhDbxeIfiWGPcf308PGl0Mc5uCxI5c0,1200
5
+ djangobible/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ djangobible/models.py,sha256=qDCKczj9nOYauVErkae14gfRaZSs0R-1mzuN3q5KD9E,3082
7
+ djangobible/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ djangobible/templatetags/verse_tags.py,sha256=xL-ZWOugyBKM1UyfLb7Hm3RD98Quu8_PhoAHV3UueGg,1811
9
+ djangobible/validators.py,sha256=nAtbb7Epwehd8oZ7ATSWKTcKCHklZZXYGlmLoUq7gow,996
10
+ djangobible-0.3.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
11
+ djangobible-0.3.0.dist-info/METADATA,sha256=tBriLOnfPvHh6XF-mw0Nvh_LhgCQUQ3hQ3Wwa0u2quU,10306
12
+ djangobible-0.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.8.0
2
+ Generator: uv 0.8.24
3
3
  Root-Is-Purelib: true
4
- Tag: py3-none-any
4
+ Tag: py3-none-any
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Nathan Patton
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,13 +0,0 @@
1
- djangobible/__init__.py,sha256=CZeKMO0N7WX92yJJRrcXxL_Vogcwva9d6WNT4f7xfZw,231
2
- djangobible/apps.py,sha256=lJgCh5Hj0i-nuTS_1s9HmwMNgVX-i1nFEIJkVsUbOfs,244
3
- djangobible/fields.py,sha256=dgACjzISLSHiP2O6W2EGkmeexq3l6NbJKGnuUMsxhVQ,3025
4
- djangobible/models.py,sha256=lDrU0RKwV8DDy2SrNky6Owrh73Rri6ud1Dm99ipapUs,3028
5
- djangobible/validators.py,sha256=MWMWUbiZLQsOp69Fy-V1z2Ly3qyGWWPLRjgG6RhU1BA,853
6
- djangobible/migrations/0001_initial.py,sha256=5lNyBJtwuZSchhDbxeIfiWGPcf308PGl0Mc5uCxI5c0,1200
7
- djangobible/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- djangobible/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- djangobible/templatetags/verse_tags.py,sha256=EmakxtAaXulVPpC9Rz3S49snWxlPdDX1vUiT0ZvqpXk,1728
10
- djangobible-0.1.1.dist-info/LICENSE,sha256=vtcKfpmHsOwjUi3axlhP7KzGGZE6OmG7cigMXbLK8xU,1070
11
- djangobible-0.1.1.dist-info/WHEEL,sha256=rSgq_JpHF9fHR1lx53qwg_1-2LypZE_qmcuXbVUq948,81
12
- djangobible-0.1.1.dist-info/METADATA,sha256=m8DjoaNMRGJ1yKE7YKlmHmNWO7C81Bydup4xv52HNd4,9850
13
- djangobible-0.1.1.dist-info/RECORD,,