Page a file, using an optional pager command and starting line.
(fname, start=0, pager_cmd=None)
| 261 | |
| 262 | |
| 263 | def 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 | |
| 283 | def get_pager_cmd(pager_cmd=None): |
nothing calls this directly
no test coverage detected