44from typing import Any
55from typing import Type
66
7+ from pythonbible .books .common_constants import FIRST
8+ from pythonbible .books .common_constants import FIRST_BOOK
9+ from pythonbible .books .common_constants import SECOND
10+ from pythonbible .books .common_constants import SECOND_BOOK
11+ from pythonbible .books .common_constants import THIRD
12+ from pythonbible .books .john import JOHN_REGULAR_EXPRESSION
13+
714
815def _build_book_regular_expression (
916 book : str ,
@@ -24,30 +31,22 @@ def _add_suffix(regex: str, suffix: str | None = None) -> str:
2431_SAMUEL_REGULAR_EXPRESSION = r"(Samuel|Sam\.*|Sa\.*|Sm\.*)"
2532_KINGS_REGULAR_EXPRESSION = r"(Kings|Kgs\.*|Kin\.*|Ki\.*)"
2633_CHRONICLES_REGULAR_EXPRESSION = r"(Chronicles|Chron\.*|Chro\.*|Chr\.*|Ch\.*)"
27- _JOHN_REGULAR_EXPRESSION = r"(John|Joh\.*|Jhn\.*|Jo\.*(?!shua|b|nah|el)|Jn\.*)"
2834_CORINTHIANS_REGULAR_EXPRESSION = r"Co\.*(?:r\.*(?:inthians)?)?"
2935_THESSALONIANS_REGULAR_EXPRESSION = r"Th\.*(?:(s|(es(?:s)?))\.*(?:alonians)?)?"
3036_TIMOTHY_REGULAR_EXPRESSION = r"Ti\.*(?:m\.*(?:othy)?)?"
3137_PETER_REGULAR_EXPRESSION = r"(Pe\.*(?:t\.*(?:er)?)?|Pt\.*)"
3238
3339_MACCABEES_REGULAR_EXPRESSION = r"(Maccabees|Macc\.*|Mac\.*|Ma\.*|M\.*)"
3440
35- _FIRST = r"1|I\s+|1st\s+|First\s+"
36- _SECOND = r"2|II|2nd\s+|Second\s+"
37- _THIRD = r"3|III|3rd\s+|Third\s+"
38-
39- _FIRST_BOOK = rf"{ _FIRST } |(First\s+Book\s+of(?:\s+the)?)"
40- _SECOND_BOOK = rf"{ _SECOND } |(Second\s+Book\s+of(?:\s+the)?)"
41-
4241_EPISTLE_OF_PAUL_TO = r"Epistle\s+of\s+Paul\s+(?:the\s+Apostle\s+)?to(?:\s+the)?"
4342_GENERAL_EPISTLE_OF = r"(?:General\s+)?Epistle\s+(?:General\s+)?of"
4443
45- _FIRST_PAUL_EPISTLE = rf"{ _FIRST } |(First\s+{ _EPISTLE_OF_PAUL_TO } )"
46- _SECOND_PAUL_EPISTLE = rf"{ _SECOND } |(Second\s+{ _EPISTLE_OF_PAUL_TO } )"
44+ _FIRST_PAUL_EPISTLE = rf"{ FIRST } |(First\s+{ _EPISTLE_OF_PAUL_TO } )"
45+ _SECOND_PAUL_EPISTLE = rf"{ SECOND } |(Second\s+{ _EPISTLE_OF_PAUL_TO } )"
4746
48- _FIRST_GENERAL_EPISTLE = rf"{ _FIRST } |(First\s+{ _GENERAL_EPISTLE_OF } )"
49- _SECOND_GENERAL_EPISTLE = rf"{ _SECOND } |(Second\s+{ _GENERAL_EPISTLE_OF } )"
50- _THIRD_GENERAL_EPISTLE = rf"{ _THIRD } |(Third\s+{ _GENERAL_EPISTLE_OF } )"
47+ _FIRST_GENERAL_EPISTLE = rf"{ FIRST } |(First\s+{ _GENERAL_EPISTLE_OF } )"
48+ _SECOND_GENERAL_EPISTLE = rf"{ SECOND } |(Second\s+{ _GENERAL_EPISTLE_OF } )"
49+ _THIRD_GENERAL_EPISTLE = rf"{ THIRD } |(Third\s+{ _GENERAL_EPISTLE_OF } )"
5150
5251
5352class Book (Enum ):
@@ -111,7 +110,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
111110 "1 Samuel" ,
112111 _build_book_regular_expression (
113112 _SAMUEL_REGULAR_EXPRESSION ,
114- prefix = _FIRST_BOOK ,
113+ prefix = FIRST_BOOK ,
115114 suffix = r"Otherwise\s+Called\s+The\s+First\s+Book\s+of\s+the\s+Kings" ,
116115 ),
117116 ("Sa" , "Sam" , "Sm" ),
@@ -121,7 +120,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
121120 "2 Samuel" ,
122121 _build_book_regular_expression (
123122 _SAMUEL_REGULAR_EXPRESSION ,
124- prefix = _SECOND_BOOK ,
123+ prefix = SECOND_BOOK ,
125124 suffix = r"Otherwise\s+Called\s+The\s+Second\s+Book\s+of\s+the\s+Kings" ,
126125 ),
127126 ("Sa" , "Sam" , "Sm" ),
@@ -131,7 +130,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
131130 "1 Kings" ,
132131 _build_book_regular_expression (
133132 _KINGS_REGULAR_EXPRESSION ,
134- prefix = _FIRST_BOOK ,
133+ prefix = FIRST_BOOK ,
135134 suffix = r"\,\s+Commonly\s+Called\s+the\s+Third\s+Book\s+of\s+the\s+Kings" ,
136135 ),
137136 ("Kgs" , "Ki" , "Kin" ),
@@ -141,7 +140,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
141140 "2 Kings" ,
142141 _build_book_regular_expression (
143142 _KINGS_REGULAR_EXPRESSION ,
144- prefix = _SECOND_BOOK ,
143+ prefix = SECOND_BOOK ,
145144 suffix = r"\,\s+Commonly\s+Called\s+the\s+Fourth\s+Book\s+of\s+the\s+Kings" ,
146145 ),
147146 ("Kgs" , "Ki" , "Kin" ),
@@ -151,7 +150,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
151150 "1 Chronicles" ,
152151 _build_book_regular_expression (
153152 _CHRONICLES_REGULAR_EXPRESSION ,
154- prefix = _FIRST_BOOK ,
153+ prefix = FIRST_BOOK ,
155154 ),
156155 ("Ch" , "Chr" , "Chro" , "Chron" ),
157156 )
@@ -160,7 +159,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
160159 "2 Chronicles" ,
161160 _build_book_regular_expression (
162161 _CHRONICLES_REGULAR_EXPRESSION ,
163- prefix = _SECOND_BOOK ,
162+ prefix = SECOND_BOOK ,
164163 ),
165164 ("Ch" , "Chr" , "Chro" , "Chron" ),
166165 )
@@ -229,7 +228,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
229228 JOHN = (
230229 43 ,
231230 "John" ,
232- rf"(?<!(?:1|2|3|I)\s)(?<!(?:1|2|3|I)){ _JOHN_REGULAR_EXPRESSION } " ,
231+ rf"(?<!(?:1|2|3|I)\s)(?<!(?:1|2|3|I)){ JOHN_REGULAR_EXPRESSION } " ,
233232 ("Jhn" , "Jn" , "Jo" , "Joh" ),
234233 )
235234 ACTS = (
@@ -336,7 +335,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
336335 62 ,
337336 "1 John" ,
338337 _build_book_regular_expression (
339- _JOHN_REGULAR_EXPRESSION ,
338+ JOHN_REGULAR_EXPRESSION ,
340339 prefix = _FIRST_GENERAL_EPISTLE ,
341340 ),
342341 ("Jhn" , "Jn" , "Jo" , "Joh" ),
@@ -345,7 +344,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
345344 63 ,
346345 "2 John" ,
347346 _build_book_regular_expression (
348- _JOHN_REGULAR_EXPRESSION ,
347+ JOHN_REGULAR_EXPRESSION ,
349348 prefix = _SECOND_GENERAL_EPISTLE ,
350349 ),
351350 ("Jhn" , "Jn" , "Jo" , "Joh" ),
@@ -354,7 +353,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
354353 64 ,
355354 "3 John" ,
356355 _build_book_regular_expression (
357- _JOHN_REGULAR_EXPRESSION ,
356+ JOHN_REGULAR_EXPRESSION ,
358357 prefix = _THIRD_GENERAL_EPISTLE ,
359358 ),
360359 ("Jhn" , "Jn" , "Jo" , "Joh" ),
@@ -374,7 +373,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
374373 "1 Esdras" ,
375374 _build_book_regular_expression (
376375 r"(Esdras|Esdr\.*|Esd\.*|Es\.*)" ,
377- _FIRST ,
376+ FIRST ,
378377 ),
379378 ("Es" , "Esd" , "Esdr" ),
380379 )
@@ -396,7 +395,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
396395 "1 Maccabees" ,
397396 _build_book_regular_expression (
398397 _MACCABEES_REGULAR_EXPRESSION ,
399- _FIRST ,
398+ FIRST ,
400399 ),
401400 ("M" , "Ma" , "Mac" , "Macc" ),
402401 )
@@ -405,7 +404,7 @@ def abbreviations(self: Book) -> tuple[str, ...]:
405404 "2 Maccabees" ,
406405 _build_book_regular_expression (
407406 _MACCABEES_REGULAR_EXPRESSION ,
408- _SECOND ,
407+ SECOND ,
409408 ),
410409 ("M" , "Ma" , "Mac" , "Macc" ),
411410 )
0 commit comments