Show More
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """Magic functions for InteractiveShell. |
|
3 | 3 | |
|
4 |
$Id: Magic.py 18 |
|
|
4 | $Id: Magic.py 1823 2006-10-13 15:09:08Z vivainio $""" | |
|
5 | 5 | |
|
6 | 6 | #***************************************************************************** |
|
7 | 7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
@@ -180,7 +180,7 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")' | |||
|
180 | 180 | cmds.append(hist[ini:fin]) |
|
181 | 181 | return cmds |
|
182 | 182 | |
|
183 | def _ofind(self,oname): | |
|
183 | def _ofind(self, oname, namespaces=None): | |
|
184 | 184 | """Find an object in the available namespaces. |
|
185 | 185 | |
|
186 | 186 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic |
@@ -190,19 +190,17 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")' | |||
|
190 | 190 | |
|
191 | 191 | oname = oname.strip() |
|
192 | 192 | |
|
193 | # Namespaces to search in: | |
|
194 | user_ns = self.shell.user_ns | |
|
195 | internal_ns = self.shell.internal_ns | |
|
196 | builtin_ns = __builtin__.__dict__ | |
|
197 | alias_ns = self.shell.alias_table | |
|
198 | ||
|
199 | # Put them in a list. The order is important so that we find things in | |
|
200 | # the same order that Python finds them. | |
|
201 | namespaces = [ ('Interactive',user_ns), | |
|
202 | ('IPython internal',internal_ns), | |
|
203 | ('Python builtin',builtin_ns), | |
|
204 | ('Alias',alias_ns), | |
|
205 | ] | |
|
193 | alias_ns = None | |
|
194 | if namespaces is None: | |
|
195 | # Namespaces to search in: | |
|
196 | # Put them in a list. The order is important so that we | |
|
197 | # find things in the same order that Python finds them. | |
|
198 | namespaces = [ ('Interactive', self.shell.user_ns), | |
|
199 | ('IPython internal', self.shell.internal_ns), | |
|
200 | ('Python builtin', __builtin__.__dict__), | |
|
201 | ('Alias', self.shell.alias_table), | |
|
202 | ] | |
|
203 | alias_ns = self.shell.alias_table | |
|
206 | 204 | |
|
207 | 205 | # initialize results to 'null' |
|
208 | 206 | found = 0; obj = None; ospace = None; ds = None; |
@@ -642,13 +640,13 b' Currently the magic system has the following functions:\\n"""' | |||
|
642 | 640 | else: |
|
643 | 641 | print 'No profile active.' |
|
644 | 642 | |
|
645 | def _inspect(self,meth,oname,**kw): | |
|
643 | def _inspect(self,meth,oname,namespaces=None,**kw): | |
|
646 | 644 | """Generic interface to the inspector system. |
|
647 | 645 | |
|
648 | 646 | This function is meant to be called by pdef, pdoc & friends.""" |
|
649 | 647 | |
|
650 | 648 | oname = oname.strip() |
|
651 | info = Struct(self._ofind(oname)) | |
|
649 | info = Struct(self._ofind(oname, namespaces)) | |
|
652 | 650 | |
|
653 | 651 | if info.found: |
|
654 | 652 | # Get the docstring of the class property if it exists. |
@@ -679,22 +677,23 b' Currently the magic system has the following functions:\\n"""' | |||
|
679 | 677 | print 'Object `%s` not found.' % oname |
|
680 | 678 | return 'not found' # so callers can take other action |
|
681 | 679 | |
|
682 | def magic_pdef(self, parameter_s=''): | |
|
680 | def magic_pdef(self, parameter_s='', namespaces=None): | |
|
683 | 681 | """Print the definition header for any callable object. |
|
684 | 682 | |
|
685 | 683 | If the object is a class, print the constructor information.""" |
|
686 | self._inspect('pdef',parameter_s) | |
|
684 | print "+++" | |
|
685 | self._inspect('pdef',parameter_s, namespaces) | |
|
687 | 686 | |
|
688 | def magic_pdoc(self, parameter_s=''): | |
|
687 | def magic_pdoc(self, parameter_s='', namespaces=None): | |
|
689 | 688 | """Print the docstring for an object. |
|
690 | 689 | |
|
691 | 690 | If the given object is a class, it will print both the class and the |
|
692 | 691 | constructor docstrings.""" |
|
693 | self._inspect('pdoc',parameter_s) | |
|
692 | self._inspect('pdoc',parameter_s, namespaces) | |
|
694 | 693 | |
|
695 | def magic_psource(self, parameter_s=''): | |
|
694 | def magic_psource(self, parameter_s='', namespaces=None): | |
|
696 | 695 | """Print (or run through pager) the source code for an object.""" |
|
697 | self._inspect('psource',parameter_s) | |
|
696 | self._inspect('psource',parameter_s, namespaces) | |
|
698 | 697 | |
|
699 | 698 | def magic_pfile(self, parameter_s=''): |
|
700 | 699 | """Print (or run through pager) the file where an object is defined. |
@@ -719,7 +718,7 b' Currently the magic system has the following functions:\\n"""' | |||
|
719 | 718 | return |
|
720 | 719 | page(self.shell.inspector.format(file(filename).read())) |
|
721 | 720 | |
|
722 | def magic_pinfo(self, parameter_s=''): | |
|
721 | def magic_pinfo(self, parameter_s='', namespaces=None): | |
|
723 | 722 | """Provide detailed information about an object. |
|
724 | 723 | |
|
725 | 724 | '%pinfo object' is just a synonym for object? or ?object.""" |
@@ -737,7 +736,8 b' Currently the magic system has the following functions:\\n"""' | |||
|
737 | 736 | if "*" in oname: |
|
738 | 737 | self.magic_psearch(oname) |
|
739 | 738 | else: |
|
740 |
self._inspect('pinfo',oname,detail_level=detail_level |
|
|
739 | self._inspect('pinfo', oname, detail_level=detail_level, | |
|
740 | namespaces=namespaces) | |
|
741 | 741 | |
|
742 | 742 | def magic_psearch(self, parameter_s=''): |
|
743 | 743 | """Search for object in namespaces by wildcard. |
@@ -1,3 +1,8 b'' | |||
|
1 | 2006-10-14 Ville Vainio <vivainio@gmail.com> | |
|
2 | ||
|
3 | * Magic.py, ipython.el: applied first part of Rocky Bernstein's | |
|
4 | patch set for pydb integration. | |
|
5 | ||
|
1 | 6 | 2006-10-12 Ville Vainio <vivainio@gmail.com> |
|
2 | 7 | |
|
3 | 8 | * jobctrl.py: Add new "jobctrl" extension for spawning background |
@@ -6,7 +6,7 b'' | |||
|
6 | 6 | ;; URL: http://ipython.scipy.org |
|
7 | 7 | ;; Compatibility: Emacs21, XEmacs21 |
|
8 | 8 | ;; FIXME: #$@! INPUT RING |
|
9 |
(defconst ipython-version "$Revision: 1 |
|
|
9 | (defconst ipython-version "$Revision: 1823 $" | |
|
10 | 10 | "VC version number.") |
|
11 | 11 | |
|
12 | 12 | ;;; Commentary |
@@ -197,8 +197,10 b' the second for a \'normal\' command, and the third for a multiline command.")' | |||
|
197 | 197 | (setq py-traceback-line-re |
|
198 | 198 | "\\(^[^\t ].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\) +") |
|
199 | 199 | |
|
200 |
;; Recognize the ipython pdb, whose prompt is 'ipdb>' |
|
|
201 | (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]db[>)]+ ") | |
|
200 | ;; Recognize the ipython pdb, whose prompt is 'ipdb>' or 'ipydb>' | |
|
201 | ;;instead of '(Pdb)' | |
|
202 | (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]y?db[>)]+ ") | |
|
203 | (setq py-pydbtrack-input-prompt "\n[(]*ipydb[>)]+ ") | |
|
202 | 204 | |
|
203 | 205 | (setq py-shell-input-prompt-1-regexp "^In \\[[0-9]+\\]: *" |
|
204 | 206 | py-shell-input-prompt-2-regexp "^ [.][.][.]+: *" ) |
General Comments 0
You need to be logged in to leave comments.
Login now