kbc.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import kbc_alt
  2. import kbc_toml
  3. import kbc_sqlite
  4. import kbc_llm
  5. import datetime
  6. # class config def read(), reload()
  7. class kbc_controller():
  8. def get_app_config(returnDict:bool=True):
  9. tomls = kbc_toml.MatchTomlTable("dev.toml", "app_config", "dict")
  10. if returnDict == True:
  11. return tomls
  12. def get_help():
  13. pass
  14. def rewrite_config():
  15. pass
  16. # [todo 4]
  17. def display_in_timezone(timezone:int=0):
  18. pass
  19. # [todo 2]
  20. def validCheck(c_list:list=[]):
  21. # c_list == 'c'ommand 'list'
  22. #
  23. commandType = {"/": 0, "..": 1, "select": 1, "add": 1, "delete": 1, "edit": 1, "move": 1, "to": 1, "in": 1}
  24. objType = {"board": 3, "class": 2, "event": 1}
  25. try:
  26. if ".." in c_list and "/" in c_list:
  27. kbc_alt.Err(0)
  28. return 0
  29. elif c_list[0] == "/":
  30. print("command is 'back_home' ")
  31. c_list = [0]
  32. print(c_list)
  33. return 0
  34. elif c_list[0] == "..":
  35. print("command is 'back_previous' ")
  36. c_list[0] = 1
  37. print(c_list)
  38. return 0
  39. # 指令总和 > 某个数说明后面还有不合规的语法
  40. except IndexError:
  41. kbc_alt.Err(0)
  42. def makeLog():
  43. pass
  44. def direct():
  45. sqls = input("direct sqls(ONE SQL STATEMENT ONLY): ")
  46. res = kbc_sqlite.exec(kbc_sqlite.oc['dp'], sqls, True)
  47. print("res: ", res)
  48. # [todo 4]
  49. def start():
  50. app_config = kbc_controller.get_app_config()["app_config"]
  51. kbc_sqlite.oc['dt'] = app_config['DBType']
  52. kbc_sqlite.oc['dp'] = app_config['DBPath']
  53. # if start_as_llmserver == True:
  54. kbc_sqlite.oc['cp'] = ['home']
  55. while(True):
  56. c_list = input("input command: ").split()
  57. kbc_controller.validCheck(c_list)
  58. if __name__ == "__main__":
  59. kbc_controller.start()
  60. # kbc_alt.pause()