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 1QiZXd-0004V3-Hk for garchives@archives.gentoo.org; Sun, 17 Jul 2011 22:10:25 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 46A7B21C2A4; 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 1A8B421C2A4 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 95EE91B400B for ; Sun, 17 Jul 2011 22:10:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 01C8B8003F 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: <0c7660db796e64194c7a4f14eb5a83d4b27990e9.mgorny@gentoo> 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: 0c7660db796e64194c7a4f14eb5a83d4b27990e9 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: 3e51f46da9892b54a0b072cd6814f841 commit: 0c7660db796e64194c7a4f14eb5a83d4b27990e9 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Sun Jul 17 22:08:35 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Sun Jul 17 22:08:35 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D0c7660db PMPackage: make .environ check if path does exist. --- gentoopm/basepm/pkg.py | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py index 853cad1..c2a27ec 100644 --- a/gentoopm/basepm/pkg.py +++ b/gentoopm/basepm/pkg.py @@ -106,12 +106,22 @@ class PMPackage(ABCObject): """ The environment accessor object for the package. =20 - @type: L{PMPackageEnvironment} + Please note that this function may return C{None} if environment is + inaccessible (path is unavailable or file does not exist). + + @type: L{PMPackageEnvironment}/C{None} """ + p =3D self.path + if p is None: + return None + if os.path.isdir(p): # XXX: look for .bz2 and plain, take the newer one p =3D os.path.join(p, 'environment.bz2') + + if not os.path.exists(p): + return None return PMPackageEnvironment(p) =20 def __eq__(self, other):