forked from rh-aiservices-bu/insurance-claim-processing
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathgen.py
38 lines (29 loc) · 758 Bytes
/
gen.py
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
#%%
import re
import os
def extract_file_names(content):
pattern = r'xref:(.*?)[\[\*]'
matches = re.findall(pattern, content)
# print(matches)
return matches
#%%
def create_files(file_names):
for name in file_names:
name = "pages/"+name
file_path = f"{name}"
print(file_path)
if not os.path.exists(file_path):
with open(file_path, "w") as file:
file.write(f"= {name}\n\n")
else:
print(f"File '{file_path}' already exists. Skipping.")
#%%
def main():
with open("nav.adoc", "r") as nav_file:
content = nav_file.read()
file_names = extract_file_names(content)
create_files(file_names)
#%%
if __name__ == "__main__":
main()
# %%