Introduce CleanChars filter

This commit is contained in:
Florent 2014-03-18 16:23:51 +01:00
commit 081d4f32f0

View file

@ -168,6 +168,21 @@ class Attr(_Filter):
def __call__(self, item):
return item.use_selector(getattr(item, 'obj_%s' % self.name))
class CleanChars(Filter):
"""
Remove chars.
"""
def __init__(self, selector, symbols):
super(CleanChars, self).__init__(selector)
self.symbols = symbols
def filter(self, txt):
if isinstance(txt, (tuple,list)):
txt = ' '.join([t.strip() for t in txt.itertext()])
for symbol in self.symbols:
txt = txt.replace(symbol, '')
return txt
class Regexp(Filter):
"""