-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (29 loc) · 881 Bytes
/
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
import os
import sys
from file_sca import FileSCA
if len(sys.argv) < 2:
print("error: Please provide a filename")
sys.exit(1)
filename = sys.argv[1]
# TODO account for multiline strings when porting this for resume
# - i.e. prevent false positives
files_to_check = []
errors = []
if os.path.isfile(filename) and filename.endswith(".py"):
files_to_check.append(filename)
elif os.path.isdir(filename):
for dir_path, dir_names, file_names in os.walk(filename):
for f in file_names:
if f.endswith(".py"):
files_to_check.append(os.path.join(dir_path, f))
else:
print("Error: Can't find given path")
sys.exit(1)
files_to_check.sort()
for f in files_to_check:
# TODO refactor to make static method
sca = FileSCA(f)
sca.analyze()
errors = errors + [e[1] for e in sca.errors]
for e in errors:
print(e)