Ticket #6290: profanepatch.2.diff

File profanepatch.2.diff, 1.1 KB (added by Jeff Anderson, 17 years ago)

Initial patch - typo fix

  • django/contrib/humanize/templatetags/humanize.py

    from django import template  
    44from django.template import defaultfilters
    55from django.conf import settings
    66from datetime import date, timedelta
    7 from random import randint
    87import re
    98
    109register = template.Library()
    def naturalday(value, arg=None):  
    9998        return _(u'yesterday')
    10099    return defaultfilters.date(value, arg)
    101100register.filter(naturalday)
    102 
    103 def profanity(value, arg='star'):
    104         """Removes profane words and replaces them with ***"""
    105         BADWORDS = settings.PROFANITIES_LIST
    106         for word in BADWORDS:
    107                 rePattern = r"\b(" + word + r")\b"
    108                 reg = re.compile(rePattern)
    109                 if (arg == 'symbol'):
    110                         symbols = ('@','!','*','#','^','*','@','!','#','@','!')
    111                         clean = ''
    112                         while len( clean) < len( word ):
    113                                 clean = clean + symbols[randint(0,len(symbols)-1)]
    114                 else:
    115                         clean = '*'
    116                         while len( clean ) < len( word ):
    117                                 clean = clean + clean
    118                 value = reg.sub(clean, value)
    119         return value
    120 register.filter(profanity)
Back to Top