1
0

2 Incheckningar bdf2b32c7b ... 180f422a43

Upphovsman SHA1 Meddelande Datum
  NandHyf 180f422a43 - 修改了样式的存储方式: 统一放在.style下 11 månader sedan
  NandHyf 6f3c6c2780 删掉了Controller 和 VM 的模式 11 månader sedan
5 ändrade filer med 127 tillägg och 119 borttagningar
  1. 0 40
      Stateful.py
  2. 15 12
      dev.toml
  3. 16 20
      kbc.py
  4. 9 0
      kbc_llm.py
  5. 87 47
      kbc_sqlite.py

+ 0 - 40
Stateful.py

@@ -1,40 +0,0 @@
-# from Controller import kbc_config
-import kbc_alt
-import kbc_toml
-import kbc_sqlite
-
-
-# ------ Basics ------
-def get_app_config(returnDict:bool=True):
-        tomls = kbc_toml.MatchTomlTable("dev.toml", "app_config", "dict")
-        global app_config
-        app_config = tomls["app_config"]
-
-        if returnDict == True:
-            return app_config
-
-
-# ----- Core Function -----
-def Translator():
-    global oc
-    oc = {
-    "dt":str, # DBType
-    "dp":str, # DBPath
-
-    "cp":list, # CurrentPath
-    "pp":list, # PreviousPath
-
-    "next_move":str,
-
-    "tp":list, # TargetPath
-    "tp_in":list, # ~ after command parameter "in"(&& before command parameter "to")
-    "tp_to":list, # ~ after command parameter "to"
-    "tp_attr":str # ~ like "-name" in "edit -name oldName to newName"
-    }
-    # some thoughts:
-    # class oc():
-    #   def get_oc(), def move_oc()
-
-
-if __name__ == "__main__":
-    pass

+ 15 - 12
dev.toml

@@ -7,10 +7,7 @@ c1_pk = "id INTEGER PRIMARY KEY ASC"
 c2 = "type"
 c3 = "name"
 c4 = "dscrp"
-#    .position = [(x1,y1), (x2, y2), z]
-#    .border
-#    .radius
-#    .bgcolor
+#     .style = {position : [(x1,y1), (x2, y2), z], bgcolor, radius, border, }
 c5 = "creator"
 c6 = "createdTime"
 c7 = "relatedBoard"
@@ -42,16 +39,22 @@ Start_as_LLM_server = false
 
 
 # ----- Some Notes -----
-# compact_main.type:
-#   0 = Board
-#   1 = Class
-#   2 = Event
+[notes]
+compact_main.type = '''
+0 = Board
+1 = Class
+2 = Event
+'''
 
-# compact_main.state:
-#   10 = alive
-#   -10 = deleted
+compact_main.state = '''
+-10 = deleted
+10 = alive
 
-# log_action.status:
+'''
+
+log_action.status = '''
+
+'''
 
 
 # Set integer prime key: <columnName> INTEGER PRIMARY KEY ASC

+ 16 - 20
Controller.py → kbc.py

@@ -1,9 +1,21 @@
 import kbc_alt 
-import Stateful
+import kbc_toml
+import kbc_sqlite
+import kbc_llm
+
 import datetime
 
 
 class kbc_controller():
+    def get_app_config(returnDict:bool=True):
+        tomls = kbc_toml.MatchTomlTable("dev.toml", "app_config", "dict")
+        global app_config
+        app_config = tomls["app_config"]
+
+        if returnDict == True:
+            return app_config
+        
+
     def get_help():
         pass
     
@@ -12,18 +24,18 @@ class kbc_controller():
 
 
     # [todo 3]
-    def InUTC(timeZone:int=0):
+    def inUTC(timeZone:int=0):
         dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
         return(dt_now_UTC0)
     
 
     # [todo 2]
     # 前端只检查输入数量正确, 内容正确统一代回后端检查
-    def InputHandler():
+    def inputHandler():
         pass
 
 
-    def TransitCommand():
+    def transitCommand():
         # do while or for (1)
         while(1):
             app_commands = input(currentPath + "/: ", ).split(" ")
@@ -32,13 +44,6 @@ class kbc_controller():
             # [todo 1]
             # Controller.InputCheck(app_commands)
 
-
-    # [todo 4]
-    def GenDB():# Stateful里面还有一个一样的方法
-        pass
-        # 1. 先检查是否已经存在DB? y/n?
-        # 2. 连接性检查(是否要切换到新建的DB)y/n?
-
     
     def makeLog():
         pass
@@ -54,14 +59,5 @@ class kbc_controller():
         # kbc_controller.TransitCommand()
 
 
