-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroup_generator.py
More file actions
65 lines (41 loc) · 1.5 KB
/
group_generator.py
File metadata and controls
65 lines (41 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import json
import argparse
from re import L
from flask import jsonify
parser = argparse.ArgumentParser()
# parser.add_argument("--dzikir_type", dest="dzikir_type", type=str, help="Please Add Al Matsurat Type")
# parser.add_argument("--lang", dest="lang", type=str, help="Please Add Al Matsurat Type")
args = parser.parse_args()
# dzikir_type = args.dzikir_type
# lang = args.lang
# if dzikir_type == None:
# dzikir_type = "sugro"
__dir__ = os.path.dirname(__file__)
def generateGroup(lang, dzikir_type):
dzikir_type_locale_file = open(f"{__dir__}/{lang}/{dzikir_type}.json")
dzikirDataLocale_file = json.loads(dzikir_type_locale_file.read())
count = 0
# print(dzikirDataLocale_file)
groups = []
for ayat in dzikirDataLocale_file:
group = {}
group["title"] = ayat['title']
group['contents'] = {}
for content in ayat['contents']:
group['contents'][str(count)] = content['ayat']
count+=1
groups.append(group)
# print(groups)
with open(f"{__dir__}/{lang}/{dzikir_type}_groups.json", "w") as groupFile:
groupFile.write(json.dumps(groups))
langs = [f for f in os.listdir(__dir__) if not f.endswith('.py') ]
for lang in langs:
if lang in ["data", "license", ".DS_Store", ".git"]:
langs.remove(lang)
elif lang.endswith('.md'):
langs.remove(lang)
langs = langs[1:len(langs)-1]
for lang in langs:
generateGroup(lang, "sugro")
generateGroup(lang, "kubro")