瀏覽代碼

就这样吧

NandHyf 11 月之前
父節點
當前提交
a470fc3e85
共有 5 個文件被更改,包括 97 次插入29 次删除
  1. 11 10
      dev.toml
  2. 68 12
      kbc.py
  3. 13 5
      kbc_alt.py
  4. 3 2
      kbc_sqlite.py
  5. 2 0
      kbc_sqlite_cache.py

+ 11 - 10
dev.toml

@@ -20,16 +20,17 @@ Start_as_LLM_server = false
 [dev.compact_main]
 createSqls = '''
 CREATE TABLE "compact_main" (
- 	"id"	INTEGER NOT NULL,
- 	"type"	INTEGER NOT NULL,
- 	"name"	TEXT NOT NULL,
- 	"dscrp"	TEXT NOT NULL,
- 	"creator"	TEXT NOT NULL,
- 	"createdTime"	TEXT NOT NULL,
- 	"relatedBoard"	TEXT NOT NULL,
- 	"relatedClass"	TEXT NOT NULL,
- 	"state"	INTEGER NOT NULL,
- 	PRIMARY KEY("id" AUTOINCREMENT)
+	"id"	INTEGER NOT NULL,
+	"type"	INTEGER NOT NULL,
+	"name"	TEXT NOT NULL,
+	"dscrp"	TEXT NOT NULL,
+	"style"	TEXT NOT NULL,
+	"creator"	TEXT NOT NULL,
+	"createdTime"	TEXT NOT NULL,
+	"relatedBoard"	TEXT NOT NULL,
+	"relatedClass"	TEXT NOT NULL,
+	"state"	INTEGER NOT NULL,
+	PRIMARY KEY("id" AUTOINCREMENT)
 );
 '''
 state.deleted = -10

+ 68 - 12
kbc.py

@@ -27,21 +27,75 @@ class kbc_controller():
     
 
     # [todo 2]
-    def validCheck():
-        pass
+    def validCheck(c_list:list=[]):
+        # c_list == 'c'ommand 'list'
 
+        # 1. Separate command
+
+
+        # 2. Basic syntax check
+        c_list = input("input command: ").split()
+        
+        # "/": 0, "..": 1
+        commandType = {"select": 2, "add": 3, "delete": 4, "edit":5, "move": 6}
+        objType = {"board": 0, "class": 1, "event": 2}
+
+        try:
+            if c_list[0] == "/":
+                print("command is 'back_home' ")
+                c_list = [0]
+                print(c_list)
+                return 0
+            
+            elif c_list[0] == "..":
+                print("command is 'back_previous' ")
+                c_list[0] = 1
+                print(c_list)
+                return 0
+            
+            elif c_list[0] in commandType and c_list[1] in objType:
+                print("Valid true")
+                
+                if c_list[1] == "board":
+
+                    if "in" in c_list:
+                        kbc_alt.Err(0)
+
+                    elif "move" in c_list:
+                        kbc_alt.Err(0)
+
+                    c_list[0] = commandType[c_list[0]]
+                    c_list[1] = objType[c_list[1]]
 
-    def makeLog():
-        pass
 
+                elif c_list[1] == "class":
+                    
+                    if "move" in c_list:
+                        kbc_alt.Err(0)
 
-    def transitCommand():
-        while(True):
-            pass
-            # Input exception check
+                    c_list[0] = commandType[c_list[0]]
+                    c_list[1] = objType[c_list[1]]                
+
+
+                elif c_list[1] == "event":
+                    c_list[0] = commandType[c_list[0]]
+                    c_list[1] = objType[c_list[1]]
+                
+                print("command list: ", c_list)
+
+            else:
+                kbc_alt.Err(0)
             
-            # [todo 1]
-            # Controller.InputCheck(app_commands)
+
+        except IndexError:
+            kbc_alt.Err(0)
+
+
+        # 3. Executable check
+
+
+    def makeLog():
+        pass
 
 
     def direct():
@@ -63,5 +117,7 @@ class kbc_controller():
 
 
 if __name__ == "__main__":
-    kbc_controller.start()
-    kbc_alt.pause()
+    # kbc_controller.start()
+    # kbc_alt.pause()
+    while(1):
+        kbc_controller.validCheck()

+ 13 - 5
kbc_alt.py

@@ -6,14 +6,22 @@
 
 def pause():
     input("pausing, press any key to continue: ")
-    exit()
+    # exit()
 
 
-def Err(errCode, lang='en'):
-    errText = ""
-    print("err ", errCode, ": ",  errText)
+def Err(errCode, sec_respond:bool=False):
+    if errCode == 0:
+        print("err 0: syntax error")
+
+    elif errCode == 1:
+        print("err 1: ")
+
+    elif errCode == 2:
+        pass
+
     pause()
-    exit()
+    # exit()
+
 
 
 def Warn():

+ 3 - 2
kbc_sqlite.py

@@ -4,18 +4,19 @@ import kbc_alt
 
 # ----- Record_main(DB record as a class) -----
 class RM():
-    def __init__(self, type:str="", name:str="", dscrp:str="", creator:str="", createdTime:str="datetime('now')", relatedBoard:str="", relatedClass:str="", statement:int=-10) -> None:
+    def __init__(self, type:str="", name:str="", dscrp:str="", style:str="", creator:str="", createdTime:str="datetime('now')", relatedBoard:str="", relatedClass:str="", statement:str="=-10") -> None:
         self.id = "null"
         self.type = type
         self.name = name
         self.dscrp = dscrp
+        self.style = style
         self.creator = creator
         self.createdTime = createdTime
         self.relatedBoard = relatedBoard
         self.relatedClass = relatedClass
         self.statement = statement
 
-
+    # WHERE {swc}.format(swc=select_where)
     def select(self, selectColumn:str="name"):
         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.statement};".format(sc=selectColumn, s=self)
     

+ 2 - 0
kbc_sqlite_cache.py

@@ -0,0 +1,2 @@
+class cache():
+    pass