Commits

Michał Górny committed 5926e39

Portage: support atom comparison in vardb.

  • Participants
  • Parent commits d098127

Comments (0)

Files changed (1)

File gentoopm/portagepm/pkg.py

 	def atom(self):
 		return PortageAtom('=%s' % self.id, self)
 
+	def __cmp__(self, other):
+		if not isinstance(other, PortageDBCPV):
+			raise TypeError('Unable to compare %s against %s' % \
+					(self, other))
+		return cmp(cpv_getkey(self._cpv), cpv_getkey(other._cpv)) \
+				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv))
+
 class PortageCPV(PortageDBCPV):
 	def __init__(self, cpv, dbapi, tree, repo_prio):
 		PortageDBCPV.__init__(self, cpv, dbapi)