File size: 1,199 Bytes
5bdffe5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import re

filepath = "/home/nexus/ultraconnect/Tars-AI-Assistant/tars_utils.py"

with open(filepath, "r", encoding="utf-8") as f:
    lines = f.readlines()

# On cherche la ligne qui contient la fonction "obter_clima"
# et on nettoie les 4 lignes suivantes si elles contiennent "try:" sans except.
new_lines = []
skip_until_index = -1

for i, line in enumerate(lines):
    if i <= skip_until_index:
        continue

    # Détecte la ligne du commentaire de la docstring
    if "Busca o clima de Curitiba" in line:
        # Regarde la ligne précédente, si c'est "try:" orphelin, on le vire
        if new_lines and new_lines[-1].strip() == "try:":
            new_lines.pop() # Supprime le try orphelin
        
        # Ajoute la docstring propre
        new_lines.append(line)
        continue

    # Si on voit un try: suivi IMMÉDIATEMENT d'une docstring (ce qui est illégal)
    # On supprime le try
    if line.strip() == "try:" and i + 1 < len(lines) and '"""' in lines[i+1]:
        continue

    new_lines.append(line)

# Réécriture
with open(filepath, "w", encoding="utf-8") as f:
    f.writelines(new_lines)

print("✅ Fichier tars_utils.py réparé (try orphelin supprimé).")