tools: ynl: don't return None for dumps

YNL currently reports None for empty dump:

 $ cli.py ...netdev.yaml --dump page-pool-get
 None

This doesn't matter for the CLI but when writing YNL based tests
having to deal with either list or None is annoying. Limit the
None conversion to non-dump ops:

 $ cli.py ...netdev.yaml --dump page-pool-get
 []

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20240412141436.828666-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2024-04-12 07:14:32 -07:00
parent 1580cbcbfe
commit 72ba6cba0a

View File

@ -995,9 +995,11 @@ class YnlFamily(SpecFamily):
rsp_msg.update(self._decode_struct(decoded.raw, op.fixed_header))
rsp.append(rsp_msg)
if dump:
return rsp
if not rsp:
return None
if not dump and len(rsp) == 1:
if len(rsp) == 1:
return rsp[0]
return rsp