fix ox.text in python 3

This commit is contained in:
j 2014-09-30 21:17:15 +02:00
parent d4d09b56b6
commit a9002374b1

View file

@ -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)