From: Alex Morega Date: Wed, 3 Jul 2013 14:28:59 +0000 (+0200) Subject: script to download and import cldr X-Git-Tag: 1.0~138^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b46315d74919a7486705b88b167643c7f222ea8b;p=thirdparty%2Fbabel.git script to download and import cldr --- diff --git a/.gitignore b/.gitignore index aeff7910..c9820fe9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ build dist .DS_Store .tox +babel/localedata/*.dat babel/messages/tests/data/project/i18n/long_messages.pot babel/messages/tests/data/project/i18n/temp.pot diff --git a/scripts/download_import_cldr.py b/scripts/download_import_cldr.py new file mode 100755 index 00000000..6195d4ad --- /dev/null +++ b/scripts/download_import_cldr.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import os +import sys +import shutil +import zipfile +import urllib +import subprocess + + +URL = 'http://unicode.org/Public/cldr/1.9.1/core.zip' +FILENAME = 'core-1.9.1.zip' +BLKSIZE = 131072 + + +def main(): + scripts_path = os.path.dirname(os.path.abspath(__file__)) + repo = os.path.dirname(scripts_path) + cldr_path = os.path.join(repo, 'cldr') + zip_path = os.path.join(cldr_path, FILENAME) + + if not os.path.isfile(zip_path): + with open(zip_path) as f: + conn = urllib.open(URL) + while True: + buf = conn.read(BLKSIZE) + if not buf: + break + f.write(buf) + conn.close() + + common_path = os.path.join(cldr_path, 'common') + if os.path.isdir(common_path): + shutil.rmtree(common_path) + + z = zipfile.ZipFile(zip_path) + z.extractall(cldr_path) + z.close() + + subprocess.check_call([ + sys.executable, + os.path.join(scripts_path, 'import_cldr.py'), + common_path]) + + +if __name__ == '__main__': + main()