import re import js2py import base64 brkregex = re.compile(r'\((?!\)|[\'\"])(.+?)(?' in f: inner = parse_brackets(f) while brkregex.match(inner) != None: inner = parse_brackets(inner) func = re.sub( r'(\w+)\s*=>\s*(.+)', r'function(\1){return \2}', inner ) start = f.find(inner) end = start + len(inner) f = f[:start] + func + f[end:] return f def exec(f): ctx = js2py.EvalJs({'atob': atob}) ctx.execute(to_ecma5_function(f)) return ctx