Skip to content

Commit

Permalink
''
Browse files Browse the repository at this point in the history
  • Loading branch information
pannous committed Jan 1, 2016
1 parent 5cbe288 commit 83bff0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion kast.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def set_var(self,var):
if not isinstance(var,list):var=[var]
self.targets=var
def set_val(self,val):
if isinstance(val,list):val=val[0] #REALLY!!?
if isinstance(val,list) and len(val)==1:val=val[0] #REALLY!!?
self.value=val
var = property(lambda self:self.targets, set_var)
object = property(lambda self:self.targets, set_var)
Expand Down Expand Up @@ -504,3 +504,4 @@ def setter(k, param):
return Assign(targets,param)

none=name("None")

12 changes: 8 additions & 4 deletions tests/test_ast_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
# import ast2json
from ast import *
import ast_export
# import ast_export

# import codegen
from astor import codegen
Expand All @@ -13,18 +13,21 @@
# source='/Users/me/angle/kast/tests/hi.py'
source='/Users/me/angle/kast/ast_import.py'
source='/Users/me/angle/core/english_parser.py'
quit()
# quit()
print(source)
contents=open(source).readlines()# all()
contents="\n".join(contents)
# contents="x.y+=1"
source="(string)" # compile from inline string source:
# contents="def x():pass"
# contents="c=c+1;beep()"
contents="1"
# contents="1"
# contents="from x import *"
# contents="x.y=1"
# contents="x=1;x=x+1"
contents="i=7"
# Module([Expr([Assign([Name(Str('i'), Store())], Num(7))])])
# Module([Assign([Name('i', Store())], Num(7))])
# contents="x=1;x++" # INVALID!
# contents="x=6;x%=3"
# contents="def x(y):pass"
Expand Down Expand Up @@ -65,8 +68,9 @@
# file_ast=compile(contents, source, 'eval',ast.PyCF_ONLY_AST) # AAAAHHH!!!


x=ast.dump(file_ast, annotate_fields=True, include_attributes=True)
print(x)
x=ast.dump(file_ast, annotate_fields=False, include_attributes=False)
# x=ast.dump(file_ast, annotate_fields=True, include_attributes=True)
print(x)
#
# file_ast=ast.parse(contents ,source,'exec')
Expand Down

0 comments on commit 83bff0f

Please sign in to comment.