Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #----------------------------------
- def register(self, lname="", fname="", amnt="", major="", guard="", pwd=""):
- #--------------------------------------
- if not os.path.isfile('data\id.txt'):
- with open('data\id.txt', 'w') as f_id:
- f_id.write("1")
- id = 1
- else:
- with open('data\id.txt', 'r') as f_id:
- sid = f_id.read()
- id = int(sid) + 1
- with open('data\id.txt', 'w') as f_id:
- f_id.write(str(id))
- # Falls Liste nicht existiert, erstelle leeres Dictionary
- if not os.path.isfile('data\liste.json'):
- with open('data\liste.json', 'w') as json_new:
- json_new.write("{"+"\n"+"}")
- obj = {id: {u"Nachname": lname, u"Vorname": fname, u"Anzahl Begleitpersonen": amnt, u"Studiengang": major, u"Betreuer": guard, u"Passwort": pwd}}
- with open('data\liste.json') as json_r:
- data = json.load(json_r)
- data.update(obj)
- with open('data\liste.json', 'w') as json_w:
- json.dump(data, json_w, indent=4)
- markup_s = "Speichern erfolgreich!"
- return markup_s
- save.exposed = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement