Now that dbapi._iter_match() is guaranteed to return a real iterator with
authorZac Medico <zmedico@gentoo.org>
Fri, 30 May 2008 21:20:11 +0000 (21:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 30 May 2008 21:20:11 +0000 (21:20 -0000)
a next() method, we can just call next() and handle StopIteration.
(trunk r10509)

svn path=/main/branches/2.1.2/; revision=10510

pym/portage.py

index eb6882f47837560e66619a93eecccaee1ba7a83f..3219a2dcc9e4227d2116c591e04e82996672d50a 100644 (file)
@@ -7879,10 +7879,10 @@ class portdbapi(dbapi):
                        cpv_iter = iter(self.cp_list(mykey))
                        if mydep != mykey:
                                cpv_iter = self._iter_match(mydep, cpv_iter)
-                       myval = ""
-                       for cpv in cpv_iter:
-                               myval = cpv
-                               break
+                       try:
+                               myval = cpv_iter.next()
+                       except StopIteration:
+                               myval = ""
 
                elif level in ("minimum-visible", "bestmatch-visible"):
                        # Find the minimum matching visible version. This is optimized to