#!/usr/bin/env python3 """Rehace las copias de nombre limpio DESPUES de la reescritura de enlaces. El orden importaba: en `45-normalize-links.py` las copias se creaban antes de reescribir, asi que `titulo?.html` quedaba reescrito pero su copia `titulo` (sin extension, la que pedira el navegador) conservaba los enlaces absolutos. Aqui se rehacen desde el fichero ya reescrito. """ import os, shutil from collections import Counter BASE = "/home/rafa/joomla-migration/mirror-antiguo" RUN = open(os.path.join(BASE, "CURRENT_RUN")).read().strip() SITE = os.path.join(BASE, "runs", RUN, "site") st = Counter() for root, _d, files in os.walk(SITE): for fn in list(files): if "?" not in fn: continue base = fn.split("?", 1)[0] if not base: continue src, dst = os.path.join(root, fn), os.path.join(root, base) if os.path.exists(dst) and os.path.getmtime(dst) >= os.path.getmtime(src): st["ya_al_dia"] += 1 continue shutil.copy2(src, dst) st["recopiados"] += 1 print(dict(st))