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 |
|
4 | $Id: Magic.py 906 2005-09-24 00:26:14Z fperez $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
@@ -35,6 +35,7 b' from IPython.Struct import Struct' | |||||
35 | from IPython.Itpl import Itpl, itpl, printpl,itplns |
|
35 | from IPython.Itpl import Itpl, itpl, printpl,itplns | |
36 | from IPython.FakeModule import FakeModule |
|
36 | from IPython.FakeModule import FakeModule | |
37 | from IPython import OInspect |
|
37 | from IPython import OInspect | |
|
38 | from IPython.PyColorize import Parser | |||
38 | from IPython.genutils import * |
|
39 | from IPython.genutils import * | |
39 |
|
40 | |||
40 | # Globals to be set later by Magic constructor |
|
41 | # Globals to be set later by Magic constructor | |
@@ -2451,4 +2452,22 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2451 | elif len(args)==2: |
|
2452 | elif len(args)==2: | |
2452 | bkms[args[0]] = args[1] |
|
2453 | bkms[args[0]] = args[1] | |
2453 | self.persist['bookmarks'] = bkms |
|
2454 | self.persist['bookmarks'] = bkms | |
|
2455 | ||||
|
2456 | def magic_pycat(self, parameter_s=''): | |||
|
2457 | """Show a syntax-highlighted file through a pager. | |||
|
2458 | ||||
|
2459 | This magic is similar to the cat utility, but it will assume the file | |||
|
2460 | to be Python source and will show it with syntax highlighting. """ | |||
|
2461 | ||||
|
2462 | try: | |||
|
2463 | filename = get_py_filename(parameter_s) | |||
|
2464 | except IndexError: | |||
|
2465 | warn('you must provide at least a filename.') | |||
|
2466 | fobj=open(filename,'r') | |||
|
2467 | source = fobj.read() | |||
|
2468 | fobj.close() | |||
|
2469 | colorize = Parser().format | |||
|
2470 | colorized_src = colorize(source,'str',self.shell.rc['colors']) | |||
|
2471 | page(colorized_src,screen_lines=self.shell.rc.screen_length) | |||
|
2472 | ||||
2454 | # end Magic |
|
2473 | # end Magic |
@@ -1,3 +1,8 b'' | |||||
|
1 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing | |||
|
4 | syntax-highlighted python sources, requested by John. | |||
|
5 | ||||
1 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
6 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
7 | |||
3 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
|
8 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
General Comments 0
You need to be logged in to leave comments.
Login now