mirror of
https://git.yoctoproject.org/poky
synced 2026-09-16 00:49:32 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
b9f8af16f4
commit
20dc452614
@@ -76,31 +76,30 @@ class BuildConfiguration:
|
|||||||
# file format.
|
# file format.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_from_file (filename):
|
def load_from_file (filename):
|
||||||
f = open (filename, "r")
|
|
||||||
|
|
||||||
conf = BuildConfiguration()
|
conf = BuildConfiguration()
|
||||||
for line in f.readlines():
|
with open(filename, "r") as f:
|
||||||
data = line.split (";")[1]
|
for line in f:
|
||||||
if (line.startswith ("metadata-url;")):
|
data = line.split (";")[1]
|
||||||
conf.metadata_url = data.strip()
|
if (line.startswith ("metadata-url;")):
|
||||||
continue
|
conf.metadata_url = data.strip()
|
||||||
if (line.startswith ("url;")):
|
continue
|
||||||
conf.urls += [data.strip()]
|
if (line.startswith ("url;")):
|
||||||
continue
|
conf.urls += [data.strip()]
|
||||||
if (line.startswith ("extra-url;")):
|
continue
|
||||||
conf.extra_urls += [data.strip()]
|
if (line.startswith ("extra-url;")):
|
||||||
continue
|
conf.extra_urls += [data.strip()]
|
||||||
if (line.startswith ("machine;")):
|
continue
|
||||||
conf.machine = data.strip()
|
if (line.startswith ("machine;")):
|
||||||
continue
|
conf.machine = data.strip()
|
||||||
if (line.startswith ("distribution;")):
|
continue
|
||||||
conf.distro = data.strip()
|
if (line.startswith ("distribution;")):
|
||||||
continue
|
conf.distro = data.strip()
|
||||||
if (line.startswith ("image;")):
|
continue
|
||||||
conf.image = data.strip()
|
if (line.startswith ("image;")):
|
||||||
continue
|
conf.image = data.strip()
|
||||||
|
continue
|
||||||
|
|
||||||
f.close ()
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
# Serialise to a file. This is part of the build process and we use this
|
# Serialise to a file. This is part of the build process and we use this
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import gtk.glade
|
|||||||
import threading
|
import threading
|
||||||
import urllib2
|
import urllib2
|
||||||
import os
|
import os
|
||||||
|
import contextlib
|
||||||
|
|
||||||
from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration
|
from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration
|
||||||
from bb.ui.crumbs.buildmanager import BuildManagerTreeView
|
from bb.ui.crumbs.buildmanager import BuildManagerTreeView
|
||||||
@@ -77,20 +78,19 @@ class MetaDataLoader(gobject.GObject):
|
|||||||
def run (self):
|
def run (self):
|
||||||
result = {}
|
result = {}
|
||||||
try:
|
try:
|
||||||
f = urllib2.urlopen (self.url)
|
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("|")
|
||||||
|
|
||||||
# Parse the metadata format. The format is....
|
result[machine] = (distros, images, urls)
|
||||||
# <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)
|
|
||||||
|
|
||||||
# Create an object representing this *potential*
|
# Create an object representing this *potential*
|
||||||
# configuration. It can become concrete if the machine, distro
|
# configuration. It can become concrete if the machine, distro
|
||||||
|
|||||||
Reference in New Issue
Block a user