forked from pychess/pychess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translators.py
executable file
·44 lines (34 loc) · 1.32 KB
/
translators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import collections
#############################
# Configuration starts here #
#############################
FILENAME = 'TRANSLATORS'
POOLSIZE = 7
###########################
# Configuration ends here #
###########################
from multiprocessing import Pool
import re
from pychess.compat import urlopen
print("Getting data from Rosetta Launchpad...")
data = urlopen('http://translations.launchpad.net/pychess/trunk/+translations').read()
langs = sorted(re.findall('/pychess/trunk/\+pots/pychess/(.*?)/\+translate', data))
def findContributors(lang):
site = "https://translations.launchpad.net/pychess/trunk/+pots/pychess/%s/+translate" % lang
data = urlopen(site).read()
language = re.findall("<h1>Browsing (.*?) translation</h1>", data)[0]
start = data.find('Contributors to this translation')
pers = re.findall('class="sprite person">(.*?)</a>', data[start:])
print("Did", language)
return [language, pers]
with open(FILENAME,'w') as file:
pool = Pool(POOLSIZE)
contributors = pool.map(findContributors, langs)
for lang, (language, pers) in zip(langs, contributors):
print("[%s] %s" % (lang, language), file=file)
for per in pers:
print(" " + per, file=file)
print(file=file)