OLD | NEW |
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 27 matching lines...) Expand all Loading... |
38 parser.add_argument( | 38 parser.add_argument( |
39 '-v', '--verbose', action='store_true', default=False, | 39 '-v', '--verbose', action='store_true', default=False, |
40 help='log included files and URLs') | 40 help='log included files and URLs') |
41 return parser.parse_args() | 41 return parser.parse_args() |
42 | 42 |
43 | 43 |
44 def main(): | 44 def main(): |
45 """Entry point for the rendering script (flrender).""" | 45 """Entry point for the rendering script (flrender).""" |
46 sources = { | 46 sources = { |
47 'http': WebSource('http'), | 47 'http': WebSource('http'), |
48 'https': WebSource('https') | 48 'https': WebSource('https'), |
49 } | 49 } |
50 args = parse_args() | 50 args = parse_args() |
51 | 51 |
52 if args.verbose: | 52 if args.verbose: |
53 logging.basicConfig(level=logging.INFO, stream=sys.stderr, | 53 logging.basicConfig(level=logging.INFO, stream=sys.stderr, |
54 format='%(message)s') | 54 format='%(message)s') |
55 | 55 |
56 for include_path in args.include: | 56 for include_path in args.include: |
57 name, path = include_path.split('=', 1) | 57 name, path = include_path.split('=', 1) |
58 sources[name] = FSSource(path) | 58 sources[name] = FSSource(path) |
59 | 59 |
60 try: | 60 try: |
61 lines = render_filterlist(args.infile, sources, TopSource()) | 61 lines = render_filterlist(args.infile, sources, TopSource()) |
62 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: |
63 for line in lines: | 63 for line in lines: |
64 out_fp.write(line.to_string() + '\n') | 64 out_fp.write(line.to_string() + '\n') |
65 except (MissingHeader, NotFound, IncludeError) as exc: | 65 except (MissingHeader, NotFound, IncludeError) as exc: |
66 sys.exit(exc) | 66 sys.exit(exc) |
OLD | NEW |