Display content in a pager, piping through a pager after a certain length. data can be a mime-bundle dict, supplying multiple representations, keyed by mime-type, or text. Pager is dispatched via the `show_in_pager` IPython hook. If no hook is registered, `pager_page` will
(data, start=0, screen_lines=0, pager_cmd=None)
| 235 | |
| 236 | |
| 237 | def page(data, start=0, screen_lines=0, pager_cmd=None): |
| 238 | """Display content in a pager, piping through a pager after a certain length. |
| 239 | |
| 240 | data can be a mime-bundle dict, supplying multiple representations, |
| 241 | keyed by mime-type, or text. |
| 242 | |
| 243 | Pager is dispatched via the `show_in_pager` IPython hook. |
| 244 | If no hook is registered, `pager_page` will be used. |
| 245 | """ |
| 246 | # Some routines may auto-compute start offsets incorrectly and pass a |
| 247 | # negative value. Offset to 0 for robustness. |
| 248 | start = max(0, start) |
| 249 | |
| 250 | # first, try the hook |
| 251 | ip = get_ipython() |
| 252 | if ip: |
| 253 | try: |
| 254 | ip.hooks.show_in_pager(data, start=start, screen_lines=screen_lines) |
| 255 | return |
| 256 | except TryNext: |
| 257 | pass |
| 258 | |
| 259 | # fallback on default pager |
| 260 | return pager_page(data, start, screen_lines, pager_cmd) |
| 261 | |
| 262 | |
| 263 | def page_file(fname, start=0, pager_cmd=None): |
no test coverage detected