فهرست منبع

fix: improve code formatting and consistency in logs_service.py

Manuel 8 ماه پیش
والد
کامیت
94a845b239
1فایلهای تغییر یافته به همراه7 افزوده شده و 7 حذف شده
  1. 7 7
      services/system/logs_service.py

+ 7 - 7
services/system/logs_service.py

@@ -1,15 +1,13 @@
 import os
+import re
 
 from loguru import logger
 
-
-import re
-
-ANSI_ESCAPE_RE = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
+ANSI_ESCAPE_RE = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]")
 
 
 def _strip_ansi(line):
-    return ANSI_ESCAPE_RE.sub('', line)
+    return ANSI_ESCAPE_RE.sub("", line)
 
 
 def read_logs(log_files, max_lines, debug=False):
@@ -20,9 +18,11 @@ def read_logs(log_files, max_lines, debug=False):
     logs = {}
     for log_file in log_files:
         try:
-            with open(log_file, errors='replace') as f:
+            with open(log_file, errors="replace") as f:
                 lines = f.readlines()
-                cleaned = [_strip_ansi(line.rstrip('\n')) for line in lines[-max_lines:]]
+                cleaned = [
+                    _strip_ansi(line.rstrip("\n")) for line in lines[-max_lines:]
+                ]
                 logs[os.path.basename(log_file)] = cleaned
         except FileNotFoundError:
             logs[os.path.basename(log_file)] = ["Log file not found"]