mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
wic: create new method _parse_line
Moved code that parses one line of 'bitbake -e' output to separate method _parse_line. This method will be also used later to parse lines of .env files. (From OE-Core rev: 49ef04d3c9eeb76cbbc89b27b4dd1570b7a2552b) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
58c393022f
commit
e1fe3479a6
@@ -131,6 +131,22 @@ class BitbakeVars(defaultdict):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
defaultdict.__init__(self, dict)
|
defaultdict.__init__(self, dict)
|
||||||
|
|
||||||
|
def _parse_line(self, line, image):
|
||||||
|
"""
|
||||||
|
Parse one line from bitbake -e output.
|
||||||
|
Put result key-value pair into the storage.
|
||||||
|
"""
|
||||||
|
if "=" not in line:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
key, val = line.split("=")
|
||||||
|
except ValueError:
|
||||||
|
return
|
||||||
|
key = key.strip()
|
||||||
|
val = val.strip()
|
||||||
|
if key.replace('_', '').isalnum():
|
||||||
|
self[image][key] = val.strip('"')
|
||||||
|
|
||||||
def get_var(self, var, image=None):
|
def get_var(self, var, image=None):
|
||||||
"""
|
"""
|
||||||
Get bitbake variable value lazy way, i.e. run
|
Get bitbake variable value lazy way, i.e. run
|
||||||
@@ -154,16 +170,7 @@ class BitbakeVars(defaultdict):
|
|||||||
|
|
||||||
# Parse bitbake -e output
|
# Parse bitbake -e output
|
||||||
for line in lines.split('\n'):
|
for line in lines.split('\n'):
|
||||||
if "=" not in line:
|
self._parse_line(line, image)
|
||||||
continue
|
|
||||||
try:
|
|
||||||
key, val = line.split("=")
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
key = key.strip()
|
|
||||||
val = val.strip()
|
|
||||||
if key.replace('_', '').isalnum():
|
|
||||||
self[image][key] = val.strip('"')
|
|
||||||
|
|
||||||
# Make first image a default set of variables
|
# Make first image a default set of variables
|
||||||
images = [key for key in self if key]
|
images = [key for key in self if key]
|
||||||
|
|||||||
Reference in New Issue
Block a user