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

Side by Side Diff: cms/converters.py

Issue 29711681: Noissue - Remove Redundant Parentheses (Closed) Base URL: https://hg.adblockplus.org/cms
Patch Set: Created Feb. 28, 2018, 11:52 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 | « no previous file | no next file » | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 if callback: 174 if callback:
175 callback(page, locale, name, result, comment, fixed_strings) 175 callback(page, locale, name, result, comment, fixed_strings)
176 176
177 # Insert fixed strings 177 # Insert fixed strings
178 for i, fixed_string in enumerate(fixed_strings, 1): 178 for i, fixed_string in enumerate(fixed_strings, 1):
179 result = result.replace('{{{}}}'.format(i), fixed_string) 179 result = result.replace('{{{}}}'.format(i), fixed_string)
180 180
181 # Insert attributes 181 # Insert attributes
182 result = escape(result) 182 result = escape(result)
183 183
184 def stringify_attribute((name, value)): 184 def stringify_attribute(attribute):
Jon Sonesen 2018/03/01 00:00:15 alternatively, you can expand tuples when passed e
185 name, value = attribute
185 return '{}="{}"'.format( 186 return '{}="{}"'.format(
186 escape(name), 187 escape(name),
187 escape(self.insert_localized_strings(value, {})) 188 escape(self.insert_localized_strings(value, {}))
188 ) 189 )
189 190
190 for tag in self.whitelist: 191 for tag in self.whitelist:
191 allowed_contents = '(?:[^<>]|{})'.format('|'.join( 192 allowed_contents = '(?:[^<>]|{})'.format('|'.join(
192 '<(?:{}[^<>]*?|/{})>'.format(t, t) 193 '<(?:{}[^<>]*?|/{})>'.format(t, t)
193 for t in map(re.escape, self.whitelist - {tag}) 194 for t in map(re.escape, self.whitelist - {tag})
194 )) 195 ))
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 stack[-1]['subitems'].append(item) 529 stack[-1]['subitems'].append(item)
529 stack.append(item) 530 stack.append(item)
530 return structured 531 return structured
531 532
532 533
533 converters = { 534 converters = {
534 'html': RawConverter, 535 'html': RawConverter,
535 'md': MarkdownConverter, 536 'md': MarkdownConverter,
536 'tmpl': TemplateConverter, 537 'tmpl': TemplateConverter,
537 } 538 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld