@@ -13,18 +13,24 @@ class Command(LabelCommand):
1313 args = '[makemessages] [compilemessages]'
1414
1515 option_list = LabelCommand .option_list + (
16- make_option ('--locale' , '-l' , default = None , dest = 'locale' , action = 'append' ,
17- help = 'Creates or updates the message files for the given locale(s) (e.g. pt_BR). '
18- 'Can be used multiple times.' ),
19- make_option ('--domain' , '-d' , default = 'django' , dest = 'domain' ,
16+ make_option (
17+ '--locale' , '-l' ,
18+ default = None , dest = 'locale' , action = 'append' ,
19+ help = 'Creates or updates the message files for the given locale(s)'
20+ ' (e.g pt_BR). Can be used multiple times.' ),
21+ make_option ('--domain' , '-d' ,
22+ default = 'django' , dest = 'domain' ,
2023 help = 'The domain of the message files (default: "django").' ),
21- make_option ('--mapping-file' , '-F' , default = None , dest = 'mapping_file' ,
24+ make_option ('--mapping-file' , '-F' ,
25+ default = None , dest = 'mapping_file' ,
2226 help = 'Mapping file' )
2327 )
2428
2529 def handle_label (self , command , ** options ):
2630 if command not in ('makemessages' , 'compilemessages' ):
27- raise CommandError ("You must either apply 'makemessages' or 'compilemessages'" )
31+ raise CommandError (
32+ "You must either apply 'makemessages' or 'compilemessages'"
33+ )
2834
2935 if command == 'makemessages' :
3036 self .handle_makemessages (** options )
@@ -42,7 +48,8 @@ def handle_makemessages(self, **options):
4248 distribution .parse_config_files (distribution .find_config_files ())
4349
4450 mapping_file = options .pop ('mapping_file' , None )
45- if mapping_file is None and 'extract_messages' in distribution .command_options :
51+ has_extract = 'extract_messages' in distribution .command_options
52+ if mapping_file is None and has_extract :
4653 opts = distribution .command_options ['extract_messages' ]
4754 try :
4855 mapping_file = opts ['mapping_file' ][1 ]
@@ -77,7 +84,10 @@ def handle_compilemessages(self, **options):
7784
7885 for path in locale_paths :
7986 for locale in locales :
80- po_file = os .path .join (path , locale , 'LC_MESSAGES' , domain + '.po' )
87+ po_file = os .path .join (
88+ path , locale , 'LC_MESSAGES' , domain + '.po'
89+ )
8190 if os .path .exists (po_file ):
82- cmd = ['pybabel' , 'compile' , '-D' , domain , '-d' , path , '-l' , locale ]
91+ cmd = ['pybabel' , 'compile' , '-D' , domain ,
92+ '-d' , path , '-l' , locale ]
8393 call (cmd )
0 commit comments