##// END OF EJS Templates
Kirill Smelkov patch 7/9: Implement %page -r (raw mode - use str, not pprint)
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 1915 2006-11-21 20:11:22Z vivainio $"""
4 $Id: Magic.py 1918 2006-11-21 20:19:13Z 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
@@ -618,13 +618,25 b' Currently the magic system has the following functions:\\n"""'
618 def magic_page(self, parameter_s=''):
618 def magic_page(self, parameter_s=''):
619 """Pretty print the object and display it through a pager.
619 """Pretty print the object and display it through a pager.
620
620
621 If no parameter is given, use _ (last output)."""
621 %page [options] OBJECT
622
623 If no object is given, use _ (last output).
624
625 Options:
626
627 -r: page str(object), don't pretty-print it."""
628
622 # After a function contributed by Olivier Aubert, slightly modified.
629 # After a function contributed by Olivier Aubert, slightly modified.
623
630
624 oname = parameter_s and parameter_s or '_'
631 # Process options/args
632 opts,args = self.parse_options(parameter_s,'r')
633 raw = 'r' in opts
634
635 oname = args and args or '_'
625 info = self._ofind(oname)
636 info = self._ofind(oname)
626 if info['found']:
637 if info['found']:
627 page(pformat(info['obj']))
638 txt = (raw and str or pformat)( info['obj'] )
639 page(txt)
628 else:
640 else:
629 print 'Object `%s` not found' % oname
641 print 'Object `%s` not found' % oname
630
642
General Comments 0
You need to be logged in to leave comments. Login now