#!/usr/bin/python # coding: utf8 import pickle import sys contenu = {} new = {} statut = True def charger(fic): global contenu try: with open(fic, "rb") as fichier: loader = pickle.Unpickler(fichier) contenu = loader.load() except: contenu = {} def sauver(fic): with open(fic, "wb") as fichier: saver = pickle.Pickler(fichier) saver.dump(contenu) if (len(sys.argv) is 4): fic=sys.argv[1] salon_orig=sys.argv[2] salon_dst=sys.argv[3] charger(fic) try: for cle,valeur in contenu.items(): if (cle[0] == salon_orig): mod=cle[1] print(str(salon_orig) + ":" + str(mod)) new[salon_dst,mod] = valeur else: new[cle] = valeur except Exception as err: print(err) statut = False if (statut): contenu = new sauver(fic) else: print("lecture.py ")