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 1QiZXh-0004VX-OB for garchives@archives.gentoo.org; Sun, 17 Jul 2011 22:10:29 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D15CD21C2C4; Sun, 17 Jul 2011 22:10:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A620921C2C4 for ; Sun, 17 Jul 2011 22:10:07 +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 359A91B4006 for ; Sun, 17 Jul 2011 22:10:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2D2E080042 for ; Sun, 17 Jul 2011 22:10:06 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/basepm/pkg.py X-VCS-Directories: gentoopm/basepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: e112f11651f529b466a46cddf481fb1a28c226ec Date: Sun, 17 Jul 2011 22:10:06 +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: 550c2dde429ed0ce4eed5e17c9de963f commit: e112f11651f529b466a46cddf481fb1a28c226ec Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Sun Jul 17 22:09:51 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Sun Jul 17 22:09:51 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3De112f116 PMPackage: make .environ try both .bz2 and plain environment. Now PMPackage.environ looks for both environment.bz2 and plain environment files. It checks which of them is newer, and uses that one. --- gentoopm/basepm/pkg.py | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py index c2a27ec..91b0264 100644 --- a/gentoopm/basepm/pkg.py +++ b/gentoopm/basepm/pkg.py @@ -117,8 +117,16 @@ class PMPackage(ABCObject): return None =20 if os.path.isdir(p): - # XXX: look for .bz2 and plain, take the newer one - p =3D os.path.join(p, 'environment.bz2') + def _mtime_if_exists(path): + try: + return os.path.getmtime(path) + except OSError: + return None + + files =3D ('environment.bz2', 'environment') + # Take the newer one. + fn =3D sorted(files, key=3D_mtime_if_exists, reverse=3DTrue)[0] + p =3D os.path.join(p, fn) =20 if not os.path.exists(p): return None