fetch: be more pythonic

no functional changes

(Bitbake rev: e88834fb7c6821cc29c12d296f2edd51f6eb3746)

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Bernhard Reutner-Fischer
2010-11-17 15:40:51 +01:00
committed by Richard Purdie
parent b7d667f252
commit 4df0d6adca
9 changed files with 21 additions and 64 deletions

View File

@@ -733,9 +733,7 @@ class Fetch(object):
""" """
Verify the md5sum we wanted with the one we got Verify the md5sum we wanted with the one we got
""" """
wanted_sum = None wanted_sum = ud.parm.get('md5sum')
if 'md5sum' in ud.parm:
wanted_sum = ud.parm['md5sum']
if not wanted_sum: if not wanted_sum:
return True return True

View File

@@ -61,9 +61,7 @@ class Bzr(Fetch):
basecmd = data.expand('${FETCHCMD_bzr}', d) basecmd = data.expand('${FETCHCMD_bzr}', d)
proto = "http" proto = ud.parm.get('proto', 'http')
if "proto" in ud.parm:
proto = ud.parm["proto"]
bzrroot = ud.host + ud.path bzrroot = ud.host + ud.path

View File

@@ -47,9 +47,7 @@ class Cvs(Fetch):
raise MissingParameterError("cvs method needs a 'module' parameter") raise MissingParameterError("cvs method needs a 'module' parameter")
ud.module = ud.parm["module"] ud.module = ud.parm["module"]
ud.tag = "" ud.tag = ud.parm.get('tag', "")
if 'tag' in ud.parm:
ud.tag = ud.parm['tag']
# Override the default date in certain cases # Override the default date in certain cases
if 'date' in ud.parm: if 'date' in ud.parm:
@@ -76,17 +74,9 @@ class Cvs(Fetch):
def go(self, loc, ud, d): def go(self, loc, ud, d):
method = "pserver" method = ud.parm.get('method', 'pserver')
if "method" in ud.parm: localdir = ud.parm.get('localdir', ud.module)
method = ud.parm["method"] cvs_port = ud.parm.get('port', '')
localdir = ud.module
if "localdir" in ud.parm:
localdir = ud.parm["localdir"]
cvs_port = ""
if "port" in ud.parm:
cvs_port = ud.parm["port"]
cvs_rsh = None cvs_rsh = None
if method == "ext": if method == "ext":

View File

@@ -44,10 +44,7 @@ class Hg(Fetch):
return ud.type in ['hg'] return ud.type in ['hg']
def forcefetch(self, url, ud, d): def forcefetch(self, url, ud, d):
if 'rev' in ud.parm: revTag = ud.parm.get('rev', 'tip')
revTag = ud.parm['rev']
else:
revTag = "tip"
return revTag == "tip" return revTag == "tip"
def localpath(self, url, ud, d): def localpath(self, url, ud, d):
@@ -84,9 +81,7 @@ class Hg(Fetch):
basecmd = data.expand('${FETCHCMD_hg}', d) basecmd = data.expand('${FETCHCMD_hg}', d)
proto = "http" proto = ud.parm.get('proto', 'http')
if "proto" in ud.parm:
proto = ud.parm["proto"]
host = ud.host host = ud.host
if proto == "file": if proto == "file":

View File

@@ -59,9 +59,7 @@ class Osc(Fetch):
basecmd = data.expand('${FETCHCMD_osc}', d) basecmd = data.expand('${FETCHCMD_osc}', d)
proto = "ocs" proto = ud.parm.get('proto', 'ocs')
if "proto" in ud.parm:
proto = ud.parm["proto"]
options = [] options = []
@@ -124,7 +122,7 @@ class Osc(Fetch):
Generate a .oscrc to be used for this run. Generate a .oscrc to be used for this run.
""" """
config_path = "%s/oscrc" % data.expand('${OSCDIR}', d) config_path = os.path.join(data.expand('${OSCDIR}', d), "oscrc")
if (os.path.exists(config_path)): if (os.path.exists(config_path)):
os.remove(config_path) os.remove(config_path)

View File

@@ -133,10 +133,7 @@ class Perforce(Fetch):
else: else:
path = depot path = depot
if "module" in parm: module = parm.get('module', os.path.basename(path))
module = parm["module"]
else:
module = os.path.basename(path)
localdata = data.createCopy(d) localdata = data.createCopy(d)
data.setVar('OVERRIDES', "p4:%s" % data.getVar('OVERRIDES', localdata), localdata) data.setVar('OVERRIDES', "p4:%s" % data.getVar('OVERRIDES', localdata), localdata)
@@ -206,4 +203,4 @@ class Perforce(Fetch):
pass pass
raise FetchError(module) raise FetchError(module)
# cleanup # cleanup
os.system('rm -rf %s' % tmpfile) bb.utils.prunedir(tmpfile)

View File

@@ -45,24 +45,11 @@ class Repo(Fetch):
"master". "master".
""" """
if "protocol" in ud.parm: ud.proto = ud.parm.get('protocol', 'git')
ud.proto = ud.parm["protocol"] ud.branch = ud.parm.get('branch', 'master')
else: ud.manifest = ud.parm.get('manifest', 'default.xml')
ud.proto = "git" if not ud.manifest.endswith('.xml'):
ud.manifest += '.xml'
if "branch" in ud.parm:
ud.branch = ud.parm["branch"]
else:
ud.branch = "master"
if "manifest" in ud.parm:
manifest = ud.parm["manifest"]
if manifest.endswith(".xml"):
ud.manifest = manifest
else:
ud.manifest = manifest + ".xml"
else:
ud.manifest = "default.xml"
ud.localfile = data.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch), d) ud.localfile = data.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch), d)

View File

@@ -48,18 +48,14 @@ class Svk(Fetch):
else: else:
ud.module = ud.parm["module"] ud.module = ud.parm["module"]
ud.revision = "" ud.revision = ud.parm.get('rev', "")
if 'rev' in ud.parm:
ud.revision = ud.parm['rev']
ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
def forcefetch(self, url, ud, d): def forcefetch(self, url, ud, d):
if (ud.date == "now"): return ud.date == "now"
return True
return False
def go(self, loc, ud, d): def go(self, loc, ud, d):
"""Fetch urls""" """Fetch urls"""
@@ -105,4 +101,4 @@ class Svk(Fetch):
pass pass
raise FetchError(ud.module) raise FetchError(ud.module)
# cleanup # cleanup
os.system('rm -rf %s' % tmpfile) bb.utils.prunedir(tmpfile)

View File

@@ -91,9 +91,7 @@ class Svn(Fetch):
basecmd = data.expand('${FETCHCMD_svn}', d) basecmd = data.expand('${FETCHCMD_svn}', d)
proto = "svn" proto = ud.parm.get('proto', 'svn')
if "proto" in ud.parm:
proto = ud.parm["proto"]
svn_rsh = None svn_rsh = None
if proto == "svn+ssh" and "rsh" in ud.parm: if proto == "svn+ssh" and "rsh" in ud.parm: