Mercurial > p > roundup > code
diff roundup/cgi/accept_language.py @ 6980:63c9680eed20
fake8 whitespace; variable name replacement
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 14 Sep 2022 20:19:59 -0400 |
| parents | 3b945aee0919 |
| children |
line wrap: on
line diff
--- a/roundup/cgi/accept_language.py Wed Sep 14 20:16:52 2022 -0400 +++ b/roundup/cgi/accept_language.py Wed Sep 14 20:19:59 2022 -0400 @@ -47,13 +47,13 @@ def parse(language_header): """parse(string_with_accept_header_content) -> languages list""" - if language_header is None: return [] + if language_header is None: return [] # noqa: E701 # strip whitespaces. lh = language_header.translate(*remove_ws) # if nothing, return - if lh == "": return [] + if lh == "": return [] # noqa: E701 # split by commas and parse the quality values. pls = [lre.findall(x) for x in lh.split(',')] @@ -64,18 +64,18 @@ # use a heap queue to sort by quality values. # the value of each item is 1.0 complement. pq = [] - order=0 - for l in qls: - order +=1 - if l[0] != '': - heapq.heappush(pq, (0.0, order, l[0])) + order = 0 + for lang in qls: + order += 1 + if lang[0] != '': + heapq.heappush(pq, (0.0, order, lang[0])) else: - heapq.heappush(pq, (1.0-float(l[2]), order, l[1])) + heapq.heappush(pq, (1.0-float(lang[2]), order, lang[1])) # get the languages ordered by quality # and replace - by _ - return [ heapq.heappop(pq)[2].replace('-','_') - for x in range(len(pq)) ] + return [heapq.heappop(pq)[2].replace('-', '_') for x in range(len(pq))] + if __name__ == "__main__": import doctest
