-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (47 loc) · 1.33 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
import os
import re
def pathread(filepath):
patha= {}
i=0
for root, dirs, files in os.walk(filepath):
patha[i]=root
i=i+1
return patha
def work(files):
File_Name = {}
i=0
for files in os.listdir(files):
File_Name[i]=files
i=i+1
return File_Name
def dealwith(path,ext):
filedict={}
a = pathread(path)
s = 0
for i in range(0, len(a)):
for j in range(0, len(work(a[i]))):
if ((os.path.splitext(str(work(a[i])[j]))[-1]) == ext):
s = s + 1
filedict[s] = a[i] + '/' + str(work(a[i])[j])
return filedict
def findapi(file):
f1 = open(file, 'r', encoding='utf-8')
text = f1.read()
f1.close()
regex = r"[ ]*(@RequestMapping|@GetMapping)[(](\s*value\W*|[\"/]*)[^\"]*\"[)}]"
matches = re.finditer(regex, text, re.MULTILINE)
strs=''
for matchNum, match in enumerate(matches, start=1):
match = [x.strip('\n') for x in match.group()]
strs = ''.join(match)
strs=strs+'\n'
return strs
if __name__ == '__main__':
print("在path处填入java项目路径")
path="/Users/mteceh/Downloads/jeecg-boot-3.4.3"
# path=sys.argv[1]
for i,j in dealwith(path,".java").items():
findapi(j)
f = open(r"./apiout.txt", 'a')
f.write(findapi(j))
f.close()