Skip to content

Instantly share code, notes, and snippets.

@Cbeck527
Created December 3, 2015 18:15
Show Gist options
  • Save Cbeck527/dcb5beeda982e0b3aeb2 to your computer and use it in GitHub Desktop.
Save Cbeck527/dcb5beeda982e0b3aeb2 to your computer and use it in GitHub Desktop.
rabbitsay
#!/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