Skip to content

Commit 82bf0f0

Browse files
authored
Merge pull request #416 from python/create-issues-by-pageviews
2 parents 8f1053a + cc0603c commit 82bf0f0

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

scripts/create_issue.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Use together with `pageviews.py`
2+
# 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 '{}'
3+
14
import os
25
import sys
36
from pathlib import Path
@@ -17,17 +20,29 @@
1720
repo = g.get_repo('PyCampES/python-docs-es')
1821

1922

20-
issues = repo.get_issues(state='open')
23+
issues = repo.get_issues(state='all')
2124
for issue in issues:
2225
if pofilename in issue.title:
26+
27+
print(f'Skipping {pofilename}. There is a similar issue already created at {issue.html_url}')
28+
sys.exit(1)
29+
2330
msg = f'There is a similar issue already created at {issue.html_url}.\nDo you want to create it anyways? [y/N] '
2431
answer = input(msg)
2532
if answer != 'y':
2633
sys.exit(1)
2734

35+
if any([
36+
pofile.translated_nb == pofile.po_file_size,
37+
pofile.untranslated_nb == 0,
38+
]):
39+
print(f'Skipping {pofilename}. The file is 100% translated already.')
40+
sys.exit(1)
41+
2842
# https://pygithub.readthedocs.io/en/latest/github_objects/Repository.html#github.Repository.Repository.create_issue
43+
title = f'Translate `{pofilename}`'
2944
issue = repo.create_issue(
30-
title=f'Translate `{pofilename}`',
45+
title=title,
3146
body=f'''This needs to reach 100% translated.
3247
3348
Current stats for `{pofilename}`:
@@ -41,4 +56,4 @@
4156
4257
Remember to follow the steps in our [Contributing Guide](https://python-docs-es.readthedocs.io/page/CONTRIBUTING.html).''',
4358
)
44-
print(f'Issue created at {issue.html_url}')
59+
print(f'Issue "{title}" created at {issue.html_url}')

scripts/pageviews.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pprint import pprint
2+
3+
results = {}
4+
5+
# page-requests-20200504-20200510.txt
6+
# is a file containing stats from pageviews on the official Python documentation
7+
# (including different versions and languages)
8+
# grep -E '\.html$' page-requests-20200504-20200510.txt | grep -v tutorial | sed 's/3\..\///g' | sed 's/3\///g' | sed 's/2\///g' > pageviews.txt
9+
pages = open('pageviews.txt').readlines()[:-1]
10+
for p in pages:
11+
count, key = int(p.split()[0]), p.split()[-1].strip()
12+
if key in results:
13+
results[key] += count
14+
else:
15+
results[key] = count
16+
17+
for p in sorted(list(results.items()), key=lambda x: x[1], reverse=True)[50:100]:
18+
print(p[1], p[0][1:])

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy