Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/templateFilters.py

Issue 29756646: Noissue - Adapt best practices for trailing commas (abpssembly) (Closed)
Patch Set: Re-run script on Python 2, added flake8-commas extension Created April 19, 2018, 2:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 def subscriptionSort(value, prioritizeRecommended=True): 123 def subscriptionSort(value, prioritizeRecommended=True):
124 value = value[:] # create a copy of the list 124 value = value[:] # create a copy of the list
125 if prioritizeRecommended: 125 if prioritizeRecommended:
126 value.sort( 126 value.sort(
127 lambda a, b: 127 lambda a, b:
128 cmp(a.type, b.type) or 128 cmp(a.type, b.type) or
129 cmp(a.deprecated, b.deprecated) or 129 cmp(a.deprecated, b.deprecated) or
130 cmp(b.catchall, a.catchall) or 130 cmp(b.catchall, a.catchall) or
131 cmp(b.recommendation != None, a.recommendation != None) or 131 cmp(b.recommendation != None, a.recommendation != None) or
132 cmp(a.name.lower(), b.name.lower()) 132 cmp(a.name.lower(), b.name.lower()),
133 ) 133 )
134 else: 134 else:
135 value.sort( 135 value.sort(
136 lambda a, b: 136 lambda a, b:
137 cmp(a.type, b.type) or 137 cmp(a.type, b.type) or
138 cmp(a.deprecated, b.deprecated) or 138 cmp(a.deprecated, b.deprecated) or
139 cmp(a.name.lower(), b.name.lower()) 139 cmp(a.name.lower(), b.name.lower()),
140 ) 140 )
141 return value 141 return value
142 142
143 143
144 def formatmime(text): 144 def formatmime(text):
145 # See http://bugs.python.org/issue5871 (not really fixed), Header() will 145 # See http://bugs.python.org/issue5871 (not really fixed), Header() will
146 # happily accept non-printable characters including newlines. Make sure to 146 # happily accept non-printable characters including newlines. Make sure to
147 # remove them. 147 # remove them.
148 text = re.sub(r'[\x00-\x1F]', '', text) 148 text = re.sub(r'[\x00-\x1F]', '', text)
149 return email.header.Header(text).encode() 149 return email.header.Header(text).encode()
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 'subscriptionSort': subscriptionSort, 201 'subscriptionSort': subscriptionSort,
202 'mime': formatmime, 202 'mime': formatmime,
203 'emailaddr': email.utils.formataddr, 203 'emailaddr': email.utils.formataddr,
204 'ljust': ljust, 204 'ljust': ljust,
205 'rjust': rjust, 205 'rjust': rjust,
206 'ltruncate': ltruncate, 206 'ltruncate': ltruncate,
207 'weekday': formatweekday, 207 'weekday': formatweekday,
208 'bytes': formatbytes, 208 'bytes': formatbytes,
209 'json': toJSON, 209 'json': toJSON,
210 } 210 }
OLDNEW
« no previous file with comments | « sitescripts/submit_email/web/submit_email.py ('k') | sitescripts/testpages/web/sitekey_frame.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld