@@ -41,29 +41,29 @@ def get_files(filenames, recurse, suffixen, verbose, hidden_files):
4141 if S_ISDIR (perms .st_mode ):
4242 if recurse :
4343 if verbose :
44- sys .stderr .write ("Scanning Directory: %s\n " % filename )
44+ sys .stdout .write ("Scanning Directory: %s\n " % filename )
4545 for f in os .listdir (filename ):
4646 if not hidden_files and f .startswith ('.' ):
4747 if verbose :
48- sys .stderr .write ("Skipping: %s (hidden)\n "
48+ sys .stdout .write ("Skipping: %s (hidden)\n "
4949 % os .path .join (filename , f ))
5050 continue
5151 new_files += get_files ([os .path .join (filename , f )],
5252 recurse , suffixen , verbose ,
5353 hidden_files )
5454 else :
5555 if verbose :
56- sys .stderr .write ("Directory: %s skipped.\n " % filename )
56+ sys .stdout .write ("Directory: %s skipped.\n " % filename )
5757 continue
5858 elif S_ISREG (perms .st_mode ):
5959 if suffixen != [] and \
6060 not True in [ filename .endswith (s ) for s in suffixen ]:
61- sys .stderr .write ("Skipping: %s (suffix not in list)\n "
61+ sys .stdout .write ("Skipping: %s (suffix not in list)\n "
6262 % filename )
6363 continue
6464 new_files += [(filename , perms )]
6565 else :
66- sys .stderr .write ("Skipping: %s (not a regular file)\n "
66+ sys .stdout .write ("Skipping: %s (not a regular file)\n "
6767 % filename )
6868 return new_files
6969
@@ -158,28 +158,28 @@ def main():
158158 sys .exit (os .EX_DATAERR )
159159
160160 if new_str == "" and not opts .quiet :
161- sys .stderr .write ("Really DELETE all occurences of %s " % old_str )
161+ sys .stdout .write ("Really DELETE all occurences of %s " % old_str )
162162 if opts .ignore_case :
163- sys .stderr .write ("(ignoring case)? (Y/[N]) " )
163+ sys .stdout .write ("(ignoring case)? (Y/[N]) " )
164164 else :
165- sys .stderr .write ("(case sensitive)? (Y/[N]) " )
165+ sys .stdout .write ("(case sensitive)? (Y/[N]) " )
166166 line = raw_input ()
167167 if line != "" and line [0 ] in "nN" :
168168 sys .stderr .write ("\n rpl: User cancelled operation.\n " )
169169 sys .exit (os .EX_TEMPFAIL )
170170
171171 # Tell the user what is going to happen
172172 if opts .dry_run :
173- sys .stderr .write ("Simulating replacement of \" %s\" with \" %s\" "
173+ sys .stdout .write ("Simulating replacement of \" %s\" with \" %s\" "
174174 % (old_str , new_str ))
175175 else :
176- sys .stderr .write ("Replacing \" %s\" with \" %s\" " % (old_str , new_str ))
177- if opts .ignore_case : sys .stderr .write ("(ignoring case) " )
178- else : sys .stderr .write ("(case sensitive) " )
179- if opts .whole_words : sys .stderr .write ("(whole words only)\n " )
180- else : sys .stderr .write ("(partial words matched)\n " )
176+ sys .stdout .write ("Replacing \" %s\" with \" %s\" " % (old_str , new_str ))
177+ if opts .ignore_case : sys .stdout .write ("(ignoring case) " )
178+ else : sys .stdout .write ("(case sensitive) " )
179+ if opts .whole_words : sys .stdout .write ("(whole words only)\n " )
180+ else : sys .stdout .write ("(partial words matched)\n " )
181181 if opts .dry_run and not opts .quiet :
182- sys .stderr .write ("The files listed below would be modified in a replace operation.\n " )
182+ sys .stdout .write ("The files listed below would be modified in a replace operation.\n " )
183183
184184 if opts .escapes :
185185 old_str = unescape (old_str )
@@ -225,17 +225,17 @@ def main():
225225 % filename )
226226 sys .stderr .write ("\n rpl: Error: %s" % e )
227227 if opts .force :
228- sys .stderr .write ("\n rpl: WARNING: New owner/group/perms may not match!\n \n " )
228+ sys .stdout .write ("\n rpl: WARNING: New owner/group/perms may not match!\n \n " )
229229 else :
230- sys .stderr .write ("\n rpl: SKIPPING %s!\n \n " % filename )
230+ sys .stdout .write ("\n rpl: SKIPPING %s!\n \n " % filename )
231231 os .unlink (tmp_path )
232232 continue
233233
234234 if opts .verbose and not opts .dry_run :
235- sys .stderr .write ("Processing: %s\n " % filename )
235+ sys .stdout .write ("Processing: %s\n " % filename )
236236 elif not opts .quiet and not opts .dry_run :
237- sys .stderr .write ("." )
238- sys .stderr .flush ()
237+ sys .stdout .write ("." )
238+ sys .stdout .flush ()
239239
240240 # Do the actual work now
241241 matches = blockrepl (f , o , regex , old_str , new_str , 1024 )
@@ -252,21 +252,21 @@ def main():
252252 fn = os .path .realpath (filename )
253253 except OSError , e :
254254 fn = filename
255- if not opts .quiet : sys .stderr .write (" %s\n " % fn )
255+ if not opts .quiet : sys .stdout .write (" %s\n " % fn )
256256 os .unlink (tmp_path )
257257 total_matches += matches
258258 continue
259259
260260 if opts .prompt :
261- sys .stderr .write ("\n Save '%s' ? ([Y]/N) " % filename )
261+ sys .stdout .write ("\n Save '%s' ? ([Y]/N) " % filename )
262262 line = ""
263263 while line == "" or line [0 ] not in "Yy\n nN" :
264264 line = raw_input ()
265265 if line [0 ] in "nN" :
266- sys .stderr .write ("Not Saved.\n " )
266+ sys .stdout .write ("Not Saved.\n " )
267267 os .unlink (tmp_path )
268268 continue
269- sys .stderr .write ("Saved.\n " )
269+ sys .stdout .write ("Saved.\n " )
270270
271271 if opts .do_backup :
272272 try : os .rename (filename , filename + "~" )
@@ -295,13 +295,13 @@ def main():
295295 # We're about to exit, give a summary
296296 if not opts .quiet :
297297 if opts .dry_run :
298- sys .stderr .write ("\n A Total of %lu matches found in %lu file%s searched."
298+ sys .stdout .write ("\n A Total of %lu matches found in %lu file%s searched."
299299 % (total_matches ,
300300 len (files ),
301301 len (files ) != 1 and "s" or "" ))
302- sys .stderr .write ("\n None replaced (simulation mode).\n " )
302+ sys .stdout .write ("\n None replaced (simulation mode).\n " )
303303 else :
304- sys .stderr .write ("\n A Total of %lu matches replaced in %lu file%s searched.\n "
304+ sys .stdout .write ("\n A Total of %lu matches replaced in %lu file%s searched.\n "
305305 % (total_matches ,
306306 len (files ),
307307 len (files ) != 1 and "s" or "" ))
0 commit comments