Skip to content

Commit b088562

Browse files
committed
[FEATURE] Added 42commandements project check.
1 parent e7a0c2a commit b088562

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

42PyChecker.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def check_norme(project_path: str):
6161
print("No source file (.c) or header (.h) to check")
6262
return 1
6363
with open(os.path.dirname(os.path.realpath(__file__)) + "/.mynorme", 'w+') as file:
64-
result = subprocess.run('norminette' + files, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
64+
result = subprocess.run(['norminette'] + files.split(), stdout=subprocess.PIPE).stdout.decode('utf-8')
6565
file.write(result)
6666
error_count = result.count('Error')
6767
warning_count = result.count('Warning')
@@ -72,4 +72,22 @@ def check_norme(project_path: str):
7272
return 0
7373

7474

75-
sys.exit(check_norme("/Users/jlasne/Clion/libft"))
75+
def check_42_commandements(project_path:str):
76+
"""
77+
:param project_path: The path of the project where you want to check the author file
78+
:return: Will return 0 if everything is ok,
79+
1 if the file doesn't exists,
80+
2 if the file content is different.
81+
"""
82+
if not os.path.exists(project_path + '/rendu'):
83+
print("file `rendu' not found.")
84+
return 1
85+
with open(project_path + '/rendu', 'r') as file:
86+
content = file.read()
87+
if content != "En choisissant d'effectuer ma scolarite a 42, je declare adherer a ces regles ainsi qu'aux valeurs morales qu'elles vehiculent.\n":
88+
print("Error: The `rendu' file content is different from what is expected.")
89+
return 2
90+
return 0
91+
92+
93+
sys.exit(check_42_commandements("/tmp/jlasne3"))

0 commit comments

Comments
 (0)