summaryrefslogtreecommitdiff
path: root/Lib/bsddb/dbtables.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-30 02:55:10 +0000
committerRaymond Hettinger <python@rcn.com>2008-01-30 02:55:10 +0000
commitd4cb56d4e88c7e001bbaba2c80953db47632f199 (patch)
tree73c95e0223ed8a98fac797fc99ab1bffae9c5457 /Lib/bsddb/dbtables.py
parentfd66e51c4c1ff9293b0f332d6ebc8093b2ef12bb (diff)
downloadcpython-git-d4cb56d4e88c7e001bbaba2c80953db47632f199.tar.gz
Convert some custom sort comparison functions to equivalent key functions.
Diffstat (limited to 'Lib/bsddb/dbtables.py')
-rw-r--r--Lib/bsddb/dbtables.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 56b4e3a01d..563390ba6f 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -88,6 +88,15 @@ class LikeCond(Cond):
def __call__(self, s):
return self.re.match(s.decode(self.encoding))
+def CmpToKey(mycmp):
+ 'Convert a cmp= function into a key= function'
+ class K(object):
+ def __init__(self, obj, *args):
+ self.obj = obj
+ def __lt__(self, other):
+ return mycmp(self.obj, other.obj) == -1
+ return K
+
#
# keys used to store database metadata
#
@@ -587,7 +596,7 @@ class bsdTableDB :
return 0
conditionlist = list(conditions.items())
- conditionlist.sort(cmp_conditions)
+ conditionlist.sort(key=CmpToKey(cmp_conditions))
# Apply conditions to column data to find what we want
cur = self.db.cursor()