-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
87 lines (57 loc) · 2.43 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
########### find header files
import os
import sys
from ForHeaders import *
from ForCMake import *
OK= False
while OK != True:
if (sys.version_info[0] == 2): # python 2
choice = raw_input("Please enter CMake or headers : ")
elif (sys.version_info[0] == 3): # python 3
choice = input("Please enter CMake or headers : ")
else:
print("Seriously man, on what computer are you running this script ?")
if(choice == "CMake" or choice == "headers"):
OK = True
else:
print("please quick enter 'CMake' of 'headers', we've got a lot of stuff to do ")
dir = "./testDir2"
OK= False
while OK != True:
if (sys.version_info[0] == 2): # python 2
dir = raw_input("Please enter a path : ")
elif (sys.version_info[0] == 3): # python 3
dir = input("Please enter a path : ")
else:
print("Seriously man, on what computer are you running this script ?")
OK = True
#toDo : path exist check
ListHeaders = [];
dictExternDependency = {}
dictInternDependency = {}
if __name__ == "__main__":
print("######### début phase de recherche des headers.")
if choice == "headers":
ListHeaders, dictExternDependency , dictInternDependency = FindHeaders(dir)
elif choice == "CMake":
ListHeaders, dictExternDependency , dictInternDependency = FindCMakeLists(dir)
print("\nlist of header : \n", *ListHeaders, sep='\n- ')
print("######### fin phase de recherche des headers.")
########### regex on file to find dependency
print("######### début phase de regex des headers.")
if choice == "headers":
dictExternDependency , dictInternDependency = GrepHeadersContent(ListHeaders, dictExternDependency , dictInternDependency)
elif choice == "CMake":
dictExternDependency , dictInternDependency = GrepCMakeContent(ListHeaders, dictExternDependency , dictInternDependency)
print("##########################DEBUG", dictInternDependency)
print("######### fin phase de regex des headers.")
########### plot dependency in graph
#print("######### début phase de graphe.")
import pygraphviz as pgv
graph = pgv.AGraph()
for header, listDependency in dictInternDependency.items():
for dependency in listDependency:
graph.add_edge(header, dependency)
graph.layout('dot')
graph.draw('graph.png')
#print("######### fin phase de graphe.")