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 1QhqoC-0000di-Sq for garchives@archives.gentoo.org; Fri, 15 Jul 2011 22:24:33 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AB23D21C0D6; Fri, 15 Jul 2011 22:24:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7A0EB21C0D6 for ; Fri, 15 Jul 2011 22:24:20 +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 F059E2AC142 for ; Fri, 15 Jul 2011 22:24:19 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 589B08003F for ; Fri, 15 Jul 2011 22:24:19 +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: <57df866612ecdce17fef00f304da795f5a3b5fbd.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/basepm/atom.py X-VCS-Directories: gentoopm/basepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 57df866612ecdce17fef00f304da795f5a3b5fbd Date: Fri, 15 Jul 2011 22:24:19 +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: d1a8f84ca46501f4b713b945ad43fd05 commit: 57df866612ecdce17fef00f304da795f5a3b5fbd Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Fri Jul 15 22:19:05 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Fri Jul 15 22:19:05 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D57df8666 PMAtom: support hashing, '=3D=3D' and '!=3D'. --- gentoopm/basepm/atom.py | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py index 040563a..11ec313 100644 --- a/gentoopm/basepm/atom.py +++ b/gentoopm/basepm/atom.py @@ -43,6 +43,19 @@ class PMAtom(ABCObject): """ pass =20 + def __eq__(self, other): + if not self.complete: + raise NotImplementedError('Unable to compare incomplete atoms') + return str(self) =3D=3D str(other) + + def __ne__(self, other): + return not self.__eq__(other) + + def __hash__(self): + if not self.complete: + raise NotImplementedError('Unable to hash incomplete atoms') + return hash(str(self)) + def __repr__(self): if self.complete: s =3D repr(self.__str__())