Răsfoiți Sursa

refactor: simplify regex and list comprehension formatting in quota and admin utilities

Manuel 8 luni în urmă
părinte
comite
159d02c1cd
2 a modificat fișierele cu 6 adăugiri și 10 ștergeri
  1. 2 6
      routes/admin/quota.py
  2. 4 4
      utils/admin.py

+ 2 - 6
routes/admin/quota.py

@@ -130,9 +130,7 @@ def register_routes(bp):
                         if not raw:
                             continue
                         # Format 1: acl usuarios_bloqueados src <IP>
-                        m = re.match(
-                            r"^acl\s+usuarios_bloqueados\s+src\s+(\S+)", raw
-                        )
+                        m = re.match(r"^acl\s+usuarios_bloqueados\s+src\s+(\S+)", raw)
                         if m:
                             username = m.group(1)
                             detail = "Bloqueado por IP (src)"
@@ -141,9 +139,7 @@ def register_routes(bp):
                             parts = [p.strip() for p in raw.split(" - ")]
                             if len(parts) >= 2:
                                 username = parts[1]
-                                detail = (
-                                    " - ".join(parts[2:]) if len(parts) > 2 else ""
-                                )
+                                detail = " - ".join(parts[2:]) if len(parts) > 2 else ""
                             else:
                                 username = raw
                                 detail = ""

+ 4 - 4
utils/admin.py

@@ -125,9 +125,7 @@ class SquidConfigManager:
         prefix = base + suffix
         try:
             backups = sorted(
-                f
-                for f in os.listdir(directory)
-                if f.startswith(prefix) and f != base
+                f for f in os.listdir(directory) if f.startswith(prefix) and f != base
             )
             # Remove all but the last (newest) backup
             for old in backups[:-1]:
@@ -894,7 +892,9 @@ class SquidConfigManager:
                     with open(filepath, encoding="utf-8") as f:
                         existing = f.read()
                     if existing == content:
-                        logger.debug(f"Modular config unchanged, skipping write: {filename}")
+                        logger.debug(
+                            f"Modular config unchanged, skipping write: {filename}"
+                        )
                         return True
                 except Exception:
                     pass  # If we can't read, proceed with write