linkture 2.6.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkture
3
- Version: 2.6.0
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`. It's in English, but you would like the scriptures to be in Spanish, with the full book name:
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
- txt = s.rewrite_scriptures(txt)
187
+ new_txt = s.rewrite_scriptures(txt)
184
188
  # the references will simply be rewritten in the desired language and format
185
189
 
186
- i = s.serial_chapter_number(txt)
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(txt)
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
- txt = s.code_chapter(i)
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
- txt = s.code_verse(i)
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
 
@@ -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`. It's in English, but you would like the scriptures to be in Spanish, with the full book name:
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
- txt = s.rewrite_scriptures(txt)
159
+ new_txt = s.rewrite_scriptures(txt)
156
160
  # the references will simply be rewritten in the desired language and format
157
161
 
158
- i = s.serial_chapter_number(txt)
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(txt)
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
- txt = s.code_chapter(i)
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
- txt = s.code_verse(i)
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
 
@@ -35,7 +35,7 @@ keywords = [
35
35
  "scripture-parser",
36
36
  "scripture-linker",
37
37
  ]
38
- version = "v2.6.0"
38
+ version = "v2.6.1"
39
39
 
40
40
  [project.license]
41
41
  text = "MIT"
@@ -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:')
@@ -27,7 +27,7 @@
27
27
  """
28
28
 
29
29
  __app__ = 'linkture'
30
- __version__ = 'v2.6.0'
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
- 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')
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 available_languages:
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 available_languages:
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 non_latin:
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]:
File without changes