Controller.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. # [todo 1]
  32. # 直接在这check一下length
  33. # Add DBType && Path
  34. app_commands.append(dbPath)
  35. app_commands.append(dbType)
  36. Stateful.PackHandler(app_commands)
  37. # [todo 4]
  38. def start():
  39. # 1. get config
  40. Client.get_config()
  41. global currentPath
  42. currentPath = " "
  43. # ↓↓↓ test code here ↓↓↓
  44. # ↑↑↑ test code here ↑↑↑
  45. # 2. Normalized Start Process
  46. startState = Stateful.TransitHandler(['list', 'board', dbPath, dbType])
  47. print(startState)
  48. Client.TransitCommand()
  49. class View:
  50. def ToDisplayTime(utcTime, TimeZone):
  51. displayTime = "displayTime translation not finished"
  52. return displayTime
  53. def Refresh():
  54. pass
  55. if __name__ == "__main__":
  56. Client.start()