Controller.py 2.1 KB

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