Show More
@@ -2030,17 +2030,16 b' Currently the magic system has the following functions:\\n"""' | |||
|
2030 | 2030 | In [60]: exec In[44:48]+In[49]""" |
|
2031 | 2031 | |
|
2032 | 2032 | opts,args = self.parse_options(parameter_s,'r',mode='list') |
|
2033 | if not args: | |
|
2034 |
|
|
|
2035 | macs.sort() | |
|
2036 | return macs | |
|
2033 | if not args: # List existing macros | |
|
2034 | return sorted(k for k,v in self.shell.user_ns.iteritems() if\ | |
|
2035 | isinstance(v, Macro)) | |
|
2037 | 2036 | if len(args) == 1: |
|
2038 | 2037 | raise UsageError( |
|
2039 | 2038 | "%macro insufficient args; usage '%macro name n1-n2 n3-4...") |
|
2040 | 2039 | name,ranges = args[0], args[1:] |
|
2041 | 2040 | |
|
2042 | 2041 | #print 'rng',ranges # dbg |
|
2043 |
lines = self.extract_input_slices(ranges, |
|
|
2042 | lines = self.extract_input_slices(ranges,'r' in opts) | |
|
2044 | 2043 | macro = Macro("\n".join(lines)) |
|
2045 | 2044 | self.shell.define_macro(name, macro) |
|
2046 | 2045 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name |
@@ -2076,7 +2075,7 b' Currently the magic system has the following functions:\\n"""' | |||
|
2076 | 2075 | if ans.lower() not in ['y','yes']: |
|
2077 | 2076 | print 'Operation cancelled.' |
|
2078 | 2077 | return |
|
2079 |
cmds = '\n'.join(self.extract_input_slices(ranges, |
|
|
2078 | cmds = '\n'.join(self.extract_input_slices(ranges, 'r' in opts)) | |
|
2080 | 2079 | with open(fname,'w') as f: |
|
2081 | 2080 | f.write(cmds) |
|
2082 | 2081 | print 'The following commands were written to file `%s`:' % fname |
@@ -183,8 +183,8 b' def test_macro():' | |||
|
183 | 183 | ip.magic("macro test 1-3") |
|
184 | 184 | nt.assert_equal(ip.user_ns["test"].value, "\n".join(cmds)+"\n") |
|
185 | 185 | |
|
186 | # List macros. This goes to stdout, so just check it doesn't crash. | |
|
187 | ip.magic("macro") | |
|
186 | # List macros. | |
|
187 | assert "test" in ip.magic("macro") | |
|
188 | 188 | |
|
189 | 189 | |
|
190 | 190 | # XXX failing for now, until we get clearcmd out of quarantine. But we should |
General Comments 0
You need to be logged in to leave comments.
Login now