diff options
| author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-08-30 20:47:01 +0300 | 
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-30 21:38:11 +0100 | 
| commit | 49ef04d3c9eeb76cbbc89b27b4dd1570b7a2552b (patch) | |
| tree | b2baf1bd9e8d7bb19f19e023f97c65d758d3ec11 | |
| parent | 3229d37993e315c9ca1902849746b9f50f35845c (diff) | |
| download | openembedded-core-49ef04d3c9eeb76cbbc89b27b4dd1570b7a2552b.tar.gz openembedded-core-49ef04d3c9eeb76cbbc89b27b4dd1570b7a2552b.tar.bz2 openembedded-core-49ef04d3c9eeb76cbbc89b27b4dd1570b7a2552b.zip | |
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.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | scripts/lib/wic/utils/oe/misc.py | 27 | 
1 files changed, 17 insertions, 10 deletions
| diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py index 3537a2e711..41e435fc27 100644 --- a/scripts/lib/wic/utils/oe/misc.py +++ b/scripts/lib/wic/utils/oe/misc.py @@ -131,6 +131,22 @@ class BitbakeVars(defaultdict):      def __init__(self):          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):          """          Get bitbake variable value lazy way, i.e. run @@ -154,16 +170,7 @@ class BitbakeVars(defaultdict):              # Parse bitbake -e output              for line in lines.split('\n'): -                if "=" not in line: -                    continue -                try: -                    key, val = line.split("=") -                except ValueError: -                    continue -                key = key.strip() -                val = val.strip() -                if key.replace('_', '').isalnum(): -                    self[image][key] = val.strip('"') +                self._parse_line(line, image)              # Make first image a default set of variables              images = [key for key in self if key] | 
