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