Przeglądaj źródła

- 视觉调整: 把app_config放在了config最前
- 没想明白config要不要单独搞方法
- 删除危险的wipeAll方法, 并使用更危险的direct方法替代

NandHyf 11 miesięcy temu
rodzic
commit
7e6f2bf979
5 zmienionych plików z 61 dodań i 69 usunięć
  1. 41 48
      dev.toml
  2. 8 9
      kbc.py
  3. 3 0
      kbc_llm.py
  4. 8 12
      kbc_sqlite.py
  5. 1 0
      kbc_toml.py

+ 41 - 48
dev.toml

@@ -1,3 +1,17 @@
+# ----- App Configuration -----
+[app_config]
+StrictMode = true
+
+DBType = "sqlite3"
+DBPath = "dev.db"
+
+Lang = "en"
+ListStyle = "tree"
+DisplayTimeZone = "utc+8"
+
+Start_as_LLM_server = false
+
+
 # ----- DB Configuration -----
 # Just a better reference for dev.db, no functional use(yet)
 # ↓ DB name("dev".db)
@@ -13,6 +27,20 @@ c6 = "createdTime"
 c7 = "relatedBoard"
 c8 = "relatedClass"
 c9 = "state"
+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)
+);
+'''
 
 [dev.log_action]
 c1_pk = "id INTEGER PRIMARY KEY ASC"
@@ -22,20 +50,18 @@ c4 = "type"
 c5 = "commitedAction"
 c6 = "operator"
 c7 = "status"
-
-
-# ----- App Configuration -----
-[app_config]
-StrictMode = true
-
-DBType = "sqlite3"
-DBPath = "dev.db"
-
-Lang = "en"
-ListStyle = "tree"
-DisplayTimeZone = "utc+8"
-
-Start_as_LLM_server = false
+createSqls = '''
+CREATE TABLE "log_action" (
+ 	"id"	INTEGER NOT NULL,
+ 	"uid"	TEXT NOT NULL,
+ 	"commitTime"	TEXT NOT NULL,
+ 	"type"	TEXT NOT NULL,
+ 	"action"	TEXT NOT NULL,
+ 	"operator"	TEXT NOT NULL,
+ 	"status"	TEXT NOT NULL,
+ 	PRIMARY KEY("id" AUTOINCREMENT)
+);
+'''
 
 
 # ----- Some Notes -----
@@ -49,7 +75,6 @@ compact_main.type = '''
 compact_main.state = '''
 -10 = deleted
 10 = alive
-
 '''
 
 log_action.status = '''
@@ -57,38 +82,8 @@ log_action.status = '''
 '''
 
 
-# Set integer prime key: <columnName> INTEGER PRIMARY KEY ASC
-# status: alive/deleted/unclassified(event only)
-#                                           ↓ Don't foget to write the method(s) for it
-# ListStyle: tree/md_table/LLM_md_table/<customName>
-
-
 # ----- used sqls -----
-# 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)
-# );
-
-# CREATE TABLE "log_action" (
-# 	"id"	INTEGER NOT NULL,
-# 	"uid"	TEXT NOT NULL,
-# 	"commitTime"	TEXT NOT NULL,
-# 	"type"	TEXT NOT NULL,
-# 	"action"	TEXT NOT NULL,
-# 	"operator"	TEXT NOT NULL,
-# 	"status"	TEXT NOT NULL,
-# 	PRIMARY KEY("id" AUTOINCREMENT)
-# );
-
-
+# Set integer prime key: <columnName> INTEGER PRIMARY KEY ASC
 # INSERT INTO compact_main VALUES(null, 'class', 'CL1', 'dscrp', 'n.HE', datetime('now'), 'KB1, KB2', '', 'alive');
 
 # SELECT name FROM compact_main WHERE belongBoard like '%KB1%'
@@ -103,5 +98,3 @@ log_action.status = '''
 # UPDATE compact_main SET relatedBoard = replace(relatedBoard, 'KB2, ', '')  WHERE type='class' AND relatedBoard like '%KB2, %';
 # UPDATE compact_main SET relatedBoard = replace(relatedBoard, ', KB2', '')  WHERE type='class' AND relatedBoard like '%, KB2%';
 # UPDATE compact_main SET relatedBoard = replace(relatedBoard, 'KB2', '')  WHERE type='class' AND relatedBoard like '%KB2%';
-
-# Explanation of abbreviations

+ 8 - 9
kbc.py

@@ -5,7 +5,7 @@ import kbc_llm
 
 import datetime
 
-
+# class config def read(), reload()
 class kbc_controller():
     def get_app_config(returnDict:bool=True):
         tomls = kbc_toml.MatchTomlTable("dev.toml", "app_config", "dict")
@@ -23,10 +23,9 @@ class kbc_controller():
         pass
 
 
-    # [todo 3]
-    def inUTC(timeZone:int=0):
-        dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
-        return(dt_now_UTC0)
+    # [todo 4]
+    def display_in_timezone():
+        pass
     
 
     # [todo 2]
@@ -35,6 +34,10 @@ class kbc_controller():
         pass
 
 
+    def makeLog():
+        pass
+
+
     def transitCommand():
         # do while or for (1)
         while(1):
@@ -44,10 +47,6 @@ class kbc_controller():
             # [todo 1]
             # Controller.InputCheck(app_commands)
 
-    
-    def makeLog():
-        pass
-
 
     # [todo 4]
     def start():

+ 3 - 0
kbc_llm.py

@@ -1,3 +1,6 @@
+import kbc_alt
+
+
 class LLM():
     def __init__(self) -> None:
         pass

+ 8 - 12
kbc_sqlite.py

@@ -1,5 +1,5 @@
 import sqlite3
-
+import kbc_alt
 
 # ----- Record_main(DB record as a class) -----
 class RM():
@@ -15,10 +15,6 @@ class RM():
         self.state = state
 
 
-    def direct():
-        pass
-
-
     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.state};".format(sc=selectColumn, s=self)
     
@@ -57,12 +53,7 @@ class RM():
 
 # ----- Record_log_action(DB record as a class) -----
 class RLA():
-    def __init__(self) -> None:
-        pass
-
-
-    def direct():
-        pass
+    pass
 
 
 # ----- DB as a class -----
@@ -79,6 +70,10 @@ class DB():
         pass
 
 
+def direct():
+    pass
+
+
 # ----- Operating Cursor -----
 oc = {
 "dt":str, # DBType
@@ -103,6 +98,7 @@ oc = {
 def execute(dbPath):
     def dec(origin_func):
         pass
+
     con = sqlite3.connect(dbPath)
     cur = con.cursor()
 
@@ -149,7 +145,7 @@ def recordExist(dbPath:str, tableName:str, capitalize:bool=False, itemName:str="
         return False
     
     else:
-        # Alt.Err(errCode)
+        # kbc_alt.Err(errCode)
         print("err <Code>: unexpected error in existence check")
 
 

+ 1 - 0
kbc_toml.py

@@ -1,4 +1,5 @@
 import tomlkit
+import kbc_alt
 
 
 # ----- Toml Methods -----