Some small refactorings to the names_dict/deep_ast_copy logic.

This commit is contained in:
Dave Halter
2015-02-12 13:24:08 +01:00
parent 774b3d5ce8
commit 4613a810a5
3 changed files with 8 additions and 10 deletions

View File

@@ -46,9 +46,13 @@ def deep_ast_copy(obj, parent=None, new_elements=None):
except AttributeError:
pass
else:
new_obj.names_dict = new_names_dict = {}
for string, names in names_dict.items():
new_names_dict[string] = [new_elements[n] for n in names]
try:
new_obj.names_dict = new_names_dict = {}
except AttributeError: # Impossible to set CompFor.names_dict
pass
else:
for string, names in names_dict.items():
new_names_dict[string] = [new_elements[n] for n in names]
return new_obj
if obj.type == 'name':

View File

@@ -610,9 +610,7 @@ class FunctionExecution(Executed):
return types
def names_dicts(self, search_global):
yield dict((k, [self._copy_dict[v] for v in values])
for k, values in self.base.names_dict.items())
#yield self.names_dict # Replace with this!
yield self.names_dict
@memoize_default(default=NO_DEFAULT)
def _get_params(self):

View File

@@ -1193,10 +1193,6 @@ class CompFor(BaseNode):
arr.append(name)
return dct
@names_dict.setter
def names_dict(self, value):
pass
def names_dicts(self, search_global):
yield self.names_dict