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

Delta Between Two Patch Sets: sitescripts/content_blocker_lists/bin/generate_lists.py

Issue 29329537: Issue 3168 - Add a script for generating content blocker lists (Closed)
Left Patch Set: Rebased, check retcode outside the finally block Created Nov. 19, 2015, 8:44 p.m.
Right Patch Set: Remove retcode variable, move return code check out of the with block Created Nov. 20, 2015, 7 a.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 | « sitescripts/content_blocker_lists/bin/__init__.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This file is part of Adblock Plus <https://adblockplus.org/>, 4 # This file is part of Adblock Plus <https://adblockplus.org/>,
5 # Copyright (C) 2006-2015 Eyeo GmbH 5 # Copyright (C) 2006-2015 Eyeo GmbH
6 # 6 #
7 # Adblock Plus is free software: you can redistribute it and/or modify 7 # Adblock Plus is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3 as 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 abp2blocklist_path = config.get("content_blocker_lists", 53 abp2blocklist_path = config.get("content_blocker_lists",
54 "abp2blocklist_path") 54 "abp2blocklist_path")
55 process = subprocess.Popen(("node", "abp2blocklist.js"), 55 process = subprocess.Popen(("node", "abp2blocklist.js"),
56 cwd=abp2blocklist_path, stdin=subprocess.PIPE, 56 cwd=abp2blocklist_path, stdin=subprocess.PIPE,
57 stdout=destination_file) 57 stdout=destination_file)
58 try: 58 try:
59 for source in sources: 59 for source in sources:
60 print >>process.stdin, source 60 print >>process.stdin, source
61 finally: 61 finally:
62 process.stdin.close() 62 process.stdin.close()
63 retcode = process.wait() 63 process.wait()
64 64
65 if retcode: 65 if process.returncode:
Sebastian Noack 2015/11/20 00:03:47 You can move that out of the with block as well. A
Felix Dahlke 2015/11/20 07:00:55 Done.
66 raise Exception("abp2blocklist returned %s" % retcode) 66 raise Exception("abp2blocklist returned %s" % process.returncode)
67 67
68 if __name__ == "__main__": 68 if __name__ == "__main__":
69 _update_abp2blocklist() 69 _update_abp2blocklist()
70 70
71 easylist = _download("easylist_url") 71 easylist = _download("easylist_url")
72 exceptionrules = _download("exceptionrules_url") 72 exceptionrules = _download("exceptionrules_url")
73 73
74 _convert_filter_list([easylist], "easylist_content_blocker_path") 74 _convert_filter_list([easylist], "easylist_content_blocker_path")
75 _convert_filter_list([easylist, exceptionrules], 75 _convert_filter_list([easylist, exceptionrules],
76 "combined_content_blocker_path") 76 "combined_content_blocker_path")
LEFTRIGHT

Powered by Google App Engine
This is Rietveld