MCPcopy Index your code
hub / github.com/ipython/ipython / pycat

Method pycat

IPython/core/magics/osm.py:798–821  ·  view source on GitHub ↗

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='')

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 3

source_to_unicodeFunction · 0.90
find_user_codeMethod · 0.80
pageMethod · 0.80

Tested by

no test coverage detected