OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 return | 50 return |
51 known_files.add(outfile) | 51 known_files.add(outfile) |
52 | 52 |
53 if os.path.exists(outfile): | 53 if os.path.exists(outfile): |
54 with codecs.open(outfile, 'rb', encoding=encoding) as handle: | 54 with codecs.open(outfile, 'rb', encoding=encoding) as handle: |
55 if handle.read() == contents: | 55 if handle.read() == contents: |
56 return | 56 return |
57 | 57 |
58 try: | 58 try: |
59 os.makedirs(os.path.dirname(outfile)) | 59 os.makedirs(os.path.dirname(outfile)) |
60 except OSError, e: | 60 except OSError as e: |
61 if e.errno != errno.EEXIST: | 61 if e.errno != errno.EEXIST: |
62 raise | 62 raise |
63 | 63 |
64 with codecs.open(outfile, 'wb', encoding=encoding) as handle: | 64 with codecs.open(outfile, 'wb', encoding=encoding) as handle: |
65 handle.write(contents) | 65 handle.write(contents) |
66 | 66 |
67 with MercurialSource(repo) as source: | 67 with MercurialSource(repo) as source: |
68 # Cache the result for some functions - we can assume here that the data | 68 # Cache the result for some functions - we can assume here that the data |
69 # never changes | 69 # never changes |
70 source.resolve_link = memoize(source.resolve_link) | 70 source.resolve_link = memoize(source.resolve_link) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 os.rmdir(path) | 143 os.rmdir(path) |
144 remove_unknown(output_dir) | 144 remove_unknown(output_dir) |
145 | 145 |
146 if __name__ == '__main__': | 146 if __name__ == '__main__': |
147 if len(sys.argv) < 3: | 147 if len(sys.argv) < 3: |
148 print >>sys.stderr, 'Usage: %s source_repository output_dir' % sys.argv[
0] | 148 print >>sys.stderr, 'Usage: %s source_repository output_dir' % sys.argv[
0] |
149 sys.exit(1) | 149 sys.exit(1) |
150 | 150 |
151 repo, output_dir = sys.argv[1:3] | 151 repo, output_dir = sys.argv[1:3] |
152 generate_pages(repo, output_dir) | 152 generate_pages(repo, output_dir) |
OLD | NEW |