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

Side by Side Diff: abp/filters/render_script.py

Issue 29341320: Noissue - Added flake8-abp and pep8-naming extension and fix reported warnings (Closed)
Patch Set: Created May 12, 2016, 2:44 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 | « abp/filters/parser.py ('k') | abp/filters/renderer.py » ('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 Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
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
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 import argparse 16 import argparse
17 import codecs 17 import io
18 import logging 18 import logging
19 import sys 19 import sys
20 20
21 from .sources import FSSource, TopSource, WebSource, NotFound 21 from .sources import FSSource, TopSource, WebSource, NotFound
22 from .renderer import render_filterlist, IncludeError, MissingHeader 22 from .renderer import render_filterlist, IncludeError, MissingHeader
23 23
24 24
25 def parse_args(): 25 def parse_args():
26 parser = argparse.ArgumentParser(description='Render a filter list.') 26 parser = argparse.ArgumentParser(description='Render a filter list.')
27 parser.add_argument( 27 parser.add_argument(
(...skipping 20 matching lines...) Expand all
48 if args.verbose: 48 if args.verbose:
49 logging.basicConfig(level=logging.INFO, stream=sys.stderr, 49 logging.basicConfig(level=logging.INFO, stream=sys.stderr,
50 format='%(message)s') 50 format='%(message)s')
51 51
52 for include_path in args.include: 52 for include_path in args.include:
53 name, path = include_path.split('=', 1) 53 name, path = include_path.split('=', 1)
54 sources[name] = FSSource(path) 54 sources[name] = FSSource(path)
55 55
56 try: 56 try:
57 lines = render_filterlist(args.infile, sources, TopSource()) 57 lines = render_filterlist(args.infile, sources, TopSource())
58 with codecs.open(args.outfile, 'wb', encoding='utf-8') as out_fp: 58 with io.open(args.outfile, 'w', encoding='utf-8') as out_fp:
59 for line in lines: 59 for line in lines:
60 out_fp.write(line.to_string() + '\n') 60 out_fp.write(line.to_string() + '\n')
Sebastian Noack 2016/05/12 14:47:24 This will fail now if line.to_string() returns a b
Vasily Kuznetsov 2016/05/12 15:22:23 line.to_string() is supposed to always return unic
61 except (MissingHeader, NotFound, IncludeError) as exc: 61 except (MissingHeader, NotFound, IncludeError) as exc:
62 sys.exit(exc) 62 sys.exit(exc)
OLDNEW
« no previous file with comments | « abp/filters/parser.py ('k') | abp/filters/renderer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld