diff options
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/pynche/ColorDB.py | 5 | ||||
-rwxr-xr-x | Tools/scripts/finddiv.py | 2 | ||||
-rw-r--r-- | Tools/unicode/makeunicodedata.py | 13 |
3 files changed, 13 insertions, 7 deletions
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py index 3b978fb..6d52b40 100644 --- a/Tools/pynche/ColorDB.py +++ b/Tools/pynche/ColorDB.py @@ -122,10 +122,7 @@ class ColorDB: self.__allnames = [] for name, aliases in self.__byrgb.values(): self.__allnames.append(name) - # sort irregardless of case - def nocase_cmp(n1, n2): - return cmp(n1.lower(), n2.lower()) - self.__allnames.sort(nocase_cmp) + self.__allnames.sort(key=unicode.lower) return self.__allnames def aliases_of(self, red, green, blue): diff --git a/Tools/scripts/finddiv.py b/Tools/scripts/finddiv.py index 9d5862b..558791f 100755 --- a/Tools/scripts/finddiv.py +++ b/Tools/scripts/finddiv.py @@ -78,7 +78,7 @@ def processdir(dir, listnames): fn = os.path.join(dir, name) if os.path.normcase(fn).endswith(".py") or os.path.isdir(fn): files.append(fn) - files.sort(lambda a, b: cmp(os.path.normcase(a), os.path.normcase(b))) + files.sort(key=os.path.normcase) exit = None for fn in files: x = process(fn, listnames) diff --git a/Tools/unicode/makeunicodedata.py b/Tools/unicode/makeunicodedata.py index 5b5b5dc..f080ca2 100644 --- a/Tools/unicode/makeunicodedata.py +++ b/Tools/unicode/makeunicodedata.py @@ -441,6 +441,15 @@ def makeunicodetype(unicode, trace): # -------------------------------------------------------------------- # unicode name database +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 + def makeunicodename(unicode, trace): FILE = "Modules/unicodename_db.h" @@ -490,7 +499,7 @@ def makeunicodename(unicode, trace): if r: return r return cmp(aword, bword) - wordlist.sort(cmpwords) + wordlist.sort(key=CmpToKey(cmpwords)) # figure out how many phrasebook escapes we need escapes = 0 @@ -514,7 +523,7 @@ def makeunicodename(unicode, trace): # length (to maximize overlap) wordlist, wordtail = wordlist[:short], wordlist[short:] - wordtail.sort(lambda a, b: len(b[0])-len(a[0])) + wordtail.sort(key=lambda a: a[0], reverse=True) wordlist.extend(wordtail) # generate lexicon from words |