From: Armin Ronacher Date: Wed, 24 Jul 2013 09:43:08 +0000 (+0200) Subject: Added an early failure for non existing data X-Git-Tag: 1.0~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8f42be4f633bb0f56cc48d23aa74ce70df8eb14;p=thirdparty%2Fbabel.git Added an early failure for non existing data --- diff --git a/babel/core.py b/babel/core.py index 5b02a1b7..034c35b1 100644 --- a/babel/core.py +++ b/babel/core.py @@ -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)