]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
script to download and import cldr
authorAlex Morega <alex@grep.ro>
Wed, 3 Jul 2013 14:28:59 +0000 (16:28 +0200)
committerAlex Morega <alex@grep.ro>
Wed, 3 Jul 2013 14:34:27 +0000 (16:34 +0200)
.gitignore
scripts/download_import_cldr.py [new file with mode: 0755]

index aeff7910f880f4ad145354cc22213aa4b3d6161a..c9820fe9804dfd8f13374f7508c203d5a18031a6 100644 (file)
@@ -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 (executable)
index 0000000..6195d4a
--- /dev/null
@@ -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()