2020-02-08 23:07:39 +00:00
|
|
|
"""Add box around string.
|
|
|
|
|
|
|
|
taken from https://stackoverflow.com/a/20757491 under https://creativecommons.org/licenses/by-sa/4.0/
|
|
|
|
https://stackoverflow.com/users/816449/bunyk
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def bordered(text: str) -> str:
|
|
|
|
"""Add border to string."""
|
2020-02-08 10:24:19 +00:00
|
|
|
lines = text.splitlines()
|
|
|
|
width = max(len(s) for s in lines)
|
|
|
|
res = ['┌' + '─' * width + '┐']
|
|
|
|
for s in lines:
|
|
|
|
res.append('│' + (s + ' ' * width)[:width] + '│')
|
|
|
|
res.append('└' + '─' * width + '┘')
|
2020-02-08 23:07:39 +00:00
|
|
|
return '\n'.join(res)
|