Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #----------------------------------
  2. def register(self, lname="", fname="", amnt="", major="", guard="", pwd=""):
  3. #--------------------------------------
  4. if not os.path.isfile('data\id.txt'):
  5. with open('data\id.txt', 'w') as f_id:
  6. f_id.write("1")
  7. id = 1
  8. else:
  9. with open('data\id.txt', 'r') as f_id:
  10. sid = f_id.read()
  11. id = int(sid) + 1
  12. with open('data\id.txt', 'w') as f_id:
  13. f_id.write(str(id))
  14.  
  15. # Falls Liste nicht existiert, erstelle leeres Dictionary
  16. if not os.path.isfile('data\liste.json'):
  17. with open('data\liste.json', 'w') as json_new:
  18. json_new.write("{"+"\n"+"}")
  19.  
  20. obj = {id: {u"Nachname": lname, u"Vorname": fname, u"Anzahl Begleitpersonen": amnt, u"Studiengang": major, u"Betreuer": guard, u"Passwort": pwd}}
  21.  
  22. with open('data\liste.json') as json_r:
  23. data = json.load(json_r)
  24. data.update(obj)
  25.  
  26. with open('data\liste.json', 'w') as json_w:
  27. json.dump(data, json_w, indent=4)
  28. markup_s = "Speichern erfolgreich!"
  29. return markup_s
  30. save.exposed = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement