Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

executable file 65 lines (56 sloc) 1.782 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#! /usr/bin/python

import sys

tom = """ \ _____
\ / \\
\ | (o|o) |
\ | _\ |
| '---' |
\_____/
_\___ ___| |____
|_/\ / '-' \ @ @@ @
\ \| .GOOGLE. | @@@
\ / | | @
\ /| | | @@
|_______|_/ @
| |_\/
| .-. |
| | | |
'._| |_.'
/__| |__\\
"""

MSG_WIDTH = 40

def split_lines(words):
    full_lines = len(words)/MSG_WIDTH
    line = 0
    msg_list = ['']
    for word in words:
        line_len = len(msg_list[line])
        if line_len > MSG_WIDTH:
            msg_list.append('')
            line = line + 1
        msg_list[line] = ' '.join((msg_list[line], word)).strip()
    return msg_list

def add_spaces(length, string):
    return string + (' ' * (length - len(string)))

def build_bubble(msg):
    lines = split_lines(msg)
    longest_line = 0
    for line in lines:
        if len(line) > longest_line:
            longest_line = len(line)
    s = [' ' + ('_'*longest_line) + '_' + ' ']
    for line in lines:
        if line == lines[0]:
            s.append("/ " + add_spaces(longest_line, line) + " \\")
        elif line == lines[-1]:
            s.append("\\ " + add_spaces(longest_line, line) + " /")
        else:
            s.append("| " + add_spaces(longest_line, line) + " |")
    s.append(' ' + ('-'*longest_line) + '-' + ' ')
    return '\n'.join(s)


def main():
    msg = sys.argv[1:]
    bubble = build_bubble(msg)
    print bubble + '\n' + tom + '\n'

if __name__ == "__main__":
    main()
Something went wrong with that request. Please try again.