wic: Add utility function for parsing sourceparams
Parses strings of the form key1=val1[,key2=val2,...] and returns a dict. Also accepts valueless keys i.e. without =. (From OE-Core rev: 36f258ee6e60c26fd44b9bc71c318363cec71f42) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
3c90ee9bc2
commit
ef700ea11f
|
@ -179,3 +179,26 @@ def get_bitbake_var(key):
|
|||
val = get_line_val(line, key)
|
||||
return val
|
||||
return None
|
||||
|
||||
def parse_sourceparams(sourceparams):
|
||||
"""
|
||||
Split sourceparams string of the form key1=val1[,key2=val2,...]
|
||||
into a dict. Also accepts valueless keys i.e. without =.
|
||||
|
||||
Returns dict of param key/val pairs (note that val may be None).
|
||||
"""
|
||||
params_dict = {}
|
||||
|
||||
params = sourceparams.split(',')
|
||||
if params:
|
||||
for p in params:
|
||||
if not p:
|
||||
continue
|
||||
if not '=' in p:
|
||||
key = p
|
||||
val = None
|
||||
else:
|
||||
key, val = p.split('=')
|
||||
params_dict[key] = val
|
||||
|
||||
return params_dict
|
||||
|
|
Loading…
Reference in New Issue