Skip to content
Merged
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
21 changes: 18 additions & 3 deletions scripts/create_issue.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}`:
Expand All @@ -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}')
18 changes: 18 additions & 0 deletions scripts/pageviews.py
Original file line number Diff line number Diff line change
@@ -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:])