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

Side by Side Diff: sitescripts/templateFilters.py

Issue 29670611: Issue 5844 - Remove redundant parentheses in sitescripts and abpsembly (Closed) Base URL: https://hg.adblockplus.org/sitescripts/
Patch Set: Addressed the comments in /sitescripts Created Jan. 25, 2018, 4:12 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
« no previous file with comments | « sitescripts/subscriptions/web/fallback.py ('k') | sitescripts/urlfixer/web/submitData.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return Markup(value) 116 return Markup(value)
117 117
118 118
119 def urlencode(value): 119 def urlencode(value):
120 return urllib.quote(value.encode('utf-8'), '') 120 return urllib.quote(value.encode('utf-8'), '')
121 121
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(lambda a, b: ( 126 value.sort(
127 cmp(a.type, b.type) or 127 lambda a, b:
128 cmp(a.deprecated, b.deprecated) or 128 cmp(a.type, b.type) or
129 cmp(b.catchall, a.catchall) or 129 cmp(a.deprecated, b.deprecated) or
130 cmp(b.recommendation != None, a.recommendation != None) or 130 cmp(b.catchall, a.catchall) or
131 cmp(a.name.lower(), b.name.lower()) 131 cmp(b.recommendation != None, a.recommendation != None) or
132 )) 132 cmp(a.name.lower(), b.name.lower())
133 )
133 else: 134 else:
134 value.sort(lambda a, b: ( 135 value.sort(
135 cmp(a.type, b.type) or 136 lambda a, b:
136 cmp(a.deprecated, b.deprecated) or 137 cmp(a.type, b.type) or
137 cmp(a.name.lower(), b.name.lower()) 138 cmp(a.deprecated, b.deprecated) or
138 )) 139 cmp(a.name.lower(), b.name.lower())
140 )
139 return value 141 return value
140 142
141 143
142 def formatmime(text): 144 def formatmime(text):
143 # See http://bugs.python.org/issue5871 (not really fixed), Header() will 145 # See http://bugs.python.org/issue5871 (not really fixed), Header() will
144 # happily accept non-printable characters including newlines. Make sure to 146 # happily accept non-printable characters including newlines. Make sure to
145 # remove them. 147 # remove them.
146 text = re.sub(r'[\x00-\x1F]', '', text) 148 text = re.sub(r'[\x00-\x1F]', '', text)
147 return email.header.Header(text).encode() 149 return email.header.Header(text).encode()
148 150
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 'subscriptionSort': subscriptionSort, 201 'subscriptionSort': subscriptionSort,
200 'mime': formatmime, 202 'mime': formatmime,
201 'emailaddr': email.utils.formataddr, 203 'emailaddr': email.utils.formataddr,
202 'ljust': ljust, 204 'ljust': ljust,
203 'rjust': rjust, 205 'rjust': rjust,
204 'ltruncate': ltruncate, 206 'ltruncate': ltruncate,
205 'weekday': formatweekday, 207 'weekday': formatweekday,
206 'bytes': formatbytes, 208 'bytes': formatbytes,
207 'json': toJSON, 209 'json': toJSON,
208 } 210 }
OLDNEW
« no previous file with comments | « sitescripts/subscriptions/web/fallback.py ('k') | sitescripts/urlfixer/web/submitData.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld