@@ -13,18 +13,24 @@ class Command(LabelCommand):
13
13
args = '[makemessages] [compilemessages]'
14
14
15
15
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' ,
20
23
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' ,
22
26
help = 'Mapping file' )
23
27
)
24
28
25
29
def handle_label (self , command , ** options ):
26
30
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
+ )
28
34
29
35
if command == 'makemessages' :
30
36
self .handle_makemessages (** options )
@@ -42,7 +48,8 @@ def handle_makemessages(self, **options):
42
48
distribution .parse_config_files (distribution .find_config_files ())
43
49
44
50
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 :
46
53
opts = distribution .command_options ['extract_messages' ]
47
54
try :
48
55
mapping_file = opts ['mapping_file' ][1 ]
@@ -77,7 +84,10 @@ def handle_compilemessages(self, **options):
77
84
78
85
for path in locale_paths :
79
86
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
+ )
81
90
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 ]
83
93
call (cmd )
0 commit comments