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 = {
@@ -63,18 +52,6 @@ def run_prebuild_script():
63
52
else :
64
53
print ("prebuild.sh not found." )
65
54
66
- def cleanup ():
67
- """ Clean up unneeded files, preserving only 'docs' and 'blog' directories """
68
- os .chdir ("./defang-docs" )
69
- for item in os .listdir ('.' ):
70
- if item not in ['docs' , 'blog' ]: # Check if the item is not one of the directories to keep
71
- item_path = os .path .join ('.' , item ) # Construct the full path
72
- if os .path .isdir (item_path ):
73
- shutil .rmtree (item_path ) # Remove the directory and all its contents
74
- else :
75
- os .remove (item_path ) # Remove the file
76
- print ("Cleanup completed successfully." )
77
-
78
55
def parse_markdown ():
79
56
""" Parse markdown files in the current directory into JSON """
80
57
reset_knowledge_base () # Reset the JSON database file
@@ -196,10 +173,8 @@ def recursive_parse_directory(root_dir):
196
173
if __name__ == "__main__" :
197
174
setup_repositories ()
198
175
run_prebuild_script ()
199
- cleanup ()
200
176
os .chdir ('../../' )
201
177
print (os .listdir ('.' ))
202
178
parse_markdown () # Start parsing logic after all setups
203
179
print (os .listdir ('.' ))
204
- clean_tmp ('./.tmp' )
205
180
print ("All processes completed successfully." )
0 commit comments