Debian Codegraph @

utils.py

raw symbols SCIP
1 # Thanks baboon project for the code.
2 import subprocess
3
4
5 def cmp_to_key(mycmp):
6 """ Converts a cmp= function into a key= function.
7 """
8
9 class K(object):
10 def __init__(self, obj, *args):
11 self.obj = obj
12
13 def __lt__(self, other):
14 return mycmp(self.obj, other.obj) < 0
15
16 def __gt__(self, other):
17 return mycmp(self.obj, other.obj) > 0
18
19 def __eq__(self, other):
20 return mycmp(self.obj, other.obj) == 0
21
22 def __le__(self, other):
23 return mycmp(self.obj, other.obj) <= 0
24
25 def __ge__(self, other):
26 return mycmp(self.obj, other.obj) >= 0
27
28 def __ne__(self, other):
29 return mycmp(self.obj, other.obj) != 0
30
31 def __hash__(self):
32 raise TypeError('hash not implemented')
33
34 return K