diff --git a/.gitignore b/.gitignore index 6d4d663d..78c4fbf3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ venv/ .potodo/ locales/ .venv/ +.envrc diff --git a/.scripts/line-length.py b/.scripts/line-length.py new file mode 100644 index 00000000..b4ac21f4 --- /dev/null +++ b/.scripts/line-length.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +"""Measure line length in given files, run as: + + python line-length.py *.po + +It does not count zero-width caracters from the Mn Unicode category +(Nonspacing Mark). + +It returns 0 on success, 1 on failure. +""" + +from unicodedata import category +import fileinput +import sys + +SOFT_LIMIT = 80 # used for splitables lines (with spaces in them) +HARD_LIMIT = 88 # used for non-splitables lines (without spaces in them) + + +def clean(line): + return "".join(char for char in line if category(char) != "Mn").rstrip("\n") + + +return_code = 0 + +for line in fileinput.input(encoding="utf-8"): + line = clean(line) + limit = SOFT_LIMIT if line.count(" ") > 1 else HARD_LIMIT + if len(line) > limit: + print( + f"{fileinput.filename()}:{fileinput.filelineno()} line too long " + f"({len(line)} > {limit} characters)", + file=sys.stderr, + ) + return_code = 1 + + +sys.exit(return_code) diff --git a/merge.py b/.scripts/merge.py similarity index 100% rename from merge.py rename to .scripts/merge.py diff --git a/.woodpecker.yml b/.woodpecker.yml index 2fda5eff..8c96fd07 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -4,7 +4,10 @@ pipeline: test: image: python commands: + - apt-get update + - apt-get install -y hunspell hunspell-fr-comprehensive - python3 -m pip install -r requirements.txt - - sphinx-lint --enable all --disable line-too-long *.po */*.po - - pospell -p dict -l fr_FR *.po */*.po - - awk '{if (length(gensub(/శ్రీనివాస్/, ".", "g", $$0)) > 80 && length(gensub(/[^ ]/, "", "g")) > 1) {print FILENAME ":" FNR, "line too long:", $$0; ERRORS+=1}} END {if (ERRORS>0) {exit 1}}' *.po */*.po + - BRANCH="$(grep ^BRANCH Makefile | awk '{print $3}')" + - git fetch origin --no-tags +refs/heads/$BRANCH + - git branch $BRANCH origin/$BRANCH + - make verifs diff --git a/Makefile b/Makefile index 1357145a..6042da54 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ else endif .PHONY: all -all: ensure_prerequisites +all: ensure_build_prerequisites git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT) || (git -C venv/cpython fetch && git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT)) mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/ $(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/ @@ -108,13 +108,22 @@ venv/cpython/.git/HEAD: git clone https://github.com/python/cpython venv/cpython -.PHONY: ensure_prerequisites -ensure_prerequisites: venv/cpython/.git/HEAD +.PHONY: ensure_test_prerequisites +ensure_test_prerequisites: + @if ! (pospell --help >/dev/null 2>&1 && potodo --help >/dev/null 2>&1); then \ + echo "You're missing dependencies please install:"; \ + echo ""; \ + echo " python -m pip install -r requirements.txt"; \ + exit 1; \ + fi + +.PHONY: ensure_build_prerequisites +ensure_build_prerequisites: venv/cpython/.git/HEAD @if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \ git -C venv/cpython/ checkout $(BRANCH); \ echo "You're missing dependencies please install:"; \ echo ""; \ - echo " python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \ + echo " python -m pip install -r venv/cpython/Doc/requirements.txt"; \ exit 1; \ fi @@ -123,11 +132,11 @@ htmlview: MODE=htmlview htmlview: all .PHONY: todo -todo: ensure_prerequisites +todo: ensure_test_prerequisites potodo --api-url 'https://git.afpy.org/api/v1/repos/AFPy/python-docs-fr/issues?state=open&type=issues' --exclude venv .venv $(EXCLUDED) .PHONY: wrap -wrap: ensure_prerequisites +wrap: ensure_test_prerequisites @echo "Re wrapping modified files" powrap -m @@ -136,15 +145,15 @@ SRCS = $(shell git diff --name-only $(BRANCH) | grep '.po$$') DESTS = $(addprefix $(POSPELL_TMP_DIR)/,$(addsuffix .out,$(SRCS))) .PHONY: spell -spell: ensure_prerequisites $(DESTS) +spell: ensure_test_prerequisites $(DESTS) .PHONY: line-length line-length: @echo "Searching for long lines..." - @awk '{if (length(gensub(/శ్రీనివాస్/, ".", "g", $$0)) > 80 && length(gensub(/[^ ]/, "", "g")) > 1) {print FILENAME ":" FNR, "line too long:", $$0; ERRORS+=1}} END {if (ERRORS>0) {exit 1}}' *.po */*.po + @python .scripts/line-length.py *.po */*.po .PHONY: sphinx-lint -sphinx-lint: +sphinx-lint: ensure_test_prerequisites @echo "Checking all files using sphinx-lint..." @sphinx-lint --enable all --disable line-too-long *.po */*.po @@ -154,7 +163,7 @@ $(POSPELL_TMP_DIR)/%.po.out: %.po dict pospell -p dict -l fr_FR $< && touch $@ .PHONY: fuzzy -fuzzy: ensure_prerequisites +fuzzy: ensure_test_prerequisites potodo --only-fuzzy --api-url 'https://git.afpy.org/api/v1/repos/AFPy/python-docs-fr/issues?state=open&type=issues' --exclude venv .venv $(EXCLUDED) .PHONY: check-headers diff --git a/howto/regex.po b/howto/regex.po index b4163780..eca54de9 100644 --- a/howto/regex.po +++ b/howto/regex.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Python 3\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-01-15 22:33+0100\n" -"PO-Revision-Date: 2022-12-16 21:12+0100\n" +"PO-Revision-Date: 2023-03-28 11:09+0200\n" "Last-Translator: Nabil Bendafi \n" "Language-Team: FRENCH \n" "Language: fr\n" @@ -1762,7 +1762,7 @@ msgid "" "substitutions." msgstr "" "Les renvois tels que celui-ci ne sont pas très utiles pour effectuer une " -"simple recherche dans une chaîne —­ il n'y a que peu de formats de textes qui " +"simple recherche dans une chaîne — il n'y a que peu de formats de textes qui " "répètent des données ainsi — mais vous verrez bientôt qu'ils sont *très* " "utiles pour effectuer des substitutions dans les chaînes." diff --git a/library/os.po b/library/os.po index b31ca706..2cc7fb56 100644 --- a/library/os.po +++ b/library/os.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Python 3\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-01-15 22:33+0100\n" -"PO-Revision-Date: 2023-02-09 12:25+0100\n" +"PO-Revision-Date: 2023-03-28 11:15+0200\n" "Last-Translator: Mathieu Dupuy \n" "Language-Team: FRENCH \n" "Language: fr\n" @@ -2372,7 +2372,7 @@ msgstr "" "répertoire, et le chemin sur lequel opérer devrait être relatif. Le chemin " "est donc relatif à ce répertoire. Si le chemin est absolu, *dir_fd* est " "ignoré (pour les systèmes POSIX, Python appelle la version avec un suffixe " -"``at`` et potentiellement préfixée avec ``f`` ­— par exemple ``faccessat`` au " +"``at`` et potentiellement préfixée avec ``f`` — par exemple ``faccessat`` au " "lieu de ``access``)." #: library/os.rst:1733