Show a syntax-highlighted file through a pager. This magic is similar to the cat utility, but it will assume the file to be Python source and will show it with syntax highlighting. This magic command can either take a local filename, an url, an history range (see %h
(self, parameter_s='')
| 796 | |
| 797 | @line_magic |
| 798 | def pycat(self, parameter_s=''): |
| 799 | """Show a syntax-highlighted file through a pager. |
| 800 | |
| 801 | This magic is similar to the cat utility, but it will assume the file |
| 802 | to be Python source and will show it with syntax highlighting. |
| 803 | |
| 804 | This magic command can either take a local filename, an url, |
| 805 | an history range (see %history) or a macro as argument. |
| 806 | |
| 807 | If no parameter is given, prints out history of current session up to |
| 808 | this point. :: |
| 809 | |
| 810 | %pycat myscript.py |
| 811 | %pycat 7-27 |
| 812 | %pycat myMacro |
| 813 | %pycat http://www.example.com/myscript.py |
| 814 | """ |
| 815 | try: |
| 816 | cont = self.shell.find_user_code(parameter_s, skip_encoding_cookie=False) |
| 817 | except (ValueError, IOError): |
| 818 | print("Error: no such file, variable, URL, history range or macro") |
| 819 | return |
| 820 | |
| 821 | page.page(self.shell.pycolorize(source_to_unicode(cont))) |
| 822 | |
| 823 | @magic_arguments.magic_arguments() |
| 824 | @magic_arguments.argument( |
nothing calls this directly
no test coverage detected