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
17 changes: 4 additions & 13 deletions contribute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pulling_from_transifex = ('zh-cn', 'pt-br', 'ja', 'uk', 'pl', 'ru', 'fa', 'id')
pulling_from_transifex: frozenset[str] = frozenset(
{'zh-cn', 'pt-br', 'ja', 'uk', 'pl', 'ru', 'fa', 'id'}
)

custom_contributing_links = {
custom_contributing_links: dict[str, str] = {
'es': 'https://python-docs-es.readthedocs.io/page/CONTRIBUTING.html',
'ko': 'https://www.flowdas.com/pages/python-docs-ko.html',
'zh-tw': 'https://github.com/python/python-docs-zh-tw/blob/3.13/README.rst#%E5%8F%83%E8%88%87%E7%BF%BB%E8%AD%AF',
Expand All @@ -21,14 +23,3 @@ def get_contrib_link(language: str, repo: str | None) -> str | None:
)
or (repo and f'https://github.com/{repo}')
)


if __name__ == '__main__':
for code, repo in (
('en', None),
('pl', None),
('ar', 'python/python-docs-ar'),
('zh-cn', None),
('id', None),
):
print(f'{code}: {get_contrib_link(code, repo)}')
45 changes: 45 additions & 0 deletions tests/test_contribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import unittest
import urllib3
import support

with support.import_scripts():
import contribute


class testContributeLink(unittest.TestCase):
def test_get_contrib_link(self):
PULL_FROM_TX = 'https://explore.transifex.com/python-doc/python-newest/'

for code, repo, expected in (
('en', None, None),
('pl', None, PULL_FROM_TX),
('ar', 'python/python-docs-ar', 'https://github.com/python/python-docs-ar'),
(
'zh-tw',
None,
'https://github.com/python/python-docs-zh-tw/blob/3.13/README.rst#%E5%8F%83%E8%88%87%E7%BF%BB%E8%AD%AF',
),
(
'id',
None,
'https://github.com/python/python-docs-id/blob/3.14/README.md#berkontribusi-untuk-menerjemahkan',
),
):
with self.subTest(code=code, repo=repo, expected=expected):
self.assertEqual(contribute.get_contrib_link(code, repo), expected)

def test_links_are_valid(self):
http = urllib3.PoolManager()
for lang, link in contribute.custom_contributing_links.items():
with self.subTest(lang=lang):
try:
r = http.request('HEAD', link, timeout=urllib3.Timeout(10.0))
self.assertTrue(
200 <= r.status < 400, f'{link} returned {r.status}'
)
except Exception as e:
self.fail(f'{link}: {e}')


if __name__ == '__main__':
unittest.main()
Loading