2011-02-28 03:55:53 +03:00
|
|
|
'''
|
|
|
|
Takes the output from a JS test, and creates a file from it. So if
|
|
|
|
you do JSON.stringify() of an array in JS, this script will take
|
|
|
|
that and make a proper file out of it
|
|
|
|
'''
|
|
|
|
|
|
|
|
import os, sys, re
|
|
|
|
|
|
|
|
data = open(sys.argv[1], 'r').read()
|
2011-10-14 02:00:30 +04:00
|
|
|
m = re.search('\[[\d, -]*\]', data)
|
2011-02-28 03:55:53 +03:00
|
|
|
data = eval(m.group(0))
|
2011-10-14 02:00:30 +04:00
|
|
|
data = [x&0xff for x in data]
|
2011-02-28 03:55:53 +03:00
|
|
|
string = ''.join([chr(item) for item in data])
|
2011-10-18 03:59:41 +04:00
|
|
|
out = open(sys.argv[1]+'.' + (sys.argv[2] if len(sys.argv) >= 3 else 'raw'), 'wb')
|
2011-02-28 03:55:53 +03:00
|
|
|
print data[0:80]
|
|
|
|
print string[0:80]
|
|
|
|
out.write(string)
|
|
|
|
out.close()
|
|
|
|
|