bitbake: fetch2: Have decodeurl() return a namedtuple
PATCH 1/1 bitbake: fetch2: Have decodeurl() return a namedtuple
Since decodeurl() returns a tuple with six values, return a namedtuple instead, so the result is easier to use and assists in writing cleaner code.
Signed-off-by Randy Witt <[email protected]>
--- bitbake/lib/bb/fetch2/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +4 -2
@@ -39,6 +39,7 @@ import bb.checksum from bb import data import bb.process import subprocess +from collections import namedtuple __version__ = "2" _checksum_cache = bb.checksum.FileChecksumCache()
@@ -379,8 +380,9 @@ def decodeurl(url): raise MalformedUrl(url, "The URL: '%s' is invalid: parameter %s does not specify a value (missing '=')" % (url, s)) s1, s2 = s.split('=') p[s1] = s2 - - return type, host, urllib.unquote(path), user, pswd, p + result_tuple = namedtuple('decodeurl_tuple', + 'type, host, path, user, password, parameters') + return result_tuple(type, host, urllib.unquote(path), user, pswd, p) def encodeurl(decoded): """Encodes a URL from tokens (scheme, network location, path,
Signature · 1 line
1.9.3