This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s1-tp/auto.py

58 lines
1.3 KiB
Python

# Scipt permettant d'automatiser les TP
import os
base = './'
rendeurs = [('BEAUSSART Jean-loup', 'Beaussart'), ('PREUD\'HOMME Geoffrey', 'PreudHomme')]
def chemin(semestre, tp=None):
return os.path.normpath(base + '/S' + str(semestre) + ('/TP' + str(tp) if tp else ''))
def semestreProchain():
i = 1
while os.path.exists(chemin(i)):
i += 1
return i
def semestreEnCours():
return semestreProchain() - 1
def tpProchain():
i = 1
semestre = semestreEnCours()
while os.path.exists(chemin(semestre, i)):
i += 1
return i
def tpEnCours():
return tpProchain() - 1
def fichiersTp(semestre, tp):
return fichiersPythons
def fichiersPythons(semestre, tp):
chem = chemin(semestre, tp)
return [os.path.join(chem, i) for i in os.listdir(chem) if os.path.isfile(os.path.join(chem, i))]
def rendeur(semestre, tp):
for i in fichiersPythons(semestre, tp):
texte = open(i, 'r').read()
rend = ''
rendeurMax = 500
for j in range(len(rendeurs)):
pos = texte.find(rendeurs[j][0])
if pos < rendeurMax:
rendeurMax = pos
rend = j
if rend != '':
return rend
return None
print('Rendeur du TP en cours :', rendeurs[rendeur(semestreEnCours(), tpEnCours())][0])