feat: add feature to update cachyOS in the background
This commit is contained in:
22
lib/classifier.py
Normal file
22
lib/classifier.py
Normal file
@ -0,0 +1,22 @@
|
||||
import re
|
||||
from config import PACKAGES_RESTART_REQUIRED, PACKAGES_SERVICE_RESTART, PACKAGES_RESTART_PATTERNS
|
||||
|
||||
|
||||
def needs_restart(name: str) -> bool:
|
||||
if name in PACKAGES_RESTART_REQUIRED:
|
||||
return True
|
||||
if name in PACKAGES_SERVICE_RESTART:
|
||||
return True
|
||||
return any(re.match(p, name) for p in PACKAGES_RESTART_PATTERNS)
|
||||
|
||||
|
||||
def classify(packages) -> tuple[list, list]:
|
||||
"""Retourne (sûrs, reportés).
|
||||
|
||||
sûrs : installables immédiatement, sans aucun redémarrage
|
||||
reportés: nécessitent un redémarrage service ou système → installation à l'extinction
|
||||
"""
|
||||
safe, deferred = [], []
|
||||
for pkg in packages:
|
||||
(deferred if needs_restart(pkg.name) else safe).append(pkg)
|
||||
return safe, deferred
|
||||
Reference in New Issue
Block a user