afegides noves validacions
This commit is contained in:
+36
-2
@@ -10,6 +10,14 @@ from core.result import ComicResult, StepResult
|
||||
from processors.validator import validate_archive
|
||||
from processors.cleaner import clean_directory
|
||||
from processors.converter import needs_conversion, conversion_step_result
|
||||
from processors.checks import (
|
||||
check_trash,
|
||||
check_page_numbering,
|
||||
check_image_extensions,
|
||||
check_comicinfo,
|
||||
)
|
||||
from processors.page_normalizer import normalize_pages
|
||||
from processors.image_normalizer import normalize_images
|
||||
|
||||
|
||||
class Pipeline:
|
||||
@@ -17,11 +25,13 @@ class Pipeline:
|
||||
self,
|
||||
steps: list,
|
||||
desired_format: str = "cbz",
|
||||
desired_image_format: str = ".jpg",
|
||||
collision_policy: str = CollisionPolicy.ABORT,
|
||||
dry_run: bool = False,
|
||||
):
|
||||
self.steps = steps
|
||||
self.desired_format = desired_format
|
||||
self.desired_image_format = desired_image_format
|
||||
self.collision_policy = collision_policy
|
||||
self.dry_run = dry_run
|
||||
|
||||
@@ -41,7 +51,15 @@ class Pipeline:
|
||||
try:
|
||||
extract_archive(path, temp_dir)
|
||||
|
||||
# 3. Aplicar cada step sobre el directorio temporal
|
||||
# 3. Ejecutar siempre los 4 content checks
|
||||
step_results += [
|
||||
check_trash(temp_dir),
|
||||
check_page_numbering(temp_dir),
|
||||
check_image_extensions(temp_dir),
|
||||
check_comicinfo(temp_dir),
|
||||
]
|
||||
|
||||
# 4. Aplicar cada fix step sobre el directorio temporal
|
||||
any_changed = False
|
||||
|
||||
if "clean" in self.steps:
|
||||
@@ -50,6 +68,22 @@ class Pipeline:
|
||||
if clean_result.changed:
|
||||
any_changed = True
|
||||
|
||||
if "normalize_pages" in self.steps:
|
||||
norm_result = normalize_pages(temp_dir)
|
||||
step_results.append(norm_result)
|
||||
if norm_result.changed:
|
||||
any_changed = True
|
||||
|
||||
if "normalize_images" in self.steps:
|
||||
img_result = normalize_images(temp_dir, self.desired_image_format)
|
||||
step_results.append(img_result)
|
||||
if img_result.errors:
|
||||
return ComicResult(
|
||||
original_path=path, final_path=None, steps=step_results
|
||||
)
|
||||
if img_result.changed:
|
||||
any_changed = True
|
||||
|
||||
if "convert" in self.steps:
|
||||
conv_result = conversion_step_result(real_format, self.desired_format)
|
||||
step_results.append(conv_result)
|
||||
@@ -60,7 +94,7 @@ class Pipeline:
|
||||
if conv_result.changed:
|
||||
any_changed = True
|
||||
|
||||
# 4. Reempaquetar si hubo cambios o conversión de formato
|
||||
# 5. Reempaquetar si hubo cambios o conversión de formato
|
||||
needs_repack = any_changed or (
|
||||
"convert" in self.steps
|
||||
and needs_conversion(real_format, self.desired_format)
|
||||
|
||||
Reference in New Issue
Block a user