From ca0ceb5fbac54ddaddd054aa95718ca5a467da38 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Fri, 19 Jun 2020 12:09:48 +0200 Subject: [PATCH 1/4] Add more checks to avoid creating duplicated issues --- scripts/create_issue.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/create_issue.py b/scripts/create_issue.py index 16b5b1d575..d6eb0d849b 100644 --- a/scripts/create_issue.py +++ b/scripts/create_issue.py @@ -17,14 +17,25 @@ 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 issue = repo.create_issue( title=f'Translate `{pofilename}`', From 4c7d446375cbe1c60cd50d1cb7ae91a6b1ac4e25 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Fri, 19 Jun 2020 12:10:07 +0200 Subject: [PATCH 2/4] Script to parse page-requests.txt --- scripts/pageviews.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripts/pageviews.py 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:]) From e4564bb1b20e06dd74b4145dfd9c1950eaba3da6 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Fri, 19 Jun 2020 12:15:41 +0200 Subject: [PATCH 3/4] Usage comment --- scripts/create_issue.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/create_issue.py b/scripts/create_issue.py index d6eb0d849b..485453bfc7 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 From cc0603ce960f1a8d27e1ea7725e713800ebc7e53 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Fri, 19 Jun 2020 12:19:13 +0200 Subject: [PATCH 4/4] Show issue's title in the output --- scripts/create_issue.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/create_issue.py b/scripts/create_issue.py index 485453bfc7..5a42043dc8 100644 --- a/scripts/create_issue.py +++ b/scripts/create_issue.py @@ -40,8 +40,9 @@ 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}`: @@ -55,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}')