Controller.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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', 'displayTime']
  8. # rl == 'r'eturn 'l'ist
  9. rl = Stateful.matchTomlKeys("config.toml", configs)
  10. global lang, listStyle, dbType, dbPath
  11. dbType = rl[0]
  12. dbPath = rl[1]
  13. lang = rl[2]
  14. listStyle = rl[3]
  15. displayTimeZone = rl[4]
  16. # [todo 4]
  17. def get_help():
  18. print(Stateful.matchTomlKey("clean_config.toml", lang, "command-help"))
  19. # [todo 3]
  20. def InUTC(timeZone=0):
  21. dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
  22. return(dt_now_UTC0)
  23. # [todo 0]
  24. def SyntaxCheck():
  25. pass
  26. def TransitCommand():
  27. # do while or for (1)
  28. while(1):
  29. app_commands = input(currentPath + "/: ", ).split(" ")
  30. # Input exception check
  31. # Add DBType && Path
  32. app_commands.append(dbPath)
  33. app_commands.append(dbType)
  34. Stateful.PackHandler(app_commands)
  35. # [todo 4]
  36. def start():
  37. # 1. get config
  38. Client.get_config()
  39. global currentPath
  40. currentPath = " "
  41. # ↓↓↓ test code here ↓↓↓
  42. # ↑↑↑ test code here ↑↑↑
  43. # 2. Normalized Start Process
  44. startState = Stateful.TransitHandler(['list', 'board', dbPath, dbType])
  45. print(startState)
  46. Client.TransitCommand()
  47. class View:
  48. def ToDisplayTime(utcTime, TimeZone):
  49. displayTime = "displayTime translation not finished"
  50. return displayTime
  51. def Refresh():
  52. pass
  53. if __name__ == "__main__":
  54. Client.start()