Patchwork [bitbake-devel,08/14] fetch2: Simplify some looping constructs in uri_replace()

login
register
mail settings
Submitter Richard Purdie
Date June 20, 2012, 2:12 p.m.
Message ID <e8b17b1317cc1908896c44125aec3a476353eb81.1340200208.git.richard.purdie@linuxfoundation.org>
Download mbox | patch
Permalink /patch/30291/
State New
Headers show

Comments

Richard Purdie - June 20, 2012, 2:12 p.m.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 bitbake/lib/bb/fetch2/__init__.py |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Patch

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 5838436..fe0c6a7 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -191,8 +191,7 @@  def uri_replace(ud, uri_find, uri_replace, d):
     uri_replace_decoded = list(decodeurl(uri_replace))
     logger.debug(2, "For url %s comparing %s to %s" % (uri_decoded, uri_find_decoded, uri_replace_decoded))
     result_decoded = ['', '', '', '', '', {}]
-    for i in uri_find_decoded:
-        loc = uri_find_decoded.index(i)
+    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])):
@@ -200,7 +199,7 @@  def uri_replace(ud, uri_find, uri_replace, d):
                     result_decoded[loc] = ""    
                 else:
                     result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
-                if uri_find_decoded.index(i) == 2:
+                if loc == 2:
                     basename = None
                     if ud.mirrortarball:
                         basename = os.path.basename(ud.mirrortarball)