-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateSection.py
More file actions
41 lines (27 loc) · 1003 Bytes
/
generateSection.py
File metadata and controls
41 lines (27 loc) · 1003 Bytes
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
import json
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--dzikir_type", dest="dzikir_type", type=str, help="Please Add Al Matsurat Type")
args = parser.parse_args()
dzikir_type = args.dzikir_type
if dzikir_type == None:
dzikir_type = "sugro"
__dir__ = os.path.dirname(__file__)
arabic_file_kubro = open(f"{__dir__}/data/kubro.json")
arabic_file_sugro = open(f"{__dir__}/data/sugro.json")
if dzikir_type == "sugro":
dzikirData = json.loads(arabic_file_sugro.read())
else:
dzikirData = json.loads(arabic_file_kubro.read())
dhikrSections = {}
count = 0
currentId = 0
for dhikrIdSection in dzikirData:
currentId = dhikrIdSection['id']
print(currentId)
for i in range(len(dhikrIdSection['contents'])):
contents = dhikrIdSection['contents'][i]
dhikrSections[str(count)] = f"{currentId}.{i}"
count+=1
open(f"{__dir__}/data/{dzikir_type}_section.json", "w").write(str(dhikrSections).replace("'", "\""))