]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
resort to hard-coded message extractors/checkers if pkg_resources is installed but...
authorFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Thu, 9 Aug 2012 11:20:25 +0000 (11:20 +0000)
committerFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Thu, 9 Aug 2012 11:20:25 +0000 (11:20 +0000)
ChangeLog
babel/messages/checkers.py
babel/messages/extract.py

index 299dd921875bfb9bd53a039a731839d440a8ba8b..9fd2e8c06c8bcb4db13dd08bc577a96bdbc035de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,8 @@ http://svn.edgewall.org/repos/babel/tags/1.0.0/
  * no warnings when running setup.py without installed setuptools (#262)
  * modified Locale.__eq__ method so Locales are only equal if all of their
    attributes (language, territory, script, variant) are equal
+ * resort to hard-coded message extractors/checkers if pkg_resources is 
+   installed but no egg-info was found (#230)
 
 
 Version 0.9.6
index fd3f6941cf936312facbff1063e63e2eda911285..2b8fa4fa12a726946e2703f5abbee4ec3601624c 100644 (file)
@@ -160,13 +160,18 @@ def _validate_format(format, alternative):
 
 
 def _find_checkers():
+    checkers = []
     try:
         from pkg_resources import working_set
     except ImportError:
+        pass
+    else:
+        for entry_point in working_set.iter_entry_points('babel.checkers'):
+            checkers.append(entry_point.load())
+    if len(checkers) == 0:
+        # if pkg_resources is not available or no usable egg-info was found
+        # (see #230), just resort to hard-coded checkers
         return [num_plurals, python_format]
-    checkers = []
-    for entry_point in working_set.iter_entry_points('babel.checkers'):
-        checkers.append(entry_point.load())
     return checkers
 
 
index d0fba801f24ecbc4860ac3395edb1cf36ff2657c..60612e7a6f5a63902eb8524e58efedf89ec2b656 100644 (file)
@@ -255,15 +255,18 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
         try:
             from pkg_resources import working_set
         except ImportError:
-            # pkg_resources is not available, so we resort to looking up the
-            # builtin extractors directly
-            builtin = {'ignore': extract_nothing, 'python': extract_python}
-            func = builtin.get(method)
+            pass
         else:
             for entry_point in working_set.iter_entry_points(GROUP_NAME,
                                                              method):
                 func = entry_point.load(require=True)
                 break
+        if func is None:
+            # if pkg_resources is not available or no usable egg-info was found
+            # (see #230), we resort to looking up the builtin extractors 
+            # directly
+            builtin = {'ignore': extract_nothing, 'python': extract_python}
+            func = builtin.get(method)
     if func is None:
         raise ValueError('Unknown extraction method %r' % method)