def test_makemessages_find_files(self): """ Test that find_files only discover files having the proper extensions. """ from django.core.management.commands.makemessages import Command cmd = Command() cmd.ignore_patterns = ['CVS', '.*', '*~', '*.pyc'] cmd.symlinks = False cmd.domain = 'django' cmd.extensions = ['html', 'txt', 'py'] cmd.verbosity = 0 cmd.locale_paths = [] cmd.default_locale_path = os.path.join(self.test_dir, 'locale') found_files = cmd.find_files(self.test_dir) found_exts = set( [os.path.splitext(tfile.file)[1] for tfile in found_files]) self.assertEqual(found_exts.difference({'.py', '.html', '.txt'}), set()) cmd.extensions = ['js'] cmd.domain = 'djangojs' found_files = cmd.find_files(self.test_dir) found_exts = set( [os.path.splitext(tfile.file)[1] for tfile in found_files]) self.assertEqual(found_exts.difference({'.js'}), set())
def makemessages(ctx, locale='en'): """Create .po files for every supervisr app""" setup() from django.core.management.commands.makemessages import Command from supervisr.core.utils import get_apps, LogOutputWrapper # Returns list of app starting with supervisr for app in get_apps(exclude=[]): # Get apps.py file from class app_file = inspect.getfile(app.__class__) # Get app basedir and change to it app_basedir = os.path.dirname(app_file) os.chdir(app_basedir) # Create locale dir in case it doesnt exist os.makedirs('locale', exist_ok=True) LOGGER.info("Building %s", app.__class__.__name__) builder = Command(stdout=LogOutputWrapper()) builder.handle( verbosity=1, settings=None, pythonpath=None, traceback=None, no_color=False, locale=locale.split(','), exclude=[], domain='django', all=False, extensions=None, symlinks=False, ignore_patterns=[], use_default_ignore_patterns=True, no_wrap=False, no_location=False, add_location=None, no_obsolete=False, keep_pot=False, )