pySim-shell: separate export summary with a headline

the export summary is printed after the log entry for the last file
without separation. This is confusing because it looks like if the
summary would refer to the last file only. Lets add a headline to make
clear that the last few lines are the "Export summary"

Change-Id: I90771e525b2b114bdb41a8e90d298ca991c09c3d
Related: OS#4963
This commit is contained in:
Philipp Maier
2021-04-19 21:24:23 +02:00
parent 04be9d6033
commit 80ce71f58c
2 changed files with 18 additions and 5 deletions

View File

@@ -841,3 +841,15 @@ class JsonEncoder(json.JSONEncoder):
if isinstance(o, BytesIO) or isinstance(o, bytes) or isinstance(o, bytearray):
return b2h(o)
return json.JSONEncoder.default(self, o)
def boxed_heading_str(heading, width=80):
"""Generate a string that contains a boxed heading."""
# Auto-enlarge box if heading exceeds length
if len(heading) > width - 4:
width = len(heading) + 4
res = "#" * width
fstr = "\n# %-" + str(width - 4) + "s #\n"
res += fstr % (heading)
res += "#" * width
return res