scripturelookup 0.0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Samuel Kenneth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # geezify-python
2
+ A Python Library to convert between Geez and Arabic numbers
3
+
4
+ Authors:
5
+
6
+ Yilkal Argaw
7
+
8
+ Samuel Kenneth
@@ -0,0 +1,43 @@
1
+ from re import sub
2
+
3
+ class Arabify:
4
+ """Converts geez numbers to arab numbers
5
+ """
6
+ numbers_dict = {'፩': 1, '፪': 2, '፫': 3, '፬': 4,
7
+ '፭': 5, '፮': 6, '፯': 7, '፰': 8,
8
+ '፱': 9, '፲': 10, '፳': 20, '፴': 30,
9
+ '፵': 40, '፶': 50, '፷': 60, '፸': 70,
10
+ '፹': 80, '፺': 90, ' ': 0}
11
+
12
+ @staticmethod
13
+ def arabify(geezNum):
14
+ # validate_number
15
+ quartets = list(reversed(Arabify.__rollback(geezNum).split('፼')))
16
+ num = sum(map
17
+ (lambda ntup:
18
+ Arabify.__arabify_quartets(ntup[1]) * (10000 ** ntup[0]),
19
+ enumerate(quartets)))
20
+
21
+ return(num)
22
+
23
+ def __rollback(strgeez):
24
+ return(sub(r'^፼', '፩፼', (sub(r'^፻', '፩፻', sub('፼፻', '፼፩፻', strgeez)))))
25
+
26
+ def __arabify_pairs(geezNum):
27
+ """pairs the geeznums to their arabnums counter parts
28
+ """
29
+ # validate_pairs
30
+ return(sum([Arabify.numbers_dict[char] for char in geezNum]))
31
+
32
+ def __arabify_quartets(geezNum):
33
+ """pairs the geeznums to their arabnums counter parts
34
+ """
35
+ # validate_quartets
36
+ paired = geezNum.split('፻')
37
+
38
+ if len(paired) == 0:
39
+ paired = ['', '']
40
+ elif len(paired) == 1:
41
+ paired = ['', paired[0]]
42
+
43
+ return((Arabify.__arabify_pairs(paired[0]) * 100) + Arabify.__arabify_pairs(paired[1]))
@@ -0,0 +1,13 @@
1
+ import unittest
2
+ from arabify import Arabify
3
+ from test_data import TESTDATA
4
+
5
+ class TestArabify(unittest.TestCase):
6
+ def test_arabify_for_all_test_cases(self):
7
+ for x in TESTDATA:
8
+ print(f"{x[1]} => {x[0]}")
9
+ print(f"{x[0]} == {Arabify.arabify(x[1])}")
10
+ self.assertEqual(x[0], Arabify.arabify(x[1]))
11
+
12
+ if __name__ == '__main__':
13
+ unittest.main()
@@ -0,0 +1,49 @@
1
+ class Geezify:
2
+
3
+ @staticmethod
4
+ def geezify(number):
5
+ return Geezify.__concat_geezified_pairs(Geezify.__geezify_pairs(Geezify.__pairup(number)))
6
+
7
+ def __pairup(number):
8
+ if (type(number) != int):
9
+ raise TypeError("not a valid number")
10
+ pairs = []
11
+
12
+ while ((number // 100 != 0) or
13
+ (number % 100 != 0)):
14
+ pairs.append(number % 100)
15
+ number = (number // 100)
16
+
17
+ return pairs
18
+
19
+
20
+ def __geezify_pairs(pairs):
21
+ oneth = ['', '፩', '፪', '፫', '፬', '፭', '፮', '፯', '፰', '፱']
22
+ tenth = ['', '፲', '፳', '፴', '፵', '፶', '፷', '፸', '፹', '፺']
23
+
24
+ geezified_pairs = list(map(lambda num: tenth[num // 10] +
25
+ oneth[num % 10],
26
+ pairs))
27
+
28
+ return geezified_pairs
29
+
30
+
31
+ def __concat_geezified_pairs(geezified_pairs):
32
+ joined_str = ""
33
+ len_gp = len(geezified_pairs)
34
+
35
+ for i in range(len_gp):
36
+ if (i == 0):
37
+ joined_str = geezified_pairs[i] + joined_str
38
+ elif (i % 2 == 0 and geezified_pairs[i] == "፩" and i == len_gp - 1):
39
+ joined_str = "፼" + joined_str
40
+ elif (i % 2 == 0):
41
+ joined_str = geezified_pairs[i] + "፼" + joined_str
42
+ elif (geezified_pairs[i] == "፩"):
43
+ joined_str = "፻" + joined_str
44
+ elif (geezified_pairs[i] == ""):
45
+ continue
46
+ else :
47
+ joined_str = geezified_pairs[i] + "፻" + joined_str
48
+
49
+ return joined_str
@@ -0,0 +1,13 @@
1
+ import unittest
2
+ from geezify import Geezify
3
+ from test_data import TESTDATA
4
+
5
+ class TestGeezify(unittest.TestCase):
6
+ def test_geezify_for_all_test_cases(self):
7
+ for x in TESTDATA:
8
+ print(f"{x[0]} => {x[1]}")
9
+ print(f"{x[1]} == {Geezify.geezify(x[0])}")
10
+ self.assertEqual(x[1], Geezify.geezify(x[0]))
11
+
12
+ if __name__ == '__main__':
13
+ unittest.main()
@@ -0,0 +1,92 @@
1
+ TESTDATA = [
2
+ [1, '፩'],
3
+ [10, '፲'],
4
+ [100, '፻'],
5
+ [1000, '፲፻'],
6
+ [10000, '፼'], # (እልፍ)
7
+ [100000, '፲፼'], # (አእላፍ)
8
+ [1000000, '፻፼'], # (አእላፋት)
9
+ [10000000, '፲፻፼'], # (ትእልፊት)
10
+ [100000000, '፼፼'], # (ትእልፊታት)
11
+ [1000000000, '፲፼፼'],
12
+ [10000000000, '፻፼፼'],
13
+ [100000000000, '፲፻፼፼'], # (ምእልፊት)
14
+ [1000000000000, '፼፼፼'], # (ምእልፊታት)
15
+ [100010000, '፼፩፼'],
16
+ [100100000, '፼፲፼'],
17
+ [100200000, '፼፳፼'],
18
+ [100110000, '፼፲፩፼'],
19
+ [1, '፩'],
20
+ [11, '፲፩'],
21
+ [111, '፻፲፩'],
22
+ [1111, '፲፩፻፲፩'],
23
+ [11111, '፼፲፩፻፲፩'],
24
+ [111111, '፲፩፼፲፩፻፲፩'],
25
+ [1111111, '፻፲፩፼፲፩፻፲፩'],
26
+ [11111111, '፲፩፻፲፩፼፲፩፻፲፩'],
27
+ [111111111, '፼፲፩፻፲፩፼፲፩፻፲፩'],
28
+ [1111111111, '፲፩፼፲፩፻፲፩፼፲፩፻፲፩'],
29
+ [11111111111, '፻፲፩፼፲፩፻፲፩፼፲፩፻፲፩'],
30
+ [111111111111, '፲፩፻፲፩፼፲፩፻፲፩፼፲፩፻፲፩'],
31
+ [1111111111111, '፼፲፩፻፲፩፼፲፩፻፲፩፼፲፩፻፲፩'],
32
+ [1, '፩'],
33
+ [12, '፲፪'],
34
+ [123, '፻፳፫'],
35
+ [1234, '፲፪፻፴፬'],
36
+ [12345, '፼፳፫፻፵፭'],
37
+ [7654321, '፯፻፷፭፼፵፫፻፳፩'],
38
+ [17654321, '፲፯፻፷፭፼፵፫፻፳፩'],
39
+ [51615131, '፶፩፻፷፩፼፶፩፻፴፩'],
40
+ [15161513, '፲፭፻፲፮፼፲፭፻፲፫'],
41
+ [10101011, '፲፻፲፼፲፻፲፩'],
42
+ [101, '፻፩'],
43
+ [1001, '፲፻፩'],
44
+ [1010, '፲፻፲'],
45
+ [1011, '፲፻፲፩'],
46
+ [1100, '፲፩፻'],
47
+ [1101, '፲፩፻፩'],
48
+ [1111, '፲፩፻፲፩'],
49
+ [10001, '፼፩'],
50
+ [10010, '፼፲'],
51
+ [10100, '፼፻'],
52
+ [10101, '፼፻፩'],
53
+ [10110, '፼፻፲'],
54
+ [10111, '፼፻፲፩'],
55
+ [100001, '፲፼፩'],
56
+ [100010, '፲፼፲'],
57
+ [100011, '፲፼፲፩'],
58
+ [100100, '፲፼፻'],
59
+ [101010, '፲፼፲፻፲'],
60
+ [1000001, '፻፼፩'],
61
+ [1000101, '፻፼፻፩'],
62
+ [1000100, '፻፼፻'],
63
+ [1010000, '፻፩፼'],
64
+ [1010001, '፻፩፼፩'],
65
+ [1100001, '፻፲፼፩'],
66
+ [1010101, '፻፩፼፻፩'],
67
+ [101010101, '፼፻፩፼፻፩'],
68
+ [100010000, '፼፩፼'],
69
+ [100010100, '፼፩፼፻'],
70
+ [101010100, '፼፻፩፼፻'],
71
+ [3, '፫'],
72
+ [30, '፴'],
73
+ [33, '፴፫'],
74
+ [303, '፫፻፫'],
75
+ [3003, '፴፻፫'],
76
+ [3030, '፴፻፴'],
77
+ [3033, '፴፻፴፫'],
78
+ [3300, '፴፫፻'],
79
+ [3303, '፴፫፻፫'],
80
+ [3333, '፴፫፻፴፫'],
81
+ [30003, '፫፼፫'],
82
+ [30303, '፫፼፫፻፫'],
83
+ [300003, '፴፼፫'],
84
+ [303030, '፴፼፴፻፴'],
85
+ [3000003, '፫፻፼፫'],
86
+ [3000303, '፫፻፼፫፻፫'],
87
+ [3030003, '፫፻፫፼፫'],
88
+ [3300003, '፫፻፴፼፫'],
89
+ [3030303, '፫፻፫፼፫፻፫'],
90
+ [303030303, '፫፼፫፻፫፼፫፻፫'],
91
+ [333333333, '፫፼፴፫፻፴፫፼፴፫፻፴፫']
92
+ ]
File without changes
@@ -0,0 +1,37 @@
1
+ # Python standard libraries
2
+ import argparse
3
+
4
+ # Internal imports
5
+ from . import data, numbers, lookup
6
+
7
+ def main_cli():
8
+ parser = argparse.ArgumentParser(description='Scripture lookup')
9
+ parser.add_argument('command', help='Command to run. Required.')
10
+ parser.add_argument('--input', help='Input text to parse (one or more references).')
11
+ parser.add_argument('--lang', help='Output language. Default: "en".')
12
+ parser.add_argument('--separator', help='Separator when there are multiple results. Default: "\n".')
13
+ parser.add_argument('--link_class', help='Link "class" attribute.')
14
+ parser.add_argument('--link_target', help='Link "target" attribute.')
15
+ parser.add_argument('--use_query_parameters', action='store_true', help='Use "id" and "context" parameters in URIs.')
16
+ parser.add_argument('--skip_lang', action='store_true', help='Skip "lang" parameter in URLs.')
17
+ parser.add_argument('--skip_fragment', action='store_true', help='Skip #frament in URLs.')
18
+ parser.add_argument('--skip_book_name', action='store_true', help='Skip scripture book name in labels.')
19
+ parser.add_argument('--abbreviated', action='store_true', help='Prefer abbreviated scripture book name in labels.')
20
+
21
+ args = parser.parse_args()
22
+
23
+ command = getattr(lookup, args.command)
24
+ result = command(
25
+ args.input,
26
+ lang = args.lang or 'en',
27
+ separator = args.separator or '\n',
28
+ link_class = args.link_class,
29
+ link_target = args.link_target,
30
+ use_query_parameters = args.use_query_parameters,
31
+ skip_lang = args.skip_lang,
32
+ skip_fragment = args.skip_fragment,
33
+ skip_book_name = args.skip_book_name,
34
+ abbreviated = args.abbreviated
35
+ )
36
+
37
+ print(result)