Print (or run through pager) the file where an object is defined. The file opens at the line where the object definition begins. IPython will honor the environment variable PAGER if set, and otherwise will do its best to print the file in a convenient form. If the g
(self, parameter_s='', namespaces=None)
| 99 | |
| 100 | @line_magic |
| 101 | def pfile(self, parameter_s='', namespaces=None): |
| 102 | """Print (or run through pager) the file where an object is defined. |
| 103 | |
| 104 | The file opens at the line where the object definition begins. IPython |
| 105 | will honor the environment variable PAGER if set, and otherwise will |
| 106 | do its best to print the file in a convenient form. |
| 107 | |
| 108 | If the given argument is not an object currently defined, IPython will |
| 109 | try to interpret it as a filename (automatically adding a .py extension |
| 110 | if needed). You can thus use %pfile as a syntax highlighting code |
| 111 | viewer.""" |
| 112 | |
| 113 | # first interpret argument as an object name |
| 114 | out = self.shell._inspect('pfile',parameter_s, namespaces) |
| 115 | # if not, try the input as a filename |
| 116 | if out == 'not found': |
| 117 | try: |
| 118 | filename = get_py_filename(parameter_s) |
| 119 | except IOError as msg: |
| 120 | print(msg) |
| 121 | return |
| 122 | page.page(self.shell.pycolorize(read_py_file(filename, skip_encoding_cookie=False))) |
| 123 | |
| 124 | @line_magic |
| 125 | def psearch(self, parameter_s=''): |
nothing calls this directly
no test coverage detected