##// END OF EJS Templates
more types
M Bussonnier -
Show More
@@ -125,7 +125,7 def _detect_screen_size(screen_lines_def):
125 # print('***Screen size:',screen_lines_real,'lines x',
125 # print('***Screen size:',screen_lines_real,'lines x',
126 # screen_cols,'columns.') # dbg
126 # screen_cols,'columns.') # dbg
127
127
128 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):
128 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None) -> None:
129 """Display a string, piping through a pager after a certain length.
129 """Display a string, piping through a pager after a certain length.
130
130
131 strng can be a mime-bundle dict, supplying multiple representations,
131 strng can be a mime-bundle dict, supplying multiple representations,
@@ -239,7 +239,7 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):
239 page_dumb(strng,screen_lines=screen_lines)
239 page_dumb(strng,screen_lines=screen_lines)
240
240
241
241
242 def page(data, start=0, screen_lines=0, pager_cmd=None):
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.
243 """Display content in a pager, piping through a pager after a certain length.
244
244
245 data can be a mime-bundle dict, supplying multiple representations,
245 data can be a mime-bundle dict, supplying multiple representations,
@@ -15,6 +15,7 Utilities for working with stack frames.
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 import sys
17 import sys
18 from typing import Any
18
19
19 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
20 # Code
21 # Code
@@ -51,7 +52,7 def extract_vars(*names,**kw):
51 return dict((k,callerNS[k]) for k in names)
52 return dict((k,callerNS[k]) for k in names)
52
53
53
54
54 def extract_vars_above(*names):
55 def extract_vars_above(*names: list[str]):
55 """Extract a set of variables by name from another frame.
56 """Extract a set of variables by name from another frame.
56
57
57 Similar to extractVars(), but with a specified depth of 1, so that names
58 Similar to extractVars(), but with a specified depth of 1, so that names
@@ -65,7 +66,7 def extract_vars_above(*names):
65 return dict((k,callerNS[k]) for k in names)
66 return dict((k,callerNS[k]) for k in names)
66
67
67
68
68 def debugx(expr,pre_msg=''):
69 def debugx(expr: str, pre_msg: str = ""):
69 """Print the value of an expression from the caller's frame.
70 """Print the value of an expression from the caller's frame.
70
71
71 Takes an expression, evaluates it in the caller's frame and prints both
72 Takes an expression, evaluates it in the caller's frame and prints both
@@ -84,7 +85,8 def debugx(expr,pre_msg=''):
84 # deactivate it by uncommenting the following line, which makes it a no-op
85 # deactivate it by uncommenting the following line, which makes it a no-op
85 #def debugx(expr,pre_msg=''): pass
86 #def debugx(expr,pre_msg=''): pass
86
87
87 def extract_module_locals(depth=0):
88
89 def extract_module_locals(depth: int = 0) -> tuple[Any, Any]:
88 """Returns (module, locals) of the function `depth` frames away from the caller"""
90 """Returns (module, locals) of the function `depth` frames away from the caller"""
89 f = sys._getframe(depth + 1)
91 f = sys._getframe(depth + 1)
90 global_ns = f.f_globals
92 global_ns = f.f_globals
General Comments 0
You need to be logged in to leave comments. Login now