From 3e543e8eaa18cecd9e360eecd3925b18e7a9058e Mon Sep 17 00:00:00 2001 From: Stefan Herbrechtsmeier Date: Fri, 7 Feb 2025 13:46:54 +0100 Subject: bitbake: fetch2: remove unnecessary expand function calls The fetch data class already expands the type, host, path, user, pswd and parm variables. The fetcher classes already expand the localfile variable. The getVar function expands the returned string per default. Remove unnecessary expand function calls to simplify the code. (Bitbake rev: 1b1eb037b861fbf20491ac17e519e9eaf232b858) Signed-off-by: Stefan Herbrechtsmeier Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 4 ++-- bitbake/lib/bb/fetch2/az.py | 5 +++-- bitbake/lib/bb/fetch2/gcp.py | 2 +- bitbake/lib/bb/fetch2/npm.py | 2 +- bitbake/lib/bb/fetch2/s3.py | 2 +- bitbake/lib/bb/fetch2/sftp.py | 2 +- bitbake/lib/bb/fetch2/wget.py | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 2a60e94ed0..628cae023a 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -1147,7 +1147,7 @@ def trusted_network(d, url): if bb.utils.to_boolean(d.getVar("BB_NO_NETWORK")): return True - pkgname = d.expand(d.getVar('PN', False)) + pkgname = d.getVar('PN') trusted_hosts = None if pkgname: trusted_hosts = d.getVarFlag('BB_ALLOWED_NETWORKS', pkgname, False) @@ -1782,7 +1782,7 @@ class Fetch(object): self.ud[url] = FetchData(url, self.d) self.ud[url].setup_localpath(self.d) - return self.d.expand(self.ud[url].localpath) + return self.ud[url].localpath def localpaths(self): """ diff --git a/bitbake/lib/bb/fetch2/az.py b/bitbake/lib/bb/fetch2/az.py index 3ccc594c22..346124a8bf 100644 --- a/bitbake/lib/bb/fetch2/az.py +++ b/bitbake/lib/bb/fetch2/az.py @@ -66,11 +66,12 @@ class Az(Wget): else: azuri = '%s%s%s' % ('https://', ud.host, ud.path) + dldir = d.getVar("DL_DIR") if os.path.exists(ud.localpath): # file exists, but we didnt complete it.. trying again. - fetchcmd += d.expand(" -c -P ${DL_DIR} '%s'" % azuri) + fetchcmd += " -c -P %s '%s'" % (dldir, azuri) else: - fetchcmd += d.expand(" -P ${DL_DIR} '%s'" % azuri) + fetchcmd += " -P %s '%s'" % (dldir, azuri) try: self._runwget(ud, d, fetchcmd, False) diff --git a/bitbake/lib/bb/fetch2/gcp.py b/bitbake/lib/bb/fetch2/gcp.py index 2ee9ed2194..268267b7ac 100644 --- a/bitbake/lib/bb/fetch2/gcp.py +++ b/bitbake/lib/bb/fetch2/gcp.py @@ -46,7 +46,7 @@ class GCP(FetchMethod): else: ud.basename = os.path.basename(ud.path) - ud.localfile = d.expand(urllib.parse.unquote(ud.basename)) + ud.localfile = urllib.parse.unquote(ud.basename) def get_gcp_client(self): from google.cloud import storage diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py index ac76d64cdb..c09f050448 100644 --- a/bitbake/lib/bb/fetch2/npm.py +++ b/bitbake/lib/bb/fetch2/npm.py @@ -166,7 +166,7 @@ class Npm(FetchMethod): # Using the 'downloadfilename' parameter as local filename # or the npm package name. if "downloadfilename" in ud.parm: - ud.localfile = npm_localfile(d.expand(ud.parm["downloadfilename"])) + ud.localfile = npm_localfile(ud.parm["downloadfilename"]) else: ud.localfile = npm_localfile(ud.package, ud.version) diff --git a/bitbake/lib/bb/fetch2/s3.py b/bitbake/lib/bb/fetch2/s3.py index 6b8ffd5359..fa5292dfd7 100644 --- a/bitbake/lib/bb/fetch2/s3.py +++ b/bitbake/lib/bb/fetch2/s3.py @@ -77,7 +77,7 @@ class S3(FetchMethod): else: ud.basename = os.path.basename(ud.path) - ud.localfile = d.expand(urllib.parse.unquote(ud.basename)) + ud.localfile = urllib.parse.unquote(ud.basename) ud.basecmd = d.getVar("FETCHCMD_s3") or "/usr/bin/env aws s3" diff --git a/bitbake/lib/bb/fetch2/sftp.py b/bitbake/lib/bb/fetch2/sftp.py index 7884cce949..45b6afb4ad 100644 --- a/bitbake/lib/bb/fetch2/sftp.py +++ b/bitbake/lib/bb/fetch2/sftp.py @@ -77,7 +77,7 @@ class SFTP(FetchMethod): else: ud.basename = os.path.basename(ud.path) - ud.localfile = d.expand(urllib.parse.unquote(ud.basename)) + ud.localfile = urllib.parse.unquote(ud.basename) def download(self, ud, d): """Fetch urls""" diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index 198426065b..7066d5e2ca 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py @@ -78,9 +78,9 @@ class Wget(FetchMethod): else: ud.basename = os.path.basename(ud.path) - ud.localfile = d.expand(urllib.parse.unquote(ud.basename)) + ud.localfile = urllib.parse.unquote(ud.basename) if not ud.localfile: - ud.localfile = d.expand(urllib.parse.unquote(ud.host + ud.path).replace("/", ".")) + ud.localfile = urllib.parse.unquote(ud.host + ud.path).replace("/", ".") self.basecmd = d.getVar("FETCHCMD_wget") or "/usr/bin/env wget -t 2 -T 100" -- cgit v1.2.3-54-g00ecf