##// END OF EJS Templates
Made %paste sentinel configurable
vivainio -
Show More
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 1070 2006-01-23 21:12:36Z vivainio $"""
4 $Id: Magic.py 1071 2006-01-23 21:30:41Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -2765,11 +2765,12 b' Defaulting color scheme to \'NoColor\'"""'
2765 clipboard.
2765 clipboard.
2766
2766
2767 You must terminate the block with '--' (two minus-signs) alone on the
2767 You must terminate the block with '--' (two minus-signs) alone on the
2768 line.
2768 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2769 is the new sentinel for this operation)
2769
2770
2770 The block is dedented prior to execution to enable execution of
2771 The block is dedented prior to execution to enable execution of
2771 method definitions. The executed block is also assigned to variable
2772 method definitions. The executed block is also assigned to variable
2772 named 'pasted_block' for later editing with %edit.
2773 named 'pasted_block' for later editing with '%edit pasted_block'.
2773
2774
2774 You can also pass a variable name as an argument, e.g. '%paste foo'.
2775 You can also pass a variable name as an argument, e.g. '%paste foo'.
2775 This assigns the pasted block to variable 'foo' as string, without
2776 This assigns the pasted block to variable 'foo' as string, without
@@ -2781,13 +2782,16 b' Defaulting color scheme to \'NoColor\'"""'
2781
2782
2782 IPython statements (magics, shell escapes) are not supported (yet).
2783 IPython statements (magics, shell escapes) are not supported (yet).
2783 """
2784 """
2784 par = parameter_s.strip()
2785 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2786 par = args.strip()
2787 sentinel = opts.get('s','--')
2788
2785 from IPython import iplib
2789 from IPython import iplib
2786 lines = []
2790 lines = []
2787 print "Pasting code; enter '--' alone on the line to stop."
2791 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2788 while 1:
2792 while 1:
2789 l = iplib.raw_input_original(':')
2793 l = iplib.raw_input_original(':')
2790 if l =='--':
2794 if l ==sentinel:
2791 break
2795 break
2792 lines.append(l)
2796 lines.append(l)
2793 block = "\n".join(lines)
2797 block = "\n".join(lines)
General Comments 0
You need to be logged in to leave comments. Login now