-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFunction def.py
56 lines (53 loc) · 1.31 KB
/
Function def.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 16 14:16:31 2019
@author: mahir
"""
import ast
mdef = 'def foo(x):\n sod\n return 2*x'
mdef = '''
import V.ast
class A(object):
def meth(self):
a= ast()
return sum(i for i in range(10) if i - 2 < 5)
def fib(self, n):
pass
class B(A):
def thi(self, mo):
return sum(i for i in range(10) if i - 2 < 5)
def fib(self, n):
h=0
__d = 0
if n < 2: return 1
return fib(n - 1) + fib(n - 2)
class C(A, B):
def fr(self):
return 34
'''
a = ast.parse(mdef)
definitions = [n for n in ast.walk(a) if type(n) == ast.ClassDef]
inheritance_tree = {}
for i in definitions:
inheritance_tree[i.name] = []
print(i.name)
for j in i.bases:
if not j.id== "object":
inheritance_tree[i.name].append(j.id)
print("Inherited",j.id)
import pprint
from radon.complexity import cc_rank, cc_visit
val = cc_visit('''
class A(object):
def meth(self):
return sum(i for i in range(10) if i - 2 < 5)
class B(A):
def thi(self):
return sum(i for i in range(10) if i - 2 < 5)
def fib(n):
if n < 2: return 1
return fib(n - 1) + fib(n - 2)
''')
pp = pprint.PrettyPrinter(indent=4)
#pp.pprint(val)
#print(val)