]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
fix 'input_dirs' option for setuptools integration (#232, initial patch by Étienne...
authorFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Thu, 23 Aug 2012 09:48:21 +0000 (09:48 +0000)
committerFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Thu, 23 Aug 2012 09:48:21 +0000 (09:48 +0000)
ChangeLog
babel/messages/frontend.py
babel/messages/tests/frontend.py

index 5c9cf1cef8b2112c435212ddeb4d138a15c11fd9..40de850a44f9f8ed9d0bb15a0eeae407f8ae2753 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,6 +55,8 @@ http://svn.edgewall.org/repos/babel/tags/1.0.0/
  * add babel.support.NullTranslations class similar to gettext.NullTranslations
    but with all of Babel's new *gettext methods (#277)
  * "init" and "update" commands support "--width" option (#284)
+ * fix 'input_dirs' option for setuptools integration (#232, initial patch by 
+   Étienne Bersac)
 
 
 Version 0.9.6
index f2f7603a9a1052ee8629de133d898467f9f033b9..41ef8939e5caa34ddf169105fb60f10f745590c7 100755 (executable)
@@ -23,6 +23,7 @@ from locale import getpreferredencoding
 import logging
 from optparse import OptionParser
 import os
+import re
 import shutil
 from StringIO import StringIO
 import sys
@@ -224,7 +225,8 @@ class extract_messages(Command):
         ('strip-comments', None,
          'strip the comment TAGs from the comments.'),
         ('input-dirs=', None,
-         'directories that should be scanned for messages'),
+         'directories that should be scanned for messages. Separate multiple '
+         'directories with commas(,)'),
     ]
     boolean_options = [
         'no-default-keywords', 'no-location', 'omit-header', 'no-wrap',
@@ -274,7 +276,9 @@ class extract_messages(Command):
             raise DistutilsOptionError("'--sort-output' and '--sort-by-file' "
                                        "are mutually exclusive")
 
-        if not self.input_dirs:
+        if self.input_dirs:
+            self.input_dirs = re.split(',\s*', self.input_dirs)
+        else:
             self.input_dirs = dict.fromkeys([k.split('.',1)[0]
                 for k in self.distribution.packages
             ]).keys()
index 48b2e6a9c8405758b1a5063645c9ab1c6a89ca8c..c5b8ba17405b05e0f060d63f34ac8d2c3afd3316 100644 (file)
@@ -28,6 +28,7 @@ from babel import __version__ as VERSION
 from babel.dates import format_datetime
 from babel.messages import frontend
 from babel.util import LOCALTZ
+from babel.messages.pofile import read_po
 
 
 this_dir = os.path.abspath(os.path.dirname(__file__))
@@ -108,6 +109,24 @@ class ExtractMessagesTestCase(unittest.TestCase):
         self.cmd.sort_by_file = True
         self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
 
+    def test_input_dirs_is_treated_as_list(self):
+        self.cmd.input_dirs = self.datadir
+        self.cmd.output_file = self._pot_file()
+        self.cmd.finalize_options()
+        self.cmd.run()
+        
+        catalog = read_po(open(self._pot_file(), 'U'))
+        msg = catalog.get('bar')
+        self.assertEqual(1, len(msg.locations))
+        self.assertTrue('file1.py' in msg.locations[0][0])
+
+    def test_input_dirs_handle_spaces_after_comma(self):
+        self.cmd.input_dirs = 'foo,  bar'
+        self.cmd.output_file = self._pot_file()
+        self.cmd.finalize_options()
+        
+        self.assertEqual(['foo', 'bar'], self.cmd.input_dirs)
+
     def test_extraction_with_default_mapping(self):
         self.cmd.copyright_holder = 'FooBar, Inc.'
         self.cmd.msgid_bugs_address = 'bugs.address@email.tld'