From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qffx1-0005Gz-BI for garchives@archives.gentoo.org; Sat, 09 Jul 2011 22:24:39 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 20D5021C0E7; Sat, 9 Jul 2011 22:24:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id DFFC621C0E7 for ; Sat, 9 Jul 2011 22:24:30 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 75B0D1B4063 for ; Sat, 9 Jul 2011 22:24:30 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id C96B48003D for ; Sat, 9 Jul 2011 22:24:29 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <50da885309a3a69f0927a730e19026734523b090.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/resolver/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/resolver/circular_dependency.py X-VCS-Directories: pym/_emerge/resolver/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 50da885309a3a69f0927a730e19026734523b090 Date: Sat, 9 Jul 2011 22:24:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: abfdb7ff45db0147ff29044bcbc5c9a6 commit: 50da885309a3a69f0927a730e19026734523b090 Author: Zac Medico gentoo org> AuthorDate: Sat Jul 9 22:23:52 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Jul 9 22:23:52 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D50da8853 circular_dependency: use itertools.product() Python's cartesian product function does exactly what we want, so use it to simplify our code. --- pym/_emerge/resolver/circular_dependency.py | 27 +++------------------= ------ 1 files changed, 3 insertions(+), 24 deletions(-) diff --git a/pym/_emerge/resolver/circular_dependency.py b/pym/_emerge/re= solver/circular_dependency.py index 1789801..9a3286c 100644 --- a/pym/_emerge/resolver/circular_dependency.py +++ b/pym/_emerge/resolver/circular_dependency.py @@ -3,7 +3,7 @@ =20 from __future__ import print_function =20 -from itertools import chain +from itertools import chain, product =20 from portage.dep import use_reduce, extract_affecting_use, check_require= d_use, get_required_use_flags from portage.exception import InvalidDependString @@ -147,27 +147,9 @@ class circular_dependency_handler(object): #We iterate over all possible settings of these use flags and gather #a set of possible changes #TODO: Use the information encoded in REQUIRED_USE - use_state =3D [] - for flag in affecting_use: - use_state.append("disabled") - - def _next_use_state(state, id=3DNone): - if id is None: - id =3D len(state)-1 - - if id =3D=3D 0 and state[0] =3D=3D "enabled": - return False - - if state[id] =3D=3D "disabled": - state[id] =3D "enabled" - for i in range(id+1,len(state)): - state[i] =3D "disabled" - return True - else: - return _next_use_state(state, id-1) - solutions =3D set() - while(True): + for use_state in product(("disabled", "enabled"), + repeat=3Dlen(affecting_use)): current_use =3D set(self.depgraph._pkg_use_enabled(parent)) for flag, state in zip(affecting_use, use_state): if state =3D=3D "enabled": @@ -200,9 +182,6 @@ class circular_dependency_handler(object): solution.add((flag, False)) solutions.add(frozenset(solution)) =20 - if not _next_use_state(use_state): - break - for solution in solutions: ignore_solution =3D False for other_solution in solutions: