diff paraspace/dexfile.py @ 132:75a31967ebee

Following the ref in resotre_dependencies()
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 09 Aug 2011 15:30:45 +0800
parents 044bfc415577
children f31bfe55d9c2
line wrap: on
line diff
--- a/paraspace/dexfile.py	Tue Aug 09 11:47:43 2011 +0800
+++ b/paraspace/dexfile.py	Tue Aug 09 15:30:45 2011 +0800
@@ -533,6 +533,28 @@
         attr_path = '.'.join(pparts[1:])
         value = _dex_tree_get_child(parent, attr_path)
         return value
+
+    def set_value(self, value, parents):
+        from paraspace.dex_deptracker import _resolve_name_path
+        from paraspace.dex_deptracker import _dex_tree_get_child
+        
+        pparts = self.target_path.split('.')
+        clazz_name = pparts[0]
+        clazz, dummy = _resolve_name_path(clazz_name)
+        
+        rev_parents = list(parents)
+        rev_parents.reverse()
+        
+        for parent in rev_parents:
+            if isinstance(parent, clazz):
+               break
+            pass
+        else:
+            raise ValueError, 'can not find %s' % (self.target_path)
+
+        attr_path = '.'.join(pparts[1:])
+        _dex_tree_set_child(parent, attr_path, value)
+        pass
     pass