MCPcopy Create free account
hub / github.com/ipython/ipython / page_file

Function page_file

IPython/core/page.py:263–280  ·  view source on GitHub ↗

Page a file, using an optional pager command and starting line.

(fname, start=0, pager_cmd=None)

Source from the content-addressed store, hash-verified

261
262
263def page_file(fname, start=0, pager_cmd=None):
264 """Page a file, using an optional pager command and starting line.
265 """
266
267 pager_cmd = get_pager_cmd(pager_cmd)
268 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
269
270 try:
271 if os.environ['TERM'] in ['emacs','dumb']:
272 raise EnvironmentError
273 system(pager_cmd + ' ' + fname)
274 except:
275 try:
276 if start > 0:
277 start -= 1
278 page(open(fname).read(),start)
279 except:
280 print('Unable to show file',repr(fname))
281
282
283def get_pager_cmd(pager_cmd=None):

Callers

nothing calls this directly

Calls 5

systemFunction · 0.90
get_pager_cmdFunction · 0.85
get_pager_startFunction · 0.85
readMethod · 0.80
pageFunction · 0.70

Tested by

no test coverage detected