Created
December 3, 2015 18:15
-
-
Save Cbeck527/dcb5beeda982e0b3aeb2 to your computer and use it in GitHub Desktop.
rabbitsay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
┌───────────┐ | |
| rabbitsay | | |
| dot | | |
| py | | |
└───────────┘ | |
(\__/) || | |
(•ㅅ•) || | |
/ づ | |
Rabbitsay.py - say (possibly mean) things but do it with a cute rabbit. | |
Many thanks to @orez- | |
usage: rabbitsay "<message>" | |
""" | |
import sys | |
rabbit = ''' | |
(\__/) || | |
(•ㅅ•) || | |
/ づ | |
''' | |
def rabbitsay(message, spacing = 2): | |
""" | |
message - message to print | |
spacing - amount of spacing around the sign, default 2 | |
""" | |
lines = message.split() | |
width = max(map(len, lines)) + spacing | |
bar = '─' * width | |
sign = '\n'.join( | |
' |{:^{width}}|'.format(line, width=width) | |
for line in lines | |
) | |
return ' ┌{bar}┐\n{contents}\n └{bar}┘{rabbit}'.format( | |
contents=sign, | |
bar=bar, | |
rabbit=rabbit, | |
) | |
if __name__ == "__main__": | |
try: | |
print rabbitsay(sys.argv[1]) | |
except IndexError: | |
print 'usage: rabbitsay "<message>"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment