From dee531fd51beabd61bd977a4cf53df0249dfd490 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 8 Feb 2020 17:07:39 -0600 Subject: [PATCH] added license info to boxprint --- src/utils/boxprint.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils/boxprint.py b/src/utils/boxprint.py index 9f37426e..e6eae1e3 100644 --- a/src/utils/boxprint.py +++ b/src/utils/boxprint.py @@ -1,8 +1,16 @@ -def bordered(text): +"""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.""" 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 + '┘') - return '\n'.join(res) \ No newline at end of file + return '\n'.join(res)