8000 dummy; by rtobar · Pull Request #3 · rtobar/python-docs-es · GitHub
[go: up one dir, main page]

Skip to content

dummy; #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on Git 8000 Hub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
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
45 changes: 45 additions & 0 deletions .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Agrega comentario a PR

on:
pull_request_target:

jobs:
pr-comment:
name: Entradas sin traducción
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
persist-credentials: false
- name: Preparar Python v3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- name: Instalar dependencias
run: |
python -m pip install -r requirements.txt
- name: Obtiene lista de archivos con cambios
id: changed-files
uses: tj-actions/changed-files@v39
with:
files: |
**/*.po
- name: Calcular entradas faltantes
if: steps.changed-files.outputs.any_changed == 'true'
id: create-pr-comment
env:
CHANGED_PO_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
{
echo 'comment<<EOF'
python scripts/list_missing_entries.py --github $CHANGED_PO_FILES
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Agregar comentario con entradas faltantes
if: steps.changed-files.outputs.any_changed == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
message: ${{ steps.create-pr-comment.outputs.comment }}
comment_tag: missing-entries
8 changes: 3 additions & 5 deletions library/filecmp.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ msgstr ""
"PO-Revision-Date: 2020-09-27 12:59-0400\n"
"Last-Translator: Enrique Giménez <fenriquegimenez@gmail.com>\n"
"Language: es_PY\n"
"Language-Team: Enrique Giménez\n"
"Language-Team: Enrique Giménez y yo\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
Expand Down Expand Up @@ -145,7 +145,6 @@ msgid "The :class:`dircmp` class"
msgstr "La clase :class:`dircmp`"

#: ../Doc/library/filecmp.rst:75
#, fuzzy
msgid ""
"Construct a new directory comparison object, to compare the directories *a* "
"and *b*. *ignore* is a list of names to ignore, and defaults to :const:"
Expand All @@ -154,7 +153,7 @@ msgid ""
msgstr ""
"Construye un nuevo objeto de comparación de directorio, para comparar los "
"directorios *a* y *b*. *ignore* es una lista de nombres a ignorar, y "
"predetermina a :attr:`filecmp.DEFAULT_IGNORES`. *hide* es una lista de "
"predetermina a :const:`filecmp.DEFAULT_IGNORES`. *hide* es una lista de "
"nombres a ocultar, y predetermina a ``[os.curdir, os.pardir]``."

#: ../Doc/library/filecmp.rst:80
Expand Down Expand Up @@ -198,13 +197,12 @@ msgstr ""
"árboles de directorio que están siendo comparados."

#: ../Doc/library/filecmp.rst:103
#, fuzzy
msgid ""
"Note that via :meth:`~object.__getattr__` hooks, all attributes are computed "
"lazily, so there is no speed penalty if only those attributes which are "
"lightweight to compute are used."
msgstr ""
"Note que vía los hooks :meth:`__getattr__`, todos los atributos son "
"Note que vía los hooks :meth:`~object.__getattr__`, todos los atributos son "
"perezosamente computados, así que no hay penalización de velocidad si sólo "
"esos atributos que son ligeros de computar son utilizados."

Expand Down
55 changes: 55 additions & 0 deletions scripts/list_missing_entries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import argparse
import dataclasses
import enum
import glob
import itertools
import os

import polib
import tabulate


class MissingReason(enum.StrEnum):
FUZZY = "fuzzy"
UNTRANSLATED = "untranslated"

@staticmethod
def from_poentry(poentry: polib.POEntry):
if poentry.fuzzy:
return MissingReason.FUZZY
assert not poentry.translated()
return MissingReason.UNTRANSLATED

@dataclasses.dataclass
class MissingEntry:
reason: MissingReason
file: str
line: int

@staticmethod
def from_poentry(pofilename: str, poentry: polib.POEntry) -> "MissingEntry":
return MissingEntry(MissingReason.from_poentry(poentry), pofilename, poentry.linenum)


def find_missing_entries(filename: str) -> list[MissingEntry]:
po = polib.pofile(filename)
fuzzy = po.fuzzy_entries()
untranslated = po.untranslated_entries()
return [MissingEntry.from_poentry(filename, entry) for entry in fuzzy + untranslated]

def main():
parser = argparse.ArgumentParser()
parser.add_argument("files", nargs="+")
parser.add_argument("-g", "--github-mode", help="Produce output as a GitHub comment", action='store_true')
opts = parser.parse_args()
missing_entries = list(itertools.chain.from_iterable(map(find_missing_entries, opts.files)))
if not missing_entries:
print(f"All entries translated, horray!{' :tada:' if opts.github_mode else ''}")
else:
missing_entries.sort(key = lambda entry: (entry.file, entry.line))
print("Entries missing translation, details follow:\n")
print(tabulate.tabulate(missing_entries,headers=["Reason", "File", "Line"], tablefmt="github"))


if __name__ == "__main__":
main()
0