diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-01-31 23:54:17 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-01-31 23:54:17 (GMT) |
commit | 5fc4926fbe2cf9e6d1e84d3241befc152d6afb81 (patch) | |
tree | b2fc9469adb034c686f569a953033ff87315ccd3 /Utils.py | |
parent | 2c57833688b6cd36b284de7194fdad7c5571087d (diff) |
use save_to_callback() instead of save() to save files to zip
Diffstat (limited to 'Utils.py')
-rw-r--r-- | Utils.py | 16 |
1 files changed, 4 insertions, 12 deletions
@@ -16,6 +16,7 @@ import os import gtk import pango import zipfile +import cStringIO from Theme import * import sugar.graphics @@ -23,26 +24,17 @@ from sugar.graphics import style from sugar.graphics.toolbutton import ToolButton from sugar.graphics.icon import Icon - class Zip(zipfile.ZipFile): def __init__(self, *args): zipfile.ZipFile.__init__(self, *args) - """ def write_pixbuf(self, arcfile, pixbuf): def push(data, buffer): - buffer += data + buffer.write(data) - buffer = '' + buffer = cStringIO.StringIO() pixbuf.save_to_callback(push, 'png', user_data=buffer) - self.writestr(arcfile, buffer) - """ - - def write_pixbuf(self, arcfile, pixbuf): - tmpfile = os.path.join(SESSION_PATH, 'tmp.png') - pixbuf.save(tmpfile, 'png') - self.write(tmpfile, arcfile) - os.unlink(tmpfile) + self.writestr(arcfile, buffer.getvalue()) def read_pixbuf(self, arcfile): tmpfile = os.path.join(SESSION_PATH, 'tmp.png') |