forked from platypush/platypush
Defined get_procedures() method on inspect plugin
This commit is contained in:
parent
fb58c89911
commit
a1c20a52da
1 changed files with 18 additions and 0 deletions
|
@ -11,6 +11,7 @@ import platypush.message.event
|
||||||
import platypush.message.response
|
import platypush.message.response
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
|
from platypush.config import Config
|
||||||
from platypush.plugins import Plugin, action
|
from platypush.plugins import Plugin, action
|
||||||
from platypush.message.event import Event
|
from platypush.message.event import Event
|
||||||
from platypush.message.response import Response
|
from platypush.message.response import Response
|
||||||
|
@ -36,6 +37,16 @@ class Model:
|
||||||
return docutils.core.publish_parts(doc, writer_name='html')['html_body']
|
return docutils.core.publish_parts(doc, writer_name='html')['html_body']
|
||||||
|
|
||||||
|
|
||||||
|
class ProcedureEncoder(json.JSONEncoder):
|
||||||
|
def default(self, o):
|
||||||
|
if callable(o):
|
||||||
|
return {
|
||||||
|
'type': 'native_function',
|
||||||
|
}
|
||||||
|
|
||||||
|
return super().default(o)
|
||||||
|
|
||||||
|
|
||||||
class BackendModel(Model):
|
class BackendModel(Model):
|
||||||
def __init__(self, backend, prefix='', html_doc: bool = False):
|
def __init__(self, backend, prefix='', html_doc: bool = False):
|
||||||
self.name = backend.__module__[len(prefix):]
|
self.name = backend.__module__[len(prefix):]
|
||||||
|
@ -321,5 +332,12 @@ class InspectPlugin(Plugin):
|
||||||
for package, events in self._responses.items()
|
for package, events in self._responses.items()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@action
|
||||||
|
def get_procedures(self) -> dict:
|
||||||
|
"""
|
||||||
|
Get the list of procedures installed on the device.
|
||||||
|
"""
|
||||||
|
return json.loads(json.dumps(Config.get_procedures(), cls=ProcedureEncoder))
|
||||||
|
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
Loading…
Reference in a new issue