##// END OF EJS Templates
Add -q option (suppress print upon creation) to %macro...
Jeff Knisley -
Show More
@@ -1031,8 +1031,13 b' python-profiler package from non-free.""")'
1031
1031
1032 -r: use 'raw' input. By default, the 'processed' history is used,
1032 -r: use 'raw' input. By default, the 'processed' history is used,
1033 so that magics are loaded in their transformed version to valid
1033 so that magics are loaded in their transformed version to valid
1034 Python. If this option is given, the raw input as typed as the
1034 Python. If this option is given, the raw input as typed at the
1035 command line is used instead.
1035 command line is used instead.
1036
1037 -q: quiet macro definition. By default, a tag line is printed
1038 to indicate the macro has been created, and then the contents of
1039 the macro are printed. If this option is given, then no printout
1040 is produced once the macro is created.
1036
1041
1037 This will define a global variable called `name` which is a string
1042 This will define a global variable called `name` which is a string
1038 made of joining the slices and lines you specify (n1,n2,... numbers
1043 made of joining the slices and lines you specify (n1,n2,... numbers
@@ -1046,7 +1051,7 b' python-profiler package from non-free.""")'
1046 Note: as a 'hidden' feature, you can also use traditional python slice
1051 Note: as a 'hidden' feature, you can also use traditional python slice
1047 notation, where N:M means numbers N through M-1.
1052 notation, where N:M means numbers N through M-1.
1048
1053
1049 For example, if your history contains (%hist prints it)::
1054 For example, if your history contains (print using %hist -n )::
1050
1055
1051 44: x=1
1056 44: x=1
1052 45: y=3
1057 45: y=3
@@ -1076,7 +1081,7 b' python-profiler package from non-free.""")'
1076 print macro_name
1081 print macro_name
1077
1082
1078 """
1083 """
1079 opts,args = self.parse_options(parameter_s,'r',mode='list')
1084 opts,args = self.parse_options(parameter_s,'rq',mode='list')
1080 if not args: # List existing macros
1085 if not args: # List existing macros
1081 return sorted(k for k,v in self.shell.user_ns.iteritems() if\
1086 return sorted(k for k,v in self.shell.user_ns.iteritems() if\
1082 isinstance(v, Macro))
1087 isinstance(v, Macro))
@@ -1093,9 +1098,10 b' python-profiler package from non-free.""")'
1093 return
1098 return
1094 macro = Macro(lines)
1099 macro = Macro(lines)
1095 self.shell.define_macro(name, macro)
1100 self.shell.define_macro(name, macro)
1096 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1101 if not ( 'q' in opts) :
1097 print '=== Macro contents: ==='
1102 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1098 print macro,
1103 print '=== Macro contents: ==='
1104 print macro,
1099
1105
1100 @magic_arguments.magic_arguments()
1106 @magic_arguments.magic_arguments()
1101 @magic_arguments.argument('output', type=str, default='', nargs='?',
1107 @magic_arguments.argument('output', type=str, default='', nargs='?',
General Comments 0
You need to be logged in to leave comments. Login now