Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Agrega pequeñas mejores a check_spell.po
* Imprime mapeo de archivos sólo si hay errores
* Path.glob() produce un map en vez de una lista. Este map se consume en
  el primer loop (al crear los archivos temporales), después del cual no
  se pueden consumir más elementos. Esto quiere decir que, en caso de
  haber fallos de ortografía, el último for que imprime el mapeo entre
  archivos no imprimía nada, dado que el objecto map ya no entregaba
  resultados.
* Usa shutil para copiar de un archivo a otro.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar committed Oct 27, 2025
commit 2b0527905f5c851ff700f4a615065cef83a172d0
15 changes: 8 additions & 7 deletions scripts/check_spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

from pathlib import Path
import shutil
import sys
import tempfile

Expand Down Expand Up @@ -43,7 +44,7 @@ def check_spell(po_files=None):

# Run pospell either against all files or the file given on the command line
if not po_files:
po_files = Path(".").glob("*/*.po")
po_files = list(Path(".").glob("*/*.po"))

# Workaround issue #3324 FIXME
# It seems that all code snippets have line breaks '\n'. This causes the
Expand All @@ -52,10 +53,9 @@ def check_spell(po_files=None):
# Create temporary copies of the original files.
po_files_tmp = []
for po_file in po_files:
with open(tempfile.mktemp(), "w") as temp_file:
# Copy content of the .po file
with open(po_file, "r", encoding="utf-8") as f:
temp_file.write(f.read())
with open(tempfile.mktemp(), "wb") as temp_file:
with open(po_file, "rb") as original_file:
shutil.copyfileobj(original_file, temp_file)
po_files_tmp.append(temp_file.name)

# Don't translate probably code entries
Expand All @@ -66,8 +66,9 @@ def check_spell(po_files=None):
polib_temp_file.save()

detected_errors = pospell.spell_check(po_files_tmp, personal_dict=output_filename, language="es_ES")
for tmp, orig in zip(po_files_tmp, po_files):
print(tmp, " == ", orig)
if detected_errors:
for tmp, orig in zip(po_files_tmp, po_files):
print(tmp, " == ", orig)
return detected_errors


Expand Down
Loading