scripturelookup 0.0.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.
Files changed (28) hide show
  1. scripturelookup-0.0.1/.github/workflows/publish.yml +19 -0
  2. scripturelookup-0.0.1/.gitignore +9 -0
  3. scripturelookup-0.0.1/LICENSE +21 -0
  4. scripturelookup-0.0.1/PKG-INFO +40 -0
  5. scripturelookup-0.0.1/README.md +3 -0
  6. scripturelookup-0.0.1/pyproject.toml +32 -0
  7. scripturelookup-0.0.1/requirements.txt +3 -0
  8. scripturelookup-0.0.1/setup.cfg +4 -0
  9. scripturelookup-0.0.1/src/geezify-python-main/LICENSE +21 -0
  10. scripturelookup-0.0.1/src/geezify-python-main/README.md +8 -0
  11. scripturelookup-0.0.1/src/geezify-python-main/arabify.py +43 -0
  12. scripturelookup-0.0.1/src/geezify-python-main/arabify_test.py +13 -0
  13. scripturelookup-0.0.1/src/geezify-python-main/geezify.py +49 -0
  14. scripturelookup-0.0.1/src/geezify-python-main/geezify_test.py +13 -0
  15. scripturelookup-0.0.1/src/geezify-python-main/test_data.py +92 -0
  16. scripturelookup-0.0.1/src/scripturelookup/__init__.py +0 -0
  17. scripturelookup-0.0.1/src/scripturelookup/command_line.py +37 -0
  18. scripturelookup-0.0.1/src/scripturelookup/data/metadata-languages.min.json +940 -0
  19. scripturelookup-0.0.1/src/scripturelookup/data/metadata-scriptures.min.json +59792 -0
  20. scripturelookup-0.0.1/src/scripturelookup/data.py +58 -0
  21. scripturelookup-0.0.1/src/scripturelookup/lookup.py +307 -0
  22. scripturelookup-0.0.1/src/scripturelookup/numbers.py +267 -0
  23. scripturelookup-0.0.1/src/scripturelookup.egg-info/PKG-INFO +40 -0
  24. scripturelookup-0.0.1/src/scripturelookup.egg-info/SOURCES.txt +26 -0
  25. scripturelookup-0.0.1/src/scripturelookup.egg-info/dependency_links.txt +1 -0
  26. scripturelookup-0.0.1/src/scripturelookup.egg-info/entry_points.txt +2 -0
  27. scripturelookup-0.0.1/src/scripturelookup.egg-info/requires.txt +1 -0
  28. scripturelookup-0.0.1/src/scripturelookup.egg-info/top_level.txt +2 -0
@@ -0,0 +1,19 @@
1
+ # From https://www.seanh.cc/2022/05/21/publishing-python-packages-from-github-actions/
2
+
3
+ name: Publish to PyPI.org
4
+ on:
5
+ release:
6
+ types: [published]
7
+ jobs:
8
+ pypi:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Checkout
12
+ uses: actions/checkout@v3
13
+ with:
14
+ fetch-depth: 0
15
+ - run: python3 -m pip install --upgrade build && python3 -m build
16
+ - name: Publish package
17
+ uses: pypa/gh-action-pypi-publish@release/v1
18
+ with:
19
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,9 @@
1
+ *.pyc
2
+ __pycache__/
3
+ .DS_Store*
4
+ ._*
5
+ .Spotlight-V100
6
+ .Trashes
7
+ Icon?
8
+ *~
9
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Samuel Bradshaw
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,40 @@
1
+ Metadata-Version: 2.1
2
+ Name: scripturelookup
3
+ Version: 0.0.1
4
+ Summary: Python and command-line utility for converting scripture references between formats.
5
+ Author-email: Samuel Bradshaw <samuel.h.bradshaw@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Samuel Bradshaw
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
+ Project-URL: Repository, https://github.com/samuelbradshaw/python-scripture-lookup
28
+ Project-URL: Issues, https://github.com/samuelbradshaw/python-scripture-lookup/issues
29
+ Project-URL: Changelog, https://github.com/samuelbradshaw/python-scripture-lookup/releases
30
+ Keywords: python,command,scripture,bible,book of mormon,reference
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python :: 3
33
+ Requires-Python: >=3.8
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: requests
37
+
38
+ # Scripture Lookup
39
+
40
+ TODO: Add readme
@@ -0,0 +1,3 @@
1
+ # Scripture Lookup
2
+
3
+ TODO: Add readme
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools", "setuptools_scm[toml]>=6.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scripturelookup"
7
+ authors = [
8
+ {name = "Samuel Bradshaw", email = "samuel.h.bradshaw@gmail.com"},
9
+ ]
10
+ description = "Python and command-line utility for converting scripture references between formats."
11
+ readme = "README.md"
12
+ license = {file = "LICENSE"}
13
+ keywords = ["python", "command", "scripture", "bible", "book of mormon", "reference",]
14
+ classifiers = [
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ ]
18
+ requires-python = ">=3.8"
19
+ dynamic = ["version"]
20
+ dependencies = [
21
+ "requests",
22
+ ]
23
+
24
+ [project.urls]
25
+ Repository = "https://github.com/samuelbradshaw/python-scripture-lookup"
26
+ Issues = "https://github.com/samuelbradshaw/python-scripture-lookup/issues"
27
+ Changelog = "https://github.com/samuelbradshaw/python-scripture-lookup/releases"
28
+
29
+ [project.scripts]
30
+ scripturelookup = "scripturelookup.command_line:main_cli"
31
+
32
+ [tool.setuptools_scm]
@@ -0,0 +1,3 @@
1
+ requests
2
+
3
+ # -e git+https://github.com/logicalperson0/geezify-python.git@main#egg=geezify-python-main
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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)