linkture 2.6.0__py3-none-any.whl → 2.6.1__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 +7 -7
- linkture/linkture.py +8 -8
- {linkture-2.6.0.dist-info → linkture-2.6.1.dist-info}/METADATA +15 -10
- linkture-2.6.1.dist-info/RECORD +10 -0
- linkture-2.6.0.dist-info/RECORD +0 -10
- {linkture-2.6.0.dist-info → linkture-2.6.1.dist-info}/WHEEL +0 -0
- {linkture-2.6.0.dist-info → linkture-2.6.1.dist-info}/licenses/LICENSE +0 -0
linkture/__main__.py
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
"""
|
28
28
|
|
29
29
|
import argparse
|
30
|
-
from .linkture import
|
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=
|
108
|
-
parser.add_argument('--translate', choices=
|
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,7 +27,7 @@
|
|
27
27
|
"""
|
28
28
|
|
29
29
|
__app__ = 'linkture'
|
30
|
-
__version__ = 'v2.6.
|
30
|
+
__version__ = 'v2.6.1'
|
31
31
|
|
32
32
|
|
33
33
|
import json, regex, sqlite3
|
@@ -35,8 +35,8 @@ import pandas as pd
|
|
35
35
|
from unidecode import unidecode
|
36
36
|
|
37
37
|
|
38
|
-
|
39
|
-
|
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')
|
40
40
|
|
41
41
|
|
42
42
|
class Scriptures():
|
@@ -44,14 +44,14 @@ class Scriptures():
|
|
44
44
|
def __init__(self, language='English', translate=None, form=None, separator=' ', upper=False, verbose=False):
|
45
45
|
self._verbose = verbose
|
46
46
|
self._separator = separator
|
47
|
-
if language not in
|
47
|
+
if language not in _available_languages:
|
48
48
|
raise ValueError("Indicated source language is not an option!")
|
49
49
|
if translate:
|
50
|
-
if translate not in
|
50
|
+
if translate not in _available_languages:
|
51
51
|
raise ValueError("Indicated translation language is not an option!")
|
52
52
|
else:
|
53
53
|
translate = language
|
54
|
-
if language in
|
54
|
+
if language in _non_latin:
|
55
55
|
self._nl = True
|
56
56
|
else:
|
57
57
|
self._nl = False
|
@@ -68,7 +68,7 @@ class Scriptures():
|
|
68
68
|
self._src_book_names = {}
|
69
69
|
|
70
70
|
self._tr_book_names = ['Bible']
|
71
|
-
con = sqlite3.connect('res/resources.db')
|
71
|
+
con = sqlite3.connect('src/linkture/res/resources.db')
|
72
72
|
cur = con.cursor()
|
73
73
|
for rec in cur.execute(f"SELECT * FROM Books WHERE Language = '{translate}';").fetchall():
|
74
74
|
if self._upper:
|
@@ -83,7 +83,7 @@ class Scriptures():
|
|
83
83
|
item = unidecode(item)
|
84
84
|
normalized = regex.sub(r'\p{P}|\p{Z}', '', item.upper())
|
85
85
|
self._src_book_names[normalized] = rec[2]
|
86
|
-
with open('res/custom.json', 'r', encoding='UTF-8') as json_file:
|
86
|
+
with open('src/linkture/res/custom.json', 'r', encoding='UTF-8') as json_file:
|
87
87
|
b = json.load(json_file)
|
88
88
|
if language in b.keys():
|
89
89
|
for row in b[language]:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: linkture
|
3
|
-
Version: 2.6.
|
3
|
+
Version: 2.6.1
|
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>
|
@@ -26,9 +26,6 @@ Requires-Dist: unidecode>=1.3.8
|
|
26
26
|
Requires-Dist: pandas==2.2.2
|
27
27
|
Description-Content-Type: text/markdown
|
28
28
|
|
29
|
-
# linkture
|
30
|
-
|
31
|
-
|
32
29
|
## Purpose
|
33
30
|
|
34
31
|
This module contains functions to parse and process Bible scripture references.
|
@@ -116,15 +113,18 @@ John 17:17; 2 Tim. 3:16, 17
|
|
116
113
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --official
|
117
114
|
Joh 17:17; 2Ti 3:16, 17
|
118
115
|
|
116
|
+
|
119
117
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -c
|
120
118
|
[('43017017', '43017017'), ('55003016', '55003017')]
|
121
119
|
|
122
120
|
$ python3 -m linkture -r "[('43017017', '43017017'), ('55003016', '55003017')]" -d --translate German
|
123
121
|
['Johannes 17:17', '2. Timotheus 3:16, 17']
|
124
122
|
|
123
|
+
|
125
124
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -l '<a href="https://my.website.com/' '/index.html" class="test">'
|
126
125
|
<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
126
|
|
127
|
+
|
128
128
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --translate Chinese
|
129
129
|
约翰福音 17:17; 提摩太后书 3:16, 17
|
130
130
|
|
@@ -137,6 +137,7 @@ Juan 17:17; 2 Tim. 3:16, 17
|
|
137
137
|
$ python3 -m linkture -r "Mat 17:17; Paul 3:16, 17" --full -x
|
138
138
|
['Matthew 17:17']
|
139
139
|
|
140
|
+
|
140
141
|
$ python3 -m linkture -cc 2
|
141
142
|
('01002001', '01002025')
|
142
143
|
|
@@ -149,6 +150,7 @@ $ python3 -m linkture -sv '01001001'
|
|
149
150
|
python3 -m linkture -sc '66022001'
|
150
151
|
1189
|
151
152
|
|
153
|
+
|
152
154
|
python3 -m linkture -r '2Ti 3:16, 17' --full -s '_'
|
153
155
|
2_Timothy_3:16,_17
|
154
156
|
```
|
@@ -162,12 +164,14 @@ Unless you use `-q`, you will see in the terminal any out-of-range errors encoun
|
|
162
164
|
____
|
163
165
|
## Script/import usage
|
164
166
|
|
165
|
-
Assume the text (short string or long document) you want to process is in the variable `txt`.
|
167
|
+
Assume the text (short string or long document) you want to process is in the variable `txt`.
|
168
|
+
|
166
169
|
```
|
167
170
|
from linkture import Scriptures
|
168
171
|
|
169
172
|
s = Scriptures(language="English", translate="Spanish", form="full")
|
170
173
|
|
174
|
+
|
171
175
|
lst = s.list_scriptures(txt)
|
172
176
|
# returns a list of (valid) extracted scriptures in the desired language and format
|
173
177
|
|
@@ -180,19 +184,20 @@ html = s.link_scriptures(txt, prefix='<a href="http://mywebsite.com/', suffix='"
|
|
180
184
|
tagged = s.tag_scriptures(txt)
|
181
185
|
# tagged will contain your document with the translated references enclosed within double braces
|
182
186
|
|
183
|
-
|
187
|
+
new_txt = s.rewrite_scriptures(txt)
|
184
188
|
# the references will simply be rewritten in the desired language and format
|
185
189
|
|
186
|
-
|
190
|
+
|
191
|
+
i = s.serial_chapter_number(ch_bcv)
|
187
192
|
# returns the serial number (1-1189) of the chapter identified by the provided BCV-format string; verse digits irrelevant
|
188
193
|
|
189
|
-
i = s.serial_verse_number(
|
194
|
+
i = s.serial_verse_number(vs_bcv)
|
190
195
|
# returns the serial number (1-31091) of the verse identified by the provided BCV-format string
|
191
196
|
|
192
|
-
|
197
|
+
ch_bcv = s.code_chapter(i)
|
193
198
|
# returns a BCV-format range string for the whole chapter indicated by the provided integer (1-1189)
|
194
199
|
|
195
|
-
|
200
|
+
vs_bcv = s.code_verse(i)
|
196
201
|
# returns a BCV-format range string for the verse indicated by the provided integer (1-31091)
|
197
202
|
```
|
198
203
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
linkture-2.6.1.dist-info/METADATA,sha256=AY9IhBRUtXz12W733RThzPzF4v8mKCVg_9hbEB3gPFQ,10985
|
2
|
+
linkture-2.6.1.dist-info/WHEEL,sha256=7sv5iXvIiTVJSnAxCz2tGBm9DHsb2vPSzeYeT7pvGUY,90
|
3
|
+
linkture-2.6.1.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=RMuAMkzho5y77nQtnmYMr-c8YDClagQ4i7sh2q5u7bc,23701
|
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.1.dist-info/RECORD,,
|
linkture-2.6.0.dist-info/RECORD
DELETED
@@ -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,,
|
File without changes
|
File without changes
|