-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfortune_cow.py
More file actions
executable file
·40 lines (30 loc) · 1.03 KB
/
fortune_cow.py
File metadata and controls
executable file
·40 lines (30 loc) · 1.03 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
#!/usr/bin/env python
__author__ = 'Isna Rahmatul Khoir <isna11583@gmail.com>'
import os
import sys
if len(sys.argv)<2:
fortune = os.popen("fortune").readlines()
else:
fortune = [i for i in sys.argv[1].split("\n")]
maxln = max(len(i.replace("\n", "")) for i in fortune)
pertama = fortune[0].strip().replace("\t"," ")
if len(fortune)==1:
print "<"+pertama+">"
else:
kurang = maxln-len(pertama)
print "/"+pertama+" "*kurang+"\\"
for i in fortune[1:-1]:
kalimat = i.strip().replace("\t", " ")
kurang = maxln-len(kalimat)
print "|"+kalimat+" "*(kurang)+"|"
terakhir = fortune[-1].strip().replace("\t", " ")
if terakhir.startswith("--"):
print "|"+" "*maxln+"|"
kurang = maxln-len(terakhir)
print "\\"+terakhir+" "*kurang+"/"
print " "+"-"*maxln
print " \\ _(__)_ V"
print " \\ '-e e -'__,--.__)"
print " (o_o) ) "
print " \. /___. |"
print " //_(/_(/_("