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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-03-10 09:58:42 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-03-10 09:58:42 +0300
commit4a089890df818636be28a3f494c5851c2c0b1efd (patch)
treeacf9c4f041acd6e641ae87f946d429527cb39341 /release
parent06d455f4280815c9197f8d9cb6c0cadcdfc5e838 (diff)
[#18388] PLY Import fails if line ending is not \n
bugfix, read the header as ascii text - open(filename, 'rU'), only the body as binary.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/ply_import.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/release/scripts/ply_import.py b/release/scripts/ply_import.py
index 302e21a0a43..43129ec01e9 100644
--- a/release/scripts/ply_import.py
+++ b/release/scripts/ply_import.py
@@ -160,13 +160,16 @@ def read(filename):
obj_spec = object_spec()
try:
- file = open(filename, 'rb')
+ file = open(filename, 'rU') # Only for parsing the header, not binary data
signature = file.readline()
- if (signature != 'ply\n'):
+
+ if not signature.startswith('ply'):
print 'Signature line was invalid'
return None
+
while 1:
tokens = re.split(r'[ \n]+', file.readline())
+
if (len(tokens) == 0):
continue
if (tokens[0] == 'end_header'):
@@ -197,14 +200,22 @@ def read(filename):
obj_spec.specs[-1].properties.append(property_spec(tokens[4], type_specs[tokens[2]], type_specs[tokens[3]]))
else:
obj_spec.specs[-1].properties.append(property_spec(tokens[2], None, type_specs[tokens[1]]))
+
+ if format != 'ascii':
+ file.close() # was ascii, now binary
+ file = open(filename, 'rb')
+
+ # skip the header...
+ while not file.readline().startswith('end_header'):
+ pass
+
obj = obj_spec.load(format_specs[format], file)
-
+
except IOError, (errno, strerror):
try: file.close()
except: pass
return None
-
try: file.close()
except: pass