1111
1212from ...volume import generate_copy_arguments
1313from ...support import subprocess_wrapper
14+ from ...support .translate_language import TranslateLanguage_sys_patch
15+ trans = TranslateLanguage_sys_patch ().utilities ()
1416
15-
16- def install_new_file (source_folder : Path , destination_folder : Path , file_name : str , method : PatchType , trans : dict = None ) -> None :
17+ def install_new_file (source_folder : Path , destination_folder : Path , file_name : str , method : PatchType ) -> None :
1718 """
1819 Installs a new file to the destination folder
1920
@@ -30,48 +31,36 @@ def install_new_file(source_folder: Path, destination_folder: Path, file_name: s
3031 file_name_str = str (file_name )
3132
3233 if not Path (destination_folder ).exists ():
33- if trans :
34- logging .info (trans [" - Skipping {file_name}, cannot locate {source_folder}" ].format (file_name = file_name , source_folder = source_folder ))
35- else :
36- logging .info (f" - Skipping { file_name } , cannot locate { source_folder } " )
34+
35+ logging .info (trans [" - Skipping {file_name}, cannot locate {source_folder}" ].format (file_name = file_name , source_folder = source_folder ))
3736 return
3837
3938 if method in [PatchType .MERGE_SYSTEM_VOLUME , PatchType .MERGE_DATA_VOLUME ]:
4039 # merge with rsync
41- if trans :
42- logging .info (trans [" - Installing: {file_name}" ].format (file_name = file_name ))
43- else :
44- logging .info (f" - Installing: { file_name } " )
40+
41+ logging .info (trans [" - Installing: {file_name}" ].format (file_name = file_name ))
4542 subprocess_wrapper .run_as_root (["/usr/bin/rsync" , "-r" , "-i" , "-a" , f"{ source_folder } /{ file_name } " , f"{ destination_folder } /" ], stdout = subprocess .PIPE )
4643 fix_permissions (destination_folder + "/" + file_name )
4744 elif Path (source_folder + "/" + file_name_str ).is_dir ():
4845 # Applicable for .kext, .app, .plugin, .bundle, all of which are directories
4946 if Path (destination_folder + "/" + file_name ).exists ():
50- if trans :
51- logging .info (trans [" - Found existing {file_name}, overwriting..." ].format (file_name = file_name ))
52- else :
53- logging .info (f" - Found existing { file_name } , overwriting..." )
47+
48+ logging .info (trans [" - Found existing {file_name}, overwriting..." ].format (file_name = file_name ))
49+
5450 subprocess_wrapper .run_as_root_and_verify (["/bin/rm" , "-R" , f"{ destination_folder } /{ file_name } " ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
5551 else :
56- if trans :
57- logging .info (trans [" - Installing: {file_name}" ].format (file_name = file_name ))
58- else :
59- logging .info (f" - Installing: { file_name } " )
52+
53+ logging .info (trans [" - Installing: {file_name}" ].format (file_name = file_name ))
54+
6055 subprocess_wrapper .run_as_root_and_verify (generate_copy_arguments (f"{ source_folder } /{ file_name } " , destination_folder ), stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
6156 fix_permissions (destination_folder + "/" + file_name )
6257 else :
6358 # Assume it's an individual file, replace as normal
6459 if Path (destination_folder + "/" + file_name ).exists ():
65- if trans :
66- logging .info (trans [" - Found existing {file_name}, overwriting..." ].format (file_name = file_name ))
67- else :
68- logging .info (f" - Found existing { file_name } , overwriting..." )
60+ logging .info (trans [" - Found existing {file_name}, overwriting..." ].format (file_name = file_name ))
6961 subprocess_wrapper .run_as_root_and_verify (["/bin/rm" , f"{ destination_folder } /{ file_name } " ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
7062 else :
71- if trans :
72- logging .info (trans [" - Installing: {file_name}" ].format (file_name = file_name ))
73- else :
74- logging .info (f" - Installing: { file_name } " )
63+ logging .info (trans [" - Installing: {file_name}" ].format (file_name = file_name ))
7564 subprocess_wrapper .run_as_root_and_verify (generate_copy_arguments (f"{ source_folder } /{ file_name } " , destination_folder ), stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
7665 fix_permissions (destination_folder + "/" + file_name )
7766
@@ -86,10 +75,9 @@ def remove_file(destination_folder: Path, file_name: str, trans: dict = None) ->
8675 """
8776
8877 if Path (destination_folder + "/" + file_name ).exists ():
89- if trans :
90- logging .info (trans [" - Removing: {file_name}" ].format (file_name = file_name ))
91- else :
92- logging .info (f" - Removing: { file_name } " )
78+
79+ logging .info (trans [" - Removing: {file_name}" ].format (file_name = file_name ))
80+
9381 if Path (destination_folder + "/" + file_name ).is_dir ():
9482 subprocess_wrapper .run_as_root_and_verify (["/bin/rm" , "-R" , f"{ destination_folder } /{ file_name } " ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
9583 else :
0 commit comments