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

Side by Side Diff: cms/converters.py

Issue 29753617: Issue 6545 - get_pages_metadata now returns all pages (Closed)
Patch Set: Rebase, changes comments to add citation to explain weird logic chain Created May 6, 2018, 10:59 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 | tests/expected_output/en/sitemap » ('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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 for page_name, _format in self._params['source'].list_pages(): 467 for page_name, _format in self._params['source'].list_pages():
468 data, filename = self._params['source'].read_page(page_name, 468 data, filename = self._params['source'].read_page(page_name,
469 _format) 469 _format)
470 page_data = utils.extract_page_metadata(data)[0] 470 page_data = utils.extract_page_metadata(data)[0]
471 page_data.setdefault('page', page_name) 471 page_data.setdefault('page', page_name)
472 if self.filter_metadata(filters, page_data) is True: 472 if self.filter_metadata(filters, page_data) is True:
473 return_data.append(page_data) 473 return_data.append(page_data)
474 return return_data 474 return return_data
475 475
476 def filter_metadata(self, filters, metadata): 476 def filter_metadata(self, filters, metadata):
477 # if only the page key is in the metadata then there
478 # was no user defined metadata
479 if metadata.keys() == ['page']:
480 return False
481 if filters is None: 477 if filters is None:
482 return True 478 return True
483 for filter_name, filter_value in filters.items(): 479 for filter_name, filter_value in filters.items():
484 if filter_name not in metadata: 480 if filter_name not in metadata:
485 return False 481 return False
486 if isinstance(metadata[filter_name], list): 482 if isinstance(metadata[filter_name], list):
487 if isinstance(filter_value, basestring): 483 if isinstance(filter_value, basestring):
488 filter_value = [filter_value] 484 filter_value = [filter_value]
489 for option in filter_value: 485 for option in filter_value:
490 if str(option) not in metadata[filter_name]: 486 if str(option) not in metadata[filter_name]:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 stack[-1]['subitems'].append(item) 524 stack[-1]['subitems'].append(item)
529 stack.append(item) 525 stack.append(item)
530 return structured 526 return structured
531 527
532 528
533 converters = { 529 converters = {
534 'html': RawConverter, 530 'html': RawConverter,
535 'md': MarkdownConverter, 531 'md': MarkdownConverter,
536 'tmpl': TemplateConverter, 532 'tmpl': TemplateConverter,
537 } 533 }
OLDNEW
« no previous file with comments | « no previous file | tests/expected_output/en/sitemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld