You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
735 B

#!/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):
charger(sys.argv[1])
try:
for cle in contenu:
if (cle == sys.argv[2]):
print(cle)
new[sys.argv[3]] = contenu[cle]
else:
new[cle] = contenu[cle]
except Exception as err:
print(err)
statut = False
if (statut):
contenu = new
sauver(sys.argv[1])
else:
print("lecture.py <fichier> <salon_orig> <salon_dest>")