@@ -218,7 +218,7 @@ class extract_messages(Command):
218218 'charset to use in the output file (default "utf-8")' ),
219219 ('keywords=' , 'k' ,
220220 'space-separated list of keywords to look for in addition to the '
221- 'defaults' ),
221+ 'defaults (may be repeated multiple times) ' ),
222222 ('no-default-keywords' , None ,
223223 'do not include the default keywords' ),
224224 ('mapping-file=' , 'F' ,
@@ -248,12 +248,12 @@ class extract_messages(Command):
248248 'set project version in output' ),
249249 ('add-comments=' , 'c' ,
250250 'place comment block with TAG (or those preceding keyword lines) in '
251- 'output file. Separate multiple TAGs with commas(,)' ),
251+ 'output file. Separate multiple TAGs with commas(,)' ), # TODO: Support repetition of this argument
252252 ('strip-comments' , None ,
253253 'strip the comment TAGs from the comments.' ),
254254 ('input-paths=' , None ,
255255 'files or directories that should be scanned for messages. Separate multiple '
256- 'files or directories with commas(,)' ),
256+ 'files or directories with commas(,)' ), # TODO: Support repetition of this argument
257257 ('input-dirs=' , None , # TODO (3.x): Remove me.
258258 'alias for input-paths (does allow files as well as directories).' ),
259259 ]
@@ -262,12 +262,11 @@ class extract_messages(Command):
262262 'sort-output' , 'sort-by-file' , 'strip-comments'
263263 ]
264264 as_args = 'input-paths'
265- multiple_value_options = ('add-comments' ,)
265+ multiple_value_options = ('add-comments' , 'keywords' )
266266
267267 def initialize_options (self ):
268268 self .charset = 'utf-8'
269- self .keywords = ''
270- self ._keywords = DEFAULT_KEYWORDS .copy ()
269+ self .keywords = None
271270 self .no_default_keywords = False
272271 self .mapping_file = None
273272 self .no_location = False
@@ -295,13 +294,19 @@ def finalize_options(self):
295294 'input-dirs and input-paths are mutually exclusive'
296295 )
297296
298- if self .no_default_keywords and not self .keywords :
297+ if self .no_default_keywords :
298+ keywords = {}
299+ else :
300+ keywords = DEFAULT_KEYWORDS .copy ()
301+
302+ for kwarg in (self .keywords or ()):
303+ keywords .update (parse_keywords (kwarg .split ()))
304+
305+ self .keywords = keywords
306+
307+ if not self .keywords :
299308 raise DistutilsOptionError ('you must specify new keywords if you '
300309 'disable the default ones' )
301- if self .no_default_keywords :
302- self ._keywords = {}
303- if self .keywords :
304- self ._keywords .update (parse_keywords (self .keywords .split ()))
305310
306311 if not self .output_file :
307312 raise DistutilsOptionError ('no output file specified' )
@@ -378,13 +383,13 @@ def callback(filename, method, options):
378383 current_dir = os .getcwd ()
379384 extracted = check_and_call_extract_file (
380385 path , method_map , options_map ,
381- callback , self ._keywords , self .add_comments ,
386+ callback , self .keywords , self .add_comments ,
382387 self .strip_comments , current_dir
383388 )
384389 else :
385390 extracted = extract_from_dir (
386391 path , method_map , options_map ,
387- keywords = self ._keywords ,
392+ keywords = self .keywords ,
388393 comment_tags = self .add_comments ,
389394 callback = callback ,
390395 strip_comment_tags = self .strip_comments
@@ -592,7 +597,7 @@ class update_catalog(Command):
592597 ('previous' , None ,
593598 'keep previous msgids of translated messages' )
594599 ]
595- boolean_options = ['ignore_obsolete ' , 'no_fuzzy_matching ' , 'previous' , 'update_header_comment ' ]
600+ boolean_options = ['no-wrap ' , 'ignore-obsolete ' , 'no-fuzzy-matching' , ' previous' , 'update-header-comment ' ]
596601
597602 def initialize_options (self ):
598603 self .domain = 'messages'
@@ -720,6 +725,8 @@ class CommandLineInterface(object):
720725 'update' : update_catalog ,
721726 }
722727
728+ log = None # Replaced on instance level
729+
723730 def run (self , argv = None ):
724731 """Main entry point of the command-line interface.
725732
@@ -768,7 +775,8 @@ def run(self, argv=None):
768775 if cmdname not in self .commands :
769776 self .parser .error ('unknown command "%s"' % cmdname )
770777
771- return self ._dispatch (cmdname , args [1 :])
778+ cmdinst = self ._configure_command (cmdname , args [1 :])
779+ return cmdinst .run ()
772780
773781 def _configure_logging (self , loglevel ):
774782 self .log = logging .getLogger ('babel' )
@@ -794,14 +802,15 @@ def _help(self):
794802 for name , description in commands :
795803 print (format % (name , description ))
796804
797- def _dispatch (self , cmdname , argv ):
805+ def _configure_command (self , cmdname , argv ):
798806 """
799807 :type cmdname: str
800808 :type argv: list[str]
801809 """
802810 cmdclass = self .command_classes [cmdname ]
803811 cmdinst = cmdclass ()
804- cmdinst .log = self .log # Use our logger, not distutils'.
812+ if self .log :
813+ cmdinst .log = self .log # Use our logger, not distutils'.
805814 assert isinstance (cmdinst , Command )
806815 cmdinst .initialize_options ()
807816
@@ -837,7 +846,7 @@ def _dispatch(self, cmdname, argv):
837846 except DistutilsOptionError as err :
838847 parser .error (str (err ))
839848
840- cmdinst . run ()
849+ return cmdinst
841850
842851
843852def main ():
0 commit comments