diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index ae6b72e946e..93add45ca47 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -251,7 +251,7 @@ class Command(BaseCommand): exts = extensions if extensions else ['js'] else: exts = extensions if extensions else ['html', 'txt', 'py'] - self.extensions = handle_extensions(exts, ignored=()) + self.extensions = handle_extensions(exts) if (locale is None and not exclude and not process_all) or self.domain is None: raise CommandError("Type '%s help %s' for usage information." % ( diff --git a/django/core/management/templates.py b/django/core/management/templates.py index d514c84755d..d088ca974ab 100644 --- a/django/core/management/templates.py +++ b/django/core/management/templates.py @@ -85,8 +85,7 @@ class TemplateCommand(BaseCommand): raise CommandError("Destination directory '%s' does not " "exist, please create it first." % top_dir) - extensions = tuple( - handle_extensions(options['extensions'], ignored=())) + extensions = tuple(handle_extensions(options['extensions'])) extra_files = [] for file in options['files']: extra_files.extend(map(lambda x: x.strip(), file.split(','))) diff --git a/django/core/management/utils.py b/django/core/management/utils.py index f9effe7192b..7a823424a69 100644 --- a/django/core/management/utils.py +++ b/django/core/management/utils.py @@ -32,19 +32,16 @@ def popen_wrapper(args, os_err_exc_type=CommandError): ) -def handle_extensions(extensions=('html',), ignored=('py',)): +def handle_extensions(extensions): """ Organizes multiple extensions that are separated with commas or passed by - using --extension/-e multiple times. Note that the .py extension is ignored - here because of the way non-*.py files are handled in make_messages() (they - are copied to file.ext.py files to trick xgettext to parse them as Python - files). + using --extension/-e multiple times. For example: running 'django-admin makemessages -e js,txt -e xhtml -a' would result in an extension list: ['.js', '.txt', '.xhtml'] >>> handle_extensions(['.html', 'html,js,py,py,py,.py', 'py,.py']) - {'.html', '.js'} + {'.html', '.js', '.py'} >>> handle_extensions(['.html, txt,.tpl']) {'.html', '.tpl', '.txt'} """ @@ -54,7 +51,7 @@ def handle_extensions(extensions=('html',), ignored=('py',)): for i, ext in enumerate(ext_list): if not ext.startswith('.'): ext_list[i] = '.%s' % ext_list[i] - return set(x for x in ext_list if x.strip('.') not in ignored) + return set(ext_list) def find_command(cmd, path=None, pathext=None):