From 60f1fa4b722a79cf86c6a0940a9df218d57787b3 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 18 Nov 2012 11:06:42 -0800 Subject: remove the mispaelled duplicate file after syncronizing any changes --- layman/compatibility.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'layman/compatibility.py') diff --git a/layman/compatibility.py b/layman/compatibility.py index b71a8af..e6206db 100644 --- a/layman/compatibility.py +++ b/layman/compatibility.py @@ -6,8 +6,6 @@ Distributed under the terms of the GNU General Public License v2 """ -import sys, types - def encode(text, enc="UTF-8"): """py2, py3 compatibility function""" @@ -27,3 +25,22 @@ def fileopen(path, mode='r', enc="UTF-8"): f = open(path, mode) return f + +def cmp_to_key(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) < 0 + def __gt__(self, other): + return mycmp(self.obj, other.obj) > 0 + def __eq__(self, other): + return mycmp(self.obj, other.obj) == 0 + def __le__(self, other): + return mycmp(self.obj, other.obj) <= 0 + def __ge__(self, other): + return mycmp(self.obj, other.obj) >= 0 + def __ne__(self, other): + return mycmp(self.obj, other.obj) != 0 + return K -- cgit v1.2.3-1-g7c22