Kaynağa Gözat

- 存储后端雏形
- 好多异常我草

NandHyf 1 yıl önce
ebeveyn
işleme
ef55d2e212
5 değiştirilmiş dosya ile 44 ekleme ve 28 silme
  1. 26 19
      Controller.py
  2. 15 6
      Stateful.py
  3. BIN
      __pycache__/Stateful.cpython-311.pyc
  4. 2 3
      clean_config.toml
  5. 1 0
      debug_backlog.txt

+ 26 - 19
Controller.py

@@ -1,34 +1,35 @@
-import Alt
-import Stateful
-
+import Alt, Stateful
+import datetime
+    
 
 class Client():
 
     def get_config():
         # T-B-C...
-        configs = ['lang', 'listStyle', 'DBType', 'DBPath']
+        configs = ['DBType', 'DBPath', 'lang', 'listStyle', 'displayTime']
         # rl == 'r'eturn 'l'ist
         rl = Stateful.matchTomlKeys("config.toml", configs)
         
         global lang, listStyle, dbType, dbPath
-        lang = rl[0]
-        listStyle = rl[1]
-        dbType = rl[2]
-        dbPath = rl[3]
-
+        dbType = rl[0]
+        dbPath = rl[1]
+        lang = rl[2]
+        listStyle = rl[3]
+        displayTime = rl[4]
 
     def get_help():
-        print(Stateful.matchTomlKey("config.toml", lang, "command-help"))
+        print(Stateful.matchTomlKey("clean_config.toml", lang, "command-help"))
 
 
     def TransitCommand():
         # do while or for (1)
-        app_command = input(currentPath).split(" ")
+        while(1):
+            app_command = input(currentPath + "/: ", ).split(" ")
+            # Syntax check
 
-
-        app_command.append(dbPath)
-        app_command.append(dbType)
-        Stateful.TransitHandler(app_command)
+            app_command.append(dbPath)
+            app_command.append(dbType)
+            Stateful.TransitHandler(app_command)
 
 
     def start():
@@ -36,7 +37,7 @@ class Client():
         Client.get_config()
 
         global currentPath
-        currentPath = "/: "
+        currentPath = " "
         # ↓↓↓ test code here ↓↓↓
 
 
@@ -44,13 +45,19 @@ class Client():
 
         # Normalized Start Process
         startState = Stateful.TransitHandler(['list', 'board', dbPath, dbType])
-        
+        print(startState)
         Client.TransitCommand()
 
 
-        # 2. list board
-        # Command.list
+class View:
+    def ToDisplayTime(utcTime, TimeZone):
+        displayTime = "displayTime translation not finished"
+        return displayTime
+    
+    def Refresh():
+        pass
 
+    
 
 if __name__ == "__main__":
     Client.start()

+ 15 - 6
Stateful.py

@@ -68,14 +68,24 @@ def matchTomlKeys(tomlName, keys, table=None) -> list:
         return rl
 
 
-
 # Sqlite3
 def operate_sqlite3(dbPath, command):
     con = sqlite3.connect(dbPath)
     cur = con.cursor()
 
-    # 
-    # cur.execute()
+    # list -> .TABLES
+    if command[0] == "list" and command[1] == "board":
+        cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
+        print(cur.fetchall())
+    # add -> CREATE
+    elif command[0] == "add" and command[1] == "board":
+        cur.execute('''        ''')
+
+    # add -> INSERT INTO
+
+    # edit -> UPDATE
+
+    # delete -> UPDATE(status -> 'deleted')
     
     cur.close()
 
@@ -93,7 +103,7 @@ def operate_sqlite3(dbPath, command):
 def TransitHandler(transit_command):
     dbType = transit_command[-1]
     dbPath = transit_command[-2]
-    exec_command = transit_command[0:-3]
+    exec_command = transit_command[0:-2]
 
     if dbType == "sqlite3":
         operate_sqlite3(dbPath, exec_command)
@@ -112,5 +122,4 @@ def TransitHandler(transit_command):
 
     else:
         input("error 1: could not found correct Data Base")
-        exit()
-
+        exit()

BIN
__pycache__/Stateful.cpython-311.pyc


+ 2 - 3
clean_config.toml

@@ -1,10 +1,9 @@
 # ----- App Configuration -----
-lang = "en"
-listStyle = "tree"
-
 DBType = "sqlite3"
 DBPath = "test.db"
 
+lang = "en"
+listStyle = "tree"
 displayTime = "utc+8"
 
 # ----- App Command to DB Syntax Translation -----

+ 1 - 0
debug_backlog.txt

@@ -3,6 +3,7 @@
 
 # ----- Controller.py -----
 1. app_command 输入不合法字符的异常处理
+2. 原本该在Focus模式工作的SELECT出现在全局命令里的异常处理
 
 # ----- Stateful.py -----
 1. 读取toml文件时候没有匹配到键的异常处理