forked from platypush/platypush
[utils
] Added utils.to_yaml
action.
This commit is contained in:
parent
c7acc03c8f
commit
f0255549c8
1 changed files with 9 additions and 0 deletions
|
@ -3,6 +3,8 @@ import threading
|
||||||
import time
|
import time
|
||||||
from typing import Dict, Union
|
from typing import Dict, Union
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
from platypush.backend.http.utils import HttpUtils
|
from platypush.backend.http.utils import HttpUtils
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.plugins import Plugin, action
|
from platypush.plugins import Plugin, action
|
||||||
|
@ -363,5 +365,12 @@ class UtilsPlugin(Plugin):
|
||||||
|
|
||||||
return docutils.core.publish_parts(text, writer_name='html')['html_body']
|
return docutils.core.publish_parts(text, writer_name='html')['html_body']
|
||||||
|
|
||||||
|
@action
|
||||||
|
def to_yaml(self, obj: Union[dict, list, tuple, str, int, float, bool]):
|
||||||
|
"""
|
||||||
|
Convert an object to YAML
|
||||||
|
"""
|
||||||
|
return yaml.dump(obj, indent=2)
|
||||||
|
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
Loading…
Reference in a new issue