From: Jakob Schnitzer Date: Thu, 28 Sep 2017 17:18:32 +0000 (+0200) Subject: Revert "Merge pull request #505 from wodo/pi_support" X-Git-Tag: v2.5.3~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fdda1fa34f20fe0feeebf35b29346e8c91b30f3;p=thirdparty%2Fbabel.git Revert "Merge pull request #505 from wodo/pi_support" This reverts commit 653e6d4f654f0f3cbce57054654e09c519b9e412, reversing changes made to 5f3b00854bbc6fa6a03e04ab572a609eebcc1f72. --- diff --git a/babel/core.py b/babel/core.py index df03b24a..5140f49d 100644 --- a/babel/core.py +++ b/babel/core.py @@ -68,7 +68,7 @@ def get_global(key): """ global _global_data if _global_data is None: - dirname = localedata.get_base_dir() + 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() diff --git a/babel/localedata.py b/babel/localedata.py index ae215478..0c94e49e 100644 --- a/babel/localedata.py +++ b/babel/localedata.py @@ -16,23 +16,13 @@ import os import threading from collections import MutableMapping from itertools import chain -import sys from babel._compat import pickle, string_types -def get_base_dir(): - if getattr(sys, 'frozen', False): - # we are running in a |PyInstaller| bundle - basedir = sys._MEIPASS - else: - # we are running in a normal Python environment - basedir = os.path.dirname(__file__) - return basedir - _cache = {} _cache_lock = threading.RLock() -_dirname = os.path.join(get_base_dir(), 'locale-data') +_dirname = os.path.join(os.path.dirname(__file__), 'locale-data') def normalize_locale(name): diff --git a/tests/test_localedata.py b/tests/test_localedata.py index 3599b215..6954d388 100644 --- a/tests/test_localedata.py +++ b/tests/test_localedata.py @@ -14,7 +14,6 @@ import unittest import random from operator import methodcaller -import sys from babel import localedata, numbers @@ -94,17 +93,6 @@ def test_mixedcased_locale(): methodcaller(random.choice(['lower', 'upper']))(c) for c in l]) assert localedata.exists(locale_id) - -def test_pi_support_frozen(monkeypatch): - monkeypatch.setattr(sys, '_MEIPASS', 'testdir', raising=False) - monkeypatch.setattr(sys, 'frozen', True, raising=False) - assert localedata.get_base_dir() == 'testdir' - - -def test_pi_support_not_frozen(): - assert not getattr(sys, 'frozen', False) - assert localedata.get_base_dir().endswith('babel') - def test_locale_argument_acceptance(): # Testing None input. normalized_locale = localedata.normalize_locale(None)