mirror of
https://github.com/AsahiLinux/m1n1
synced 2025-02-16 21:58:27 +00:00
m1n1.constructutils: Abbreviate lists with trailing zero/null items
Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
parent
5ab443ccd7
commit
4bc08e9173
1 changed files with 6 additions and 2 deletions
|
@ -87,13 +87,17 @@ def str_value(value, repr=False):
|
|||
else:
|
||||
return f"{value:#x}"
|
||||
if isinstance(value, ListContainer):
|
||||
om = ""
|
||||
while len(value) > 1 and not value[-1]:
|
||||
value = value[:-1]
|
||||
om = " ..."
|
||||
if len(value) <= 16:
|
||||
return "[" + ", ".join(map(str_value, value)) + "]"
|
||||
return "[" + ", ".join(map(str_value, value)) + f"{om}]"
|
||||
else:
|
||||
sv = ["[\n"]
|
||||
for off in range(0, len(value), 16):
|
||||
sv.append(" " + ", ".join(map(str_value, value[off:off+16])) + ",\n")
|
||||
sv.append("]\n")
|
||||
sv.append(f"{om}]\n")
|
||||
return "".join(sv)
|
||||
|
||||
return str(value)
|
||||
|
|
Loading…
Add table
Reference in a new issue