linkture 2.6.0__py3-none-any.whl → 2.6.2__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
@@ -27,7 +27,7 @@
27
27
  """
28
28
 
29
29
  import argparse
30
- from .linkture import available_languages, __app__, __version__, Scriptures
30
+ from .linkture import _available_languages, __app__, __version__, Scriptures
31
31
  from ast import literal_eval
32
32
 
33
33
 
@@ -43,11 +43,11 @@ def main(args):
43
43
  elif args['sv']:
44
44
  return s.serial_verse_number(args['sv'])
45
45
  if args['l'] is not None:
46
- prefix = '<a href='
47
- suffix = '>'
48
- if len(args['l']) > 1:
46
+ prefix = '<a href="'
47
+ suffix = '">'
48
+ if len(args['l']) > 1 and args['l'][1] != '':
49
49
  suffix = args['l'][1]
50
- if len(args['l']) > 0:
50
+ if len(args['l']) > 0 and args['l'][0] != '':
51
51
  prefix = args['l'][0]
52
52
  return s.link_scriptures(text, prefix, suffix)
53
53
  elif args['c']:
@@ -104,8 +104,8 @@ mode.add_argument('-f', metavar='in-file', help='get input from file (UTF-8)')
104
104
  mode.add_argument('-r', metavar='reference', help='process "reference; reference; etc."')
105
105
  parser.add_argument('-o', metavar='out-file', help='output file (terminal output if not provided)')
106
106
 
107
- parser.add_argument('--language', default='English', choices=available_languages, help='indicate source language for book names (English if unspecified)')
108
- parser.add_argument('--translate', choices=available_languages, help='indicate output language for book names (same as source if unspecified)')
107
+ parser.add_argument('--language', default='English', choices=_available_languages, help='indicate source language for book names (English if unspecified)')
108
+ parser.add_argument('--translate', choices=_available_languages, help='indicate output language for book names (same as source if unspecified)')
109
109
  parser.add_argument('-s', metavar='separator', default=' ', help='segment separator (space by default)')
110
110
  parser.add_argument('-u', action='store_true', help='capitalize (upper-case) book names')
111
111
  format_group = parser.add_argument_group('output format (optional)', 'if provided, book names will be rewritten accordingly:')
linkture/linkture.py CHANGED
@@ -27,16 +27,17 @@
27
27
  """
28
28
 
29
29
  __app__ = 'linkture'
30
- __version__ = 'v2.6.0'
30
+ __version__ = 'v2.6.2'
31
31
 
32
32
 
33
33
  import json, regex, sqlite3
34
34
  import pandas as pd
35
+ from pathlib import Path
35
36
  from unidecode import unidecode
36
37
 
37
38
 
38
- available_languages = ('Cebuano', 'Chinese', 'Danish', 'Dutch', 'English', 'French', 'German', 'Greek', 'Hungarian', 'Italian', 'Japanese', 'Korean', 'Norwegian', 'Polish', 'Portuguese', 'Russian', 'Spanish', 'Tagalog', 'Ukrainian')
39
- non_latin = ('Chinese', 'Greek', 'Japanese', 'Korean', 'Russian', 'Ukrainian')
39
+ _available_languages = ('Cebuano', 'Chinese', 'Danish', 'Dutch', 'English', 'French', 'German', 'Greek', 'Hungarian', 'Italian', 'Japanese', 'Korean', 'Norwegian', 'Polish', 'Portuguese', 'Russian', 'Spanish', 'Tagalog', 'Ukrainian')
40
+ _non_latin = ('Chinese', 'Greek', 'Japanese', 'Korean', 'Russian', 'Ukrainian')
40
41
 
41
42
 
42
43
  class Scriptures():
@@ -44,14 +45,14 @@ class Scriptures():
44
45
  def __init__(self, language='English', translate=None, form=None, separator=' ', upper=False, verbose=False):
45
46
  self._verbose = verbose
46
47
  self._separator = separator
47
- if language not in available_languages:
48
+ if language not in _available_languages:
48
49
  raise ValueError("Indicated source language is not an option!")
49
50
  if translate:
50
- if translate not in available_languages:
51
+ if translate not in _available_languages:
51
52
  raise ValueError("Indicated translation language is not an option!")
