commit inicial
This commit is contained in:
15
filter_plugins/belist.py
Normal file
15
filter_plugins/belist.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from collections import Sequence
|
||||
def assert_list(arg):
|
||||
''' Convert string argument to list-of-strings '''
|
||||
if isinstance(arg, basestring):
|
||||
return [ arg ]
|
||||
if not isinstance(arg, Sequence):
|
||||
return [ arg ]
|
||||
return arg
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {
|
||||
'belist': assert_list
|
||||
}
|
||||
15
filter_plugins/binary.py
Normal file
15
filter_plugins/binary.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from collections import Sequence
|
||||
def binary(arg,yes_value='yes',no_value='no'):
|
||||
''' Convert boolean argument to 'yes' or 'no' string value '''
|
||||
if isinstance(arg, bool):
|
||||
if arg:
|
||||
return yes_value
|
||||
return no_value
|
||||
return arg
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {
|
||||
'binary': binary
|
||||
}
|
||||
Reference in New Issue
Block a user