Fixes issue 70, Improves plugin management, Refactoring, Updates tests, Introduces multiple data dir support
This commit is contained in:
parent
40fd3516c4
commit
0fd1f34852
16 changed files with 216 additions and 49 deletions
26
filter_plugins/custom.py
Normal file
26
filter_plugins/custom.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
__author__ = 'dale mcdiarmid'
|
||||
|
||||
import re
|
||||
|
||||
def modify_list(values=[], pattern='', replacement='', ignorecase=False):
|
||||
''' Perform a `re.sub` on every item in the list'''
|
||||
if ignorecase:
|
||||
flags = re.I
|
||||
else:
|
||||
flags = 0
|
||||
_re = re.compile(pattern, flags=flags)
|
||||
return [_re.sub(replacement, value) for value in values]
|
||||
|
||||
def append_to_list(values=[], suffix=''):
|
||||
if isinstance(values, basestring):
|
||||
values = values.split(',')
|
||||
return [str(value+suffix) for value in values]
|
||||
|
||||
def array_to_str(values=[],separator=','):
|
||||
return separator.join(values)
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {'modify_list': modify_list,
|
||||
'append_to_list':append_to_list,
|
||||
'array_to_str':array_to_str}
|
||||
Loading…
Add table
Add a link
Reference in a new issue