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

Unified Diff: cms/converters.py

Issue 29711681: Noissue - Remove Redundant Parentheses (Closed) Base URL: https://hg.adblockplus.org/cms
Patch Set: add list comprehension and positional args Created March 2, 2018, 12:51 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/converters.py
===================================================================
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -176,30 +176,30 @@
# Insert fixed strings
for i, fixed_string in enumerate(fixed_strings, 1):
result = result.replace('{{{}}}'.format(i), fixed_string)
# Insert attributes
result = escape(result)
- def stringify_attribute((name, value)):
+ def stringify_attribute(name, value):
return '{}="{}"'.format(
escape(name),
escape(self.insert_localized_strings(value, {}))
)
for tag in self.whitelist:
allowed_contents = '(?:[^<>]|{})'.format('|'.join(
'<(?:{}[^<>]*?|/{})>'.format(t, t)
for t in map(re.escape, self.whitelist - {tag})
))
saved = saved_attributes.get(tag, [])
for attrs in saved:
- attrs = map(stringify_attribute, attrs)
+ attrs = [stringify_attribute(*attr) for attr in attrs]
result = re.sub(
r'{}({}*?){}'.format(re_escape('<{}>'.format(tag)),
allowed_contents,
re_escape('</{}>'.format(tag))),
lambda match: r'<{}{}>{}</{}>'.format(
tag,
' ' + ' '.join(attrs) if attrs else '',
match.group(1),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld