Ravi Mistry | 914f0e3 | 2019-03-22 13:25:45 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2019 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Script that generates a page_set for the webpages_playback.py script.""" |
| 7 | |
| 8 | import jinja2 |
| 9 | import os |
| 10 | |
| 11 | |
| 12 | PAGE_SET_TEMPLATE = 'page_set_template' |
| 13 | PAGE_SET_DIR = 'page_sets' |
| 14 | |
| 15 | |
| 16 | def main(): |
| 17 | created_page_sets = [] |
| 18 | while True: |
| 19 | user_agent = raw_input('user agent? (mobile/desktop/tablet): ') |
| 20 | url_name = raw_input('URL name? (eg: google): ') |
| 21 | url = raw_input('URL? (eg: http://www.google.com): ') |
| 22 | comment = raw_input('Reason for adding the URL? (eg: go/skia-skps-3-2019): ') |
| 23 | |
| 24 | with open(PAGE_SET_TEMPLATE) as f: |
| 25 | t = jinja2.Template(f.read()) |
| 26 | subs = { |
| 27 | 'user_agent': user_agent, |
| 28 | 'url_name': url_name, |
| 29 | 'url': url, |
| 30 | 'comment': comment, |
| 31 | } |
| 32 | |
| 33 | page_set_name = 'skia_%s_%s.py' % (url_name, user_agent) |
| 34 | page_set_path = os.path.join(PAGE_SET_DIR, page_set_name) |
| 35 | with open(page_set_path, 'w') as f: |
| 36 | f.write(t.render(**subs)) |
| 37 | created_page_sets.append(page_set_path) |
| 38 | print '\nPage set has been created in %s\n\n' % page_set_path |
| 39 | |
| 40 | keep_going = raw_input('Do you have more page sets to create? (y/n)') |
| 41 | if keep_going != 'y': |
| 42 | break |
| 43 | |
| 44 | print '\n\nSummarizing all created page sets:' |
| 45 | for page_set_path in created_page_sets: |
| 46 | print '* %s' % page_set_path |
| 47 | |
| 48 | |
| 49 | if __name__ == '__main__': |
| 50 | main() |