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>2011-01-20 12:32:59 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-20 12:32:59 +0300
commite5af17ebbc8fc950ac60bfb7ca7c5974e1720d49 (patch)
treeab0b3f913bd4e3dd8874b06aba27b8cd838fe825
parent79c899da0040c7e058a30760f0b5178f3be672be (diff)
unique name exporting was broken, needed to export bytes.
-rw-r--r--io_scene_3ds/export_3ds.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/io_scene_3ds/export_3ds.py b/io_scene_3ds/export_3ds.py
index 24013243..5a467297 100644
--- a/io_scene_3ds/export_3ds.py
+++ b/io_scene_3ds/export_3ds.py
@@ -89,23 +89,24 @@ import struct
# So 3ds max can open files, limit names to 12 in length
# this is verry annoying for filenames!
-name_unique = []
-name_mapping = {}
+name_unique = [] # stores str, ascii only
+name_mapping = {} # stores {orig: byte} mapping
def sane_name(name):
name_fixed = name_mapping.get(name)
if name_fixed is not None:
return name_fixed
- new_name = name[:12]
-
+ # strip non ascii chars
+ new_name_clean = new_name = name.encode("ASCII", "replace").decode("ASCII")[:12]
i = 0
while new_name in name_unique:
- new_name = new_name[:-4] + '.%.3d' % i
+ new_name = new_name_clean + ".%.3d" % i
i+=1
+ # note, appending the 'str' version.
name_unique.append(new_name)
- name_mapping[name] = new_name
+ name_mapping[name] = new_name = new_name.encode("ASCII", "replace")
return new_name
def uv_key(uv):
@@ -167,7 +168,8 @@ class _3ds_string(object):
'''Class representing a zero-terminated string for a 3ds file.'''
__slots__ = ('value', )
def __init__(self, val):
- self.value=val
+ assert(type(val) == bytes)
+ self.value = val
def get_size(self):
return (len(self.value)+1)