detecció de fitxers extranys en el fitxer
This commit is contained in:
+11
-9
@@ -18,6 +18,7 @@ from processors.checks import (
|
||||
check_page_numbering,
|
||||
check_image_extensions,
|
||||
check_comicinfo,
|
||||
check_foreign,
|
||||
)
|
||||
from processors.page_normalizer import normalize_pages, preview_normalize_pages
|
||||
from processors.image_normalizer import (
|
||||
@@ -45,12 +46,11 @@ class Pipeline:
|
||||
|
||||
def _compute_preview(self, step: str, temp_dir: str, step_results: list) -> dict:
|
||||
if step == "clean":
|
||||
trash_result = next((r for r in step_results if r.step == "check_trash"), None)
|
||||
if trash_result:
|
||||
prefix = "Basura detectada: "
|
||||
items = [w.removeprefix(prefix) for w in trash_result.warnings if w.startswith(prefix)]
|
||||
else:
|
||||
items = []
|
||||
trash_r = next((r for r in step_results if r.step == "check_trash"), None)
|
||||
foreign_r = next((r for r in step_results if r.step == "check_foreign"), None)
|
||||
prefix = "Basura detectada: "
|
||||
items = [w.removeprefix(prefix) for w in (trash_r.warnings if trash_r else []) if w.startswith(prefix)]
|
||||
items += [w.removeprefix("Fichero extraño: ") for w in (foreign_r.warnings if foreign_r else [])]
|
||||
return {"items": items}
|
||||
|
||||
elif step == "normalize_pages":
|
||||
@@ -81,8 +81,9 @@ class Pipeline:
|
||||
if ext != self.desired_format:
|
||||
return True
|
||||
if step == "clean":
|
||||
trash = next((r for r in step_results if r.step == "check_trash"), None)
|
||||
if trash and trash.warnings:
|
||||
trash = next((r for r in step_results if r.step == "check_trash"), None)
|
||||
foreign = next((r for r in step_results if r.step == "check_foreign"), None)
|
||||
if (trash and trash.warnings) or (foreign and foreign.warnings):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -104,12 +105,13 @@ class Pipeline:
|
||||
step_results.append(StepResult(step="list", changed=False, errors=[str(exc)]))
|
||||
return ComicResult(original_path=path, final_path=None, steps=step_results)
|
||||
|
||||
# 3. Ejecutar siempre los 4 content checks sobre los nombres (sin extraer)
|
||||
# 3. Ejecutar siempre los content checks sobre los nombres (sin extraer)
|
||||
step_results += [
|
||||
check_trash(names),
|
||||
check_page_numbering(names),
|
||||
check_image_extensions(names),
|
||||
check_comicinfo(names),
|
||||
check_foreign(names),
|
||||
]
|
||||
|
||||
# 4. Pre-flight: si ningún step necesita extracción, salir sin tocar el archivo
|
||||
|
||||
Reference in New Issue
Block a user