Jelajahi Sumber

- 补充了说明
- 引入了todo<n>项管机制

nandHyf 1 tahun lalu
induk
melakukan
d6a8857252
2 mengubah file dengan 18 tambahan dan 6 penghapusan
  1. 11 3
      Controller.py
  2. 7 3
      sqlite.py

+ 11 - 3
Controller.py

@@ -2,10 +2,11 @@ import Alt, Stateful
 import datetime
     
 
+# 如果需要再封装class Board/KB_Class/Event的话就在这里
 class Client():
 
     def get_config():
-        # T-B-C...
+        # [todo 1]
         configs = ['DBType', 'DBPath', 'lang', 'listStyle', 'displayTime']
         # rl == 'r'eturn 'l'ist
         rl = Stateful.matchTomlKeys("config.toml", configs)
@@ -17,16 +18,23 @@ class Client():
         listStyle = rl[3]
         displayTimeZone = rl[4]
 
+
+    # [todo 1]
     def get_help():
         print(Stateful.matchTomlKey("clean_config.toml", lang, "command-help"))
 
 
-    # not finished
+    # [todo 2]
     def InUTC(timeZone=0):
         dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
         return(dt_now_UTC0)
     
 
+    # [todo 3]
+    def SyntaxCheck():
+        pass
+    
+
     def TransitCommand():
         # do while or for (1)
         while(1):
@@ -38,7 +46,7 @@ class Client():
             app_commands.append(dbType)
             Stateful.PackHandler(app_commands)
 
-
+    # [todo 1]
     def start():
         # 1. get config
         Client.get_config()

+ 7 - 3
sqlite.py

@@ -8,12 +8,14 @@ dbPath = "dev.db"
 def is_exist(tableName, columnName):
     pass
 
+
+# [todo 0]
 def Secondary_response():
     pass
 
 
 def Operate_sqlite3(dbPath, commands):
-    # Command e.g.
+    # Commands e.g.
     #    0       1       2      3      4      5     6
     # [add]
     # ['add', 'board', '<KB>']
@@ -55,8 +57,10 @@ def Operate_sqlite3(dbPath, commands):
 
     # [/]
     
-    
+    # [todo 3]
     # 1. 检查commands[5]是否为dbPath, 不是话报错(syntax error)
+    # ↑↑↑ 但是总感觉输入检查应该放在Controller里面(也就是放在前端去检查)...
+    # 前端检查语法, 冲突代回到后端去检查, 然后顺便就执行了
     # 2. 命令里面的<KB>, <CL>, <EV>都代入检查是否存在, 区分add/edit(INSERT INTO/UPDATE)
     # 3. 匹配SQL关键字
     # 4. 拼完以后进行to和in的判断
@@ -80,7 +84,7 @@ def Operate_sqlite3(dbPath, commands):
             # Secondary_response()
 
         # 2. exec command
-        matched = Stateful.MatchTomlKeys('d<EV>_config.toml', commands, 'sqlite3')
+        matched = Stateful.MatchTomlKeys('dev_config.toml', commands, 'sqlite3')
         print(matched)