From 9c00068386332d6e31741e7411f971ad088b2801 Mon Sep 17 00:00:00 2001 From: Christopher Grebs Date: Sun, 20 Apr 2014 18:27:08 +0200 Subject: [PATCH] Fix some pep8 errors --- django_babel/extract.py | 14 +++++++++--- django_babel/management/commands/babel.py | 28 +++++++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/django_babel/extract.py b/django_babel/extract.py index d23011d..a2bb571 100644 --- a/django_babel/extract.py +++ b/django_babel/extract.py @@ -35,10 +35,18 @@ def extract_django(fileobj, keywords, comment_tags, options): pluralmatch = plural_re.match(t.contents) if endbmatch: if inplural: - yield lineno, 'ngettext', (smart_unicode(u''.join(singular)), - smart_unicode(u''.join(plural))), [] + yield ( + lineno, + 'ngettext', + (smart_unicode(u''.join(singular)), + smart_unicode(u''.join(plural))), + []) else: - yield lineno, None, smart_unicode(u''.join(singular)), [] + yield ( + lineno, + None, + smart_unicode(u''.join(singular)), + []) intrans = False inplural = False diff --git a/django_babel/management/commands/babel.py b/django_babel/management/commands/babel.py index 9a979ce..5d6914c 100644 --- a/django_babel/management/commands/babel.py +++ b/django_babel/management/commands/babel.py @@ -13,18 +13,24 @@ class Command(LabelCommand): args = '[makemessages] [compilemessages]' option_list = LabelCommand.option_list + ( - make_option('--locale', '-l', default=None, dest='locale', action='append', - help='Creates or updates the message files for the given locale(s) (e.g. pt_BR). ' - 'Can be used multiple times.'), - make_option('--domain', '-d', default='django', dest='domain', + make_option( + '--locale', '-l', + default=None, dest='locale', action='append', + help='Creates or updates the message files for the given locale(s)' + ' (e.g pt_BR). Can be used multiple times.'), + make_option('--domain', '-d', + default='django', dest='domain', help='The domain of the message files (default: "django").'), - make_option('--mapping-file', '-F', default=None, dest='mapping_file', + make_option('--mapping-file', '-F', + default=None, dest='mapping_file', help='Mapping file') ) def handle_label(self, command, **options): if command not in ('makemessages', 'compilemessages'): - raise CommandError("You must either apply 'makemessages' or 'compilemessages'") + raise CommandError( + "You must either apply 'makemessages' or 'compilemessages'" + ) if command == 'makemessages': self.handle_makemessages(**options) @@ -42,7 +48,8 @@ class Command(LabelCommand): distribution.parse_config_files(distribution.find_config_files()) mapping_file = options.pop('mapping_file', None) - if mapping_file is None and 'extract_messages' in distribution.command_options: + has_extract = 'extract_messages' in distribution.command_options + if mapping_file is None and has_extract: opts = distribution.command_options['extract_messages'] try: mapping_file = opts['mapping_file'][1] @@ -77,7 +84,10 @@ class Command(LabelCommand): for path in locale_paths: for locale in locales: - po_file = os.path.join(path, locale, 'LC_MESSAGES', domain + '.po') + po_file = os.path.join( + path, locale, 'LC_MESSAGES', domain + '.po' + ) if os.path.exists(po_file): - cmd = ['pybabel', 'compile', '-D', domain, '-d', path, '-l', locale] + cmd = ['pybabel', 'compile', '-D', domain, + '-d', path, '-l', locale] call(cmd)