-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForHeaders.py
36 lines (30 loc) · 1.42 KB
/
ForHeaders.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
import os
def FindHeaders(dir):
ListHeaders = [];
dictExternDependency = {}
dictInternDependency = {}
for root, dir, files in os.walk(dir):
for file in files:
if file.endswith(".h") or file.endswith(".hpp") or file.endswith(".hxx"):
print("Header trouvé :", os.path.join(root,file))
ListHeaders.append(os.path.join(root,file))
dictExternDependency[file] = [];
dictInternDependency[file] = [];
return ListHeaders, dictExternDependency , dictInternDependency
def GrepHeadersContent(ListHeaders, dictExternDependency , dictInternDependency):
for header in ListHeaders:
#print("on analyse le header", header)
F = open(header,'r')
#print(F)
for line in F:
if line.startswith("#include"):
if '<' in line:
name = line[line.find("<")+1:line.find(">")];
dictExternDependency[os.path.basename(header)].append(name);
#print("dependance externe trouvée : ", name)
elif '"' in line:
name = line.split('"')[1];
#print(os.path.basename(header))
if name.endswith(".h"): dictInternDependency[os.path.basename(header)].append(name); #exclude cpp
#print("dependance interne trouvée : ", name)
return dictExternDependency , dictInternDependency