diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | scripts/download_import_cldr.py | 47 |
2 files changed, 48 insertions, 0 deletions
@@ -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 0000000..6195d4a --- /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() |