linkture 2.5.6__tar.gz → 2.6.1__tar.gz
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-2.5.6 → linkture-2.6.1}/PKG-INFO +15 -11
- {linkture-2.5.6 → linkture-2.6.1}/README.md +14 -9
- {linkture-2.5.6 → linkture-2.6.1}/pyproject.toml +2 -3
- linkture-2.6.1/src/linkture/__init__.py +3 -0
- linkture-2.6.1/src/linkture/__main__.py +133 -0
- linkture-2.5.6/src/linkture/__main__.py → linkture-2.6.1/src/linkture/linkture.py +10 -116
- linkture-2.5.6/src/linkture/__init__.py +0 -0
- {linkture-2.5.6 → linkture-2.6.1}/LICENSE +0 -0
- {linkture-2.5.6 → linkture-2.6.1}/src/linkture/res/custom.json +0 -0
- {linkture-2.5.6 → linkture-2.6.1}/src/linkture/res/resources.db +0 -0
- {linkture-2.5.6 → linkture-2.6.1}/src/linkture/res/rss-36.png +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: linkture
|
3
|
-
Version: 2.
|
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>
|
@@ -23,13 +23,9 @@ 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: pathlib>=1.0.1
|
27
26
|
Requires-Dist: pandas==2.2.2
|
28
27
|
Description-Content-Type: text/markdown
|
29
28
|
|
30
|
-
# linkture
|
31
|
-
|
32
|
-
|
33
29
|
## Purpose
|
34
30
|
|
35
31
|
This module contains functions to parse and process Bible scripture references.
|
@@ -117,15 +113,18 @@ John 17:17; 2 Tim. 3:16, 17
|
|
117
113
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --official
|
118
114
|
Joh 17:17; 2Ti 3:16, 17
|
119
115
|
|
116
|
+
|
120
117
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -c
|
121
118
|
[('43017017', '43017017'), ('55003016', '55003017')]
|
122
119
|
|
123
120
|
$ python3 -m linkture -r "[('43017017', '43017017'), ('55003016', '55003017')]" -d --translate German
|
124
121
|
['Johannes 17:17', '2. Timotheus 3:16, 17']
|
125
122
|
|
123
|
+
|
126
124
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -l '<a href="https://my.website.com/' '/index.html" class="test">'
|
127
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>
|
128
126
|
|
127
|
+
|
129
128
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --translate Chinese
|
130
129
|
约翰福音 17:17; 提摩太后书 3:16, 17
|
131
130
|
|
@@ -138,6 +137,7 @@ Juan 17:17; 2 Tim. 3:16, 17
|
|
138
137
|
$ python3 -m linkture -r "Mat 17:17; Paul 3:16, 17" --full -x
|
139
138
|
['Matthew 17:17']
|
140
139
|
|
140
|
+
|
141
141
|
$ python3 -m linkture -cc 2
|
142
142
|
('01002001', '01002025')
|
143
143
|
|
@@ -150,6 +150,7 @@ $ python3 -m linkture -sv '01001001'
|
|
150
150
|
python3 -m linkture -sc '66022001'
|
151
151
|
1189
|
152
152
|
|
153
|
+
|
153
154
|
python3 -m linkture -r '2Ti 3:16, 17' --full -s '_'
|
154
155
|
2_Timothy_3:16,_17
|
155
156
|
```
|
@@ -163,12 +164,14 @@ Unless you use `-q`, you will see in the terminal any out-of-range errors encoun
|
|
163
164
|
____
|
164
165
|
## Script/import usage
|
165
166
|
|
166
|
-
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
|
+
|
167
169
|
```
|
168
170
|
from linkture import Scriptures
|
169
171
|
|
170
172
|
s = Scriptures(language="English", translate="Spanish", form="full")
|
171
173
|
|
174
|
+
|
172
175
|
lst = s.list_scriptures(txt)
|
173
176
|
# returns a list of (valid) extracted scriptures in the desired language and format
|
174
177
|
|
@@ -181,19 +184,20 @@ html = s.link_scriptures(txt, prefix='<a href="http://mywebsite.com/', suffix='"
|
|
181
184
|
tagged = s.tag_scriptures(txt)
|
182
185
|
# tagged will contain your document with the translated references enclosed within double braces
|
183
186
|
|
184
|
-
|
187
|
+
new_txt = s.rewrite_scriptures(txt)
|
185
188
|
# the references will simply be rewritten in the desired language and format
|
186
189
|
|
187
|
-
|
190
|
+
|
191
|
+
i = s.serial_chapter_number(ch_bcv)
|
188
192
|
# returns the serial number (1-1189) of the chapter identified by the provided BCV-format string; verse digits irrelevant
|
189
193
|
|
190
|
-
i = s.serial_verse_number(
|
194
|
+
i = s.serial_verse_number(vs_bcv)
|
191
195
|
# returns the serial number (1-31091) of the verse identified by the provided BCV-format string
|
192
196
|
|
193
|
-
|
197
|
+
ch_bcv = s.code_chapter(i)
|
194
198
|
# returns a BCV-format range string for the whole chapter indicated by the provided integer (1-1189)
|
195
199
|
|
196
|
-
|
200
|
+
vs_bcv = s.code_verse(i)
|
197
201
|
# returns a BCV-format range string for the verse indicated by the provided integer (1-31091)
|
198
202
|
```
|
199
203
|
|
@@ -1,6 +1,3 @@
|
|
1
|
-
# linkture
|
2
|
-
|
3
|
-
|
4
1
|
## Purpose
|
5
2
|
|
6
3
|
This module contains functions to parse and process Bible scripture references.
|
@@ -88,15 +85,18 @@ John 17:17; 2 Tim. 3:16, 17
|
|
88
85
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --official
|
89
86
|
Joh 17:17; 2Ti 3:16, 17
|
90
87
|
|
88
|
+
|
91
89
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -c
|
92
90
|
[('43017017', '43017017'), ('55003016', '55003017')]
|
93
91
|
|
94
92
|
$ python3 -m linkture -r "[('43017017', '43017017'), ('55003016', '55003017')]" -d --translate German
|
95
93
|
['Johannes 17:17', '2. Timotheus 3:16, 17']
|
96
94
|
|
95
|
+
|
97
96
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" -l '<a href="https://my.website.com/' '/index.html" class="test">'
|
98
97
|
<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>
|
99
98
|
|
99
|
+
|
100
100
|
$ python3 -m linkture -r "Joh 17:17; 2Ti 3:16, 17" --translate Chinese
|
101
101
|
约翰福音 17:17; 提摩太后书 3:16, 17
|
102
102
|
|
@@ -109,6 +109,7 @@ Juan 17:17; 2 Tim. 3:16, 17
|
|
109
109
|
$ python3 -m linkture -r "Mat 17:17; Paul 3:16, 17" --full -x
|
110
110
|
['Matthew 17:17']
|
111
111
|
|
112
|
+
|
112
113
|
$ python3 -m linkture -cc 2
|
113
114
|
('01002001', '01002025')
|
114
115
|
|
@@ -121,6 +122,7 @@ $ python3 -m linkture -sv '01001001'
|
|
121
122
|
python3 -m linkture -sc '66022001'
|
122
123
|
1189
|
123
124
|
|
125
|
+
|
124
126
|
python3 -m linkture -r '2Ti 3:16, 17' --full -s '_'
|
125
127
|
2_Timothy_3:16,_17
|
126
128
|
```
|
@@ -134,12 +136,14 @@ Unless you use `-q`, you will see in the terminal any out-of-range errors encoun
|
|
134
136
|
____
|
135
137
|
## Script/import usage
|
136
138
|
|
137
|
-
Assume the text (short string or long document) you want to process is in the variable `txt`.
|
139
|
+
Assume the text (short string or long document) you want to process is in the variable `txt`.
|
140
|
+
|
138
141
|
```
|
139
142
|
from linkture import Scriptures
|
140
143
|
|
141
144
|
s = Scriptures(language="English", translate="Spanish", form="full")
|
142
145
|
|
146
|
+
|
143
147
|
lst = s.list_scriptures(txt)
|
144
148
|
# returns a list of (valid) extracted scriptures in the desired language and format
|
145
149
|
|
@@ -152,19 +156,20 @@ html = s.link_scriptures(txt, prefix='<a href="http://mywebsite.com/', suffix='"
|
|
152
156
|
tagged = s.tag_scriptures(txt)
|
153
157
|
# tagged will contain your document with the translated references enclosed within double braces
|
154
158
|
|
155
|
-
|
159
|
+
new_txt = s.rewrite_scriptures(txt)
|
156
160
|
# the references will simply be rewritten in the desired language and format
|
157
161
|
|
158
|
-
|
162
|
+
|
163
|
+
i = s.serial_chapter_number(ch_bcv)
|
159
164
|
# returns the serial number (1-1189) of the chapter identified by the provided BCV-format string; verse digits irrelevant
|
160
165
|
|
161
|
-
i = s.serial_verse_number(
|
166
|
+
i = s.serial_verse_number(vs_bcv)
|
162
167
|
# returns the serial number (1-31091) of the verse identified by the provided BCV-format string
|
163
168
|
|
164
|
-
|
169
|
+
ch_bcv = s.code_chapter(i)
|
165
170
|
# returns a BCV-format range string for the whole chapter indicated by the provided integer (1-1189)
|
166
171
|
|
167
|
-
|
172
|
+
vs_bcv = s.code_verse(i)
|
168
173
|
# returns a BCV-format range string for the verse indicated by the provided integer (1-31091)
|
169
174
|
```
|
170
175
|
|
@@ -10,7 +10,6 @@ dependencies = [
|
|
10
10
|
"argparse>=1.4.0",
|
11
11
|
"regex>=2023.8.8",
|
12
12
|
"unidecode>=1.3.8",
|
13
|
-
"pathlib>=1.0.1",
|
14
13
|
"pandas==2.2.2",
|
15
14
|
]
|
16
15
|
requires-python = ">=3.9"
|
@@ -36,7 +35,7 @@ keywords = [
|
|
36
35
|
"scripture-parser",
|
37
36
|
"scripture-linker",
|
38
37
|
]
|
39
|
-
version = "v2.
|
38
|
+
version = "v2.6.1"
|
40
39
|
|
41
40
|
[project.license]
|
42
41
|
text = "MIT"
|
@@ -56,4 +55,4 @@ distribution = true
|
|
56
55
|
|
57
56
|
[tool.pdm.version]
|
58
57
|
source = "file"
|
59
|
-
path = "src/linkture/
|
58
|
+
path = "src/linkture/linkture.py"
|
@@ -0,0 +1,133 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
|
3
|
+
"""
|
4
|
+
File: linkture
|
5
|
+
|
6
|
+
Description: Parse and process Bible scripture references
|
7
|
+
|
8
|
+
MIT License: Copyright (c) 2024 Eryk J.
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
18
|
+
copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
"""
|
28
|
+
|
29
|
+
import argparse
|
30
|
+
from .linkture import _available_languages, __app__, __version__, Scriptures
|
31
|
+
from ast import literal_eval
|
32
|
+
|
33
|
+
|
34
|
+
def main(args):
|
35
|
+
|
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
|
+
if args['l'] is not None:
|
46
|
+
prefix = '<a href="'
|
47
|
+
suffix = '">'
|
48
|
+
if len(args['l']) > 1 and args['l'][1] != '':
|
49
|
+
suffix = args['l'][1]
|
50
|
+
if len(args['l']) > 0 and args['l'][0] != '':
|
51
|
+
prefix = args['l'][0]
|
52
|
+
return s.link_scriptures(text, prefix, suffix)
|
53
|
+
elif args['c']:
|
54
|
+
return s.code_scriptures(text)
|
55
|
+
elif args['d']:
|
56
|
+
return s.decode_scriptures(literal_eval(text))
|
57
|
+
elif args['x']:
|
58
|
+
return s.list_scriptures(text)
|
59
|
+
elif args['t']:
|
60
|
+
return s.tag_scriptures(text)
|
61
|
+
else:
|
62
|
+
return s.rewrite_scriptures(text)
|
63
|
+
|
64
|
+
form = None
|
65
|
+
if args['standard']:
|
66
|
+
form = 'standard'
|
67
|
+
elif args['official']:
|
68
|
+
form = 'official'
|
69
|
+
elif args['full']:
|
70
|
+
form = 'full'
|
71
|
+
|
72
|
+
s = Scriptures(language=args['language'], translate=args['translate'], form=form, separator=args['s'], upper=args['u'], verbose=(not args['q']))
|
73
|
+
|
74
|
+
if args['f']:
|
75
|
+
if args['o'] and (args['o'] == args['f']):
|
76
|
+
print('Make sure in-file and out-file are different!\n')
|
77
|
+
exit()
|
78
|
+
with open(args['f'], 'r', encoding='UTF-8') as f:
|
79
|
+
txt = f.read()
|
80
|
+
else:
|
81
|
+
txt = args['r']
|
82
|
+
|
83
|
+
if txt:
|
84
|
+
txt = switchboard(txt)
|
85
|
+
else:
|
86
|
+
print(parser.format_help())
|
87
|
+
exit()
|
88
|
+
|
89
|
+
if args['o']:
|
90
|
+
with open(args['o'], 'w', encoding='UTF-8') as f:
|
91
|
+
f.write(str(txt))
|
92
|
+
else:
|
93
|
+
print(txt)
|
94
|
+
|
95
|
+
|
96
|
+
parser = argparse.ArgumentParser(description="PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode. See README for more information")
|
97
|
+
|
98
|
+
parser.add_argument('-v', action='version', version=f"{__app__} {__version__}", help='show version and exit')
|
99
|
+
parser.add_argument('-q', action='store_true', help="don't show errors")
|
100
|
+
|
101
|
+
function_group = parser.add_argument_group('data source (one required - except for auxiliary functions, which only take command-line arguments)', 'choose between terminal or file input:')
|
102
|
+
mode = function_group.add_mutually_exclusive_group()
|
103
|
+
mode.add_argument('-f', metavar='in-file', help='get input from file (UTF-8)')
|
104
|
+
mode.add_argument('-r', metavar='reference', help='process "reference; reference; etc."')
|
105
|
+
parser.add_argument('-o', metavar='out-file', help='output file (terminal output if not provided)')
|
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)')
|
109
|
+
parser.add_argument('-s', metavar='separator', default=' ', help='segment separator (space by default)')
|
110
|
+
parser.add_argument('-u', action='store_true', help='capitalize (upper-case) book names')
|
111
|
+
format_group = parser.add_argument_group('output format (optional)', 'if provided, book names will be rewritten accordingly:')
|
112
|
+
formats = format_group.add_mutually_exclusive_group()
|
113
|
+
formats.add_argument('--full', action='store_true', help='output as full name - default (eg., "Genesis")')
|
114
|
+
formats.add_argument('--official', action='store_true', help='output as official abbreviation (eg., "Ge")')
|
115
|
+
formats.add_argument('--standard', action='store_true', help='output as standard abbreviation (eg., "Gen.")')
|
116
|
+
|
117
|
+
type_group = parser.add_argument_group('type of conversion', 'if not specified, references are simply rewritten according to chosen (or default) output format:')
|
118
|
+
tpe = type_group.add_mutually_exclusive_group(required=False)
|
119
|
+
tpe.add_argument('-c', action='store_true', help='encode as BCV-notation ranges')
|
120
|
+
tpe.add_argument('-d', action='store_true', help='decode list of BCV-notation ranges')
|
121
|
+
tpe.add_argument('-l', nargs='*', metavar=('prefix', 'suffix'), help='create <a></a> links; provide a "prefix" and a "suffix" (or neither for testing)')
|
122
|
+
tpe.add_argument('-t', action='store_true', help='tag scriptures with {{ }}')
|
123
|
+
tpe.add_argument('-x', action='store_true', help='extract list of scripture references')
|
124
|
+
|
125
|
+
aux_group = parser.add_argument_group('auxiliary functions')
|
126
|
+
aux = aux_group.add_mutually_exclusive_group(required=False)
|
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")')
|
129
|
+
aux.add_argument('-cc', metavar=('chapter'), help='return the BCV range for serial chapter number "chapter" (integer value)')
|
130
|
+
aux.add_argument('-cv', metavar=('verse'), help='return the BCV code for serial verse number "verse" (integer value)')
|
131
|
+
|
132
|
+
args = parser.parse_args()
|
133
|
+
main(vars(args))
|
@@ -26,19 +26,17 @@
|
|
26
26
|
SOFTWARE.
|
27
27
|
"""
|
28
28
|
|
29
|
-
|
29
|
+
__app__ = 'linkture'
|
30
|
+
__version__ = 'v2.6.1'
|
30
31
|
|
31
32
|
|
32
|
-
import
|
33
|
+
import json, regex, sqlite3
|
33
34
|
import pandas as pd
|
34
|
-
|
35
|
-
from ast import literal_eval
|
36
|
-
from pathlib import Path
|
37
35
|
from unidecode import unidecode
|
38
36
|
|
39
37
|
|
40
|
-
|
41
|
-
|
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')
|
42
40
|
|
43
41
|
|
44
42
|
class Scriptures():
|
@@ -46,14 +44,14 @@ class Scriptures():
|
|
46
44
|
def __init__(self, language='English', translate=None, form=None, separator=' ', upper=False, verbose=False):
|
47
45
|
self._verbose = verbose
|
48
46
|
self._separator = separator
|
49
|
-
if language not in
|
47
|
+
if language not in _available_languages:
|
50
48
|
raise ValueError("Indicated source language is not an option!")
|
51
49
|
if translate:
|
52
|
-
if translate not in
|
50
|
+
if translate not in _available_languages:
|
53
51
|
raise ValueError("Indicated translation language is not an option!")
|
54
52
|
else:
|
55
53
|
translate = language
|
56
|
-
if language in
|
54
|
+
if language in _non_latin:
|
57
55
|
self._nl = True
|
58
56
|
else:
|
59
57
|
self._nl = False
|
@@ -68,10 +66,9 @@ class Scriptures():
|
|
68
66
|
else:
|
69
67
|
form = 3
|
70
68
|
self._src_book_names = {}
|
71
|
-
path = Path(__file__).resolve().parent
|
72
69
|
|
73
70
|
self._tr_book_names = ['Bible']
|
74
|
-
con = sqlite3.connect(
|
71
|
+
con = sqlite3.connect('src/linkture/res/resources.db')
|
75
72
|
cur = con.cursor()
|
76
73
|
for rec in cur.execute(f"SELECT * FROM Books WHERE Language = '{translate}';").fetchall():
|
77
74
|
if self._upper:
|
@@ -86,7 +83,7 @@ class Scriptures():
|
|
86
83
|
item = unidecode(item)
|
87
84
|
normalized = regex.sub(r'\p{P}|\p{Z}', '', item.upper())
|
88
85
|
self._src_book_names[normalized] = rec[2]
|
89
|
-
with open(
|
86
|
+
with open('src/linkture/res/custom.json', 'r', encoding='UTF-8') as json_file:
|
90
87
|
b = json.load(json_file)
|
91
88
|
if language in b.keys():
|
92
89
|
for row in b[language]:
|
@@ -608,106 +605,3 @@ class Scriptures():
|
|
608
605
|
except:
|
609
606
|
self._error_report(verse, 'OUT OF RANGE')
|
610
607
|
return None
|
611
|
-
|
612
|
-
|
613
|
-
def _main(args):
|
614
|
-
|
615
|
-
def switchboard(text):
|
616
|
-
if args['cc']:
|
617
|
-
return s.code_chapter(args['cc'])
|
618
|
-
elif args['cv']:
|
619
|
-
return s.code_verse(args['cv'])
|
620
|
-
elif args['sc']:
|
621
|
-
return s.serial_chapter_number(args['sc'])
|
622
|
-
elif args['sv']:
|
623
|
-
return s.serial_verse_number(args['sv'])
|
624
|
-
if args['l'] is not None:
|
625
|
-
prefix = '<a href='
|
626
|
-
suffix = '>'
|
627
|
-
if len(args['l']) > 1:
|
628
|
-
suffix = args['l'][1]
|
629
|
-
if len(args['l']) > 0:
|
630
|
-
prefix = args['l'][0]
|
631
|
-
return s.link_scriptures(text, prefix, suffix)
|
632
|
-
elif args['c']:
|
633
|
-
return s.code_scriptures(text)
|
634
|
-
elif args['d']:
|
635
|
-
return s.decode_scriptures(literal_eval(text))
|
636
|
-
elif args['x']:
|
637
|
-
return s.list_scriptures(text)
|
638
|
-
elif args['t']:
|
639
|
-
return s.tag_scriptures(text)
|
640
|
-
else:
|
641
|
-
return s.rewrite_scriptures(text)
|
642
|
-
|
643
|
-
form = None
|
644
|
-
if args['standard']:
|
645
|
-
form = 'standard'
|
646
|
-
elif args['official']:
|
647
|
-
form = 'official'
|
648
|
-
elif args['full']:
|
649
|
-
form = 'full'
|
650
|
-
|
651
|
-
s = Scriptures(language=args['language'], translate=args['translate'], form=form, separator=args['s'], upper=args['u'], verbose=(not args['q']))
|
652
|
-
|
653
|
-
if args['f']:
|
654
|
-
if args['o'] and (args['o'] == args['f']):
|
655
|
-
print('Make sure in-file and out-file are different!\n')
|
656
|
-
exit()
|
657
|
-
with open(args['f'], 'r', encoding='UTF-8') as f:
|
658
|
-
txt = f.read()
|
659
|
-
else:
|
660
|
-
txt = args['r']
|
661
|
-
|
662
|
-
if txt:
|
663
|
-
txt = switchboard(txt)
|
664
|
-
else:
|
665
|
-
print(parser.format_help())
|
666
|
-
exit()
|
667
|
-
|
668
|
-
if args['o']:
|
669
|
-
with open(args['o'], 'w', encoding='UTF-8') as f:
|
670
|
-
f.write(str(txt))
|
671
|
-
else:
|
672
|
-
print(txt)
|
673
|
-
|
674
|
-
if __name__ == "__main__":
|
675
|
-
PROJECT_PATH = Path(__file__).resolve().parent
|
676
|
-
APP = 'linkture' # Path(__file__).stem
|
677
|
-
parser = argparse.ArgumentParser(description="PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode. See README for more information")
|
678
|
-
|
679
|
-
parser.add_argument('-v', action='version', version=f"{APP} {__version__}", help='show version and exit')
|
680
|
-
parser.add_argument('-q', action='store_true', help="don't show errors")
|
681
|
-
|
682
|
-
function_group = parser.add_argument_group('data source (one required - except for auxiliary functions, which only take command-line arguments)', 'choose between terminal or file input:')
|
683
|
-
mode = function_group.add_mutually_exclusive_group()
|
684
|
-
mode.add_argument('-f', metavar='in-file', help='get input from file (UTF-8)')
|
685
|
-
mode.add_argument('-r', metavar='reference', help='process "reference; reference; etc."')
|
686
|
-
parser.add_argument('-o', metavar='out-file', help='output file (terminal output if not provided)')
|
687
|
-
|
688
|
-
parser.add_argument('--language', default='English', choices=available_languages, help='indicate source language for book names (English if unspecified)')
|
689
|
-
parser.add_argument('--translate', choices=available_languages, help='indicate output language for book names (same as source if unspecified)')
|
690
|
-
parser.add_argument('-s', metavar='separator', default=' ', help='segment separator (space by default)')
|
691
|
-
parser.add_argument('-u', action='store_true', help='capitalize (upper-case) book names')
|
692
|
-
format_group = parser.add_argument_group('output format (optional)', 'if provided, book names will be rewritten accordingly:')
|
693
|
-
formats = format_group.add_mutually_exclusive_group()
|
694
|
-
formats.add_argument('--full', action='store_true', help='output as full name - default (eg., "Genesis")')
|
695
|
-
formats.add_argument('--official', action='store_true', help='output as official abbreviation (eg., "Ge")')
|
696
|
-
formats.add_argument('--standard', action='store_true', help='output as standard abbreviation (eg., "Gen.")')
|
697
|
-
|
698
|
-
type_group = parser.add_argument_group('type of conversion', 'if not specified, references are simply rewritten according to chosen (or default) output format:')
|
699
|
-
tpe = type_group.add_mutually_exclusive_group(required=False)
|
700
|
-
tpe.add_argument('-c', action='store_true', help='encode as BCV-notation ranges')
|
701
|
-
tpe.add_argument('-d', action='store_true', help='decode list of BCV-notation ranges')
|
702
|
-
tpe.add_argument('-l', nargs='*', metavar=('prefix', 'suffix'), help='create <a></a> links; provide a "prefix" and a "suffix" (or neither for testing)')
|
703
|
-
tpe.add_argument('-t', action='store_true', help='tag scriptures with {{ }}')
|
704
|
-
tpe.add_argument('-x', action='store_true', help='extract list of scripture references')
|
705
|
-
|
706
|
-
aux_group = parser.add_argument_group('auxiliary functions')
|
707
|
-
aux = aux_group.add_mutually_exclusive_group(required=False)
|
708
|
-
aux.add_argument('-sc', metavar=('BCV'), help='return the serial number (1-1189) of the chapter with code "BCV" ("bbcccvvv")')
|
709
|
-
aux.add_argument('-sv', metavar=('BCV'), help='return the serial number (1-31091) of the verse with code "BCV" ("bbcccvvv")')
|
710
|
-
aux.add_argument('-cc', metavar=('chapter'), help='return the BCV range for serial chapter number "chapter" (integer value)')
|
711
|
-
aux.add_argument('-cv', metavar=('verse'), help='return the BCV code for serial verse number "verse" (integer value)')
|
712
|
-
args = parser.parse_args()
|
713
|
-
_main(vars(args))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|