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

svn path=/main/trunk/; revision=10509

pym/portage/dbapi/porttree.py

index 685fd18c5adec34f824d46dd1fc912723fb55e0f..83069bd2c18e92d4b4c212dd7440670cd86f0db1 100644 (file)
@@ -619,10 +619,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