52
53
  else:
53
54
  translate = language
54
- if language in non_latin:
55
+ if language in _non_latin:
55
56
  self._nl = True
56
57
  else:
57
58
  self._nl = False
@@ -66,9 +67,10 @@ class Scriptures():
66
67
  else:
67
68
  form = 3
68
69
  self._src_book_names = {}
70
+ path = Path(__file__).resolve().parent
69
71
 
70
72
  self._tr_book_names = ['Bible']
71
- con = sqlite3.connect('res/resources.db')
73
+ con = sqlite3.connect(path / 'res/resources.db')
72
74
  cur = con.cursor()
73
75
  for rec in cur.execute(f"SELECT * FROM Books WHERE Language = '{translate}';").fetchall():
74
76
  if self._upper:
@@ -83,7 +85,7 @@ class Scriptures():
83
85
  item = unidecode(item)
84
86
  normalized = regex.sub(r'\p{P}|\p{Z}', '', item.upper())
85
87
  self._src_book_names[normalized] = rec[2]
86
- with open('res/custom.json', 'r', encoding='UTF-8') as json_file:
88
+ with open(path / 'res/custom.json', 'r', encoding='UTF-8') as json_file:
87
89
  b = json.load(json_file)
88
90
  if language in b.keys():
89
91
  for row in b[language]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkture
3
- Version: 2.6.0
3
+ Version: 2.6.2
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>
@@ -24,11 +24,9 @@ Requires-Dist: argparse>=1.4.0
24
24
  Requires-Dist: regex>=2023.8.8
25
25
  Requires-Dist: unidecode>=1.3.8
26
26
  Requires-Dist: pandas==2.2.2
27
+ Requires-Dist: pathlib>=1.0.1
27
28
  Description-Content-Type: text/markdown
28
29
 
29
- # linkture
30
-
31
-
32
30
  ## Purpose
33
31
 
34
32
  This module contains functions to parse and process Bible scripture references.
@@ -116,15 +114,18 @@ John 17:17; 2 Tim. 3:16, 17
116
114
  $ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --official
117
115
  Joh 17:17; 2Ti 3:16, 17
118
116
 
117
+
119
118
  $ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -c
120
119
  [('43017017', '43017017'), ('55003016', '55003017')]
121
120
 
122
121
  $ python3 -m linkture -r "[('43017017', '43017017'), ('55003016', '55003017')]" -d --translate German
123
122
  ['Johannes 17:17', '2. Timotheus 3:16, 17']
124
123
 
124
+
125
125
  $ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -l '<a href="https://my.website.com/' '/index.html" class="test">'
126
126
  <a href="https://my.website.com/43:17:17/index.html" class="test">John 17:17</a>; <a href="https://my.website.com/55:3:16-55:3:17/index.html" class="test">2 Timothy 3:16, 17</a>
127
127
 
128
+
128
129
  $ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --translate Chinese
129
130
  约翰福音 17:17; 提摩太后书 3:16, 17
130
131
 
@@ -137,6 +138,7 @@ Juan 17:17; 2 Tim. 3:16, 17
137
138
  $ python3 -m linkture -r "Mat 17:17; Paul 3:16, 17" --full -x
138
139
  ['Matthew 17:17']
139
140
 
141
+
140
142
  $ python3 -m linkture -cc 2
141
143
  ('01002001', '01002025')
142
144
 
@@ -149,6 +151,7 @@ $ python3 -m linkture -sv '01001001'
149
151
  python3 -m linkture -sc '66022001'
150
152
  1189
151
153
 
154
+
152
155
  python3 -m linkture -r '2Ti 3:16, 17' --full -s '_'
153
156
  2_Timothy_3:16,_17
154
157
  ```
@@ -162,12 +165,14 @@ Unless you use `-q`, you will see in the terminal any out-of-range errors encoun
162
165
  ____
163
166
  ## Script/import usage
164
167
 
165
- Assume the text (short string or long document) you want to process is in the variable `txt`. It's in English, but you would like the scriptures to be in Spanish, with the full book name:
168
+ Assume the text (short string or long document) you want to process is in the variable `txt`.
169
+
166
170
  ```
167
171
  from linkture import Scriptures
168
172
 
169
173
  s = Scriptures(language="English", translate="Spanish", form="full")
