benchmark.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Этот скрипт генерирует большое количество профилей и вставляет в календарь
  2. from PyQt5.QtGui import *
  3. from random import randint
  4. import datetime
  5. import json
  6. def main():
  7. profile_count = 3
  8. days_ahead = 10
  9. calendar = open('calendar.json', 'w+', encoding='utf-8')
  10. profiles = open('profiles.json', 'w+', encoding='utf-8')
  11. profiles_array = [ ]
  12. calendar_dict = { }
  13. for i in range(profile_count + 1):
  14. profile = {
  15. 'id': i,
  16. 'name': f'Тестовый профиль {i}',
  17. 'color': QColor.fromHsv(randint(0, 359), 128, 255).rgb(),
  18. 'timetable': { }
  19. }
  20. time = datetime.datetime.today() + datetime.timedelta(hours=7)
  21. for _ in range(randint(4, 10)):
  22. profile['timetable'][f'{time.hour}:{time.minute}'] = 'lesson.wav'
  23. time += datetime.timedelta(minutes=45)
  24. profile['timetable'][f'{time.hour}:{time.minute}'] = 'break.wav'
  25. time += datetime.timedelta(minutes=5)
  26. profiles_array.append(profile)
  27. date = datetime.datetime.now() + datetime.timedelta(days=1)
  28. for _ in range(days_ahead):
  29. calendar_dict[f'{date.year}.{date.month}.{date.day}'] = randint(0, profile_count)
  30. date += datetime.timedelta(days=1)
  31. json.dump(profiles_array, profiles, indent=4, ensure_ascii=False)
  32. json.dump(calendar_dict, calendar, indent=4, ensure_ascii=False)
  33. profiles.close()
  34. calendar.close()
  35. if __name__ == '__main__':
  36. main()