py33 / locale /

from __future__ import print_function

from paver.easy import *
from txclib.project import Project
import requests

def update_pot():
    proj = Project()
    conf = proj.config

    base = path('pot')
    for pot in base.walkfiles('*.pot'):
        # 'pot/whatsnew/3.3.pot' => 'whatsnew-3_3'
        relpath = base.relpathto(pot)
        name = relpath.stripext().replace('/', '-').replace('.', '_')

        resource = "python-doc-ja.33-" + name
        print("Updating ", name)
        if not conf.has_section(resource):
        conf.set(resource, 'source_lang', 'en')
        conf.set(resource, 'source_file', pot)
        conf.set(resource, 'file_filter', '<lang>/LC_MESSAGES/' + relpath.stripext() + '.po')
        conf.set(resource, 'type', 'PO')
    sh("tx push -s -len")

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_ = ''

    for section in proj.config.sections():
        if section == 'main':
        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)
        print(filename, url)
        with open(filename, 'wb') as f:

def compile():
    import polib
    base = path('ja')
    for po in base.walkfiles('*.po'):
        print("Compiling ", po)
        pofile = polib.pofile(po, encoding='utf-8')
        pofile.save_as_mofile(po.stripext() + '.mo')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.