Controller.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import Alt, Stateful
  2. import datetime
  3. # 如果需要再封装class Board/KB_Class/Event的话就在这里
  4. class Client():
  5. def get_config():
  6. # [todo 4]
  7. configs = ['DBType', 'DBPath', 'lang', 'listStyle', 'displayTimeZone']
  8. # rl == 'r'eturn 'l'ist
  9. rl = Stateful.MatchTomlKeys("dev_config.toml", configs)
  10. global lang, listStyle, dbType, dbPath, displayTimeZone, currentPath
  11. dbType = rl[0]
  12. dbPath = rl[1]
  13. lang = rl[2]
  14. listStyle = rl[3]
  15. displayTimeZone = rl[4]
  16. currentPath = ""
  17. # [todo 4]
  18. def get_help():
  19. print(Stateful.MatchTomlKey("clean_config.toml", lang, "command-help"))
  20. # [todo 3]
  21. def InUTC(timeZone=0):
  22. dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
  23. return(dt_now_UTC0)
  24. # [todo 2]
  25. # 前端只检查输入数量正确, 内容正确统一代回后端检查
  26. def InputCheck(inputs):
  27. pass
  28. def TransitCommand():
  29. # do while or for (1)
  30. while(1):
  31. app_commands = input(currentPath + "/: ", ).split(" ")
  32. # Input exception check
  33. # [todo 1]
  34. # Client.InputCheck(app_commands)
  35. if len(app_commands) < 5:
  36. # Add CurrentPath && DBType && Path
  37. app_commands.append(currentPath)
  38. app_commands.append(dbPath)
  39. app_commands.append(dbType)
  40. Stateful.Handler(app_commands)
  41. elif len(app_commands) >= 5:
  42. print("app_commands >5 error")
  43. # [todo 4]
  44. def start():
  45. # 1. get config
  46. Client.get_config()
  47. # 2.
  48. startState = Stateful.Handler(['/', dbPath, dbType])
  49. print(startState)
  50. Client.TransitCommand()
  51. class View:
  52. def ToDisplayTime(utcTime, TimeZone):
  53. displayTime = "displayTime translation not finished"
  54. return displayTime
  55. def Refresh():
  56. pass
  57. if __name__ == "__main__":
  58. Client.start()