-
Notifications
You must be signed in to change notification settings - Fork 1
/
pyook.py
33 lines (29 loc) · 1006 Bytes
/
pyook.py
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
import sys
import re
import bucket
def hurl(sick, bucket):
pyook = "py"
for chunk in sick:
pyook += bucket[chunk]
if chunk == " ":
pyook += "py"
else:
pyook += "0"
return pyook[:-1]+"k"
def pour(pyook, bucket):
pyook = re.sub(r"([pP][yY])|([0]*[kK])", lambda x: '', pyook)
return "".join([bucket[chunk] for chunk in re.compile(r"[0]+").split(pyook)])
def empty(pyook, bucket):
bucket = {v:k for k,v in bucket.items()}
return re.sub(r"([pP][yY])?[O0o]+[kK]", lambda x: pour(x.group(0), bucket), pyook)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Ni! Gimme PyOok!")
else:
pyook = " ".join(sys.argv[1:]).strip()
if re.match(r"^(([pP][yY])?[O0o]+[kK]\s*)+$", pyook):
print(empty(pyook, bucket.get()))
elif re.match(r"^(([pP][yY])?\w+[kK]\s*)+$", pyook):
print("I don't like the PyOok.")
else:
print(hurl(pyook.lower(), bucket.get()))