Skip to content

Commit 28eed00

Browse files
committed
add attribute check Fix attribute checks (#1)
1 parent 4a58316 commit 28eed00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# will be added to the list instead of the operator family.
1111
nodesToSkip = {'Store', 'Load', 'Name', 'Expr', 'arguments', 'Subscript', 'BoolOp', 'BinOp', 'Compare', 'UnaryOp'}
1212
tokensToSkip = {}
13-
allowed_call_names = ['print','input','dict','set','list']
13+
allowed_call_names = json.load(open(path.join(path.dirname(__file__), 'py_keyword_functions.json')))['allowed_call_names']
1414

1515
# *****************************************************************************
1616
# Special handlers for some nodes
@@ -31,7 +31,11 @@ def simpleTraverse(node, line, nodes):
3131
name = node.__class__.__name__
3232
# if name == 'Constant': print(re.split(r'[<,\s,>,\']',str(type(node.__dict__['value']))))
3333
# if name == 'Call': print(node.__dict__['func'].__dict__['id'])
34-
34+
if name == 'Attribute':
35+
# print(node.__dict__)
36+
name = f"{node.__dict__['attr']}"
37+
if not(name.lower() in allowed_call_names): name = ''
38+
3539
if name == 'Constant':
3640
name = re.split(r'[<,\s,>,\']',str(type(node.__dict__['value'])))[3].capitalize()
3741

0 commit comments

Comments
 (0)