Skip to content

Commit ee2d78e

Browse files
Improve reify methods
1 parent a548bc2 commit ee2d78e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

evalo/reify.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ def reify_ast(s):
1111
for s_dict in s:
1212
for k,v in s_dict.items():
1313
s_without_k = deepcopy(s_dict)
14-
del s_without_k[k]
15-
print('Reifying {}:{} with {}'.format(k, v, s_without_k))
14+
#del s_without_k[k]
15+
print('Reifying {}:{} with {}'.format(k, ast_dump_if_possible(v),
16+
ast_dump_substitute(s_without_k)))
1617
try:
17-
o = reify_object(v, s_without_k)
18+
v = reify_object(v, s_without_k)
19+
print('Reified object {}'.format(k))
1820
except AttributeError:
19-
o = reify(v, s_without_k)
20-
objects.append(o)
21-
return [ast_dump_if_possible(o) for o in objects]
21+
v = reify(v, s_without_k)
22+
s_dict[k] = v
23+
print('Reified {} to {}'.format(k, ast_dump_if_possible(v),
24+
s_without_k))
25+
return s
2226

2327
def ast_dump_if_possible(a):
2428
if isinstance(a, ast.AST):
2529
return ast.dump(a)
2630
return a
31+
32+
def ast_dump_substitute(s):
33+
return {k: ast_dump_if_possible(v) for k,v in s.items()}

0 commit comments

Comments
 (0)