mirror of
https://xff.cz/git/u-boot/
synced 2025-09-27 13:31:16 +02:00
dtoc: Tidy up implementation of AddStringList()
Refactor this to avoid a loop. Also add a test for an empty string. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
This commit is contained in:
@@ -158,6 +158,8 @@ def GetString(node, propname, default=None):
|
||||
if not prop:
|
||||
return default
|
||||
value = prop.value
|
||||
if not prop.bytes:
|
||||
return ''
|
||||
if isinstance(value, list):
|
||||
raise ValueError("Node '%s' property '%s' has list value: expecting "
|
||||
"a single string" % (node.name, propname))
|
||||
@@ -179,6 +181,8 @@ def GetStringList(node, propname, default=None):
|
||||
if not prop:
|
||||
return default
|
||||
value = prop.value
|
||||
if not prop.bytes:
|
||||
return []
|
||||
if not isinstance(value, list):
|
||||
strval = GetString(node, propname)
|
||||
return [strval]
|
||||
|
Reference in New Issue
Block a user