Controller.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import Alt, Stateful
  2. import datetime
  3. class Client():
  4. def get_config():
  5. # [todo 4]
  6. configs = ['DBType', 'DBPath', 'lang', 'listStyle', 'displayTimeZone']
  7. # rl == 'r'eturn 'l'ist
  8. rl = Stateful.MatchTomlKeys("dev_config.toml", configs)
  9. global lang, listStyle, dbType, dbPath, displayTimeZone, currentPath
  10. dbType = rl[0]
  11. dbPath = rl[1]
  12. lang = rl[2]
  13. listStyle = rl[3]
  14. displayTimeZone = rl[4]
  15. currentPath = ""
  16. global config_dict
  17. config_dict = {}
  18. # [todo 4]
  19. def get_help():
  20. print(Stateful.MatchTomlKey("clean_config.toml", lang, "command-help"))
  21. # [todo 3]
  22. def InUTC(timeZone=0):
  23. dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
  24. return(dt_now_UTC0)
  25. # [todo 2]
  26. # 前端只检查输入数量正确, 内容正确统一代回后端检查
  27. def InputCheck(inputs):
  28. pass
  29. def TransitCommand():
  30. # do while or for (1)
  31. while(1):
  32. app_commands = input(currentPath + "/: ", ).split(" ")
  33. # Input exception check
  34. # [todo 1]
  35. # Client.InputCheck(app_commands)
  36. if len(app_commands) < 5:
  37. # Add CurrentPath && DBType && Path
  38. app_commands.append(currentPath)
  39. app_commands.append(dbPath)
  40. app_commands.append(dbType)
  41. Stateful.Handler(app_commands)
  42. elif len(app_commands) >= 5:
  43. print("app_commands >5 error")
  44. # [todo 4]
  45. def GenDB():# Stateful里面还有一个一样的方法
  46. pass
  47. # 1. 先检查是否已经存在DB? y/n?
  48. # 2. 连接性检查(是否要切换到新建的DB)y/n?
  49. # [todo 4]
  50. def start():
  51. # 0. init
  52. # 1. get config
  53. Client.get_config()
  54. # 2.
  55. startState = Stateful.Handler(['/', dbPath, dbType])
  56. print(startState)
  57. Client.TransitCommand()
  58. class View:
  59. def ToDisplayTime(utcTime, TimeZone):
  60. displayTime = "displayTime translation not finished"
  61. return displayTime
  62. def Refresh():
  63. pass
  64. # For ChatGLM3-6B
  65. class LLMCall():
  66. pass
  67. if __name__ == "__main__":
  68. Client.start()