diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-27 07:14:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-27 07:14:14 +0400 |
commit | 7ccfec1ff3ea0ee0ebdbdb91e3e44ab03ab81d6f (patch) | |
tree | 1e7bf189ae469fe2b6248a0f7de923fa62f155fe | |
parent | 4b5819a5af816ef76409d2c7e228e3027ca21841 (diff) |
fix (own bug) [#26628] "FCurve/Driver Version Fix" Incorrectly Clobbers Array Indexing
also escape strings properly now.
-rw-r--r-- | release/scripts/modules/animsys_refactor.py | 11 |
1 files changed, 10 insertions, 1 deletions
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): |