]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Added an early failure for non existing data
authorArmin Ronacher <armin.ronacher@active-4.com>
Wed, 24 Jul 2013 09:43:08 +0000 (11:43 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Wed, 24 Jul 2013 09:43:08 +0000 (11:43 +0200)
babel/core.py

index 5b02a1b7bb69643ec33e74e191f45abc19192eeb..034c35b1703d595826fd1693641f7fc6be6d4c57 100644 (file)
@@ -24,6 +24,15 @@ __all__ = ['UnknownLocaleError', 'Locale', 'default_locale', 'negotiate_locale',
 
 _global_data = None
 
+
+def _raise_no_data_error():
+    raise RuntimeError('The babel data files are not available. '
+                       'This usually happens because you are using '
+                       'a source checkout from Babel and you did '
+                       'not build the data files.  Just make sure '
+                       'to run "python setup.py import_cldr" before '
+                       'installing the library.')
+
 def get_global(key):
     """Return the dictionary for the given key in the global data.
 
@@ -44,6 +53,8 @@ def get_global(key):
     if _global_data is None:
         dirname = os.path.join(os.path.dirname(__file__))
         filename = os.path.join(dirname, 'global.dat')
+        if not os.path.isfile(filename):
+            _raise_no_data_error()
         fileobj = open(filename, 'rb')
         try:
             _global_data = pickle.load(fileobj)