dict2str: -> plugins/filter
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
#!/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}
|
||||
))
|
||||
Reference in New Issue
Block a user