versiref 0.1.0__py3-none-any.whl → 0.2.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.
- versiref/bible_ref.py +78 -1
- versiref/data/book_names/en-douay-rheims_names.json +78 -0
- versiref/versification.py +20 -0
- {versiref-0.1.0.dist-info → versiref-0.2.0.dist-info}/METADATA +7 -5
- {versiref-0.1.0.dist-info → versiref-0.2.0.dist-info}/RECORD +10 -9
- {versiref-0.1.0.dist-info → versiref-0.2.0.dist-info}/WHEEL +1 -1
- {versiref-0.1.0.dist-info → versiref-0.2.0.dist-info}/licenses/LICENSE +0 -0
versiref/bible_ref.py
CHANGED
|
@@ -6,7 +6,7 @@ This module provides classes for representing and manipulating Bible references.
|
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from typing import Generator, Optional
|
|
8
8
|
|
|
9
|
-
from versiref.ref_style import RefStyle
|
|
9
|
+
from versiref.ref_style import RefStyle, standard_names
|
|
10
10
|
from versiref.versification import Versification
|
|
11
11
|
|
|
12
12
|
|
|
@@ -98,6 +98,21 @@ class SimpleBibleRef:
|
|
|
98
98
|
ranges: list[VerseRange] = field(default_factory=list)
|
|
99
99
|
original_text: Optional[str] = None
|
|
100
100
|
|
|
101
|
+
def __str__(self) -> str:
|
|
102
|
+
"""Return a string representation of this simple Bible reference.
|
|
103
|
+
|
|
104
|
+
Shows a concise representation using the reference's original text
|
|
105
|
+
or formatted representation.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
A string representation of this simple Bible reference
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
ref_part = self.original_text or self.format(
|
|
112
|
+
RefStyle(names=standard_names("en-sbl_abbreviations"))
|
|
113
|
+
)
|
|
114
|
+
return f'SimpleBibleRef("{ref_part}")'
|
|
115
|
+
|
|
101
116
|
@classmethod
|
|
102
117
|
def for_range(
|
|
103
118
|
cls,
|
|
@@ -320,6 +335,23 @@ class BibleRef:
|
|
|
320
335
|
versification: Optional[Versification] = None
|
|
321
336
|
original_text: Optional[str] = None
|
|
322
337
|
|
|
338
|
+
def __str__(self) -> str:
|
|
339
|
+
"""Return a string representation of this Bible reference.
|
|
340
|
+
|
|
341
|
+
Shows a concise representation using the versification identifier if available,
|
|
342
|
+
and the reference's original text or formatted representation.
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
A string representation of this Bible reference
|
|
346
|
+
|
|
347
|
+
"""
|
|
348
|
+
ref_part = self.original_text or self.format(
|
|
349
|
+
RefStyle(names=standard_names("en-sbl_abbreviations"))
|
|
350
|
+
)
|
|
351
|
+
if self.versification is None:
|
|
352
|
+
return f'BibleRef("{ref_part}")'
|
|
353
|
+
return f'BibleRef("{ref_part}", versification={self.versification})'
|
|
354
|
+
|
|
323
355
|
@classmethod
|
|
324
356
|
def for_range(
|
|
325
357
|
cls,
|
|
@@ -394,6 +426,51 @@ class BibleRef:
|
|
|
394
426
|
return False
|
|
395
427
|
return all(ref.is_valid(self.versification) for ref in self.simple_refs)
|
|
396
428
|
|
|
429
|
+
def range_keys(self) -> Generator[tuple[int, int], None, None]:
|
|
430
|
+
"""Yield an integer key range for each verse range in the ref.
|
|
431
|
+
|
|
432
|
+
Book numbers are derived from self.versification, so it cannot be None.
|
|
433
|
+
If any book ID in the simple refs is not included in the versification,
|
|
434
|
+
no ranges for that book are yielded.
|
|
435
|
+
|
|
436
|
+
Verse numbers less than 0 (undefined) are replaced with:
|
|
437
|
+
- 0 for start verses
|
|
438
|
+
- the last verse number for the chapter for end verses
|
|
439
|
+
|
|
440
|
+
Yields:
|
|
441
|
+
(start_key, end_key): integer keys for the start and end of a range in the ref
|
|
442
|
+
Each key has 2 book digits, 3 chapter digits, and 3 verse digits.
|
|
443
|
+
|
|
444
|
+
"""
|
|
445
|
+
if self.versification is None:
|
|
446
|
+
return
|
|
447
|
+
for simple_ref in self.simple_refs:
|
|
448
|
+
if simple_ref.book_id not in self.versification.max_verses:
|
|
449
|
+
continue
|
|
450
|
+
else:
|
|
451
|
+
book_num = (
|
|
452
|
+
list(self.versification.max_verses.keys()).index(simple_ref.book_id)
|
|
453
|
+
+ 1
|
|
454
|
+
)
|
|
455
|
+
for range_ref in simple_ref.range_refs():
|
|
456
|
+
range = range_ref.ranges[0]
|
|
457
|
+
|
|
458
|
+
# Replace undefined start verse with 0
|
|
459
|
+
start_verse = 0 if range.start_verse < 0 else range.start_verse
|
|
460
|
+
|
|
461
|
+
# Replace undefined end verse with last verse of chapter
|
|
462
|
+
end_verse = range.end_verse
|
|
463
|
+
if end_verse < 0:
|
|
464
|
+
end_verse = self.versification.last_verse(
|
|
465
|
+
simple_ref.book_id, range.end_chapter
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
start_key = (
|
|
469
|
+
book_num * 1000000 + range.start_chapter * 1000 + start_verse
|
|
470
|
+
)
|
|
471
|
+
end_key = book_num * 1000000 + range.end_chapter * 1000 + end_verse
|
|
472
|
+
yield (start_key, end_key)
|
|
473
|
+
|
|
397
474
|
def range_refs(self) -> Generator["BibleRef", None, None]:
|
|
398
475
|
"""Yield a new BibleRef for each verse range across all simple refs.
|
|
399
476
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"GEN": "Genesis",
|
|
3
|
+
"EXO": "Exodus",
|
|
4
|
+
"LEV": "Leviticus",
|
|
5
|
+
"NUM": "Numbers",
|
|
6
|
+
"DEU": "Deuteronomy",
|
|
7
|
+
"JOS": "Josue",
|
|
8
|
+
"JDG": "Judges",
|
|
9
|
+
"RUT": "Ruth",
|
|
10
|
+
"1SA": "1 Kings",
|
|
11
|
+
"2SA": "2 Kings",
|
|
12
|
+
"1KI": "3 Kings",
|
|
13
|
+
"2KI": "4 Kings",
|
|
14
|
+
"1CH": "1 Paralipomenon",
|
|
15
|
+
"2CH": "2 Paralipomenon",
|
|
16
|
+
"EZR": "1 Esdras",
|
|
17
|
+
"NEH": "Nehemias",
|
|
18
|
+
"TOB": "Tobias",
|
|
19
|
+
"JDT": "Judith",
|
|
20
|
+
"EST": "Esther",
|
|
21
|
+
"JOB": "Job",
|
|
22
|
+
"PSA": "Psalm",
|
|
23
|
+
"PSAS": "Psalms",
|
|
24
|
+
"PRO": "Proverbs",
|
|
25
|
+
"ECC": "Ecclesiastes",
|
|
26
|
+
"SNG": "Canticle of Canticles",
|
|
27
|
+
"WIS": "Wisdom",
|
|
28
|
+
"SIR": "Ecclesiasticus",
|
|
29
|
+
"ISA": "Isaias",
|
|
30
|
+
"JER": "Jeremias",
|
|
31
|
+
"LAM": "Lamentations",
|
|
32
|
+
"BAR": "Baruch",
|
|
33
|
+
"EZK": "Ezechiel",
|
|
34
|
+
"DAN": "Daniel",
|
|
35
|
+
"HOS": "Osee",
|
|
36
|
+
"JOL": "Joel",
|
|
37
|
+
"AMO": "Amos",
|
|
38
|
+
"OBA": "Abdias",
|
|
39
|
+
"JON": "Jonas",
|
|
40
|
+
"MIC": "Micheas",
|
|
41
|
+
"NAM": "Nahum",
|
|
42
|
+
"HAB": "Habacuc",
|
|
43
|
+
"ZEP": "Sophonias",
|
|
44
|
+
"HAG": "Aggaeus",
|
|
45
|
+
"ZEC": "Zacharias",
|
|
46
|
+
"MAL": "Malachias",
|
|
47
|
+
"1MA": "1 Machabees",
|
|
48
|
+
"2MA": "2 Machabees",
|
|
49
|
+
"MAT": "Matthew",
|
|
50
|
+
"MRK": "Mark",
|
|
51
|
+
"LUK": "Luke",
|
|
52
|
+
"JHN": "John",
|
|
53
|
+
"ACT": "Acts",
|
|
54
|
+
"ROM": "Romans",
|
|
55
|
+
"1CO": "1 Corinthians",
|
|
56
|
+
"2CO": "2 Corinthians",
|
|
57
|
+
"GAL": "Galatians",
|
|
58
|
+
"EPH": "Ephesians",
|
|
59
|
+
"PHP": "Philippians",
|
|
60
|
+
"COL": "Colossians",
|
|
61
|
+
"1TH": "1 Thessalonians",
|
|
62
|
+
"2TH": "2 Thessalonians",
|
|
63
|
+
"1TI": "1 Timothy",
|
|
64
|
+
"2TI": "2 Timothy",
|
|
65
|
+
"TIT": "Titus",
|
|
66
|
+
"PHM": "Philemon",
|
|
67
|
+
"HEB": "Hebrews",
|
|
68
|
+
"JAS": "James",
|
|
69
|
+
"1PE": "1 Peter",
|
|
70
|
+
"2PE": "2 Peter",
|
|
71
|
+
"1JN": "1 John",
|
|
72
|
+
"2JN": "2 John",
|
|
73
|
+
"3JN": "3 John",
|
|
74
|
+
"JUD": "Jude",
|
|
75
|
+
"REV": "Apocalypse",
|
|
76
|
+
"1ES": "3 Esdras",
|
|
77
|
+
"2ES": "4 Esdras"
|
|
78
|
+
}
|
versiref/versification.py
CHANGED
|
@@ -13,11 +13,31 @@ class Versification:
|
|
|
13
13
|
Versifications are defined by JSON data that is loaded from a file when an instance is created.
|
|
14
14
|
The class provides methods to query information about the versification, such as the last verse
|
|
15
15
|
of a given chapter in a given book.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
max_verses: last valid verse number for each chapter of each book
|
|
19
|
+
The order of keys defines the book order.
|
|
20
|
+
identifier: optional name for the versification
|
|
21
|
+
|
|
16
22
|
"""
|
|
17
23
|
|
|
18
24
|
max_verses: dict[str, list[int]] = field(default_factory=dict)
|
|
19
25
|
identifier: Optional[str] = None
|
|
20
26
|
|
|
27
|
+
def __str__(self) -> str:
|
|
28
|
+
"""Return a string representation of this versification.
|
|
29
|
+
|
|
30
|
+
If an identifier is set, returns a concise form: Versification.named("identifier")
|
|
31
|
+
Otherwise, returns the default dataclass representation.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
A string representation of this versification
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
if self.identifier:
|
|
38
|
+
return f'Versification.named("{self.identifier}")'
|
|
39
|
+
return object.__str__(self)
|
|
40
|
+
|
|
21
41
|
@classmethod
|
|
22
42
|
def from_file(
|
|
23
43
|
cls, file_path: str, identifier: Optional[str] = None
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: versiref
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A package for sophisticated parsing, manipulation, and printing of references to the Bible
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Author-email: "Fr. John Lawrence M. Polis" <emptier-sank-dose@duck.com>
|
|
5
|
+
Author: Fr. John Lawrence M. Polis
|
|
6
|
+
Author-email: Fr. John Lawrence M. Polis <emptier-sank-dose@duck.com>
|
|
8
7
|
License-Expression: MIT
|
|
9
8
|
License-File: LICENSE
|
|
10
9
|
Classifier: Development Status :: 3 - Alpha
|
|
@@ -18,10 +17,13 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
21
|
Classifier: Topic :: Religion
|
|
22
22
|
Classifier: Topic :: Text Processing
|
|
23
|
-
Requires-Python: >=3.9
|
|
24
23
|
Requires-Dist: pyparsing>=3.2.3
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Project-URL: Homepage, https://github.com/fiapps/versiref
|
|
26
|
+
Project-URL: Issues, https://github.com/fiapps/versiref/issues
|
|
25
27
|
Description-Content-Type: text/markdown
|
|
26
28
|
|
|
27
29
|
# VersiRef
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
versiref/__init__.py,sha256=3uQ8CnJzBRxQLgoi52Mo4enh3MvarDyya9SVzZdDrp4,601
|
|
2
|
-
versiref/bible_ref.py,sha256=
|
|
3
|
-
versiref/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
versiref/ref_parser.py,sha256=ef359WpR_tlTumym28_MaH6Zp0dyVixTEm8eHkmIyqQ,22266
|
|
5
|
-
versiref/ref_style.py,sha256=iRPCPqbgJDDvRPmFixLU2IGMDA0inMOZ3mdAB57354Q,4672
|
|
6
|
-
versiref/versification.py,sha256=FQsKJ35YspRLBzkjWSRs6jVOVx1xVqELICJYGQW3LGk,4712
|
|
2
|
+
versiref/bible_ref.py,sha256=loifWIiLdGctxvwFzBM1-X9pLTXUnib28OrYhwD61wQ,19093
|
|
7
3
|
versiref/data/book_names/en-cmos_long.json,sha256=nxSutcEoBVXHvA3UwzKi3Y8z7NEqr_8lTAMelsoDSWc,1517
|
|
8
4
|
versiref/data/book_names/en-cmos_short.json,sha256=8ZO3d3wXGL3FSYj38PBdepjOkbQoSPBNq8_zw-PDGTc,1403
|
|
5
|
+
versiref/data/book_names/en-douay-rheims_names.json,sha256=o3SXK-kSLM3PUZnOEW7JwTmqP2UC3livWjrEMN_r91M,1587
|
|
9
6
|
versiref/data/book_names/en-sbl_abbreviations.json,sha256=8GenBCjOqFUbH25Kzw1eaxb2LMxqJBh8F0UI5peqhzc,1575
|
|
10
7
|
versiref/data/book_names/en-sbl_names.json,sha256=DL3EnhZzAlvYQW0m7rRfrZhDWakVaWrMk5Y-nSivnjQ,1979
|
|
11
8
|
versiref/data/book_names/it-cei_abbreviazioni.json,sha256=U9j2SkqMjJfKb9QHz0rjxjZov6Da7p4tGqDd5p34Sf0,1157
|
|
@@ -18,7 +15,11 @@ versiref/data/versifications/org.json,sha256=O44GX7WSEAJl_5686nH1N2kn-gPAhYRPMFj
|
|
|
18
15
|
versiref/data/versifications/rsc.json,sha256=znZgOjXbV_0OD9A3Oqxu9N-luzjwjXmlv67JiGsxPok,23139
|
|
19
16
|
versiref/data/versifications/rso.json,sha256=Re9PapvlfZs-bogtcEmRp8Sxtk2ftWGoQkAbqIJjNAU,29748
|
|
20
17
|
versiref/data/versifications/vulgata.json,sha256=MI4u2oQbBhPchjuJOunUsNJg1MeAqStPF7DcU42w-MY,33617
|
|
21
|
-
versiref
|
|
22
|
-
versiref
|
|
23
|
-
versiref
|
|
24
|
-
versiref
|
|
18
|
+
versiref/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
versiref/ref_parser.py,sha256=ef359WpR_tlTumym28_MaH6Zp0dyVixTEm8eHkmIyqQ,22266
|
|
20
|
+
versiref/ref_style.py,sha256=iRPCPqbgJDDvRPmFixLU2IGMDA0inMOZ3mdAB57354Q,4672
|
|
21
|
+
versiref/versification.py,sha256=QP4LYxrofeZNY3TK2Z7o4dfqXqhvogaDcakizXtCEMw,5383
|
|
22
|
+
versiref-0.2.0.dist-info/licenses/LICENSE,sha256=15zx8RJP7jG7okR50pC9aCpkaWcCzGDBzKif3PMBXPo,1073
|
|
23
|
+
versiref-0.2.0.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
24
|
+
versiref-0.2.0.dist-info/METADATA,sha256=5F8Aj521jBPtnQ3XMJboVHtyhuprIZXCjbhSqs6F3KU,5312
|
|
25
|
+
versiref-0.2.0.dist-info/RECORD,,
|
|
File without changes
|