diff --git a/cineclubBlog.py b/cineclubBlog.py index 1bd1c96..ff6fbc7 100644 --- a/cineclubBlog.py +++ b/cineclubBlog.py @@ -50,7 +50,7 @@ class film(): return res def calendrier(self): - res = '
' + res = ' \n \n
' res += '
' res += '' res += '

Retour en haut de page' - res += "

" + res += "
\n \n
" return res def bocal(self): @@ -122,14 +122,22 @@ def strListe(liste): res += liste[-1] return res -def nouveauFilm(): - with open('filmsCode', 'rb') as file: - pickler = pickle.Unpickler(file) - dicFilms = pickler.load() - with open('index', 'rb') as index: - pickler = pickle.Unpickler(index) - dicIndex = pickler.load() - i = pickler.load() + 1 +i = 38 + +def nouveauFilm(dicFilms = {}, index = {}): + ind, dic = True, True + if dicFilms == {}: + with open('filmsCode', 'rb') as file: + pickler = pickle.Unpickler(file) + dicFilms = pickler.load() + dic = False + if index == {}: + with open('index', 'rb') as index: + pickler = pickle.Unpickler(index) + dicIndex = pickler.load() + i = pickler.load() + 1 + ind = False + i += 1 idN = input("identifiant du film ? ") date = input("date de la séance (format mardi JJ MOIS AAAA) ") nom = input("titre ? ") @@ -144,13 +152,15 @@ def nouveauFilm(): seance = film(i, idN, date, nom, acteurs, realisateur, duree, synopsis, pays, annee, youtube, couleur) dicIndex[i] = idN dicFilms[idN] = seance - with open('index', 'wb') as index: - pickler = pickle.Pickler(index) - pickler.dump(dicIndex) - pickler.dump(i) - with open('filmsCode', 'wb') as fichier: - mon_pickler = pickle.Pickler(fichier) - mon_pickler.dump(dicFilms) + if not(ind) : + with open('index', 'wb') as index: + pickler = pickle.Pickler(index) + pickler.dump(dicIndex) + pickler.dump(i) + if not(dic): + with open('filmsCode', 'wb') as fichier: + mon_pickler = pickle.Pickler(fichier) + mon_pickler.dump(dicFilms) return seance def getIndex(): diff --git a/filmsCode2 b/filmsCode2 new file mode 100644 index 0000000..dc5d884 Binary files /dev/null and b/filmsCode2 differ