"🔧 Programme de nettoyage des fichiers non UTF-8"
This commit is contained in:
16
detect_encodage.py
Normal file
16
detect_encodage.py
Normal file
@@ -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)
|
||||||
Reference in New Issue
Block a user