PyAPI: allow subclasses of io_utils.ExportHelper to set when the extension is enforced.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 7 Mar 2011 08:01:38 +0000 (08:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 7 Mar 2011 08:01:38 +0000 (08:01 +0000)
release/scripts/modules/io_utils.py

index 69e82f15327d78b2eec0dd623b6a0f169286ec07..21c0457ff253d17b2a7c97d569838feacc754459 100644 (file)
@@ -25,6 +25,10 @@ from bpy.props import StringProperty, BoolProperty
 class ExportHelper:
     filepath = StringProperty(name="File Path", description="Filepath used for exporting the file", maxlen=1024, default="", subtype='FILE_PATH')
     check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
+    
+    # subclasses can override with decorator
+    # True == use ext, False == no ext, None == do nothing.
+    check_extension = True
 
     def invoke(self, context, event):
         import os
@@ -41,12 +45,18 @@ class ExportHelper:
         return {'RUNNING_MODAL'}
 
     def check(self, context):
-        filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext)
+        check_extension = self.check_extension
+        
+        if check_extension is None:
+            return False
+
+        filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext if check_extension else "")
+
         if filepath != self.filepath:
             self.filepath = filepath
             return True
-        else:
-            return False
+
+        return False
 
 
 class ImportHelper: