normalizar-case
This commit is contained in:
@@ -155,3 +155,28 @@ def check_comicinfo(names: list[str]) -> StepResult:
|
||||
)
|
||||
warnings = [] if found else ["Falta ComicInfo.xml"]
|
||||
return StepResult(step="check_comicinfo", changed=False, warnings=warnings)
|
||||
|
||||
|
||||
def check_extension_case(names: list[str], mode: str = "lower") -> StepResult:
|
||||
"""Detecta imágenes cuya extensión no está en el case esperado (lower/upper)."""
|
||||
mismatches = []
|
||||
for name in names:
|
||||
normalized = name.replace("\\", "/")
|
||||
if normalized.endswith("/"):
|
||||
continue
|
||||
basename = normalized.rsplit("/", 1)[-1]
|
||||
_, ext = os.path.splitext(basename)
|
||||
if not ext or ext.lower() not in IMAGE_EXTENSIONS:
|
||||
continue
|
||||
target_ext = ext.lower() if mode == "lower" else ext.upper()
|
||||
if ext != target_ext:
|
||||
mismatches.append(basename)
|
||||
|
||||
if not mismatches:
|
||||
warnings = []
|
||||
elif len(mismatches) <= 3:
|
||||
warnings = [f"Case incorrecto en extensión: {f}" for f in sorted(mismatches)]
|
||||
else:
|
||||
warnings = [f"Case incorrecto en extensión: {len(mismatches)} ficheros"]
|
||||
|
||||
return StepResult(step="check_extension_case", changed=False, warnings=warnings)
|
||||
|
||||
Reference in New Issue
Block a user