From patchwork Wed Jun 20 14:13:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel, 09/14] fetch2: Remove basestring test and simplify uri_replace Date: Wed, 20 Jun 2012 14:13:00 -0000 From: Richard Purdie X-Patchwork-Id: 30309 Message-Id: <131dd58bcea697f67768d02a7af8e89010f82b1f.1340200208.git.richard.purdie@linuxfoundation.org> To: bitbake-devel@lists.openembedded.org Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 35 ++++++++++++++++++----------------- 1 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index fe0c6a7..7045e1b 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -193,24 +193,25 @@ def uri_replace(ud, uri_find, uri_replace, d): result_decoded = ['', '', '', '', '', {}] for loc, i in enumerate(uri_find_decoded): result_decoded[loc] = uri_decoded[loc] - if isinstance(i, basestring): - if (re.match(i, uri_decoded[loc])): - if not uri_replace_decoded[loc]: - result_decoded[loc] = "" - else: - result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) - if loc == 2: - basename = None - if ud.mirrortarball: - basename = os.path.basename(ud.mirrortarball) - elif ud.localpath: - basename = os.path.basename(ud.localpath) - if basename and result_decoded[loc].endswith("/"): - result_decoded[loc] = os.path.dirname(result_decoded[loc]) - if basename and not result_decoded[loc].endswith(basename): - result_decoded[loc] = os.path.join(result_decoded[loc], basename) + if loc == 5: + continue + elif (re.match(i, uri_decoded[loc])): + if not uri_replace_decoded[loc]: + result_decoded[loc] = "" else: - return None + result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) + if loc == 2: + basename = None + if ud.mirrortarball: + basename = os.path.basename(ud.mirrortarball) + elif ud.localpath: + basename = os.path.basename(ud.localpath) + if basename and result_decoded[loc].endswith("/"): + result_decoded[loc] = os.path.dirname(result_decoded[loc]) + if basename and not result_decoded[loc].endswith(basename): + result_decoded[loc] = os.path.join(result_decoded[loc], basename) + else: + return None result = encodeurl(result_decoded) if result == ud.url: return None