pyln: add context manager to simpify filter use.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: pyln: LightningRpc has new `reply_filter` context manager for reducing output of RPC commands.
This commit is contained in:
Rusty Russell
2022-11-09 14:10:57 +10:30
parent 1436ad334d
commit b6134303d4
3 changed files with 26 additions and 1 deletions

View File

@@ -705,7 +705,8 @@ class PrettyPrintingLightningRpc(LightningRpc):
"result": res
}, indent=2))
if schemas and schemas[1] and not filter:
# FIXME: if filter set, just remove "required" from schemas?
if schemas and schemas[1] and filter is None and self._filter is None:
schemas[1].validate(res)
return res