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

Delta Between Two Patch Sets: abp/filters/diff_script.py

Issue 29884571: Issue 6945 - Add script to make filter list diffs (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Left Patch Set: Address comments on PS3, add README Created Sept. 24, 2018, 10:04 p.m.
Right Patch Set: Fix docstring Created Sept. 26, 2018, 6:20 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 | « README.md ('k') | abp/filters/renderer.py » ('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 Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
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 12 matching lines...) Expand all
23 23
24 from .renderer import render_diff 24 from .renderer import render_diff
25 25
26 __all__ = ['main'] 26 __all__ = ['main']
27 27
28 28
29 def parse_args(): 29 def parse_args():
30 parser = argparse.ArgumentParser(description='Render a filter list diff.') 30 parser = argparse.ArgumentParser(description='Render a filter list diff.')
31 parser.add_argument( 31 parser.add_argument(
32 'base', help='the older filter list that needs to be updated', 32 'base', help='the older filter list that needs to be updated',
33 nargs='?') 33 nargs='?')
Sebastian Noack 2018/09/24 22:21:09 Didn't we want to make those arguments mandatory?
rhowell 2018/09/25 01:53:45 Positional arguments are already mandatory (or it
Sebastian Noack 2018/09/25 17:00:39 I see, the documentation seems a little misleading
34 parser.add_argument( 34 parser.add_argument(
35 'latest', help='the most recent version of the filter list', 35 'latest', help='the most recent version of the filter list',
36 nargs='?') 36 nargs='?')
37 parser.add_argument( 37 parser.add_argument(
38 'outfile', help='output file for filter list diff', 38 'outfile', help='output file for filter list diff',
39 default='-', nargs='?') 39 default='-', nargs='?')
40 return parser.parse_args() 40 return parser.parse_args()
41 41
42 42
43 def main(): 43 def main():
44 """Entry point for the diff rendering script (diffrender).""" 44 """Entry point for the diff rendering script (fldiff)."""
45 args = parse_args() 45 args = parse_args()
46 46
47 with io.open(args.base, 'r', encoding='utf-8') as base, \ 47 with io.open(args.base, 'r', encoding='utf-8') as base, \
48 io.open(args.latest, 'r', encoding='utf-8') as latest: 48 io.open(args.latest, 'r', encoding='utf-8') as latest:
49 49
50 lines = render_diff(base, latest) 50 lines = render_diff(base, latest)
51 if args.outfile == '-': 51 if args.outfile == '-':
52 outfile = io.open(sys.stdout.fileno(), 'w', 52 outfile = io.open(sys.stdout.fileno(), 'w',
53 closefd=False, 53 closefd=False,
54 encoding=sys.stdout.encoding or 'utf-8') 54 encoding=sys.stdout.encoding or 'utf-8')
55 else: 55 else:
56 outfile = io.open(args.outfile, 'w', encoding='utf-8') 56 outfile = io.open(args.outfile, 'w', encoding='utf-8')
57 57
58 with outfile: 58 with outfile:
59 for line in lines: 59 for line in lines:
60 print(line, file=outfile) 60 print(line, file=outfile)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld