linkture 2.6.3__py3-none-any.whl → 3.0.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.
linkture/__main__.py CHANGED
@@ -34,14 +34,6 @@ from ast import literal_eval
34
34
  def main(args):
35
35
 
36
36
  def switchboard(text):
37
- if args['cc']:
38
- return s.code_chapter(args['cc'])
39
- elif args['cv']:
40
- return s.code_verse(args['cv'])
41
- elif args['sc']:
42
- return s.serial_chapter_number(args['sc'])
43
- elif args['sv']:
44
- return s.serial_verse_number(args['sv'])
45
37
  if args['l'] is not None:
46
38
  prefix = '<a href="'
47
39
  suffix = '">'
@@ -80,7 +72,15 @@ def main(args):
80
72
  else:
81
73
  txt = args['r']
82
74
 
83
- if txt:
75
+ if args['cc']:
76
+ txt = s.code_chapter(args['cc'])
77
+ elif args['cv']:
78
+ txt = s.code_verse(args['cv'])
79
+ elif args['sc']:
80
+ txt = s.serial_chapter_number(args['sc'])
81
+ elif args['sv']:
82
+ txt = s.serial_verse_number(args['sv'])
83
+ elif txt:
84
84
  txt = switchboard(txt)
85
85
  else:
86
86
  print(parser.format_help())
