7
7
8
8
kb_file_path = './data/knowledge_base.json'
9
9
10
- def clean_tmp (dir_path ):
11
- """ Clears out all contents of the specified directory except for prebuild.sh """
12
- for item in os .listdir (dir_path ):
13
- item_path = os .path .join (dir_path , item )
14
- if item != "prebuild.sh" : # Keep prebuild.sh
15
- if os .path .isdir (item_path ):
16
- shutil .rmtree (item_path )
17
- else :
18
- os .remove (item_path )
19
-
20
10
def clone_repository (repo_url , local_dir ):
21
11
""" Clone or pull the repository based on its existence. """
22
12
if not os .path .exists (local_dir ):
@@ -30,7 +20,6 @@ def clone_repository(repo_url, local_dir):
30
20
def setup_repositories ():
31
21
tmp_dir = ".tmp"
32
22
os .makedirs (tmp_dir , exist_ok = True )
33
- clean_tmp (tmp_dir ) # Clean the temporary directory before setting up
34
23
35
24
# Define repositories and their URLs
36
25
repos = {
@@ -62,18 +51,6 @@ def run_prebuild_script():
62
51
else :
63
52
print ("prebuild.sh not found." )
64
53
65
- def cleanup ():
66
- """ Clean up unneeded files, preserving only 'docs' and 'blog' directories """
67
- os .chdir ("./defang-docs" )
68
- for item in os .listdir ('.' ):
69
- if item not in ['docs' , 'blog' ]: # Check if the item is not one of the directories to keep
70
- item_path = os .path .join ('.' , item ) # Construct the full path
71
- if os .path .isdir (item_path ):
72
- shutil .rmtree (item_path ) # Remove the directory and all its contents
73
- else :
74
- os .remove (item_path ) # Remove the file
75
- print ("Cleanup completed successfully." )
76
-
77
54
def parse_markdown ():
78
55
""" Parse markdown files in the current directory into JSON """
79
56
reset_knowledge_base () # Reset the JSON database file
@@ -195,10 +172,8 @@ def recursive_parse_directory(root_dir):
195
172
if __name__ == "__main__" :
196
173
setup_repositories ()
197
174
run_prebuild_script ()
198
- cleanup ()
199
175
os .chdir ('../../' )
200
176
print (os .listdir ('.' ))
201
177
parse_markdown () # Start parsing logic after all setups
202
178
print (os .listdir ('.' ))
203
- clean_tmp ('./.tmp' )
204
179
print ("All processes completed successfully." )
0 commit comments