Index: babel/messages/frontend.py
===================================================================
--- babel/messages/frontend.py	(revision 361)
+++ babel/messages/frontend.py	(working copy)
@@ -33,8 +33,8 @@
 from babel import Locale, localedata
 from babel.core import UnknownLocaleError
 from babel.messages.catalog import Catalog
-from babel.messages.extract import extract_from_dir, DEFAULT_KEYWORDS, \
-                                   DEFAULT_MAPPING
+from babel.messages.extract import extract_from_dir, extract_from_file, \
+                                   DEFAULT_KEYWORDS, DEFAULT_MAPPING
 from babel.messages.mofile import write_mo
 from babel.messages.pofile import read_po, write_po
 from babel.messages.plurals import PLURALS
@@ -770,7 +770,8 @@
 
         :param argv: the command arguments
         """
-        parser = OptionParser(usage=self.usage % ('extract', 'dir1 <dir2> ...'),
+        parser = OptionParser(usage=self.usage % ('extract',
+                              'dir1/module1 <dir2/module2> ...'),
                               description=self.commands['extract'])
         parser.add_option('--charset', dest='charset',
                           help='charset to use in the output (default '
@@ -865,28 +866,37 @@
                               charset=options.charset)
 
             for dirname in args:
-                if not os.path.isdir(dirname):
-                    parser.error('%r is not a directory' % dirname)
+                if os.path.isdir(dirname):
+                    def callback(filename, method, options):
+                        if method == 'ignore':
+                            return
+                        filepath = os.path.normpath(os.path.join(dirname,
+                                                    filename))
+                        optstr = ''
+                        if options:
+                            optstr = ' (%s)' % ', '.join(
+                                ['%s="%s"' % (k, v) for k, v
+                                in options.items()])
+                        self.log.info('extracting messages from %s%s',
+                                      filepath, optstr)
 
-                def callback(filename, method, options):
-                    if method == 'ignore':
-                        return
-                    filepath = os.path.normpath(os.path.join(dirname, filename))
-                    optstr = ''
-                    if options:
-                        optstr = ' (%s)' % ', '.join(['%s="%s"' % (k, v) for
-                                                      k, v in options.items()])
-                    self.log.info('extracting messages from %s%s', filepath,
-                                  optstr)
+                    extracted = extract_from_dir(dirname, method_map,
+                                                 options_map, keywords,
+                                                 options.comment_tags,
+                                                 callback=callback)
+                    for filename, lineno, message, comments in extracted:
+                        filepath = os.path.normpath(os.path.join(dirname,
+                            filename))
+                        catalog.add(message, None, [(filepath, lineno)],
+                                    auto_comments=comments)
+                else:
+                    extracted = extract_from_file(
+                        'python', dirname, keywords, options.comment_tags)
+                    for lineno, message, comments in extracted:
+                        filepath = os.path.normpath(dirname)
+                        catalog.add(message, None, [(filepath, lineno)],
+                                    auto_comments=comments)
 
-                extracted = extract_from_dir(dirname, method_map, options_map,
-                                             keywords, options.comment_tags,
-                                             callback=callback)
-                for filename, lineno, message, comments in extracted:
-                    filepath = os.path.normpath(os.path.join(dirname, filename))
-                    catalog.add(message, None, [(filepath, lineno)],
-                                auto_comments=comments)
-
             if options.output not in (None, '-'):
                 self.log.info('writing PO template file to %s' % options.output)
             write_po(outfile, catalog, width=options.width,

