[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53803] trunk/blender/release/scripts/ modules/bpy_extras/io_utils.py: fix issue reported in '[#33876] bpy.path. ensure_ext adds extension twice / extra period if filename empty, just a period or equal to extension'

Campbell Barton ideasman42 at gmail.com
Tue Jan 15 05:33:20 CET 2013


Revision: 53803
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53803
Author:   campbellbarton
Date:     2013-01-15 04:33:08 +0000 (Tue, 15 Jan 2013)
Log Message:
-----------
fix issue reported in '[#33876] bpy.path.ensure_ext adds extension twice / extra period if filename empty, just a period or equal to extension'

For python operators that used the ExportHelper mix-in class, an empty file field would become '.ext', entering and existing the text field would become '.ext.ext',
Now only add an extension if the filename part of the path is set, so '.ext' will still become '.ext.ext' but having only the extension isn't so likely to happen in the first place now.

This is a different fix then the changes suggested in the report but I'd prefer to keep path functions stupid+predictable.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_extras/io_utils.py

Modified: trunk/blender/release/scripts/modules/bpy_extras/io_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_extras/io_utils.py	2013-01-15 03:48:13 UTC (rev 53802)
+++ trunk/blender/release/scripts/modules/bpy_extras/io_utils.py	2013-01-15 04:33:08 UTC (rev 53803)
@@ -79,20 +79,23 @@
         return {'RUNNING_MODAL'}
 
     def check(self, context):
+        import os
         change_ext = False
         change_axis = _check_axis_conversion(self)
 
         check_extension = self.check_extension
 
         if check_extension is not None:
-            filepath = bpy.path.ensure_ext(self.filepath,
-                                           self.filename_ext
-                                           if check_extension
-                                           else "")
+            filepath = self.filepath
+            if os.path.basename(filepath):
+                filepath = bpy.path.ensure_ext(filepath,
+                                               self.filename_ext
+                                               if check_extension
+                                               else "")
 
-            if filepath != self.filepath:
-                self.filepath = filepath
-                change_ext = True
+                if filepath != self.filepath:
+                    self.filepath = filepath
+                    change_ext = True
 
         return (change_ext or change_axis)
 




More information about the Bf-blender-cvs mailing list