From a9002374b1ed87cbef6278beac2376adab3320bc Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 30 Sep 2014 21:17:15 +0200 Subject: [PATCH] fix ox.text in python 3 --- ox/text.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ox/text.py b/ox/text.py index 9158de9..7630652 100644 --- a/ox/text.py +++ b/ox/text.py @@ -322,7 +322,7 @@ def find_string(string, string0='', string1 = ''): def parse_useragent(useragent): data = {} for key in UA_REGEXPS: - for alias, regexp in UA_ALIASES[key].iteritems(): + for alias, regexp in UA_ALIASES[key].items(): alias = alias if key == 'browser' else alias + ' \\1' useragent = re.sub(regexp, alias, useragent) for regexp in UA_REGEXPS[key]: @@ -390,7 +390,7 @@ def wrap_string(string, length=80, separator='\n', balance=False): # can be achieved with a shorter line length lines = wrap_string(string, length, separator, False).split(separator) if len(lines) > 1: - while length > max(map(lambda x : len(x), words)): + while length > max([len(x) for x in words]): length -= 1 if len(wrap_string(string, length, separator, False).split(separator)) > len(lines): length += 1 @@ -588,4 +588,6 @@ def sort_string(string): return unicodedata.normalize('NFKD', string) def sorted_strings(strings, key=None): - return sorted(strings, cmp=lambda a, b: cmp(sort_string(a), sort_string(b)), key=key) + if not key: + key = lambda k: sort_string(k) + return sorted(strings, key=key)