Report II
In addition to visualising which plug-in processed which instance, it would also be helpful to visualise error messages (if any). So that's what we'll do in this example.
1
Success Plug-in -> Instance
2
----------------------------------------------------------------------
3
1 CollectCaptainAmerica -> None
4
0 ValidateCaptainAmerica -> Captain America
5
+-- EXCEPTION: Captain America must be a hero
Copied!
Building from our previous example, this is how to format it in order to end up with the above.
1
header = "{:<10}{:<40} -> {}".format("Success", "Plug-in", "Instance")
2
result = "{success:<10}{plugin.__name__:<40} -> {instance}"
3
error = "{:<10}+-- EXCEPTION: {:<70}"
4
5
results = list()
6
for r in context.data["results"]:
7
results.append(result.format(**r))
8
if r["error"]:
9
results.append(error.format("", r["error"]))
10
11
report = """
12
{header}
13
{line}
14
{results}
15
"""
16
print(report.format(header=header,
17
results="\n".join(results),
18
line="-" * 70))
Copied!
Now all error messages are neatly printed in a tree-like fashion underneath each relevant result.
Last modified 1yr ago
Copy link