From 7ccfec1ff3ea0ee0ebdbdb91e3e44ab03ab81d6f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 03:14:14 +0000 Subject: fix (own bug) [#26628] "FCurve/Driver Version Fix" Incorrectly Clobbers Array Indexing also escape strings properly now. --- release/scripts/modules/animsys_refactor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'release/scripts') diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index 7a83a1434c5..9f2acc5e268 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -27,6 +27,10 @@ The main function to use is: update_data_paths(...) 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 @@ class DataPathBuilder(object): 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): -- cgit v1.2.3