kbc.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. commandType = {"/": 0, "..": 1, "select": 1, "add": 1, "delete": 1, "edit": 1, "move": 1, "to": 1, "in": 1}
  23. objType = {"board": 3, "class": 2, "event": 1}
  24. # split multi commands
  25. # valid each
  26. try:
  27. counter = 0
  28. if counter > 5:
  29. kbc_alt.Err(0)
  30. # 指令总和大于或者小于某个数就说明后面还有不合规的语法
  31. except IndexError:
  32. kbc_alt.Err(0)
  33. def makeLog():
  34. pass
  35. def direct():
  36. sqls = input("direct sqls(ONE SQL STATEMENT ONLY): ")
  37. res = kbc_sqlite.exec(kbc_sqlite.oc['dp'], sqls, True)
  38. print("res: ", res)
  39. # [todo 4]
  40. def start():
  41. app_config = kbc_controller.get_app_config()["app_config"]
  42. kbc_sqlite.oc['dt'] = app_config['DBType']
  43. kbc_sqlite.oc['dp'] = app_config['DBPath']
  44. # if start_as_llmserver == True:
  45. kbc_sqlite.oc['cp'] = ['home']
  46. while(True):
  47. c_list = input("input command: ").split()
  48. kbc_controller.validCheck(c_list)
  49. if __name__ == "__main__":
  50. kbc_controller.start()
  51. # kbc_alt.pause()