Loading django/core/management/commands/makemessages.py +1 −24 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from subprocess import PIPE, Popen import django from django.core.management.base import CommandError, NoArgsCommand from django.core.management.utils import handle_extensions from django.utils.functional import total_ordering from django.utils.text import get_text_list from django.utils.jslex import prepare_js_for_gettext Loading Loading @@ -130,30 +131,6 @@ def write_pot_file(potfile, msgs): with open(potfile, 'a') as fp: fp.write(msgs) def handle_extensions(extensions=('html',), ignored=('py',)): """ 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). 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']) set(['.html', '.js']) >>> handle_extensions(['.html, txt,.tpl']) set(['.html', '.tpl', '.txt']) """ ext_list = [] for ext in extensions: ext_list.extend(ext.replace(' ', '').split(',')) 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]) class Command(NoArgsCommand): option_list = NoArgsCommand.option_list + ( Loading django/core/management/templates.py +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ from django.template import Template, Context from django.utils import archive from django.utils._os import rmtree_errorhandler from django.core.management.base import BaseCommand, CommandError from django.core.management.commands.makemessages import handle_extensions from django.core.management.utils import handle_extensions _drive_re = re.compile('^([a-z]):', re.I) Loading django/core/management/utils.py +24 −0 Original line number Diff line number Diff line Loading @@ -12,3 +12,27 @@ def popen_wrapper(args): close_fds=os.name != 'nt', universal_newlines=True) output, errors = p.communicate() return output, errors, p.returncode def handle_extensions(extensions=('html',), ignored=('py',)): """ 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). 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']) set(['.html', '.js']) >>> handle_extensions(['.html, txt,.tpl']) set(['.html', '.tpl', '.txt']) """ ext_list = [] for ext in extensions: ext_list.extend(ext.replace(' ', '').split(',')) 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]) Loading
django/core/management/commands/makemessages.py +1 −24 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from subprocess import PIPE, Popen import django from django.core.management.base import CommandError, NoArgsCommand from django.core.management.utils import handle_extensions from django.utils.functional import total_ordering from django.utils.text import get_text_list from django.utils.jslex import prepare_js_for_gettext Loading Loading @@ -130,30 +131,6 @@ def write_pot_file(potfile, msgs): with open(potfile, 'a') as fp: fp.write(msgs) def handle_extensions(extensions=('html',), ignored=('py',)): """ 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). 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']) set(['.html', '.js']) >>> handle_extensions(['.html, txt,.tpl']) set(['.html', '.tpl', '.txt']) """ ext_list = [] for ext in extensions: ext_list.extend(ext.replace(' ', '').split(',')) 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]) class Command(NoArgsCommand): option_list = NoArgsCommand.option_list + ( Loading
django/core/management/templates.py +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ from django.template import Template, Context from django.utils import archive from django.utils._os import rmtree_errorhandler from django.core.management.base import BaseCommand, CommandError from django.core.management.commands.makemessages import handle_extensions from django.core.management.utils import handle_extensions _drive_re = re.compile('^([a-z]):', re.I) Loading
django/core/management/utils.py +24 −0 Original line number Diff line number Diff line Loading @@ -12,3 +12,27 @@ def popen_wrapper(args): close_fds=os.name != 'nt', universal_newlines=True) output, errors = p.communicate() return output, errors, p.returncode def handle_extensions(extensions=('html',), ignored=('py',)): """ 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). 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']) set(['.html', '.js']) >>> handle_extensions(['.html, txt,.tpl']) set(['.html', '.tpl', '.txt']) """ ext_list = [] for ext in extensions: ext_list.extend(ext.replace(' ', '').split(',')) 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])