@@ -22,15 +22,15 @@ def __init__(self, db_file: str) -> None:
2222 self .conn = sqlite3 .connect (db_file )
2323 self .cur = self .conn .cursor ()
2424
25- def getTableNames (self ) -> list [str ]:
25+ def get_table_names (self ) -> list [str ]:
2626 self .cur .execute ("SELECT name FROM sqlite_master WHERE type='table';" )
2727 return [x [0 ] for x in self .cur .fetchall ()]
2828
29- def hasTable (self , table_name : str ) -> bool :
29+ def has_table (self , table_name : str ) -> bool :
3030 self .cur .execute (f"SELECT name FROM sqlite_master WHERE type='table' AND name='{ table_name } ';" )
3131 return len (self .cur .fetchall ()) > 0
3232
33- def getMessagesFromTable (
33+ def get_messages_from (
3434 self ,
3535 table_name : str ,
3636 level_name : Optional [str ] = None ,
@@ -41,7 +41,7 @@ def getMessagesFromTable(
4141 self .cur .execute (f"SELECT * FROM { table_name } WHERE level_name='{ level_name } ' ORDER BY time DESC LIMIT { limit } " )
4242 return self .cur .fetchall ()
4343
44- def getCountFromTable (
44+ def get_count_from (
4545 self ,
4646 table_name : str ,
4747 level_name : Optional [str ] = None ) -> int :
@@ -58,16 +58,16 @@ def getCountFromTable(
5858 "ERROR" : BCOLORS .FAIL ,
5959 "CRITICAL" : BCOLORS .FAIL ,
6060}
61- def formatLine (line : tuple ) -> str :
61+ def format_line (line : tuple ) -> str :
6262 time = line [1 ]
6363 level_name = line [3 ]
6464 message = line [4 ]
6565 return f"{ BCOLORS .OKCYAN } { time } { BCOLORS .ENDC } { __color_level [level_name ]} { level_name } { BCOLORS .ENDC } : { message } "
66- def formatLines (lines : list [tuple ]) -> Generator [str , None , None ]:
66+ def format_lines (lines : list [tuple ]) -> Generator [str , None , None ]:
6767 for i in range (0 , len (lines )):
68- yield formatLine (lines [i ])
68+ yield format_line (lines [i ])
6969
70- def sortLines (lines : list [tuple ]) -> list [tuple ]:
70+ def sort_lines (lines : list [tuple ]) -> list [tuple ]:
7171 # in the order of time
7272 return sorted (lines , key = lambda x : x [0 ], reverse = False )
7373
@@ -102,17 +102,17 @@ def main():
102102 parser .print_help ()
103103 return
104104
105- def getAllTableNames (files ) -> list [str ]:
105+ def get_all_table_names (files ) -> list [str ]:
106106 __all_table_names = []
107107 for file in files :
108108 reader = LogDBReader (file )
109- __all_table_names .extend (reader .getTableNames ())
109+ __all_table_names .extend (reader .get_table_names ())
110110 return sorted (list (set (__all_table_names )))
111111
112112 if args .subparser_name == 'view' :
113113 __all_lines = []
114114 table_name = args .table
115- __all_table_names = getAllTableNames (args .files )
115+ __all_table_names = get_all_table_names (args .files )
116116 if table_name is None or table_name == "" :
117117 for idx , table_name in enumerate (__all_table_names ):
118118 print (f"[{ idx } ] { table_name } " )
@@ -143,13 +143,13 @@ def getAllTableNames(files) -> list[str]:
143143
144144 for file in args .files :
145145 reader = LogDBReader (file )
146- if not reader .hasTable (table_name ):
146+ if not reader .has_table (table_name ):
147147 continue
148- lines = reader .getMessagesFromTable (table_name , args .level , limit = args .limit )
148+ lines = reader .get_messages_from (table_name , args .level , limit = args .limit )
149149 __all_lines .extend (lines )
150- __all_lines = sortLines (__all_lines )
150+ __all_lines = sort_lines (__all_lines )
151151 try :
152- for line in formatLines (__all_lines ):
152+ for line in format_lines (__all_lines ):
153153 print (line )
154154 print ('\n ' + '-' * 80 )
155155 print (f"Total { len (__all_lines )} lines, from table { table_name } " )
@@ -164,14 +164,14 @@ def getAllTableNames(files) -> list[str]:
164164
165165 elif args .subparser_name == 'check' :
166166 # get size of each table
167- all_tables = getAllTableNames (args .files )
167+ all_tables = get_all_table_names (args .files )
168168 count = {}
169169 for file in args .files :
170170 reader = LogDBReader (file )
171171 for table_name in all_tables :
172- if not reader .hasTable (table_name ):
172+ if not reader .has_table (table_name ):
173173 continue
174- lines = reader .getCountFromTable (table_name , level_name = args .level )
174+ lines = reader .get_count_from (table_name , level_name = args .level )
175175 count [table_name ] = count .setdefault (table_name , 0 ) + lines
176176 # print
177177 max_len = max ([len (x ) for x in all_tables ])
@@ -191,8 +191,8 @@ async def ensureNotLogging():
191191 from lires .core .error import LiresError
192192 from lires .utils import BCOLORS
193193 from lires .api import RegistryConn
194- from lires .config import getConf
195- group_id = getConf ()['group' ]
194+ from lires .config import get_conf
195+ group_id = get_conf ()['group' ]
196196 rconn = RegistryConn ()
197197 try :
198198 log_service = await rconn .get ('log' , group_id )
@@ -211,7 +211,7 @@ def unifyPath(path: str) -> str:
211211 if unifyPath (all_files [i ]) == unifyPath (args .output ):
212212 all_files .pop (i )
213213 break
214- all_tables = getAllTableNames (all_files )
214+ all_tables = get_all_table_names (all_files )
215215 conn = sqlite3 .connect (args .output )
216216 cur = conn .cursor ()
217217
@@ -232,9 +232,9 @@ def unifyPath(path: str) -> str:
232232 sql_create = sql_create [:- 2 ] + ")"
233233 cur .execute (sql_create )
234234
235- if not reader .hasTable (table_name ):
235+ if not reader .has_table (table_name ):
236236 continue
237- lines = reader .getMessagesFromTable (table_name )
237+ lines = reader .get_messages_from (table_name )
238238 for line in lines :
239239 cur .execute (f"INSERT INTO { table_name } VALUES (?,?,?,?,?)" , line )
240240 conn .commit ()
0 commit comments