Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-05 16:45:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-05 16:45:27 +0400
commitd385f455ca1071422664d0b66200e2fe6b6c1178 (patch)
treeedf8589329a325f569059ba01cdf464b6d8d6d21 /io_scene_x3d
parentf5e765036da06edfa5b080b8a3395071e1b7ea75 (diff)
x3d writing compressed files was broken.
Diffstat (limited to 'io_scene_x3d')
-rw-r--r--io_scene_x3d/export_x3d.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py
index 7c8870f9..e0710e6a 100644
--- a/io_scene_x3d/export_x3d.py
+++ b/io_scene_x3d/export_x3d.py
@@ -1534,6 +1534,23 @@ def export(file,
##########################################################
+def gzip_open_utf8(filepath, mode):
+ """Workaround for py3k only allowing binary gzip writing"""
+
+ import gzip
+
+ # need to investigate encoding
+ file = gzip.open(filepath, mode)
+ write_real = file.write
+
+ def write_wrap(data):
+ return write_real(data.encode("utf-8"))
+
+ file.write = write_wrap
+
+ return file
+
+
def save(operator, context, filepath="",
use_selection=True,
use_apply_modifiers=False,
@@ -1553,9 +1570,7 @@ def save(operator, context, filepath="",
bpy.ops.object.mode_set(mode='OBJECT')
if use_compress:
- import gzip
- # need to investigate encoding
- file = gzip.open(filepath, 'w')
+ file = gzip_open_utf8(filepath, 'w')
else:
file = open(filepath, 'w', encoding='utf-8')