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