afpy / padpo Goto Github PK
View Code? Open in Web Editor NEWLinter for gettext files (*.po)
License: BSD 3-Clause "New" or "Revised" License
Linter for gettext files (*.po)
License: BSD 3-Clause "New" or "Revised" License
<NBSP>:<space>::
is OK but padpo tells some problem about NBSP
Logs are hard to read:
I think they should be narrower and maybe with less colors, at least no background color. why not sticking to gcc-style errors, as an example:
2019-12-12 21:27:53,569 [ERROR ] pofile.py(153):display_warnings :: distutils/apiref.po: 618 [ NBSP ] There should be a non-breakable space before ":": between ###ralement exactement un symbole ### and ###: « init + nom_de_l'extension »###
2019-12-12 21:27:54,937 [WARNING ] pofile.py(156):display_warnings :: faq/library.po: 938 [ Grammalecte ] Unknown word "CGI" in ###mment reproduire un envoi de formulaire CGI (« METHOD###
2019-12-12 21:27:58,011 [WARNING ] pofile.py(156):display_warnings :: faq/programming.po: 72 [ Double space ] Double spaces detected between ###s développés sans *PythonWin*.### and ###*PythonWin* est disponible dan###
2019-12-12 21:27:58,026 [WARNING ] pofile.py(156):display_warnings :: faq/programming.po:1979 [ Grammalecte ] Pour le “t” euphonique, il faut deux traits d’union. Pas d’apostrophe. Pas d’espace. => ###Pourquoi « a_tuple[i] += ['item'] » lève-t'il une exc###
2019-12-12 21:27:58,812 [WARNING ] pofile.py(156):display_warnings :: faq/windows.po: 354 [ Grammalecte ] Unknown word "DLL" in ###avez « pas » besoin de créer un fichier DLL, et cela ###
Could be more readable as:
distutils/apiref.po:618: error: There should be a non-breakable space before ":": between ###ralement exactement un symbole ### and ###: « init + nom_de_l'extension »###
faq/library.po:938: warning: Unknown word "CGI" in ###mment reproduire un envoi de formulaire CGI (« METHOD###
faq/programming.po:72: warning: Double spaces detected between ###s développés sans *PythonWin*.### and ###*PythonWin* est disponible dan###
faq/programming.po:1979: warning: Pour le “t” euphonique, il faut deux traits d’union. Pas d’apostrophe. Pas d’espace. => ###Pourquoi « a_tuple[i] += ['item'] » lève-t'il une exc###
faq/windows.po:354: warning: Unknown word "DLL" in ###avez « pas » besoin de créer un fichier DLL, et cela ###
Note that in github the wide version is so wide we have literally no relevant information in the screen :(
Bonus: By sticking to gcc error format we could easily use padpo in vim/emacs :]
padpo -p 1059
fails:
padpo -p 1059
Traceback (most recent call last):
File "/home/vincent/Documents/programmation/padpo/venv/bin/padpo", line 11, in <module>
load_entry_point('padpo', 'console_scripts', 'padpo')()
File "/home/vincent/Documents/programmation/padpo/padpo/padpo.py", line 115, in main
pull_request_info = pull_request_files(pull_request)
File "/home/vincent/Documents/programmation/padpo/padpo/github.py", line 59, in pull_request_files
pr.add_file(filename, temp_file, fileinfo["patch"])
KeyError: 'patch'
A huge file may have no patch in GitHub API response.
Any idea why grammalecte is not on PyPI? it would be nice so we can package padpo with grammalecte as an install dependency.
the https://github.com/AFPy/padpo/blob/master/tests/po_without_warnings/abc.po file is not compliant with po file format
Do not emit a warning for double spaces, according to the decision made in python/python-docs-fr#1113
Ca serait ouf que padpo fasse des suggestions dans github automatiquement, en tant que bot même, sans avoir a le lancer (genre un cron ou un bot comme miss-illington)
#: ../Doc/howto/unicode.rst:344
msgid ""
"The syntax is inspired by Emacs's notation for specifying variables local to "
"a file. Emacs supports many different variables, but Python only supports "
"'coding'. The ``-*-`` symbols indicate to Emacs that the comment is "
"special; they have no significance to Python but are a convention. Python "
"looks for ``coding: name`` or ``coding=name`` in the comment."
msgstr ""
"La syntaxe s'inspire de la notation d'*Emacs* pour spécifier les variables "
"locales à un fichier. *Emacs* supporte de nombreuses variables différentes, "
"mais Python ne gère que *coding*. Les symboles ``-*-`` indiquent à *Emacs* "
"que le commentaire est spécial ; ils n'ont aucune signification pour Python "
"mais sont une convention. Python cherche ``coding: name`` ou "
"``coding=name`` dans le commentaire."
2019-12-13 16:29:00,094 [WARNING ] pofile.py(156):display_warnings :: howto/unicode.po: 615 [ Grammalecte ] Incohérence : l’espace insécable à côté de l’espace sécable n’a pas d’effet. => ###ing ». Les symboles « -« - » indiquent à »Emacs* qu###
(python-docs-i18n) ➜ python-docs-fr git:(3.8) pip install --upgrade pip padpo potodo pospell powrap
Looking in indexes: https://pypi.python.org/simple, https://pypi.apple.com/simple
Requirement already up-to-date: pip in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (19.3.1)
Collecting padpo
Downloading https://files.pythonhosted.org/packages/cc/78/34e0096714a5412acccb78c92fff709dbd1c599f901596a000da15c7edee/padpo-0.3.0-py3-none-any.whl
Requirement already up-to-date: potodo in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (0.0.9)
Requirement already up-to-date: pospell in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (1.0.3)
Requirement already up-to-date: powrap in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (0.3.0)
Collecting wheel
Using cached https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl
Collecting simplelogging
Using cached https://files.pythonhosted.org/packages/63/00/e173efe1df19b62a599b2c543245fc01976ce7cdc2c32f6d16c1288b8fd6/simplelogging-0.10.0-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: requests in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from padpo) (2.21.0)
Requirement already satisfied, skipping upgrade: polib in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from potodo) (1.1.0)
Requirement already satisfied, skipping upgrade: regex in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from pospell) (2019.8.19)
Requirement already satisfied, skipping upgrade: docutils>=0.11 in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from pospell) (0.14)
Requirement already satisfied, skipping upgrade: tqdm in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from powrap) (4.36.1)
Collecting colorlog==4.0.2
Using cached https://files.pythonhosted.org/packages/68/4d/892728b0c14547224f0ac40884e722a3d00cb54e7a146aea0b3186806c9e/colorlog-4.0.2-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from requests->padpo) (2018.11.29)
Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from requests->padpo) (1.24.1)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from requests->padpo) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages (from requests->padpo) (2.8)
Installing collected packages: wheel, colorlog, simplelogging, padpo
Successfully installed colorlog-4.0.2 padpo-0.3.0 simplelogging-0.10.0 wheel-0.33.6
(python-docs-i18n) ➜ python-docs-fr git:(3.8) padpo
Traceback (most recent call last):
File "/Users/seluj78/.venvs/python-docs-i18n/bin/padpo", line 8, in <module>
sys.exit(main())
File "/Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages/padpo/padpo.py", line 522, in main
path, pull_request_info = pull_request_files(pull_request)
File "/Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages/padpo/padpo.py", line 458, in pull_request_files
request.raise_for_status()
File "/Users/seluj78/.venvs/python-docs-i18n/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.github.com/repos//files
(python-docs-i18n) ➜ python-docs-fr git:(3.8)
Tried padpo v0.11 today on my laptop, got:
$ padpo -i *.po
<frozen importlib._bootstrap>:1049: ImportWarning: VendorImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:673: ImportWarning: VendorImporter.exec_module() not found; falling back to load_module()
<frozen importlib._bootstrap>:1049: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:673: ImportWarning: _SixMetaPathImporter.exec_module() not found; falling back to load_module()
/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/pkg_resources/_vendor/pyparsing.py:87: DeprecationWarning: module 'sre_constants' is deprecated
import sre_constants
<frozen importlib._bootstrap>:1049: ImportWarning: VendorImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: VendorImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: VendorImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: VendorImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:1049: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
Traceback (most recent call last):
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/pygrammalecte/pygrammalecte.py", line 108, in grammalecte_file
result = _run_grammalecte(filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/pygrammalecte/pygrammalecte.py", line 139, in _run_grammalecte
return subprocess.run(
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'grammalecte-cli.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mdk/clones/python/python-docs-fr/.venv/bin/padpo", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/padpo/padpo.py", line 131, in main
errors, warnings = check_paths(path, pull_request_info=pull_request_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/padpo/padpo.py", line 54, in check_paths
errors, warnings = check_path(path, pull_request_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/padpo/padpo.py", line 46, in check_path
return check_file(path, pull_request_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/padpo/padpo.py", line 23, in check_file
checker.check_file(pofile)
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/padpo/checkers/grammalecte.py", line 40, in check_file
self.manage_warnings(warnings, pofile)
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/padpo/checkers/grammalecte.py", line 48, in manage_warnings
for warning in warnings:
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/pygrammalecte/pygrammalecte.py", line 97, in grammalecte_text
yield from grammalecte_file(tmpfile)
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/pygrammalecte/pygrammalecte.py", line 112, in grammalecte_file
_install_grammalecte()
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/pygrammalecte/pygrammalecte.py", line 163, in _install_grammalecte
download_request.raise_for_status()
File "/home/mdk/clones/python/python-docs-fr/.venv/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://grammalecte.net/grammalecte/zip/Grammalecte-fr-v1.12.0.zip
padpo/padpo/checkers/grammalecte.py
Line 103 in 429ef81
get_personal_dict
is run at startup, and fetches https://raw.githubusercontent.com/python/python-docs-fr/3.9/dict (c.f. https://github.com/python/python-docs-fr/blob/3.9/dict ) which
a) should be cached somewhere and not refetched at startup every time, and
b) should be configurable to assist using with other projects (i.e. not python-docs-fr) or other languages
Words ending with _
are internal links in rst, it raises a false positive, like in https://travis-ci.org/python/python-docs-fr/builds/624345482:
2019-12-12 21:24:48,786 [WARNING ] pofile.py(156):display_warnings :: library/argparse.po: 936 [ Grammalecte ] Unknown word "choices_" in ###Voir le chapitre choices_ pour plus###
Would be nice in a CI also, like:
padpo -i *.po
see travis result for python/python-docs-fr#1117
padpo -p 1015
library/re.po:1321 [ Grammalecte ] Guillemets typographiques ouvrants. => ###s ASCII et aux 4 caractères non ASCII : 'İ' (« U+01###
Do you see any other subjects?
Would enjoy a padpo --version
for our CI.
Padpo, on the fake-docs
repository, takes about 5 minutes and a half to complete :/ How can it be sped up ?
https://github.com/PyDocTeur/fake-docs/pull/18/checks?check_run_id=1493393281
Suite à la discussion sur python/python-docs-fr#978, il pourrait être intéressant d'appliquer en automatique les corrections dont on est sûr.
padpo implements its own parser of .po files and entries.
The idea is to enable the translator to tell padpo that he deliberately knows there is a false positive. The translator would do it in writing a pragma in the "translator comment" field.
The way padpo parses the .po file does not enable this feature.
I would recommend to use the polib library which give access to "translator comment" field.
As said in python/python-docs-fr#1059
#: ../Doc/reference/expressions.rst:1427
msgid ""
"``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that "
"comparisons for singletons should always be done with ``is`` or ``is not``, "
"never the equality operators."
msgstr ""
"``None`` et ``NotImplemented`` sont des singletons. :PEP:`8` conseille de "
"toujours comparer les singletons en utilisant soit ``is`` soit ``is not``, "
"jamais les autres opérateurs."
2019-12-12 11:20:14,289 [ERROR ] pofile.py(153):display_warnings :: reference/expressions.po:2148 [ NBSP ] There should be a non-breakable space before ":": between ###emented » sont des singletons. ### and ###:PEP:`8` conseille de toujours ###
Dependabot couldn't authenticate with https://pypi.python.org/simple/.
You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.
https://github.com/vpoulailleau/padpo/blob/82604c068cf57b398dec048c8e37484081b2086c/padpo.py#L83
Est tu sur que cette liste est complète ?
2019-12-01 23:30:04,425 [ERROR ] padpo.py(147):display_warnings :: using/windows.po:2453 [ NBSP ] There should be a non-breakable space before ":": between ###cf. `Cygwin package source <ftp### and ###://ftp.uni-erlangen.de/pub/pc/g###
found using padpo on using/windows.po
(obviously on python-docs-fr).
This does not looks like a good idea, and it's wrong: setuptools is not a runtime dependency of your project, just a dependency of your build system.
It's also not nice as it could conflict with pip itself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.