Show More
@@ -24,6 +24,7 b' except ImportError:' | |||||
24 | import threading |
|
24 | import threading | |
25 |
|
25 | |||
26 | # Our own packages |
|
26 | # Our own packages | |
|
27 | from IPython.core.error import StdinNotImplementedError | |||
27 | from IPython.config.configurable import Configurable |
|
28 | from IPython.config.configurable import Configurable | |
28 | from IPython.external.decorator import decorator |
|
29 | from IPython.external.decorator import decorator | |
29 | from IPython.testing.skipdoctest import skip_doctest |
|
30 | from IPython.testing.skipdoctest import skip_doctest | |
@@ -761,8 +762,10 b" def magic_history(self, parameter_s = ''):" | |||||
761 | the default is the last 10 lines. |
|
762 | the default is the last 10 lines. | |
762 |
|
763 | |||
763 | -f FILENAME: instead of printing the output to the screen, redirect it to |
|
764 | -f FILENAME: instead of printing the output to the screen, redirect it to | |
764 |
the given file. The file is always overwritten, though |
|
765 | the given file. The file is always overwritten, though *when it can*, | |
765 | confirmation first if it already exists. |
|
766 | IPython asks for confirmation first. In particular, running the command | |
|
767 | "history -f FILENAME" from the IPython Notebook interface will replace | |||
|
768 | FILENAME even if it already exists *without* confirmation. | |||
766 |
|
769 | |||
767 | Examples |
|
770 | Examples | |
768 | -------- |
|
771 | -------- | |
@@ -797,10 +800,14 b" def magic_history(self, parameter_s = ''):" | |||||
797 | close_at_end = False |
|
800 | close_at_end = False | |
798 | else: |
|
801 | else: | |
799 | if os.path.exists(outfname): |
|
802 | if os.path.exists(outfname): | |
800 | if not io.ask_yes_no("File %r exists. Overwrite?" % outfname): |
|
803 | try: | |
|
804 | ans = io.ask_yes_no("File %r exists. Overwrite?" % outfname) | |||
|
805 | except StdinNotImplementedError: | |||
|
806 | ans = True | |||
|
807 | if not ans: | |||
801 | print('Aborting.') |
|
808 | print('Aborting.') | |
802 | return |
|
809 | return | |
803 |
|
810 | print("Overwriting file.") | ||
804 | outfile = open(outfname,'w') |
|
811 | outfile = open(outfname,'w') | |
805 | close_at_end = True |
|
812 | close_at_end = True | |
806 |
|
813 |
@@ -45,6 +45,7 b' import IPython' | |||||
45 | from IPython.core import debugger, oinspect |
|
45 | from IPython.core import debugger, oinspect | |
46 | from IPython.core.error import TryNext |
|
46 | from IPython.core.error import TryNext | |
47 | from IPython.core.error import UsageError |
|
47 | from IPython.core.error import UsageError | |
|
48 | from IPython.core.error import StdinNotImplementedError | |||
48 | from IPython.core.fakemodule import FakeModule |
|
49 | from IPython.core.fakemodule import FakeModule | |
49 | from IPython.core.profiledir import ProfileDir |
|
50 | from IPython.core.profiledir import ProfileDir | |
50 | from IPython.core.macro import Macro |
|
51 | from IPython.core.macro import Macro | |
@@ -983,13 +984,22 b' Currently the magic system has the following functions:\\n"""' | |||||
983 |
|
984 | |||
984 | In [1]: 'a' in _ip.user_ns |
|
985 | In [1]: 'a' in _ip.user_ns | |
985 | Out[1]: False |
|
986 | Out[1]: False | |
|
987 | ||||
|
988 | Notes | |||
|
989 | ----- | |||
|
990 | Calling this magic from clients that do not implement standard input, | |||
|
991 | such as the ipython notebook interface, will reset the namespace | |||
|
992 | without confirmation. | |||
986 | """ |
|
993 | """ | |
987 | opts, args = self.parse_options(parameter_s,'sf') |
|
994 | opts, args = self.parse_options(parameter_s,'sf') | |
988 | if 'f' in opts: |
|
995 | if 'f' in opts: | |
989 | ans = True |
|
996 | ans = True | |
990 | else: |
|
997 | else: | |
991 | ans = self.shell.ask_yes_no( |
|
998 | try: | |
|
999 | ans = self.shell.ask_yes_no( | |||
992 | "Once deleted, variables cannot be recovered. Proceed (y/[n])? ", default='n') |
|
1000 | "Once deleted, variables cannot be recovered. Proceed (y/[n])? ", default='n') | |
|
1001 | except StdinNotImplementedError: | |||
|
1002 | ans = True | |||
993 | if not ans: |
|
1003 | if not ans: | |
994 | print 'Nothing done.' |
|
1004 | print 'Nothing done.' | |
995 | return |
|
1005 | return | |
@@ -1052,6 +1062,12 b' Currently the magic system has the following functions:\\n"""' | |||||
1052 |
|
1062 | |||
1053 | In [11]: who_ls |
|
1063 | In [11]: who_ls | |
1054 | Out[11]: ['a'] |
|
1064 | Out[11]: ['a'] | |
|
1065 | ||||
|
1066 | Notes | |||
|
1067 | ----- | |||
|
1068 | Calling this magic from clients that do not implement standard input, | |||
|
1069 | such as the ipython notebook interface, will reset the namespace | |||
|
1070 | without confirmation. | |||
1055 | """ |
|
1071 | """ | |
1056 |
|
1072 | |||
1057 | opts, regex = self.parse_options(parameter_s,'f') |
|
1073 | opts, regex = self.parse_options(parameter_s,'f') | |
@@ -1059,9 +1075,12 b' Currently the magic system has the following functions:\\n"""' | |||||
1059 | if opts.has_key('f'): |
|
1075 | if opts.has_key('f'): | |
1060 | ans = True |
|
1076 | ans = True | |
1061 | else: |
|
1077 | else: | |
1062 | ans = self.shell.ask_yes_no( |
|
1078 | try: | |
|
1079 | ans = self.shell.ask_yes_no( | |||
1063 | "Once deleted, variables cannot be recovered. Proceed (y/[n])? ", |
|
1080 | "Once deleted, variables cannot be recovered. Proceed (y/[n])? ", | |
1064 | default='n') |
|
1081 | default='n') | |
|
1082 | except StdinNotImplementedError: | |||
|
1083 | ans = True | |||
1065 | if not ans: |
|
1084 | if not ans: | |
1066 | print 'Nothing done.' |
|
1085 | print 'Nothing done.' | |
1067 | return |
|
1086 | return |
General Comments 0
You need to be logged in to leave comments.
Login now