eric7/DebugClients/Python/coverage/debug.py

branch
eric7
changeset 8991
2fc945191992
parent 8775
0802ae193343
child 9099
0e511e0e94a3
equal deleted inserted replaced
8990:ca8e477c590c 8991:2fc945191992
116 label_len = 30 116 label_len = 30
117 assert all(len(l) < label_len for l, _ in info) 117 assert all(len(l) < label_len for l, _ in info)
118 for label, data in info: 118 for label, data in info:
119 if data == []: 119 if data == []:
120 data = "-none-" 120 data = "-none-"
121 if isinstance(data, (list, set, tuple)): 121 if isinstance(data, tuple) and len(repr(tuple(data))) < 30:
122 # Convert to tuple to scrub namedtuples.
123 yield "%*s: %r" % (label_len, label, tuple(data))
124 elif isinstance(data, (list, set, tuple)):
122 prefix = "%*s:" % (label_len, label) 125 prefix = "%*s:" % (label_len, label)
123 for e in data: 126 for e in data:
124 yield "%*s %s" % (label_len+1, prefix, e) 127 yield "%*s %s" % (label_len+1, prefix, e)
125 prefix = "" 128 prefix = ""
126 else: 129 else:
127 yield "%*s: %s" % (label_len, label, data) 130 yield "%*s: %s" % (label_len, label, data)
128 131
129 132
130 def write_formatted_info(writer, header, info): 133 def write_formatted_info(write, header, info):
131 """Write a sequence of (label,data) pairs nicely.""" 134 """Write a sequence of (label,data) pairs nicely.
132 writer.write(info_header(header)) 135
136 `write` is a function write(str) that accepts each line of output.
137 `header` is a string to start the section. `info` is a sequence of
138 (label, data) pairs, where label is a str, and data can be a single
139 value, or a list/set/tuple.
140
141 """
142 write(info_header(header))
133 for line in info_formatter(info): 143 for line in info_formatter(info):
134 writer.write(" %s" % line) 144 write(f" {line}")
135 145
136 146
137 def short_stack(limit=None, skip=0): 147 def short_stack(limit=None, skip=0):
138 """Return a string summarizing the call stack. 148 """Return a string summarizing the call stack.
139 149

eric ide

mercurial