Skip to content
Permalink
Browse files

Broken import in python_to_emoji

  • Loading branch information...
DavidCEllis committed Sep 17, 2016
1 parent b881ec8 commit de29daa5015d17b098951239cecac863df927892
Showing with 37 additions and 6 deletions.
  1. +37 −6 snake/emoji_to_python.py
@@ -1,5 +1,12 @@
#! /usr/bin/env python
"""
Functions to convert code from emojicode to python
USAGE:
emoji_to_python(inputfile) - Returns string python code
write_emoji_to_python(inputfile, outputfile) -
"""

import sys
import tokenize
@@ -12,13 +19,37 @@ def parse_file(f):
return untokenize


def emoji_to_python(inpath, outpath):
with open(inpath, 'rb') as f, open(outpath, 'w', encoding='utf8') as n:
n.write(parse_file(f).decode('utf8'))
def emoji_to_python(inpath):
"""
Open an 'emojicode' file and convert it to python
:param inpath: File to convert to python code
:returns: UTF-8 string python code
"""
with open(inpath, 'rb') as f:
return parse_file(f).decode('utf8')


def write_emoji_to_python(inpath, outpath):
"""
Open an 'emojicode' file and convert it to python - write to a file
:param inpath: file to convert
:param outpath: output file
"""
with open(outpath, 'w', encoding='utf8') as outfile:
outfile.write(emoji_to_python(inpath))


if __name__ == '__main__':
if len(sys.argv) != 3:
sys.exit("USAGE: python emoji_to_python.py inputfilepath outputfilepath")
"""
-i to intepret the code
outputfilepath to output to file
"""
args = sys.argv
if len(args) != 3:
sys.exit("USAGE: python emoji_to_python.py [-i] inputfilepath [outputfilepath]")
elif '-i' in args:
args.remove('-i')
eval(emoji_to_python(args[1]))
else:
emoji_to_python(sys.argv[1], sys.argv[2])
write_emoji_to_python(*args)

0 comments on commit de29daa

Please sign in to comment.
You can’t perform that action at this time.