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

Delta Between Two Patch Sets: cms/converters.py

Issue 29378736: NoIssue - Improves converters.py PEP8 compliance (Closed) Base URL: https://hg.adblockplus.org/cms
Left Patch Set: Created March 8, 2017, 6:06 p.m.
Right Patch Set: Created March 9, 2017, 2:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | tox.ini » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 include_end_regex = '>' 272 include_end_regex = '>'
273 273
274 def resolve_includes(self, text): 274 def resolve_includes(self, text):
275 def resolve_include(match): 275 def resolve_include(match):
276 name = match.group(1) 276 name = match.group(1)
277 for format_, converter_class in converters.iteritems(): 277 for format_, converter_class in converters.iteritems():
278 if self._params['source'].has_include(name, format_): 278 if self._params['source'].has_include(name, format_):
279 self._params['includedata'] = ( 279 self._params['includedata'] = (
280 self._params['source'].read_include(name, format)) 280 self._params['source'].read_include(name, format))
281 281
282 converter = converter_class(self._params, key='includedata' 282 converter = converter_class(self._params,
Vasily Kuznetsov 2017/03/09 12:33:27 This looks kind of awkward with just the closing p
Jon Sonesen 2017/03/09 14:04:17 Yep, will do
283 ) 283 key='includedata')
284 result = converter() 284 result = converter()
285 self.missing_translations += converter.missing_translations 285 self.missing_translations += converter.missing_translations
286 self.total_translations += converter.total_translations 286 self.total_translations += converter.total_translations
287 return result 287 return result
288 raise Exception('Failed to resolve include {}' 288 raise Exception('Failed to resolve include {}'
289 'on page {}'.format(name, self._params['page'])) 289 'on page {}'.format(name, self._params['page']))
290 290
291 return re.sub( 291 return re.sub(
292 r'{}\?\s*include\s+([^\s<>"]+)\s*\?{}'.format( 292 r'{}\?\s*include\s+([^\s<>"]+)\s*\?{}'.format(
293 self.include_start_regex, 293 self.include_start_regex,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 stack.pop() 477 stack.pop()
478 stack[-1]['subitems'].append(item) 478 stack[-1]['subitems'].append(item)
479 stack.append(item) 479 stack.append(item)
480 return structured 480 return structured
481 481
482 converters = { 482 converters = {
483 'html': RawConverter, 483 'html': RawConverter,
484 'md': MarkdownConverter, 484 'md': MarkdownConverter,
485 'tmpl': TemplateConverter, 485 'tmpl': TemplateConverter,
486 } 486 }
LEFTRIGHT
« no previous file | tox.ini » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld