Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2b05279

Browse files
committed
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>
1 parentbe65505 commit2b05279

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎scripts/check_spell.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
frompathlibimportPath
7+
importshutil
78
importsys
89
importtempfile
910

@@ -43,7 +44,7 @@ def check_spell(po_files=None):
4344

4445
# Run pospell either against all files or the file given on the command line
4546
ifnotpo_files:
46-
po_files=Path(".").glob("*/*.po")
47+
po_files=list(Path(".").glob("*/*.po"))
4748

4849
# Workaround issue #3324 FIXME
4950
# It seems that all code snippets have line breaks '\n'. This causes the
@@ -52,10 +53,9 @@ def check_spell(po_files=None):
5253
# Create temporary copies of the original files.
5354
po_files_tmp= []
5455
forpo_fileinpo_files:
55-
withopen(tempfile.mktemp(),"w")astemp_file:
56-
# Copy content of the .po file
57-
withopen(po_file,"r",encoding="utf-8")asf:
58-
temp_file.write(f.read())
56+
withopen(tempfile.mktemp(),"wb")astemp_file:
57+
withopen(po_file,"rb")asoriginal_file:
58+
shutil.copyfileobj(original_file,temp_file)
5959
po_files_tmp.append(temp_file.name)
6060

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

6868
detected_errors=pospell.spell_check(po_files_tmp,personal_dict=output_filename,language="es_ES")
69-
fortmp,originzip(po_files_tmp,po_files):
70-
print(tmp," == ",orig)
69+
ifdetected_errors:
70+
fortmp,originzip(po_files_tmp,po_files):
71+
print(tmp," == ",orig)
7172
returndetected_errors
7273

7374

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp