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

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

Issue 29465720: Issue 4970 - Document the library API of python-abp (Closed)
Left Patch Set: Created June 14, 2017, 5:45 p.m.
Right Patch Set: Rebase to match the new master and retouche the docstrings. Created Oct. 24, 2017, 4:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
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
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 """Command line script for rendering Adblock Plus filter lists."""
17
16 import argparse 18 import argparse
17 import io 19 import io
18 import logging 20 import logging
19 import sys 21 import sys
20 22
21 from .sources import FSSource, TopSource, WebSource, NotFound 23 from .sources import FSSource, TopSource, WebSource, NotFound
22 from .renderer import render_filterlist, IncludeError, MissingHeader 24 from .renderer import render_filterlist, IncludeError, MissingHeader
25
26 __all__ = ['main']
23 27
24 28
25 def parse_args(): 29 def parse_args():
26 parser = argparse.ArgumentParser(description='Render a filter list.') 30 parser = argparse.ArgumentParser(description='Render a filter list.')
27 parser.add_argument( 31 parser.add_argument(
28 'infile', help='top level filter list fragment from which the ' 32 'infile', help='top level filter list fragment from which the '
29 'rendering starts') 33 'rendering starts')
30 parser.add_argument('outfile', help='output filter list file') 34 parser.add_argument('outfile', help='output filter list file')
31 parser.add_argument( 35 parser.add_argument(
32 '-i', '--include', action='append', default=[], metavar='NAME=PATH', 36 '-i', '--include', action='append', default=[], metavar='NAME=PATH',
(...skipping 20 matching lines...) Expand all
53 name, path = include_path.split('=', 1) 57 name, path = include_path.split('=', 1)
54 sources[name] = FSSource(path) 58 sources[name] = FSSource(path)
55 59
56 try: 60 try:
57 lines = render_filterlist(args.infile, sources, TopSource()) 61 lines = render_filterlist(args.infile, sources, TopSource())
58 with io.open(args.outfile, 'w', encoding='utf-8') as out_fp: 62 with io.open(args.outfile, 'w', encoding='utf-8') as out_fp:
59 for line in lines: 63 for line in lines:
60 out_fp.write(line.to_string() + '\n') 64 out_fp.write(line.to_string() + '\n')
61 except (MissingHeader, NotFound, IncludeError) as exc: 65 except (MissingHeader, NotFound, IncludeError) as exc:
62 sys.exit(exc) 66 sys.exit(exc)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld