diff options
author | Alex Morega <alex@grep.ro> | 2013-07-03 16:28:59 +0200 |
---|---|---|
committer | Alex Morega <alex@grep.ro> | 2013-07-03 16:34:27 +0200 |
commit | b46315d74919a7486705b88b167643c7f222ea8b (patch) | |
tree | dba9c49f387accabf46fa2c6be4888c0168163c1 /scripts/download_import_cldr.py | |
parent | 5ba4f47c4b38ee6ce08b1f32a9eb8d46eebf2f09 (diff) | |
download | babel-b46315d74919a7486705b88b167643c7f222ea8b.tar.gz |
script to download and import cldr
Diffstat (limited to 'scripts/download_import_cldr.py')
-rwxr-xr-x | scripts/download_import_cldr.py | 47 |
1 files changed, 47 insertions, 0 deletions
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() |