From 20dc452614c991d1a4f5b7dcc1307cd03cba0c55 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Fri, 18 Jun 2010 07:56:55 -0700 Subject: Drop a couple usages of readlines (Bitbake rev: 40925230781ddd550bf21d90714c5349f9240a51) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/puccho.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'bitbake/lib/bb/ui/puccho.py') 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.... - # ;|...;|...;|... - 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.... + # ;|...;|...;|... + 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 -- cgit v1.2.3-54-g00ecf