def handle(self, *args, **options):
        self.options = options

        # go through each dmp_enabled app and compile its mako templates
        for app_config in get_dmp_apps():
            self.compile_mako_files(app_config)

        # add any extra xgettext_options (the regular makemessages doesn't do this, and I need to include other aliases like _(), _z(), etc.
        for opt in options.get('extra_gettext_option', []):
           self.xgettext_options.append(opt)

        # call the superclass command
        return MakeMessagesCommand.handle(self, *args, **options)
Esempio n. 2
0
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,
        )
Esempio n. 3
0
    def handle(self, *args, **options):
        dmp = apps.get_app_config('django_mako_plus')
        self.options = options
        if self.options.get('template_dir', []):
            self.SEARCH_DIRS = []
            for subdir in self.options.get('template_dir', []):
                self.SEARCH_DIRS.append(os.path.join('{app_path}', subdir))

        # go through each dmp_enabled app and compile its mako templates
        for app_config in dmp.get_registered_apps():
            self.compile_mako_files(app_config)

        # add any extra xgettext_options (the regular makemessages doesn't do this, and I need to include other aliases like _(), _z(), etc.
        for opt in options.get('extra_gettext_option', []):
           self.xgettext_options.append(opt)

        # call the superclass command
        return MakeMessagesCommand.handle(self, *args, **options)
Esempio n. 4
0
    def test_makemessages_find_files(self):
        """
        find_files only discover files having the proper extensions.
        """
        cmd = MakeMessagesCommand()
        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 = {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 = {os.path.splitext(tfile.file)[1] for tfile in found_files}
        self.assertEqual(found_exts.difference({'.js'}), set())
    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())
Esempio n. 6
0
    def test_makemessages_find_files(self):
        """
        find_files only discover files having the proper extensions.
        """
        cmd = MakeMessagesCommand()
        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 = {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 = {os.path.splitext(tfile.file)[1] for tfile in found_files}
        self.assertEqual(found_exts.difference({".js"}), set())
Esempio n. 7
0
    def test_makemessages_find_files(self):
        """
        Test that find_files only discover files having the proper extensions.
        """
        cmd = MakeMessagesCommand()
        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())