Browse Source

return var -> return statement

nandHyf 1 year ago
parent
commit
7762ccf3ac
3 changed files with 15 additions and 35 deletions
  1. 0 9
      Controller.py
  2. 5 0
      dev.toml
  3. 10 26
      kbc_sqlite.py

+ 0 - 9
Controller.py

@@ -50,15 +50,6 @@ class kbc_controller():
         # kbc_controller.TransitCommand()
 
 
-class View:
-    def ToDisplayTime(utcTime, TimeZone):
-        displayTime = "displayTime translation not finished"
-        return displayTime
-    
-    def Refresh():
-        pass
-
-
 # For ChatGLM3-6B
 class LLM():
     def call():

+ 5 - 0
dev.toml

@@ -38,6 +38,11 @@ Start_as_LLM_server = false
 
 
 # ----- Some Notes -----
+# compact_main.type:
+#   0 = Board
+#   1 = Class
+#   2 = Event
+
 # compact_main.state:
 #   10 = alive
 #   -10 = deleted

+ 10 - 26
kbc_sqlite.py

@@ -27,7 +27,7 @@ def isExist(dbPath:str, tableName:str, capitalize:bool=False, itemName:str="", r
         tableName = tableName.capitalize()
 
     sqls = "SELECT name FROM {table} WHERE name='{name}'".format(table=tableName, name=itemName)
-    ie = Exec_one(dbPath, sqls)
+    ie = exec_one(dbPath, sqls)
 
     if ie != [] and returnBool == False:
         return ie
@@ -58,51 +58,35 @@ class RM():
 
     
     def select(self, selectColumn:str="name"):
-        sqls = "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)                                              
-        
-        return sqls
+        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)
     
 
     def add(self):
-        sqls = "INSERT INTO compact_main VALUES({a.id}, '{a.type}', '{a.name}', '{a.dscrp}', '{a.creator}', '{a.createdTime}', '{a.relatedBoard}', '{a.relatedClass}', {a.state});".format(a=self)
-
-        return sqls
+        return "INSERT INTO compact_main VALUES({a.id}, '{a.type}', '{a.name}', '{a.dscrp}', '{a.creator}', '{a.createdTime}', '{a.relatedBoard}', '{a.relatedClass}', {a.state});".format(a=self)
 
 
     def delete(self): # 1. withstate:int=10? 2. withStatement >= or > or <?
-        sqls = "UPDATE compact_main SET state=-10 WHERE type='{d.type}' AND name='{d.name}' AND relatedBoard='{d.relatedBoard}' AND relatedClass='{d.relatedClass}' AND state=10;".format(d=self)
-
-        return sqls
+        return "UPDATE compact_main SET state=-10 WHERE type='{d.type}' AND name='{d.name}' AND relatedBoard='{d.relatedBoard}' AND relatedClass='{d.relatedClass}' AND state=10;".format(d=self)
 
 
     def edit(self, editColumn:str="", editValue:str=""):
-        sqls = "UPDATE compact_main SET {ec}='{ev}' WHERE type='{e.type}' AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state={e.state};".format(ec=editColumn, ev=editValue, e=self)
-
-        return sqls
+        return "UPDATE compact_main SET {ec}='{ev}' WHERE type='{e.type}' AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state={e.state};".format(ec=editColumn, ev=editValue, e=self)
     
 
-    def edit_state(self, editColumn:str="", editValue:int=-10):
-        sqls = "UPDATE compact_main SET {ec}='{ev}' WHERE type='{e.type}' AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state={e.state};".format(ec=editColumn, ev=editValue, e=self)
-
-        return sqls
+    def edit_state(self, editValue:int=-10):
+        return "UPDATE compact_main SET state={ev} WHERE type='{e.type}' AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state={e.state};".format(ec=editColumn, ev=editValue, e=self)
 
 
     def move(self, moveColumn:str="", moveValue:str=""):
-        sqls = "UPDATE compact_main SET {mc}='{mv}' WHERE type='{m.type}' AND name='{m.name}' AND relatedBoard='{m.relatedBoard}' AND relatedClass='{m.relatedClass}' AND state=10;".format(mc=moveColumn, mv=moveValue, m=self)
-        
-        return sqls
+        return "UPDATE compact_main SET {mc}='{mv}' WHERE type='{m.type}' AND name='{m.name}' AND relatedBoard='{m.relatedBoard}' AND relatedClass='{m.relatedClass}' AND state=10;".format(mc=moveColumn, mv=moveValue, m=self)
 
 
     def back(self, selectColumn:str="name"):
-        sqls = "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)                                              
-        
-        return sqls
+        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)
 
 
     def export(self, selectColumn:str="name"):
-        sqls = "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)                                              
-        
-        return sqls
+        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)
 
 
 # ----- Record_log_action(DB record as a class) -----