File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -707,16 +707,29 @@ def write2file(self):
707707 if not fn .endswith ('.py' ) and self .config .save_append_py :
708708 fn = fn + '.py'
709709
710+ mode = 'w'
711+ if os .path .exists (fn ):
712+ mode = self .interact .file_prompt ('%s already exists. Do you want '
713+ 'to (c)ancel, (o)verwrite or '
714+ '(a)ppend? ' % (fn , ))
715+ if mode in ('o' , 'overwrite' ):
716+ mode = 'w'
717+ elif mode in ('a' , 'append' ):
718+ mode = 'a'
719+ else :
720+ self .interact .notify ('Save cancelled.' )
721+ return
722+
710723 s = self .formatforfile (self .getstdout ())
711724
712725 try :
713- f = open (fn , 'w' )
726+ f = open (fn , mode )
714727 f .write (s )
715728 f .close ()
716729 except IOError :
717730 self .interact .notify ("Disk write error for file '%s'." % (fn , ))
718731 else :
719- self .interact .notify ('Saved to %s' % (fn , ))
732+ self .interact .notify ('Saved to %s. ' % (fn , ))
720733
721734 def pastebin (self , s = None ):
722735 """Upload to a pastebin and display the URL in the status bar."""
You can’t perform that action at this time.
0 commit comments