コード例 #1
0
    def handle_noargs(self, *args, **options):
        locale = options.get('locale')
        domain = options.get('domain')
        verbosity = int(options.get('verbosity'))
        process_all = options.get('all')
        extensions = options.get('extensions')
        symlinks = options.get('symlinks')
        ignore_patterns = options.get('ignore_patterns')
        if options.get('use_default_ignore_patterns'):
            ignore_patterns += ['CVS', '.*', '*~']
        ignore_patterns = list(set(ignore_patterns))
        no_wrap = options.get('no_wrap')
        no_location = options.get('no_location')
        no_obsolete = options.get('no_obsolete')
        if domain == 'djangojs':
            exts = extensions if extensions else ['js']
        else:
            exts = extensions if extensions else ['html', 'txt']
        extensions = handle_extensions(exts)

        if verbosity > 1:
            self.stdout.write('examining files with the extensions: %s\n'
                             % get_text_list(list(extensions), 'and'))

        make_messages(locale, domain, verbosity, process_all, extensions,
            symlinks, ignore_patterns, no_wrap, no_location, no_obsolete, self.stdout)
コード例 #2
0
ファイル: models.py プロジェクト: timothyclemans/djangocg
 def get_unique_error_message(self, unique_check):
     if len(unique_check) == 1:
         return ugettext("Please correct the duplicate data for %(field)s.") % {
             "field": unique_check[0],
         }
     else:
         return ugettext("Please correct the duplicate data for %(field)s, "
             "which must be unique.") % {
                 "field": get_text_list(unique_check, six.text_type(_("and"))),
             }
コード例 #3
0
ファイル: tests.py プロジェクト: timothyclemans/djangocg
 def test_get_text_list(self):
     self.assertEqual(get_text_list(['a', 'b', 'c', 'd']), 'a, b, c or d')
     self.assertEqual(get_text_list(['a', 'b', 'c'], 'and'), 'a, b and c')
     self.assertEqual(get_text_list(['a', 'b'], 'and'), 'a and b')
     self.assertEqual(get_text_list(['a']), 'a')
     self.assertEqual(get_text_list([]), '')
     with override('ar'):
         self.assertEqual(get_text_list(['a', 'b', 'c']), "a، b أو c")
コード例 #4
0
ファイル: forms.py プロジェクト: timothyclemans/djangocg
 def clean_comment(self):
     """
     If COMMENTS_ALLOW_PROFANITIES is False, check that the comment doesn't
     contain anything in PROFANITIES_LIST.
     """
     comment = self.cleaned_data["comment"]
     if settings.COMMENTS_ALLOW_PROFANITIES == False:
         bad_words = [w for w in settings.PROFANITIES_LIST if w in comment.lower()]
         if bad_words:
             raise forms.ValidationError(ungettext(
                 "Watch your mouth! The word %s is not allowed here.",
                 "Watch your mouth! The words %s are not allowed here.",
                 len(bad_words)) % get_text_list(
                     ['"%s%s%s"' % (i[0], '-'*(len(i)-2), i[-1])
                      for i in bad_words], ugettext('and')))
     return comment
コード例 #5
0
ファイル: base.py プロジェクト: timothyclemans/djangocg
    def unique_error_message(self, model_class, unique_check):
        opts = model_class._meta
        model_name = capfirst(opts.verbose_name)

        # A unique field
        if len(unique_check) == 1:
            field_name = unique_check[0]
            field = opts.get_field(field_name)
            field_label = capfirst(field.verbose_name)
            # Insert the error into the error dict, very sneaky
            return field.error_messages["unique"] % {
                "model_name": six.text_type(model_name),
                "field_label": six.text_type(field_label),
            }
        # unique_together
        else:
            field_labels = [capfirst(opts.get_field(f).verbose_name) for f in unique_check]
            field_labels = get_text_list(field_labels, _("and"))
            return _("%(model_name)s with this %(field_label)s already exists.") % {
                "model_name": six.text_type(model_name),
                "field_label": six.text_type(field_labels),
            }
コード例 #6
0
ファイル: base.py プロジェクト: timothyclemans/djangocg
 def invalid_block_tag(self, token, command, parse_until=None):
     if parse_until:
         raise self.error(token, "Invalid block tag: '%s', expected %s" %
             (command, get_text_list(["'%s'" % p for p in parse_until])))
     raise self.error(token, "Invalid block tag: '%s'" % command)