@@ -227,16 +227,19 @@ def copy_dirs(source_path, dest_path):
227227 shutil .copytree (source_folder , destination_folder )
228228 print (f"Copied { folder_name } folder from { source_folder } to { destination_folder } " )
229229
230- def copy_files (source_path , dest_path ):
231- file_names = ["src/SUMMARY.md" , "hacktricks-preprocessor.py" , "book.toml" , ".gitignore" , "src/robots.txt" ]
232- for file_name in file_names :
233- source_filepath = os .path .join (source_path , file_name )
234- dest_filepath = os .path .join (dest_path , file_name )
230+ def move_files_to_push (source_path , dest_path , relative_file_paths ):
231+ for file_path in relative_file_paths :
232+ source_filepath = os .path .join (source_path , file_path )
233+ dest_filepath = os .path .join (dest_path , file_path )
235234 if not os .path .exists (source_filepath ):
236235 print (f"Error: { source_filepath } does not exist." )
237236 else :
238237 shutil .copy2 (source_filepath , dest_filepath )
239- print (f"[+] Copied { file_name } " )
238+ print (f"[+] Copied { file_path } " )
239+
240+ def copy_files (source_path , dest_path ):
241+ file_names = ["src/SUMMARY.md" , "hacktricks-preprocessor.py" , "book.toml" , ".gitignore" , "src/robots.txt" ]
242+ move_files_to_push (source_path , dest_path , file_names )
240243
241244def translate_file (language , file_path , file_dest_path , model , client ):
242245 global VERBOSE
@@ -301,7 +304,7 @@ def translate_directory(language, source_path, dest_path, model, num_threads, cl
301304
302305
303306if __name__ == "__main__" :
304- print ("- Version 1.1.1 " )
307+ print ("- Version 2.0.0 " )
305308 # Set up argparse
306309 parser = argparse .ArgumentParser (description = 'Translate gitbook and copy to a new branch.' )
307310 parser .add_argument ('-d' , '--directory' , action = 'store_true' , help = 'Translate a full directory.' )
@@ -389,7 +392,10 @@ def translate_directory(language, source_path, dest_path, model, num_threads, cl
389392 print ("You need to indicate either a directory or a list of files to translate." )
390393 exit (0 )
391394
392- # Copy summary
395+ # Copy translated files
396+ move_files_to_push (source_folder , dest_folder , translate_files )
397+
398+ # Copy Summary
393399 copy_files (source_folder , dest_folder )
394400
395401 # Copy .gitbook folder
0 commit comments