diff --git a/scripts/create_issue.py b/scripts/create_issue.py index 16b5b1d575..5a42043dc8 100644 --- a/scripts/create_issue.py +++ b/scripts/create_issue.py @@ -1,3 +1,6 @@ +# 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 @@ -17,17 +20,29 @@ repo = g.get_repo('PyCampES/python-docs-es') -issues = repo.get_issues(state='open') +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}`' issue = repo.create_issue( - title=f'Translate `{pofilename}`', + title=title, body=f'''This needs to reach 100% translated. Current stats for `{pofilename}`: @@ -41,4 +56,4 @@ Remember to follow the steps in our [Contributing Guide](https://python-docs-es.readthedocs.io/page/CONTRIBUTING.html).''', ) -print(f'Issue created at {issue.html_url}') +print(f'Issue "{title}" created at {issue.html_url}') diff --git a/scripts/pageviews.py b/scripts/pageviews.py new file mode 100644 index 0000000000..2288896794 --- /dev/null +++ b/scripts/pageviews.py @@ -0,0 +1,18 @@ +from pprint import pprint + +results = {} + +# page-requests-20200504-20200510.txt +# is a file containing stats from pageviews on the official Python documentation +# (including different versions and languages) +# 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 +pages = open('pageviews.txt').readlines()[:-1] +for p in pages: + count, key = int(p.split()[0]), p.split()[-1].strip() + if key in results: + results[key] += count + else: + results[key] = count + +for p in sorted(list(results.items()), key=lambda x: x[1], reverse=True)[50:100]: + print(p[1], p[0][1:])