-
Notifications
You must be signed in to change notification settings - Fork 0
/
conan.py
executable file
·64 lines (57 loc) · 2.89 KB
/
conan.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
import os
from datetime import datetime
from pprint import pprint
timestamp = datetime.today().strftime("%Y-%m-%d %H:%M")
archivos = (
("ejercicio 1", "java.md", "code"),
("ejercicio 2", "hola.md", "code"),
("ejercicio 3A", "build/reports/checkstyle/main.html", "exists"),
("ejercicio 3B", "build/reports/checkstyle/test.html", "exists"),
("ejercicio 3C", "build/reports/pmd/main.html", "exists"),
("ejercicio 3D", "build/reports/pmd/test.html", "exists"),
("ejercicio 3E", "build/reports/tests/test/index.html", "exists"),
("ejercicio 3F", "build/reports/tests/test/classes/ar.unrn.DesordenadoAppTest.html", "exists"),
("ejercicio 4", "src/main/java/ar/unrn/DesordenadoApp.java", "code"),
("ejercicio 5", "ejercicio5.md", "markdown")
)
practicas = [f for f in os.listdir("tp1-2024-submissions")]
pprint(f"procesando: {practicas}")
for tp in practicas:
print(f"Repositorio: {tp} / {timestamp}")
with open(f"{tp}.md", "w") as informe:
informe.write(f"# Informe creado el {timestamp}\n")
informe.write("\n\nImportante, este informe no es el resultado de la corrección (eso es en un comentario separado.\n\n")
informe.write("![Mira como te revisa conan](https://github.com/INGCOM-UNRN-PII/cursada-2024/blob/main/plantel/bot/conan.png?raw=true)\n")
informe.write("\n\n**Importante** Este informe no es el resultado de la corrección, es lo que se usa para corregir en otro comentario a continuación.\n")
contador = 0
for punto, nombre_archivo, tipo in archivos:
print(("*" * 4) + punto)
informe.write(f"\n\n# {punto} / {nombre_archivo}\n\n")
path_archivo = "tp1-2024-submissions" + "/" + tp + "/" + nombre_archivo
try:
ejercicio = open(path_archivo, encoding="utf8", errors='ignore').read()
msg = f"`{punto}::/{nombre_archivo}` con '{len(ejercicio)}' bytes"
print(msg)
contador = contador + 1 # cuantos archivos encontró
if tipo == "code":
informe.write("```\n")
informe.writelines(ejercicio)
informe.write("\n```")
elif tipo == "exists":
informe.write("\n")
informe.writelines(msg)
else:
informe.write("\n")
informe.writelines(ejercicio)
except FileNotFoundError as exc:
err_msg = f"{nombre_archivo} no fue encontrado en la ubicación esperada\n `{path_archivo}`"
print(err_msg)
informe.write(err_msg)
except Exception as exc:
err_msg = f" La excepcion fue {exc}"
print(err_msg)
informe.write(err_msg)
stats = f"\n# {tp}:{contador}/{len(archivos)}"
print(stats)
#informe.write(stats)