[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1891] trunk/py/scripts/addons/ io_export_directx_x.py: - Punctuation characters are now stripped from symbol names and replaced with underscores .

Chris Foster cdbfoster at gmail.com
Tue May 3 11:26:38 CEST 2011


Revision: 1891
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1891
Author:   kiravakaan
Date:     2011-05-03 09:26:37 +0000 (Tue, 03 May 2011)
Log Message:
-----------
- Punctuation characters are now stripped from symbol names and replaced with underscores.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_export_directx_x.py

Modified: trunk/py/scripts/addons/io_export_directx_x.py
===================================================================
--- trunk/py/scripts/addons/io_export_directx_x.py	2011-05-03 08:49:14 UTC (rev 1890)
+++ trunk/py/scripts/addons/io_export_directx_x.py	2011-05-03 09:26:37 UTC (rev 1891)
@@ -66,8 +66,15 @@
 
 
 def LegalName(Name):
-    NewName = Name.replace(".", "_")
-    NewName = NewName.replace(" ", "_")
+    
+    def ReplaceSet(String, OldSet, NewChar):
+        for OldChar in OldSet:
+            String = String.replace(OldChar, NewChar)
+        return String
+    
+    import string
+    
+    NewName = ReplaceSet(Name, string.punctuation, "_")
     if NewName[0].isdigit() or NewName in ["ARRAY",
                                            "DWORD",
                                            "UCHAR",
@@ -1199,10 +1206,8 @@
     Verbose = BoolProperty(name="Verbose", description="Run the exporter in debug mode.  Check the console for output.", default=False)
 
     def execute(self, context):
-        #Append .x if needed
-        FilePath = self.filepath
-        if not FilePath.lower().endswith(".x"):
-            FilePath += ".x"
+        #Append .x
+        FilePath = os.path.splitext(self.filepath)[0] + ".x"
 
         Config = DirectXExporterSettings(context,
                                          FilePath,
@@ -1243,4 +1248,4 @@
 
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file



More information about the Bf-extensions-cvs mailing list