mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
pylightning: Allow both kwargs as well as positional args
We don't allow a mix (just like JSON-RPC), but we can use either or now. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
b7da41e674
commit
a50529bcb0
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- JSON API: `pay` and `decodepay` accept and ignore `lightning:` prefixes.
|
- JSON API: `pay` and `decodepay` accept and ignore `lightning:` prefixes.
|
||||||
|
- pylightning: Allow either keyword arguments or positional arguments.
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
@ -48,7 +48,12 @@ class UnixDomainSocketRpc(object):
|
|||||||
"""
|
"""
|
||||||
name = name.replace('_', '-')
|
name = name.replace('_', '-')
|
||||||
|
|
||||||
def wrapper(**kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
|
if len(args) != 0 and len(kwargs) != 0:
|
||||||
|
raise RpcError("Cannot mix positional and non-positional arguments")
|
||||||
|
elif len(args) != 0:
|
||||||
|
return self.call(name, payload=args)
|
||||||
|
else:
|
||||||
return self.call(name, payload=kwargs)
|
return self.call(name, payload=kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
@ -58,6 +63,7 @@ class UnixDomainSocketRpc(object):
|
|||||||
if payload is None:
|
if payload is None:
|
||||||
payload = {}
|
payload = {}
|
||||||
# Filter out arguments that are None
|
# Filter out arguments that are None
|
||||||
|
if isinstance(payload, dict):
|
||||||
payload = {k: v for k, v in payload.items() if v is not None}
|
payload = {k: v for k, v in payload.items() if v is not None}
|
||||||
|
|
||||||
# FIXME: we open a new socket for every readobj call...
|
# FIXME: we open a new socket for every readobj call...
|
||||||
|
Loading…
Reference in New Issue
Block a user