Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created April 22, 2014 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/11197719 to your computer and use it in GitHub Desktop.
Save zeffii/11197719 to your computer and use it in GitHub Desktop.
import os
import sys
import ast
file_location = "C:/Users/dealga/Desktop/code/opener.coffee"
file_modified = 'C:/Users/dealga/Desktop/code/temp_eval.coffee'
post_boilerplate = """\n\n
# added automatically by sverchok coffeescript parser module
for i of out_object
if out_object.hasOwnProperty(i)
console.log i + ' = [' + out_object[i] + ']'
\n"""
with open(file_modified, 'w') as m:
with open(file_location) as donor:
m.write(donor.read())
m.write(post_boilerplate)
a = " ".join(['coffee', file_modified])
b = os.popen(a, 'r', 1)
if b:
def closure_eval(stream_in):
exec(stream_in.read())
g = vars()
del g['stream_in']
return g
f = closure_eval(b)
print(f)
k = [0..40]
g = [20..50]
out_object = {out1: k, out2: g}
@zeffii
Copy link
Author

zeffii commented Apr 22, 2014

post_boilerplate is added by the script, and then the temp_eval is loaded as coffeescript instead:

k = [0..40]

g = [20..50]

out_object = {out1: k, out2: g}




# added automatically by sverchok coffeescript parser module
for i of out_object
    if out_object.hasOwnProperty(i)
        console.log i + ' = [' + out_object[i] + ']'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment