From ea50d05d1c8eb849e9412bec9c2f5b2e14d213bf Mon Sep 17 00:00:00 2001 From: Michel Date: Sun, 20 Apr 2025 10:18:57 +0200 Subject: [PATCH] =?UTF-8?q?"=F0=9F=94=A7=20Programme=20de=20nettoyage=20de?= =?UTF-8?q?s=20fichiers=20non=20UTF-8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detect_encodage.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 detect_encodage.py diff --git a/detect_encodage.py b/detect_encodage.py new file mode 100644 index 0000000..65a0fa1 --- /dev/null +++ b/detect_encodage.py @@ -0,0 +1,16 @@ +import os + +racine = "." # point de départ = dossier courant + +def detect_fichiers_non_utf8(dossier): + for root, dirs, files in os.walk(dossier): + for file in files: + if file.endswith(".py"): + chemin = os.path.join(root, file) + try: + with open(chemin, encoding="utf-8") as f: + f.read() + except UnicodeDecodeError: + print(f"⚠️ Encodage non UTF-8 : {chemin}") + +detect_fichiers_non_utf8(racine)