2015-09-21 19:53:37 +00:00
|
|
|
#!/usr/bin/env python
|
2016-10-21 16:21:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-09-21 19:53:37 +00:00
|
|
|
import StringIO, zipfile, os.path, imp, sys
|
|
|
|
import marshal
|
|
|
|
import zlib
|
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
def get_encoded_library_string():
|
2015-09-21 19:53:37 +00:00
|
|
|
filepath=None
|
2016-10-21 16:21:54 +00:00
|
|
|
filepath=os.path.join("resources","library.zip")
|
|
|
|
|
2015-09-21 19:53:37 +00:00
|
|
|
f = StringIO.StringIO()
|
|
|
|
f.write(open(filepath, "rb").read())
|
|
|
|
|
|
|
|
zip = zipfile.ZipFile(f)
|
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
modules = dict([
|
|
|
|
(z.filename, zip.open(z.filename,).read()) for z in zip.infolist() \
|
|
|
|
if os.path.splitext(z.filename)[1] in [
|
2016-10-22 15:40:11 +00:00
|
|
|
'.py', '.pyd', '.dll', '.pyc', '.pyo', '.so'
|
2016-10-21 16:21:54 +00:00
|
|
|
]
|
|
|
|
])
|
2015-09-21 19:53:37 +00:00
|
|
|
|
|
|
|
return zlib.compress(marshal.dumps(modules),9)
|
2016-10-21 16:21:54 +00:00
|
|
|
|
|
|
|
with open(os.path.join("resources","library_compressed_string.txt"),'wb') as w:
|
|
|
|
w.write(get_encoded_library_string())
|