@@ -148,17 +148,44 @@ def extract_to_vtr_flow_dir(args, tar_gz_filename):
148148 source_file = os .path .join (root , file )
149149 relative_path = os .path .relpath (source_file , tmp_source_blif_dir )
150150 destination_file = os .path .join (mlp_benchmarks_dir , relative_path )
151- print (source_file , destination_file )
152151 os .makedirs (os .path .dirname (destination_file ), exist_ok = True )
153152 shutil .copy2 (source_file , destination_file )
154153
154+ # Create symbolic links to blif files
155+ find_and_link_files (mlp_benchmarks_dir , ".blif" , "blif_files" )
156+ # Create symbolic links to traffic flow files
157+ find_and_link_files (mlp_benchmarks_dir , ".flows" , "traffic_flow_files" )
158+
155159 finally :
156160 # Clean-up
157161 shutil .rmtree (tmpdir )
158162
159163 print ("Done" )
160164
161165
166+ def find_and_link_files (base_path , target_extension , link_folder_name ):
167+ """
168+ Finds files with a given extension and make symbolic links to them
169+ """
170+
171+ # Create a folder to store symbolic links
172+ link_folder_path = os .path .join (base_path , link_folder_name )
173+ os .makedirs (link_folder_path , exist_ok = True )
174+
175+ # Walk through all subdirectories
176+ for root , dirs , files in os .walk (base_path ):
177+ if root == link_folder_path :
178+ continue
179+
180+ for file in files :
181+ if file .endswith (target_extension ):
182+ # Get the full path of the file
183+ file_path = os .path .join (root , file )
184+
185+ # Create symbolic link in the link folder
186+ link_name = os .path .join (link_folder_path , file )
187+ os .symlink (file_path , link_name )
188+
162189
163190if __name__ == "__main__" :
164191 main ()
0 commit comments