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.
 
 
 

47 lines
1.2 KiB

  1. import json
  2. import sys
  3. def main(fname):
  4. with open(fname, 'r') as f:
  5. d = json.loads(f.read())
  6. d = d[0]
  7. start = {
  8. 8: [None,None,None,None,None,],
  9. 9: [None,None,None,None,None,],
  10. 10: [None,None,None,None,None,],
  11. 11: [None,None,None,None,None,],
  12. 12: [None,None,None,None,None,],
  13. 13: [None,None,None,None,None,],
  14. 14: [None,None,None,None,None,],
  15. 15: [None,None,None,None,None,],
  16. 16: [None,None,None,None,None,],
  17. 17: [None,None,None,None,None,],
  18. 18: [None,None,None,None,None,],
  19. }
  20. for v in d['CategoryEvents']:
  21. key = int(v['StartDateTime'].split("T")[1][:2])
  22. day = int(v['StartDateTime'].split("T")[0][-2:]) - 4
  23. print(day)
  24. location = v['Location']
  25. module = v['Description']
  26. if not(module):
  27. module = v['ExtraProperties'][0]['Value']
  28. lecturer = v['ExtraProperties'][1]['Value']
  29. s = location + "\n" + module + "\n" + lecturer
  30. start[key][day] = s
  31. for k in range(8,19):
  32. for i in range(5):
  33. if start[k][i] == None:
  34. start[k][i] = "Free"
  35. print(json.dumps(start))
  36. if __name__ == "__main__":
  37. main(sys.argv[1])