GabrielGD commited on
Commit
534b550
·
verified ·
1 Parent(s): ec704a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -420,16 +420,17 @@ def calcular_diff_interno(texto_original, texto_corrigido):
420
  kw_add = ["custas", "art. 319", "art. 337", "art. 1022", "art. 1015", "art. 300", "fumus", "periculum", "essencial", "preliminar", "tempestividade", "cabimento"]
421
  for linha in diff:
422
  txt = linha[2:]; txt_esc = escape(txt)
423
- if linha.startswith(' '): res_html.append(f"<div class='linha-igual'>{txt_esc}</div>")
 
424
  elif linha.startswith('- '):
425
  l_rem += 1
426
  res_html.append(f"<div class='linha-removida'><del>{txt_esc}</del></div>")
427
- if txt.strip() and any(kw in txt.lower() for kw in kw_rem): # CORRIGIDO: if em nova linha
428
  crit.append(f"<span style='color:red'>🔴 REMOVIDO:</span> {txt_esc}")
429
  elif linha.startswith('+ '):
430
  l_add += 1
431
  res_html.append(f"<div class='linha-adicionada'><ins>{txt_esc}</ins></div>")
432
- if txt.strip() and any(kw in txt.lower() for kw in kw_add): # CORRIGIDO: if em nova linha
433
  crit.append(f"<span style='color:green'>🟢 ADICIONADO:</span> {txt_esc}")
434
  resumo = f"**Resumo:** Rem={l_rem}, Add={l_add}, Saldo={l_add - l_rem}"
435
  crit_txt = "### 🚨 Mudanças Críticas:\n" + "\n".join(crit) if crit else "*Nenhuma mudança crítica detectada.*"
@@ -443,7 +444,11 @@ def calcular_progresso():
443
  for entry in HISTORICO:
444
  tipos.add(entry["tipo_peticao"])
445
  m = re.search(r"Nota Final:?\s*\**(\d{1,2}[,.]\d{1}|\d{1,2})\s*/\s*10", entry["analise_formatada"], re.I)
446
- if m: try: notas.append(float(m.group(1).replace(",", "."))) except ValueError: pass
 
 
 
 
447
  tot = len(HISTORICO); media = sum(notas)/len(notas) if notas else 0
448
  tend = ""
449
  if len(notas) > 1: tend = "⬆️" if notas[-1] > notas[-2] else ("⬇️" if notas[-1] < notas[-2] else "↔️")
 
420
  kw_add = ["custas", "art. 319", "art. 337", "art. 1022", "art. 1015", "art. 300", "fumus", "periculum", "essencial", "preliminar", "tempestividade", "cabimento"]
421
  for linha in diff:
422
  txt = linha[2:]; txt_esc = escape(txt)
423
+ if linha.startswith(' '):
424
+ res_html.append(f"<div class='linha-igual'>{txt_esc}</div>")
425
  elif linha.startswith('- '):
426
  l_rem += 1
427
  res_html.append(f"<div class='linha-removida'><del>{txt_esc}</del></div>")
428
+ if txt.strip() and any(kw in txt.lower() for kw in kw_rem):
429
  crit.append(f"<span style='color:red'>🔴 REMOVIDO:</span> {txt_esc}")
430
  elif linha.startswith('+ '):
431
  l_add += 1
432
  res_html.append(f"<div class='linha-adicionada'><ins>{txt_esc}</ins></div>")
433
+ if txt.strip() and any(kw in txt.lower() for kw in kw_add):
434
  crit.append(f"<span style='color:green'>🟢 ADICIONADO:</span> {txt_esc}")
435
  resumo = f"**Resumo:** Rem={l_rem}, Add={l_add}, Saldo={l_add - l_rem}"
436
  crit_txt = "### 🚨 Mudanças Críticas:\n" + "\n".join(crit) if crit else "*Nenhuma mudança crítica detectada.*"
 
444
  for entry in HISTORICO:
445
  tipos.add(entry["tipo_peticao"])
446
  m = re.search(r"Nota Final:?\s*\**(\d{1,2}[,.]\d{1}|\d{1,2})\s*/\s*10", entry["analise_formatada"], re.I)
447
+ if m:
448
+ try: # CORRIGIDO: try/except em bloco separado
449
+ notas.append(float(m.group(1).replace(",", ".")))
450
+ except ValueError:
451
+ pass # Ignora se não conseguir converter a nota
452
  tot = len(HISTORICO); media = sum(notas)/len(notas) if notas else 0
453
  tend = ""
454
  if len(notas) > 1: tend = "⬆️" if notas[-1] > notas[-2] else ("⬇️" if notas[-1] < notas[-2] else "↔️")