pytho****@googl*****
pytho****@googl*****
2012年 11月 26日 (月) 00:08:37 JST
Revision: ca2bf169ffd7 Branch: default Author: "INADA Naoki <songo****@gmail*****> Date: Sun Nov 25 07:08:16 2012 Log: Faster po download http://code.google.com/p/python-doc-ja/source/detail?r=ca2bf169ffd7&repo=py33 Modified: /locale/pavement.py ======================================= --- /locale/pavement.py Sun Nov 25 02:38:52 2012 +++ /locale/pavement.py Sun Nov 25 07:08:16 2012 @@ -2,6 +2,7 @@ from paver.easy import * from txclib.project import Project +import requests @task def update_pot(): @@ -26,9 +27,29 @@ proj.save() sh("tx push -s -len") + @task -def download(): - sh("tx pull -f -l ja") + @ consume_args +def download(args): + proj = Project() + host = proj.config.get('main', 'host') + username = proj.txrc.get(host, 'username') + password = proj.txrc.get(host, 'password') + auth = requests.auth.HTTPBasicAuth(username, password) + url_ = 'https://www.transifex.com/api/2/project/python-doc-ja/resource/%s/translation/ja/?file' + + for section in proj.config.sections(): + if section == 'main': + continue + filename = proj.config.get(section, 'file_filter') + filename = filename.replace('<lang>', 'ja') + resource = section.split('.', 1)[1] + url = url_ % resource + response = requests.get(url, auth=auth) + response.raise_for_status() + print(filename, url) + with open(filename, 'wb') as f: + f.write(response.content) @task def compile():