Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
run: powrap --check --quiet **/*.po
- name: Pospell
run: |
python scripts/create_dict.py
pospell -p dict.txt -l es_ES **/*.po
python scripts/check_spell.py
- name: Construir documentación
run: PYTHONWARNINGS=ignore::FutureWarning sphinx-build -j auto -W --keep-going -b html -d cpython/Doc/_build/doctree -D language=es . cpython/Doc/_build/html
3 changes: 1 addition & 2 deletions .overrides/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ pospell. Pospell puede ser instalada en tu entorno de Python empleando pip
Una vez instalado, para chequear el fichero .po sobre el que estás trabajando,
ejecuta desde el directorio principal del repo::

python scripts/create_dict.py # para crear el archivo 'dict.txt'
pospell -p dict.txt -l es_ES path/tu_fichero.po
python scripts/check_spell.py path/tu_fichero.po

pospell emplea la herramienta de diccionarios hunspell. Si pospell falla dando
como error que no tiene hunspell instalado, lo puedes instalar así:
Expand Down
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ repos:
- id: powrap
- repo: local
hooks:
- id: merge-dicts
name: merge-dicts
entry: python ./scripts/create_dict.py
- id: check-spell
name: Check spelling
entry: python ./scripts/check_spell.py
language: python
# This one requires package ``hunspell-es_es`` in Archlinux
- repo: https://github.com/AFPy/pospell
rev: v1.1
hooks:
- id: pospell
args: ['--personal-dict', 'dict.txt', '--language', 'es_ES', '--language', 'es_AR']
additional_dependencies: ['pospell>=1.1']
files: \.po$
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ progress: venv

.PHONY: spell
spell: venv
$(VENV)/bin/python scripts/create_dict.py
$(VENV)/bin/pospell -p dict.txt -l es_ES **/*.po
$(VENV)/bin/python scripts/check_spell.py


.PHONY: wrap
Expand Down
35 changes: 35 additions & 0 deletions scripts/check_spell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Script to check the spelling of one, many or all .po files based
on the custom dictionaries under the 'dictionaries/' directory.
"""

from pathlib import Path
import sys
import tempfile

import pospell

# Read custom dictionaries
entries = set()
for filename in Path("dictionaries").glob("*.txt"):
with open(filename, "r") as f:
entries.update(
stripped_line
for stripped_line in (line.strip() for line in f.readlines())
if stripped_line
)

# Write merged dictionary file
output_filename = tempfile.mktemp(suffix="_merged_dict.txt")
with open(output_filename, "w") as f:
for e in entries:
f.write(e)
f.write("\n")

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

errors = pospell.spell_check(po_files, personal_dict=output_filename, language="es_ES")
sys.exit(0 if errors == 0 else -1)
33 changes: 0 additions & 33 deletions scripts/create_dict.py

This file was deleted.