Skip to content

Commit 9c00068

Browse files
committed
Fix some pep8 errors
1 parent 179a56d commit 9c00068

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

django_babel/extract.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ def extract_django(fileobj, keywords, comment_tags, options):
3535
pluralmatch = plural_re.match(t.contents)
3636
if endbmatch:
3737
if inplural:
38-
yield lineno, 'ngettext', (smart_unicode(u''.join(singular)),
39-
smart_unicode(u''.join(plural))), []
38+
yield (
39+
lineno,
40+
'ngettext',
41+
(smart_unicode(u''.join(singular)),
42+
smart_unicode(u''.join(plural))),
43+
[])
4044
else:
41-
yield lineno, None, smart_unicode(u''.join(singular)), []
45+
yield (
46+
lineno,
47+
None,
48+
smart_unicode(u''.join(singular)),
49+
[])
4250

4351
intrans = False
4452
inplural = False

django_babel/management/commands/babel.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)