170
174
 
175
+
171
176
  lst = s.list_scriptures(txt)
172
177
  # returns a list of (valid) extracted scriptures in the desired language and format
173
178
 
@@ -180,19 +185,20 @@ html = s.link_scriptures(txt, prefix='<a href="http://mywebsite.com/', suffix='"
180
185
  tagged = s.tag_scriptures(txt)
181
186
  # tagged will contain your document with the translated references enclosed within double braces
182
187
 
183
- txt = s.rewrite_scriptures(txt)
188
+ new_txt = s.rewrite_scriptures(txt)
184
189
  # the references will simply be rewritten in the desired language and format
185
190
 
186
- i = s.serial_chapter_number(txt)
191
+
192
+ i = s.serial_chapter_number(ch_bcv)
187
193
  # returns the serial number (1-1189) of the chapter identified by the provided BCV-format string; verse digits irrelevant
188
194
 
189
- i = s.serial_verse_number(txt)
195
+ i = s.serial_verse_number(vs_bcv)
190
196
  # returns the serial number (1-31091) of the verse identified by the provided BCV-format string
191
197
 
192
- txt = s.code_chapter(i)
198
+ ch_bcv = s.code_chapter(i)
193
199
  # returns a BCV-format range string for the whole chapter indicated by the provided integer (1-1189)
194
200
 
195
- txt = s.code_verse(i)
201
+ vs_bcv = s.code_verse(i)
196
202
  # returns a BCV-format range string for the verse indicated by the provided integer (1-31091)
197
203
  ```
198
204
 
@@ -0,0 +1,10 @@
1
+ linkture-2.6.2.dist-info/METADATA,sha256=dXIjfifmuIx-zeruRMMzd9uVEmTg1jMJvHBc-cgXxAE,11015
2
+ linkture-2.6.2.dist-info/WHEEL,sha256=7sv5iXvIiTVJSnAxCz2tGBm9DHsb2vPSzeYeT7pvGUY,90
3
+ linkture-2.6.2.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=HMfdWzwLx6VJhGPXduZqqicYWSva8TDN5vY578r8Lxo,23761
7
+ linkture/res/custom.json,sha256=PnCI0N5uBn1ZzEG05V3r8uwrW2uBogCQ_uCQKTHJe4E,1904
8
+ linkture/res/resources.db,sha256=ceXVt21jdJwJCCWsfMPy6aRcHo9yHzyTQk_i22aJZD8,581632
9
+ linkture/res/rss-36.png,sha256=DeZ-xvFxyjeHSNHen3inNFWPm4qHdlNI3MQ1fclu9CQ,1297
10
+ linkture-2.6.2.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- linkture-2.6.0.dist-info/METADATA,sha256=DpJS7s4hvIkgsgQTM72-WH70NlDF5TteOUAKyyqrs5o,11068
2
- linkture-2.6.0.dist-info/WHEEL,sha256=7sv5iXvIiTVJSnAxCz2tGBm9DHsb2vPSzeYeT7pvGUY,90
3
- linkture-2.6.0.dist-info/licenses/LICENSE,sha256=kPqKoVmo3Tx1HgQvqfjBZuYkjT1mZXnQ5R0KBbEeFfs,1064
4
- linkture/__init__.py,sha256=-CsRDvXLUig8T6RvwkktRP8e8DWrpjlyqBcw26kOv1E,47
5
- linkture/__main__.py,sha256=4Z6KGvQL4kX42H5P7yDz3xiLf2TS89P-d5IYsxqOlSI,6427
6
- linkture/linkture.py,sha256=hLFvzqj7dLU-xuFW_rAP1Emc034DKo2VcF72tYvO1rc,23670
7
- linkture/res/custom.json,sha256=PnCI0N5uBn1ZzEG05V3r8uwrW2uBogCQ_uCQKTHJe4E,1904
8
- linkture/res/resources.db,sha256=ceXVt21jdJwJCCWsfMPy6aRcHo9yHzyTQk_i22aJZD8,581632
9
- linkture/res/rss-36.png,sha256=DeZ-xvFxyjeHSNHen3inNFWPm4qHdlNI3MQ1fclu9CQ,1297
10
- linkture-2.6.0.dist-info/RECORD,,