@@ -91,7 +91,7 @@ def migrate_file(self, file_path: Path) -> bool:
9191 True if file was modified, False otherwise
9292 """
9393 if file_path .suffix != '.yaml' :
94- print (f"Skipping non-YAML file: { file_path } " )
94+ sys . stdout . write (f"Skipping non-YAML file: { file_path } \n " )
9595 return False
9696
9797 try :
@@ -101,25 +101,25 @@ def migrate_file(self, file_path: Path) -> bool:
101101 migrated_content = self .migrate_content (original_content )
102102
103103 if migrated_content == original_content :
104- print (f"No changes needed: { file_path } " )
104+ sys . stdout . write (f"No changes needed: { file_path } \n " )
105105 return False
106106
107107 if self .dry_run :
108- print (f"\n { '=' * 60 } " )
109- print (f"Would modify: { file_path } " )
110- print (f"{ '=' * 60 } " )
108+ sys . stdout . write (f"\n { '=' * 60 } \n " )
109+ sys . stdout . write (f"Would modify: { file_path } \n " )
110+ sys . stdout . write (f"{ '=' * 60 } \n " )
111111 self ._show_diff (original_content , migrated_content )
112112 return True
113113
114114 # Write migrated content
115115 with open (file_path , 'w' ) as f :
116116 f .write (migrated_content )
117117
118- print (f"Migrated: { file_path } " )
118+ sys . stdout . write (f"Migrated: { file_path } \n " )
119119 return True
120120
121121 except Exception as e :
122- print (f"Error migrating { file_path } : { e } " , file = sys . stderr )
122+ sys . stderr . write (f"Error migrating { file_path } : { e } \n " )
123123 return False
124124
125125 def _show_diff (self , original : str , migrated : str ):
@@ -129,9 +129,9 @@ def _show_diff(self, original: str, migrated: str):
129129
130130 for i , (orig , mig ) in enumerate (zip (orig_lines , mig_lines , strict = False ), 1 ):
131131 if orig != mig :
132- print (f"Line { i } :" )
133- print (f" - { orig } " )
134- print (f" + { mig } " )
132+ sys . stdout . write (f"Line { i } :\n " )
133+ sys . stdout . write (f" - { orig } \n " )
134+ sys . stdout . write (f" + { mig } \n " )
135135
136136 def migrate_directory (self , directory : Path , recursive : bool = True ) -> int :
137137 """Migrate all YAML files in directory.
@@ -143,10 +143,10 @@ def migrate_directory(self, directory: Path, recursive: bool = True) -> int:
143143 yaml_files = list (directory .glob (pattern ))
144144
145145 if not yaml_files :
146- print (f"No YAML files found in { directory } " )
146+ sys . stdout . write (f"No YAML files found in { directory } \n " )
147147 return 0
148148
149- print (f"Found { len (yaml_files )} YAML files" )
149+ sys . stdout . write (f"Found { len (yaml_files )} YAML files\n " )
150150
151151 modified_count = 0
152152 for yaml_file in yaml_files :
@@ -184,7 +184,7 @@ def main():
184184 total_modified = 0
185185 for path in args .paths :
186186 if not path .exists ():
187- print (f"Path not found: { path } " , file = sys . stderr )
187+ sys . stderr . write (f"Path not found: { path } \n " )
188188 continue
189189
190190 if path .is_file ():
@@ -197,14 +197,14 @@ def main():
197197 )
198198 total_modified += modified
199199 else :
200- print (f"Invalid path: { path } " , file = sys . stderr )
200+ sys . stderr . write (f"Invalid path: { path } \n " )
201201
202- print (f"\n { '=' * 60 } " )
202+ sys . stdout . write (f"\n { '=' * 60 } \n " )
203203 if args .dry_run :
204- print (f"Dry run complete. { total_modified } files would be modified." )
204+ sys . stdout . write (f"Dry run complete. { total_modified } files would be modified.\n " )
205205 else :
206- print (f"Migration complete. { total_modified } files modified." )
207- print (f"{ '=' * 60 } " )
206+ sys . stdout . write (f"Migration complete. { total_modified } files modified.\n " )
207+ sys . stdout . write (f"{ '=' * 60 } \n " )
208208
209209
210210if __name__ == '__main__' :
0 commit comments