This commit is contained in:
emile 2019-11-04 23:01:59 +01:00
parent c8f16d8f9c
commit 7810382082
2 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ dodaj - dodaj osobę
list - listuj osoby
list pesele
pesel - sprawdź pesel osoby
zapis - zapisanie danych do pliku
""")
from pesel import PeselStorage
storage = PeselStorage()
@ -30,4 +30,4 @@ while True:
def list_pesele():
print("\n".join([": ".join([x.name, str(x.pesel)]) for x in storage.set]))
{"dodaj":enter, "list":_list, "pesel":get_pesel, "list pesele":list_pesele}[input("$ ")]()
{"dodaj":enter, "list":_list, "pesel":get_pesel, "list pesele":list_pesele, "zapis":lambda: storage.dump("dump.json")}[input("$ ")]()

View File

@ -52,7 +52,7 @@ class PeselStorage:
def dump(self, filename:str):
with open(filename, "w+") as f:
json.dump(list(self.set), f)
json.dump(list([x.__dict__ for x in self.set]), f)