diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-17 20:08:00 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-17 20:08:00 +0200 |
commit | 3f5edf8ce97a493f5215d452a2a91f27cbe9bfbb (patch) | |
tree | 60bd92b9fdcb841ae0d059845f4af66b70f51cbd /pavement.py | |
parent | Paver task to compile PO files (diff) | |
download | pyload-3f5edf8ce97a493f5215d452a2a91f27cbe9bfbb.tar.xz |
improved build script a little
Diffstat (limited to 'pavement.py')
-rw-r--r-- | pavement.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/pavement.py b/pavement.py index 49b018246..2dbec0cf3 100644 --- a/pavement.py +++ b/pavement.py @@ -135,10 +135,9 @@ def generate_locale(): @cmdopts([ ('key=', 'k', 'api key') ]) -def upload_locale(options): +def upload_translations(options): """ Uploads the locale files to translation server """ tmp = path(mkdtemp()) - print tmp shutil.copy('locale/crowdin.yaml', tmp) os.mkdir(tmp / 'pyLoad') @@ -157,6 +156,8 @@ def upload_locale(options): shutil.rmtree(tmp) + print "Translations uploaded" + @task @cmdopts([ ('key=', 'k', 'api key') @@ -164,7 +165,6 @@ def upload_locale(options): def download_translations(options): """ Downloads the translated files from translation server """ tmp = path(mkdtemp()) - print tmp shutil.copy('locale/crowdin.yaml', tmp) os.mkdir(tmp / 'pyLoad') @@ -181,27 +181,29 @@ def download_translations(options): call(['crowdin-cli', '-c', config, 'download']) - shutil.rmtree('locale') - shutil.copytree(tmp + '/pyLoad', 'locale') - shutil.copy(tmp + '/crowdin.yaml', 'locale') + for language in (tmp / 'pyLoad').listdir(): + if not language.isdir(): + continue + + target = path('locale') / language.basename() + print "Copy language %s" % target + if target.exists(): + shutil.rmtree(target) + + shutil.copytree(language, target) shutil.rmtree(tmp) @task def compile_translations(): """ Compile PO files to MO """ - os.chdir('locale') - - languages = list() - for item in os.listdir('.'): - if os.path.isdir(item): - languages.append(item) - - for lang in languages: - for file in ('cli', 'core', 'plugins', 'setup'): - path = lang + '/LC_MESSAGES/' + file - call(['msgfmt', '-o', path + '.mo', path + '.po']) - os.remove(path + '.po') + for language in path('locale').listdir(): + if not language.isdir(): + continue + + for f in glob(language / 'LC_MESSAGES' / '*.po'): + print "Compiling %s" % f + call(['msgfmt', '-o', f.replace('.po', '.mo'), f]) @task def tests(): |