-
-
Notifications
You must be signed in to change notification settings - Fork 403
Expand file tree
/
Copy pathcreate_issue.py
More file actions
63 lines (46 loc) · 2.08 KB
/
create_issue.py
File metadata and controls
63 lines (46 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Use together with `pageviews.py`
# python scripts/pageviews.py | head -n 150 | grep -v whats | cut -d ' ' -f 2 | sed 's/\.html/\.po/g' | xargs -I '{}' python scripts/create_issue.py '{}'
import os
import sys
from pathlib import Path
from github import Github
from potodo._po_file import PoFileStats
if len(sys.argv) != 2:
print('Specify PO filename')
sys.exit(1)
pofilename = sys.argv[1]
pofile = PoFileStats(Path(pofilename))
g = Github(os.environ.get('GITHUB_TOKEN'))
repo = g.get_repo('python/python-docs-es')
issues = repo.get_issues(state='all')
for issue in issues:
if pofilename in issue.title:
print(f'Skipping {pofilename}. There is a similar issue already created at {issue.html_url}')
sys.exit(1)
msg = f'There is a similar issue already created at {issue.html_url}.\nDo you want to create it anyways? [y/N] '
answer = input(msg)
if answer != 'y':
sys.exit(1)
if any([
pofile.translated_nb == pofile.po_file_size,
pofile.untranslated_nb == 0,
]):
print(f'Skipping {pofilename}. The file is 100% translated already.')
sys.exit(1)
# https://pygithub.readthedocs.io/en/latest/github_objects/Repository.html#github.Repository.Repository.create_issue
title = f'Translate `{pofilename}`'
urlfile = pofilename.replace('.po', '.html')
issue = repo.create_issue(
title=title,
body=f'''This needs to reach 100% translated.
The rendered version of this file will be available at https://docs.python.org/es/3.8/{urlfile} once translated.
Meanwhile, the English version is shown.
Current stats for `{pofilename}`:
- Fuzzy: {pofile.fuzzy_nb}
- Percent translated: {pofile.percent_translated}%
- Entries: {pofile.translated_nb} / {pofile.po_file_size}
- Untranslated: {pofile.untranslated_nb}
Please, comment here if you want this file to be assigned to you and a member will assign it to you as soon as possible, so you can start working on it.
Remember to follow the steps in our [Contributing Guide](https://python-docs-es.readthedocs.io/page/CONTRIBUTING.html).''',
)
print(f'Issue "{title}" created at {issue.html_url}')