@@ -125,7 +125,7 @@ tpe.add_argument('-x', action='store_true', help='extract list of scripture refe
125
125
  aux_group = parser.add_argument_group('auxiliary functions')
126
126
  aux = aux_group.add_mutually_exclusive_group(required=False)
127
127
  aux.add_argument('-sc', metavar=('BCV'), help='return the serial number (1-1189) of the chapter with code "BCV" ("bbcccvvv")')
128
- aux.add_argument('-sv', metavar=('BCV'), help='return the serial number (1-31091) of the verse with code "BCV" ("bbcccvvv")')
128
+ aux.add_argument('-sv', metavar=('BCV'), help='return the serial number (1-31194) of the verse with code "BCV" ("bbcccvvv")')
129
129
  aux.add_argument('-cc', metavar=('chapter'), help='return the BCV range for serial chapter number "chapter" (integer value)')
130
130
  aux.add_argument('-cv', metavar=('verse'), help='return the BCV code for serial verse number "verse" (integer value)')
131
131
 
linkture/linkture.py CHANGED
@@ -27,7 +27,7 @@
27
27
  """
28
28
 
29
29
  __app__ = 'linkture'
30
- __version__ = 'v2.6.3'
30
+ __version__ = 'v3.0.0'
31
31
 
32
32
 
33
33
  import json, regex, sqlite3
@@ -36,7 +36,7 @@ from pathlib import Path
36
36
  from unidecode import unidecode
37
37
 
38
38
 
39
- _available_languages = ('Cebuano', 'Chinese', 'Danish', 'Dutch', 'English', 'French', 'German', 'Greek', 'Hungarian', 'Italian', 'Japanese', 'Korean', 'Norwegian', 'Polish', 'Portuguese', 'Russian', 'Spanish', 'Swedish', 'Tagalog', 'Ukrainian')
39
+ _available_languages = ('Cebuano', 'Chinese', 'Danish', 'Dutch', 'English', 'Ewe', 'French', 'German', 'Greek', 'Hungarian', 'Italian', 'Japanese', 'Korean', 'Norwegian', 'Polish', 'Portuguese', 'Russian', 'Spanish', 'Swedish', 'Tagalog', 'Ukrainian')
40
40
  _non_latin = ('Chinese', 'Greek', 'Japanese', 'Korean', 'Russian', 'Ukrainian')
41
41
 
42
42
 
@@ -98,6 +98,7 @@ class Scriptures():
98
98
  self._ranges = pd.read_sql_query("SELECT * FROM Ranges;", con)
99
99
  self._verses = pd.read_sql_query("SELECT * FROM Verses;", con)
100
100
  self._chapters = pd.read_sql_query("SELECT * FROM Chapters;", con)
101
+ self._headings = (3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 98, 100, 101, 102, 103, 108, 109, 110, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 138, 139, 140, 141, 142, 143, 144, 145)
101
102
  cur.close()
102
103
  con.close()
103
104
  self._reported = []
@@ -359,7 +360,10 @@ class Scriptures():
359
360
  if not validate(book, c, v):
360
361
  return None, 0
361
362
  ch1 = c.zfill(3)
362
- v1 = '001'
363
+ if book == 19 and int(c) in self._headings: # some chapters start at verse 0
364
+ v1 = '000'
365
+ else:
366
+ v1 = '001'
363
367
 
364
368
  c = result.group(2)
365
369
  if not validate(book, c, v):
@@ -390,7 +394,10 @@ class Scriptures():
390
394
  if not validate(book, c, v):
391
395
  return None, 0
392
396
  ch1 = c.zfill(3)
393
- v1 = '001'
397
+ if book == 19 and int(c) in self._headings: # some chapters start at verse 0
398
+ v1 = '000'
399
+ else:
400
+ v1 = '001'
394
401
  v2 = str(self._ranges.loc[(self._ranges.Book == book) & (self._ranges.Chapter == int(ch1)), ['Last']].values[0][0]).zfill(3)
395
402
  return (b+ch1+v1, b+ch1+v2), None
396
403
  else:
@@ -456,7 +463,13 @@ class Scriptures():
456
463
  return None, '', 0, False
457
464
  se = self._ranges.loc[(self._ranges.Book == sb) & (self._ranges.Chapter == sc), ['Last']].values[0][0]
458
465
  le = self._ranges.loc[(self._ranges.Book == sb) & (self._ranges.Chapter == ec), ['Last']].values[0][0]
459
- if not ((0 < sv <= se) & (0 < ev <= le)): # verse(s) out of range
466
+ minsv = minev = 1
467
+ if sb == 19:
468
+ if sc in self._headings: # some chapters start at verse 0
469
+ minsv = 0
470
+ if ec in self._headings:
471
+ minev = 0
472
+ if not ((minsv <= sv <= se) & (minev <= ev <= le)): # verse(s) out of range
460
473
  return None, '', 0, False
461
474
  bk_name = self._tr_book_names[sb]
462
475
  if book == bk_name:
@@ -532,7 +545,8 @@ class Scriptures():
532
545
  return scriptures
533
546
 
534
547
 
535
- def link_scriptures(self, text, prefix='<a href=', suffix='>'): # NOTE: this always rewrites (full by default) - what if one wants to leave as is??
548
+ def link_scriptures(self, text, prefix='<a href=', suffix='>'):
549
+ # this always rewrites (full by default); if rewrite not desired, get code the scripture and build your own link
536
550
 
537
551
  def convert_range(bcv_range):
538
552
  if not bcv_range:
@@ -583,7 +597,7 @@ class Scriptures():
583
597
 
584
598
  def serial_verse_number(self, bcv):
585
599
  try:
586
- return int(self._verses.loc[(self._verses['Book'] == int(bcv[0:2])) & (self._verses['Chapter'] == int(bcv[2:5])) & (self._verses['Verse'] == int(bcv[5:]))].values[0][0])
600
+ return int(self._verses.loc[(self._verses['Book'] == int(bcv[0:2])) & (self._verses['Chapter'] == int(bcv[2:5])) & (self._verses['Verse'] == int(bcv[5:]))].values[0][0]) + 1
587
601
  except:
588
602
  self._error_report(bcv, 'OUT OF RANGE')
589
603
  return None
@@ -592,8 +606,12 @@ class Scriptures():
592
606
  try:
593
607
  book, chapter = self._chapters[self._chapters['ChapterId'] == int(chapter)].values[0][1:]
594
608
  last = self._ranges.loc[(self._ranges.Book == book) & (self._ranges.Chapter == chapter), ['Last']].values[0][0]
595
- bcv = str(book).zfill(2) + str(chapter).zfill(3)
596
- return f"('{bcv}001', '{bcv}{str(last).zfill(3)}')"
609
+ bc = str(book).zfill(2) + str(chapter).zfill(3)
610
+ if book == 19 and chapter in self._headings: # some chapters start at verse 0
611
+ v = '000'
612
+ else:
613
+ v = '001'
614
+ return f"('{bc}{v}', '{bc}{str(last).zfill(3)}')"
597
615
  except:
598
616
  self._error_report(chapter, 'OUT OF RANGE')
599
617
  return None
@@ -601,7 +619,7 @@ class Scriptures():
601
619
  def code_verse(self, verse):
602
620
  bcv = ''
603
621
  try:
604
- for i in self._verses[self._verses['VerseId'] == int(verse)].values[0][1:]:
622
+ for i in self._verses[self._verses['VerseId'] == int(verse)-1].values[0][1:]:
605
623
  bcv += str(i).zfill(3)
606
624
  return f"('{bcv[1:]}', '{bcv[1:]}')"
607
625
  except:
linkture/res/resources.db CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkture
3
- Version: 2.6.3
3
+ Version: 3.0.0
4
4
  Summary: PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode
5
5
  Keywords: bible,scriptures,scripture-references,scripture-translation,scripture-parser,scripture-linker
6
6
  Author-Email: "Eryk J." <infiniti@inventati.org>
@@ -23,7 +23,7 @@ Requires-Dist: setuptools>=59.6.0
23
23
  Requires-Dist: argparse>=1.4.0
24
24
  Requires-Dist: regex>=2023.8.8
25
25
  Requires-Dist: unidecode>=1.3.8
26
- Requires-Dist: pandas==2.2.2
26
+ Requires-Dist: pandas==2.2.*
27
27
  Requires-Dist: pathlib>=1.0.1
28
28
  Description-Content-Type: text/markdown
29
29
 
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
33
33
 
34
34
  This module contains functions to parse and process Bible scripture references.
35
35
 
36
- The parser can work in **Cebuano, Chinese, Danish, Dutch, English, French, German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Tagalog and Ukrainian**. It will **recognize** such references and **validate** them to ensure the chapter(s) and/or verse(s) are within range.
36
+ The parser can work in **Cebuano, Chinese, Danish, Dutch, English, Ewe, French, German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Tagalog and Ukrainian**. It will **recognize** such references and **validate** them to ensure the chapter(s) and/or verse(s) are within range.
37
37
 
38
38
  It *does not* work with whole books (like "James") unless they are preceded by a number (like "1 John"); otherwise it would have to look up ever single word. Also, it will *not* find the multi-word book name "Song of Solomon" (and its variations), though this (and any other scripture) can be force-detected by tagging the desired reference "manually" within the source text (eg., "{{Song of Solomon 1:1}}") - *one book* per brace pair. These two limitations aside, it works with most book name variants in all the available languages (including common abbreviations): "2 Sam.", "2nd Samuel", "II Samuel", "2Sa", etc. Any special/unusual variants can be added to the *res/custom.json* list.
39
39
 
@@ -54,8 +54,8 @@ ____
54
54
  ```
55
55
  > python3 -m linkture -h
56
56
  usage: linkture.py [-h] [-v] [-q] [-f in-file | -r reference] [-o out-file]
57
- [--language {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}]
58
- [--translate {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}]
57
+ [--language {Cebuano,Chinese,Danish,Dutch,English,Ewe,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}]
58
+ [--translate {Cebuano,Chinese,Danish,Dutch,English,Ewe,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}]
59
59
  [-s separator] [-u] [--full | --official | --standard]
60
60
  [-c | -d | -l [prefix [suffix ...]] | -t | -x]
61
61
  [-sc BCV | -sv BCV | -cc chapter | -cv verse]
@@ -68,9 +68,9 @@ options:
68
68
  -v show version and exit
69
69
  -q don't show errors
70
70
  -o out-file output file (terminal output if not provided)
71
- --language {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}
71
+ --language {Cebuano,Chinese,Danish,Dutch,English,Ewe,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}
72
72
  indicate source language for book names (English if unspecified)
73
- --translate {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}
73
+ --translate {Cebuano,Chinese,Danish,Dutch,English,Ewe,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}
74
74
  indicate output language for book names (same as source if unspecified)
75
75
  -s separator segment separator (space by default)
76
76
  -u capitalize (upper-case) book names
@@ -100,7 +100,7 @@ type of conversion:
100
100
 
101
101
  auxiliary functions:
102
102
  -sc BCV return the serial number (1-1189) of the chapter with code "BCV" ("bbcccvvv")
103
- -sv BCV return the serial number (1-31091) of the verse with code "BCV" ("bbcccvvv")
103
+ -sv BCV return the serial number (1-31194) of the verse with code "BCV" ("bbcccvvv")
104
104
  -cc chapter return the BCV range for serial chapter number "chapter" (integer value)
105
105
  -cv verse return the BCV code for serial verse number "verse" (integer value)
106
106
  ```
@@ -144,22 +144,20 @@ $ python3 -m linkture -r "Mat 17:17; Paul 3:16, 17" --full -x
144
144
  $ python3 -m linkture -cc 2
145
145
  ('01002001', '01002025')
146
146
 
147
- $ python3 -m linkture -cv 31091
147
+ $ python3 -m linkture -cv 31194
148
148
  ('66022021', '66022021')
149
149
 
150
150
  $ python3 -m linkture -sv '01001001'
151
151
  1
152
152
 
153
- python3 -m linkture -sc '66022001'
153
+ $ python3 -m linkture -sc '66022001'
154
154
  1189
155
155
 
156
156
 
157
- python3 -m linkture -r '2Ti 3:16, 17' --full -s '_'
157
+ $ python3 -m linkture -r '2Ti 3:16, 17' --full -s '_'
158
158
  2_Timothy_3:16,_17
159
159
  ```
160
160
 
161
- **Note**: The serial verse options (`-sv` and `-cv`) *do not* count Psalm headings as separate verses.
162
-
163
161
  Of course, you can pass a whole text file to parse and process using the `-f in_file` flag, instead of `-r "references"`. And you can output to another text file (instead of the terminal) using `-o out_file`.
164
162
 
165
163
  Unless you use `-q`, you will see in the terminal any out-of-range errors encountered while parsing. Of course, these entries will not be processed, but they will not affect the rest of the operation.
@@ -195,13 +193,13 @@ i = s.serial_chapter_number(ch_bcv)
195
193
  # returns the serial number (1-1189) of the chapter identified by the provided BCV-format string; verse digits irrelevant
196
194
 
197
195
  i = s.serial_verse_number(vs_bcv)
198
- # returns the serial number (1-31091) of the verse identified by the provided BCV-format string
196
+ # returns the serial number (1-31194) of the verse identified by the provided BCV-format string
199
197
 
200
198
  ch_bcv = s.code_chapter(i)
201
199
  # returns a BCV-format range string for the whole chapter indicated by the provided integer (1-1189)
202
200
 
203
201
  vs_bcv = s.code_verse(i)
204
- # returns a BCV-format range string for the verse indicated by the provided integer (1-31091)
202
+ # returns a BCV-format range string for the verse indicated by the provided integer (1-31194)
205
203
  ```
206
204
 
207
205
  Parameters:
@@ -0,0 +1,10 @@
1
+ linkture-3.0.0.dist-info/METADATA,sha256=GeDDtoiK1KJHOhgZC2aN9q6i0THUxCi-n7lpRi9n8aY,11304
2
+ linkture-3.0.0.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ linkture-3.0.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ linkture-3.0.0.dist-info/licenses/LICENSE,sha256=kPqKoVmo3Tx1HgQvqfjBZuYkjT1mZXnQ5R0KBbEeFfs,1064
5
+ linkture/__init__.py,sha256=-CsRDvXLUig8T6RvwkktRP8e8DWrpjlyqBcw26kOv1E,47
6
+ linkture/__main__.py,sha256=_HuNLVB-JSzNqxSxhkSrfJ5ZkQ6nK9jqaoy4xhMoC3c,6444
7
+ linkture/linkture.py,sha256=Gvt9ldcDClOCPtgFji4jKC4OtSq190LVr8z3fZ-Qt4Q,25032
8
+ linkture/res/custom.json,sha256=qlpTEux2w7kb-w9ZimDqTLhnB0Eyy1Mj3zfbQ1sxKvg,2046
9
+ linkture/res/resources.db,sha256=0l6lUJB5p4cQ6YpnIn9rDTnmbiZGSKb6k3OKNZmVF7M,569344
10
+ linkture-3.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.3.3)
2
+ Generator: pdm-backend (2.4.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+
3
+ [gui_scripts]
4
+
@@ -1,9 +0,0 @@
1
- linkture-2.6.3.dist-info/METADATA,sha256=INENJJdqb-nbYN0-3pBccYlqTnaQj9chaQmhWoPREok,11383
2
- linkture-2.6.3.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
- linkture-2.6.3.dist-info/licenses/LICENSE,sha256=kPqKoVmo3Tx1HgQvqfjBZuYkjT1mZXnQ5R0KBbEeFfs,1064
4
- linkture/__init__.py,sha256=-CsRDvXLUig8T6RvwkktRP8e8DWrpjlyqBcw26kOv1E,47
5
- linkture/__main__.py,sha256=K1TDrBlT-_N_-iWpjOK_XW2rdm_IRiI7aWyKbFcdFxg,6478
6
- linkture/linkture.py,sha256=238AhNQyPsU5ozN8KhGE8N6xeMLhR5QzIyGrEDENGt0,23772
7
- linkture/res/custom.json,sha256=qlpTEux2w7kb-w9ZimDqTLhnB0Eyy1Mj3zfbQ1sxKvg,2046
8
- linkture/res/resources.db,sha256=_vHwq2w1BHB7pGgO5txQVPAbJ5ak6msVbVoPLKG9QtE,581632
9
- linkture-2.6.3.dist-info/RECORD,,