128 def format(config, name=None, writeSourceLine=True, prefix="", verbose=False):
129 """Format the history record for config.name"""
132 for i, name
in enumerate(config.history.keys()):
135 print format(config, name)
138 for value, tb, label
in config.history[name]:
141 if frame.functionName
in (
"__new__",
"__set__",
"__setattr__",
"execfile",
"wrapper")
or \
142 os.path.split(frame.fileName)[1]
in (
"argparse.py",
"argumentParser.py"):
148 line.append([
"%s" % (
"%s:%d" % (frame.fileName, frame.lineNumber)),
"FILE",])
150 line.append([frame.text,
"TEXT",])
152 line.append([frame.functionName,
"FUNCTION_NAME",])
156 outputs.append([value, output])
162 for value, output
in outputs:
163 sourceLengths.append(max([len(x[0][0])
for x
in output]))
164 sourceLength = max(sourceLengths)
166 valueLength = len(prefix) + max([len(str(value))
for value, output
in outputs])
171 fullname =
"%s.%s" %(config._name, name)
if config._name
is not None else name
172 msg.append(
_colorize(re.sub(
r"^root\.",
"", fullname),
"NAME"))
173 for value, output
in outputs:
174 line = prefix +
_colorize(
"%-*s" % (valueLength, value),
"VALUE") +
" "
175 for i, vt
in enumerate(output):
177 vt[0][0] =
"%-*s" % (sourceLength, vt[0][0])
179 output[i] =
" ".join([
_colorize(v, t)
for v, t
in vt])
181 line += (
"\n%*s" % (valueLength + 1,
"")).join(output)
184 return "\n".join(msg)