linkture 2.5.5__tar.gz → 2.6.0__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.5 → linkture-2.6.0}/PKG-INFO +1 -2
- {linkture-2.5.5 → linkture-2.6.0}/pyproject.toml +6 -2
- linkture-2.6.0/src/linkture/__init__.py +3 -0
- linkture-2.6.0/src/linkture/__main__.py +133 -0
- linkture-2.5.5/src/linkture/__main__.py → linkture-2.6.0/src/linkture/linkture.py +5 -111
- linkture-2.5.5/src/linkture/__init__.py +0 -0
- {linkture-2.5.5 → linkture-2.6.0}/LICENSE +0 -0
- {linkture-2.5.5 → linkture-2.6.0}/README.md +0 -0
- {linkture-2.5.5 → linkture-2.6.0}/src/linkture/res/custom.json +0 -0
- {linkture-2.5.5 → linkture-2.6.0}/src/linkture/res/resources.db +0 -0
- {linkture-2.5.5 → linkture-2.6.0}/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.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,6 @@ 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
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "linkture"
|
3
|
-
|
3
|
+
dynamic = []
|
4
4
|
description = "PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode"
|
5
5
|
authors = [
|
6
6
|
{ name = "Eryk J.", email = "infiniti@inventati.org" },
|
@@ -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,6 +35,7 @@ keywords = [
|
|
36
35
|
"scripture-parser",
|
37
36
|
"scripture-linker",
|
38
37
|
]
|
38
|
+
version = "v2.6.0"
|
39
39
|
|
40
40
|
[project.license]
|
41
41
|
text = "MIT"
|
@@ -52,3 +52,7 @@ build-backend = "pdm.backend"
|
|
52
52
|
|
53
53
|
[tool.pdm]
|
54
54
|
distribution = true
|
55
|
+
|
56
|
+
[tool.pdm.version]
|
57
|
+
source = "file"
|
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:
|
49
|
+
suffix = args['l'][1]
|
50
|
+
if len(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,14 +26,12 @@
|
|
26
26
|
SOFTWARE.
|
27
27
|
"""
|
28
28
|
|
29
|
-
|
29
|
+
__app__ = 'linkture'
|
30
|
+
__version__ = 'v2.6.0'
|
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
|
|
@@ -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('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('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
|
File without changes
|