[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35808] trunk/blender/release/scripts/ modules/animsys_refactor.py: fix (own bug) [#26628] "FCurve/ Driver Version Fix" Incorrectly Clobbers Array Indexing

Campbell Barton ideasman42 at gmail.com
Sun Mar 27 05:14:17 CEST 2011


Revision: 35808
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35808
Author:   campbellbarton
Date:     2011-03-27 03:14:14 +0000 (Sun, 27 Mar 2011)
Log Message:
-----------
fix (own bug) [#26628] "FCurve/Driver Version Fix" Incorrectly Clobbers Array Indexing
also escape strings properly now.

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

Modified: trunk/blender/release/scripts/modules/animsys_refactor.py
===================================================================
--- trunk/blender/release/scripts/modules/animsys_refactor.py	2011-03-27 03:06:21 UTC (rev 35807)
+++ trunk/blender/release/scripts/modules/animsys_refactor.py	2011-03-27 03:14:14 UTC (rev 35808)
@@ -27,6 +27,10 @@
 
 IS_TESTING = False
 
+def drepr(string):
+    # is there a less crappy way to do this in python?, re.escape also escapes
+    # single quotes strings so cant use it.
+    return '"%s"' % repr(string)[1:-1].replace("\"", "\\\"").replace("\\'","'")
 
 class DataPathBuilder(object):
     __slots__ = ("data_path", )
@@ -40,7 +44,12 @@
         return DataPathBuilder(self.data_path + (str_value, ))
 
     def __getitem__(self, key):
-        str_value = '["%s"]' % key
+        if type(key) is int:
+            str_value = '[%d]' % key
+        elif type(key) is str:
+            str_value = '[%s]' % drepr(key)
+        else:
+            raise Exception("unsupported accessor %r of type %r (internal error)" % (key, type(key)))
         return DataPathBuilder(self.data_path + (str_value, ))
 
     def resolve(self, real_base, rna_update_from_map=None):




More information about the Bf-blender-cvs mailing list