diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-06-18 07:56:55 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-07-02 15:41:37 +0100 |
commit | 20dc452614c991d1a4f5b7dcc1307cd03cba0c55 (patch) | |
tree | 096376554cde186c8abea965a84b842dd3b8ff24 /bitbake/lib/bb/ui | |
parent | b9f8af16f4aca5df1849e0ee2904d58e120cb67d (diff) | |
download | openembedded-core-20dc452614c991d1a4f5b7dcc1307cd03cba0c55.tar.gz openembedded-core-20dc452614c991d1a4f5b7dcc1307cd03cba0c55.tar.bz2 openembedded-core-20dc452614c991d1a4f5b7dcc1307cd03cba0c55.zip |
Drop a couple usages of readlines
(Bitbake rev: 40925230781ddd550bf21d90714c5349f9240a51)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/buildmanager.py | 43 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/puccho.py | 28 |
2 files changed, 35 insertions, 36 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/buildmanager.py b/bitbake/lib/bb/ui/crumbs/buildmanager.py index b5a4dae0de..e858d75e4c 100644 --- a/bitbake/lib/bb/ui/crumbs/buildmanager.py +++ b/bitbake/lib/bb/ui/crumbs/buildmanager.py @@ -76,31 +76,30 @@ class BuildConfiguration: # file format. @staticmethod def load_from_file (filename): - f = open (filename, "r") conf = BuildConfiguration() - for line in f.readlines(): - data = line.split (";")[1] - if (line.startswith ("metadata-url;")): - conf.metadata_url = data.strip() - continue - if (line.startswith ("url;")): - conf.urls += [data.strip()] - continue - if (line.startswith ("extra-url;")): - conf.extra_urls += [data.strip()] - continue - if (line.startswith ("machine;")): - conf.machine = data.strip() - continue - if (line.startswith ("distribution;")): - conf.distro = data.strip() - continue - if (line.startswith ("image;")): - conf.image = data.strip() - continue + with open(filename, "r") as f: + for line in f: + data = line.split (";")[1] + if (line.startswith ("metadata-url;")): + conf.metadata_url = data.strip() + continue + if (line.startswith ("url;")): + conf.urls += [data.strip()] + continue + if (line.startswith ("extra-url;")): + conf.extra_urls += [data.strip()] + continue + if (line.startswith ("machine;")): + conf.machine = data.strip() + continue + if (line.startswith ("distribution;")): + conf.distro = data.strip() + continue + if (line.startswith ("image;")): + conf.image = data.strip() + continue - f.close () return conf # Serialise to a file. This is part of the build process and we use this diff --git a/bitbake/lib/bb/ui/puccho.py b/bitbake/lib/bb/ui/puccho.py index 2ac025303e..a627fc803f 100644 --- a/bitbake/lib/bb/ui/puccho.py +++ b/bitbake/lib/bb/ui/puccho.py @@ -24,6 +24,7 @@ import gtk.glade import threading import urllib2 import os +import contextlib from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration from bb.ui.crumbs.buildmanager import BuildManagerTreeView @@ -77,20 +78,19 @@ class MetaDataLoader(gobject.GObject): def run (self): result = {} try: - f = urllib2.urlopen (self.url) - - # Parse the metadata format. The format is.... - # <machine>;<default distro>|<distro>...;<default image>|<image>...;<type##url>|... - for line in f.readlines(): - components = line.split(";") - if (len (components) < 4): - raise MetaDataLoader.LoaderThread.LoaderImportException - machine = components[0] - distros = components[1].split("|") - images = components[2].split("|") - urls = components[3].split("|") - - result[machine] = (distros, images, urls) + with contextlib.closing (urllib2.urlopen (self.url)) as f: + # Parse the metadata format. The format is.... + # <machine>;<default distro>|<distro>...;<default image>|<image>...;<type##url>|... + for line in f: + components = line.split(";") + if (len (components) < 4): + raise MetaDataLoader.LoaderThread.LoaderImportException + machine = components[0] + distros = components[1].split("|") + images = components[2].split("|") + urls = components[3].split("|") + + result[machine] = (distros, images, urls) # Create an object representing this *potential* # configuration. It can become concrete if the machine, distro |