Show More
@@ -681,10 +681,6 b' class OSMagics(Magics):' | |||
|
681 | 681 | |
|
682 | 682 | @magic_arguments.magic_arguments() |
|
683 | 683 | @magic_arguments.argument( |
|
684 | '-f', '--force', action='store_true', default=False, | |
|
685 | help='Force overwrite without prompting' | |
|
686 | ) | |
|
687 | @magic_arguments.argument( | |
|
688 | 684 | '-a', '--amend', action='store_true', default=False, |
|
689 | 685 | help='Open file for amending if it exists' |
|
690 | 686 | ) |
@@ -699,30 +695,16 b' class OSMagics(Magics):' | |||
|
699 | 695 | For frontends that do not support stdin (Notebook), -f is implied. |
|
700 | 696 | """ |
|
701 | 697 | args = magic_arguments.parse_argstring(self.file, line) |
|
702 |
|
|
|
703 | force = args.force | |
|
698 | filename = unquote_filename(args.filename) | |
|
704 | 699 | |
|
705 |
if os.path.exists( |
|
|
700 | if os.path.exists(filename): | |
|
706 | 701 | if args.amend: |
|
707 |
print "Amending to %s" % |
|
|
702 | print "Amending to %s" % filename | |
|
708 | 703 | else: |
|
709 | if not force: | |
|
710 | try: | |
|
711 | force = self.shell.ask_yes_no( | |
|
712 | "%s exists, overwrite (y/[n])?", | |
|
713 | default='n' | |
|
714 | ) | |
|
715 | except StdinNotImplementedError: | |
|
716 | force = True | |
|
717 | ||
|
718 | if not force: | |
|
719 | # prompted, but still no | |
|
720 | print "Force overwrite with %%file -f " + args.filename | |
|
721 | return | |
|
722 | print "Overwriting %s" % args.filename | |
|
704 | print "Overwriting %s" % filename | |
|
723 | 705 | else: |
|
724 |
print "Writing %s" % |
|
|
706 | print "Writing %s" % filename | |
|
725 | 707 | |
|
726 | 708 | mode = 'a' if args.amend else 'w' |
|
727 |
with io.open( |
|
|
709 | with io.open(filename, mode, encoding='utf-8') as f: | |
|
728 | 710 | f.write(cell) |
General Comments 0
You need to be logged in to leave comments.
Login now