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) |