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

Delta Between Two Patch Sets: cms/bin/generate_static_pages.py

Issue 29555839: Issue 5336 - Allow additional include, page, and template paths using CMS (Closed)
Left Patch Set: Address comments on PS1 Created Sept. 27, 2017, 11:33 a.m.
Right Patch Set: Rename 'static' parameter to 'cached' Created Oct. 2, 2017, 10:49 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 | « no previous file | cms/bin/test_server.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 try: 46 try:
47 os.makedirs(os.path.dirname(outfile)) 47 os.makedirs(os.path.dirname(outfile))
48 except OSError as e: 48 except OSError as e:
49 if e.errno != errno.EEXIST: 49 if e.errno != errno.EEXIST:
50 raise 50 raise
51 51
52 with codecs.open(outfile, 'wb', encoding=encoding) as handle: 52 with codecs.open(outfile, 'wb', encoding=encoding) as handle:
53 handle.write(contents) 53 handle.write(contents)
54 54
55 with create_source(repo, static=True, revision=revision) as source: 55 with create_source(repo, cached=True, revision=revision) as source:
56 config = source.read_config() 56 config = source.read_config()
57 defaultlocale = config.get('general', 'defaultlocale') 57 defaultlocale = config.get('general', 'defaultlocale')
58 locales = list(source.list_locales()) 58 locales = list(source.list_locales())
59 if defaultlocale not in locales: 59 if defaultlocale not in locales:
60 locales.append(defaultlocale) 60 locales.append(defaultlocale)
61 61
62 # First pass: compile the list of pages with given translation level 62 # First pass: compile the list of pages with given translation level
63 def get_locale_file(page): 63 def get_locale_file(page):
64 try: 64 try:
65 return config.get('locale_overrides', page) 65 return config.get('locale_overrides', page)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 if __name__ == '__main__': 125 if __name__ == '__main__':
126 parser = ArgumentParser('Convert website source to static website') 126 parser = ArgumentParser('Convert website source to static website')
127 parser.add_argument('-r', '--rev', 127 parser.add_argument('-r', '--rev',
128 help=('Specify which revision to generate from. ' 128 help=('Specify which revision to generate from. '
129 'See "hg help revisions" for details.'), 129 'See "hg help revisions" for details.'),
130 default='default') 130 default='default')
131 parser.add_argument('source', help="Path to website's repository") 131 parser.add_argument('source', help="Path to website's repository")
132 parser.add_argument('output', help='Path to desired output directory') 132 parser.add_argument('output', help='Path to desired output directory')
133 args = parser.parse_args() 133 args = parser.parse_args()
134 generate_pages(args.source, args.output, args.rev) 134 generate_pages(args.source, args.output, args.rev)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld