Browse Source

- 发现了toml键丢失引发的异常
-- 保留了引发异常的toml (line 6)
- 分离了Exceptions.py

NandHyf 1 year ago
parent
commit
23b71b6d2b
5 changed files with 10 additions and 12 deletions
  1. 1 2
      Controller.py
  2. 0 0
      Exceptions.py
  3. 7 8
      Stateful.py
  4. 1 1
      View.py
  5. 1 1
      config.toml

+ 1 - 2
Controller.py

@@ -1,5 +1,4 @@
-# @author: nandHyf
-
+import Exceptions
 import Stateful, View
 
 class Command():

+ 0 - 0
Exceptions.py


+ 7 - 8
Stateful.py

@@ -1,5 +1,4 @@
-# @author:hyf
-
+import Exceptions
 import base64, datetime
 import tomlkit, sqlite3
 
@@ -12,7 +11,6 @@ def generate_uid(kw):
     return(uid)
 
 
-
 # ----- Methods binding command to model -----
 
 # Toml
@@ -22,14 +20,12 @@ def getTomlDoc(tomlName):
             doc = tomlkit.load(t)
 
             if doc == {}:
-                input("Error 0: Could not find correct 'config.toml'")
-                exit()
+                Exceptions.err0()
 
             return doc
         
     except:
-        input("Error 0: Could not find correct 'config.toml'")
-        exit()
+        Exceptions.err0()
     
 
 def matchTomlKey(tomlName, key, table=None) -> str:
@@ -51,7 +47,10 @@ def matchTomlKeys(tomlName, keys, table=None) -> list:
         rl = []
 
         for key in keys:
-            rl.append(doc.item(key))
+            try:
+                rl.append(doc.item(key))
+            except:
+                Exceptions.err0()
 
         return rl
     

+ 1 - 1
View.py

@@ -1 +1 @@
-# @author:nandHyf
+

+ 1 - 1
config.toml

@@ -3,7 +3,7 @@
 lang = "en"
 
 # tree/expand
-listStyle = "tree"
+# listStyle = "tree"
 
 # >>>need some guidance here<<<
 EnableGlobalCommand = false