38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# processors/converter.py
|
|
|
|
from core.result import StepResult
|
|
|
|
|
|
def needs_conversion(real_format: str, desired_format: str) -> bool:
|
|
"""True si el formato real no coincide con el deseado."""
|
|
if desired_format == "cbz" and real_format == "zip":
|
|
return False
|
|
if desired_format == "cbr" and real_format == "rar":
|
|
return False
|
|
return True
|
|
|
|
|
|
def conversion_step_result(real_format: str, desired_format: str) -> StepResult:
|
|
"""
|
|
Informa si se necesita conversión.
|
|
El pipeline decide si reempaquetar; este step solo evalúa.
|
|
"""
|
|
if desired_format == "cbr":
|
|
return StepResult(
|
|
step="convert",
|
|
changed=False,
|
|
errors=["Crear CBR requiere 'rar' instalado (no implementado)"],
|
|
)
|
|
|
|
convert = needs_conversion(real_format, desired_format)
|
|
details = (
|
|
[f"Conversión necesaria: {real_format} → {desired_format}"]
|
|
if convert
|
|
else [f"Sin conversión: ya es {desired_format}"]
|
|
)
|
|
return StepResult(
|
|
step="convert",
|
|
changed=convert,
|
|
details=details,
|
|
)
|