Implement Atom.__cmp__() so that things like list.sort() work correctly
authorZac Medico <zmedico@gentoo.org>
Sat, 21 Jun 2008 22:22:59 +0000 (22:22 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 21 Jun 2008 22:22:59 +0000 (22:22 -0000)
for Atom instances.

svn path=/main/trunk/; revision=10757

pym/portage/dep.py

index 23b26a3cba363ff1ebe71369f4d75bd01069d381..3d3b5d954d1f4e80f325cf37b7a10d6ab18441e8 100644 (file)
@@ -440,6 +440,15 @@ class Atom(object):
                else:
                        self.use = None
 
+       def __cmp__(self, other):
+               self_str = str(self)
+               other_str = str(other)
+               if self_str == other_str:
+                       return 0
+               if self_str > other_str:
+                       return 1
+               return -1
+
 def get_operator(mydep):
        """
        Return the operator used in a depstring.