Skip to content

Commit 716bce5

Browse files
committed
[FIX] Added try catch to get FilenotFound exeption on forbidden functions. This fixes #102
1 parent 4ab0b13 commit 716bce5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

PyChecker/utils/forbidden_functions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ def check(project_path: str, authorized_func, root_path: str):
2323
functions_called = []
2424

2525
# Get binary name
26-
with open(project_path + '/Makefile', 'r') as file:
27-
data = file.read()
28-
binary = re.findall("NAME[\s]*=[\s]*(.*)", data)[0]
26+
try:
27+
with open(project_path + '/Makefile', 'r') as file:
28+
data = file.read()
29+
binary = re.findall("NAME[\s]*=[\s]*(.*)", data)[0]
30+
except FileNotFoundError:
31+
print(project_path + '/Makefile: File not found. Stopping')
32+
return project_path + '/Makefile: File not found. Stopping'
2933

3034
subprocess.run(['make', '-C', project_path, 'all'])
3135
result = subprocess.run(['nm', project_path + '/' + binary],

0 commit comments

Comments
 (0)