We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 272d01c commit a548bc2Copy full SHA for a548bc2
evalo/reify.py
@@ -0,0 +1,26 @@
1
+import ast
2
+from kanren import reify
3
+from unification.more import reify_object
4
+from copy import deepcopy
5
+
6
+def reify_ast(s):
7
+ """
8
+ Reify ast objects in s
9
10
+ objects = []
11
+ for s_dict in s:
12
+ for k,v in s_dict.items():
13
+ s_without_k = deepcopy(s_dict)
14
+ del s_without_k[k]
15
+ print('Reifying {}:{} with {}'.format(k, v, s_without_k))
16
+ try:
17
+ o = reify_object(v, s_without_k)
18
+ except AttributeError:
19
+ o = reify(v, s_without_k)
20
+ objects.append(o)
21
+ return [ast_dump_if_possible(o) for o in objects]
22
23
+def ast_dump_if_possible(a):
24
+ if isinstance(a, ast.AST):
25
+ return ast.dump(a)
26
+ return a
0 commit comments