Controller.py 2.5 KB

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