-# For ChatGLM3-6B
-class LLM():
-    def call():
-        pass
-
-    def respond():
-        pass
-
-
 if __name__ == "__main__":
     kbc_controller.start()   

+ 9 - 0
kbc_llm.py

@@ -0,0 +1,9 @@
+class LLM():
+    def __init__(self) -> None:
+        pass
+
+    def call():
+        pass
+
+    def respond():
+        pass

+ 87 - 47
kbc_sqlite.py

@@ -1,48 +1,6 @@
 import sqlite3
 
 
-# ----- Sqlite Methods -----
-def exec_one(dbPath:str, commands:list, fetchall:bool=False):
-    con = sqlite3.connect(dbPath)
-    cur = con.cursor()
-
-    cur.execute(commands)
-    con.commit()
-
-    # if fetchall == input, return 0?
-    if fetchall == True:
-        re = cur.fetchall()
-        return re
-    
-    cur.close()
-    con.close()
-
-    return 0
-
-
-def isExist(dbPath:str, tableName:str, capitalize:bool=False, itemName:str="", returnBool:bool=True):
-    # [todo 4] 这里面.capitalize()后面需要根据config.toml里面的内容判断
-    # 可能也不用, 因为KBCLEV的表名和本身并无关系
-    if capitalize == True:
-        tableName = tableName.capitalize()
-
-    sqls = "SELECT name FROM {table} WHERE name='{name}'".format(table=tableName, name=itemName)
-    ie = exec_one(dbPath, sqls)
-
-    if ie != [] and returnBool == False:
-        return ie
-    
-    elif ie != [] and returnBool == True:
-        return True
-
-    elif ie == []:
-        return False
-    
-    else:
-        # Alt.Err(errCode)
-        print("err <Code>: unexpected error in existence check")
-
-
 # ----- Record_main(DB record as a class) -----
 class RM():
     def __init__(self, type:str="", name:str="", dscrp:str="", creator:str="", relatedBoard:str="", relatedClass:str="", state:int=-10) -> None:
@@ -89,7 +47,7 @@ class RM():
         return "SELECT {sc} FROM compact_main WHERE type='{s.type}' AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state={s.state};".format(sc=selectColumn, s=self)
     
 
-    def get_styles():
+    def get_style():
         pass
 
 
@@ -99,9 +57,91 @@ class RLA():
 
 
 # ----- Auto generate DB from config.toml -----
-def genDB():
-    # model IE?
-    # over write?
-    # exec
+class DB():
+    def __init__(self) -> None:
+        pass
+
+    def dbExist():
+        pass
+
+
+    def reGenerate():
+        pass
+
+
+# ----- Operating Cursor -----
+oc = {
+"dt":str, # DBType
+"dp":str, # DBPath
+
+"cp":list, # CurrentPath
+"pp":list, # PreviousPath
+
+"next_move":str,
+
+"tp":list, # TargetPath
+"tp_in":list, # ~ after command parameter "in"(&& before command parameter "to")
+"tp_to":list, # ~ after command parameter "to"
+"tp_attr":str # ~ like "-name" in "edit -name oldName to newName"
+}
+# some thoughts:
+# class oc():
+#   def get_oc(), def move_oc()
+
+
+# ----- Sqlite Methods -----
+def execute(dbPath):
+    def dec(origin_func):
+        pass
+    con = sqlite3.connect(dbPath)
+    cur = con.cursor()
+
+    cur.execute(commands)
+    con.commit()
+
+    # if fetchall == input, return 0?
+    if fetchall == True:
+        re = cur.fetchall()
+        return re
+    
+    cur.close()
+    con.close()
+    def dec():
+        pass
+
+
+@execute(oc["dp"])
+def exec_one(dbPath:str, commands:list, fetchall:bool=False):
     pass
 
+
+@execute(oc["dp"])
+def exec_many():
+    pass
+
+
+def recordExist(dbPath:str, tableName:str, capitalize:bool=False, itemName:str="", returnBool:bool=True):
+    # [todo 4] 这里面.capitalize()后面需要根据config.toml里面的内容判断
+    # 可能也不用, 因为KBCLEV的表名和本身并无关系
+    if capitalize == True:
+        tableName = tableName.capitalize()
+
+    sqls = "SELECT name FROM {table} WHERE name='{name}'".format(table=tableName, name=itemName)
+    ie = exec_one(dbPath, sqls)
+
+    if ie != [] and returnBool == False:
+        return ie
+    
+    elif ie != [] and returnBool == True:
+        return True
+
+    elif ie == []:
+        return False
+    
+    else:
+        # Alt.Err(errCode)
+        print("err <Code>: unexpected error in existence check")
+
+
+def master():
+    pass