Skip to content

Instantly share code, notes, and snippets.

@mys721tx
Last active January 20, 2016 01:18
Show Gist options
  • Save mys721tx/5400087 to your computer and use it in GitHub Desktop.
Save mys721tx/5400087 to your computer and use it in GitHub Desktop.
A python script to generate [cat kaomoji](https://gist.github.com/mys721tx/5400031).
# -*- coding: utf-8 -*-
"""
CatKaomoji.py: Generate cat kaomoji.
"""
import itertools
import codecs
EYES = [
(u"O",), (u" ̄",), (u"ㄒ",), (u"▼",), (u"°",), (u"╯", u"╰"), (u"¬",),
(u"^",), (u"'",), (u"‵", u"′"), (u"⊙",), (u"❤",), (u"⊝",), (u"⊚",),
(u"ಥ",), (u"→",), (u"←",), (u"❂",), (u"✦",), (u"﹂",), (u"︸",),
(u"ಠ",), (u"⌒",), (u"。",), (u"゜",), (u"✪",), (u"✖",), (u"¥",), (u"·",),
(u"◑",), (u"Φ",), (u"ರ",), (u"⓿",), (u"◕",), (u"Φ",), (u"╥",), (u"θ",),
(u"////",), (u"☆",), (u"╹",), (u">", u"<"), (u"΄◉", u"◉‵"), (u"≧", u"≦"),
(u"▰▰ ̄", u" ̄▰▰")
]
MOUTHS = [
u"_", u"▽", u"□", u"﹏", u"Д", u"ﺏ", u"╭╮", u"﹃", u"皿", u"益", u"ω", u"w",
u"‿", u"◞౪◟", u"”", u"ヘ", u"3", u"ε", u"︿", u"_, ", u"ܫ"
]
def main():
"""
Generate cat faces.
"""
with codecs.open("cat_kaomoji.txt", "w", "utf-8") as file:
for faces in itertools.product(EYES, MOUTHS):
# eyes is a single element tuple when two eyes are the same.
# otherwise eyes is a two-element tuple.
try:
(eye_left, eye_right), mouth = faces
file.write((u"<(={0}{2}{1}=)>\n".format(eye_left, eye_right, mouth)))
except ValueError:
(eye_left,), mouth = faces
file.write((u"<(={0}{1}{0}=)>\n".format(eye_left, mouth)))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment