Private
Public Access
2
0
Files
bgwaf/filter_plugins/filters.py
2026-01-20 17:40:16 +03:00

22 lines
539 B
Python

#!/usr/bin/python
class FilterModule(object):
def filters(self):
return {
'dict2str': self.dict2str
}
def dict2str(self, d, sep1='=', sep2=';', sep3=''):
return sep2.join(
[ str(k) + (sep1+str(v) if v!=None and v!='' else '') for k, v in d.items() ]
) + sep3
if __name__ == "__main__":
# Tests
filters = FilterModule()
print(filters.filters())
print(filters.dict2str(
{"un": 1, "deux": 2, "str": "a string", "rien": None, "bool": True}
))