[bitbake-devel] [PATCH] bitbake: fetch2: Have decodeurl() return a namedtuple

Randy Witt randy.e.witt at linux.intel.com
Thu Feb 26 18:44:25 UTC 2015


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 <randy.e.witt at linux.intel.com>
---
 bitbake/lib/bb/fetch2/__init__.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 599ea8c..8dfe978 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -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,
-- 
1.9.3




More information about the bitbake-devel mailing list