| 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 |
|
| 7 |
"""Script that generates a page_set for the webpages_playback.py script.""" |
| 8 |
|
| 9 |
|
| 10 |
from __future__ import print_function |
| 11 |
import jinja2 |
| 12 |
import os |
| 13 |
|
| 14 |
|
| 15 |
PAGE_SET_TEMPLATE = 'page_set_template' |
| 16 |
PAGE_SET_DIR = 'page_sets' |
| 17 |
|
| 18 |
|
| 19 |
def main(): |
| 20 |
created_page_sets = [] |
| 21 |
while True: |
| 22 |
user_agent = raw_input('user agent? (mobile/desktop/tablet): ') |
| 23 |
url_name = raw_input('URL name? (eg: google): ') |
| 24 |
url = raw_input('URL? (eg: http://www.google.com): ') |
| 25 |
comment = raw_input('Reason for adding the URL? (eg: go/skia-skps-3-2019): ') |
| 26 |
|
| 27 |
with open(PAGE_SET_TEMPLATE) as f: |
| 28 |
t = jinja2.Template(f.read()) |
| 29 |
subs = { |
| 30 |
'user_agent': user_agent, |
| 31 |
'url_name': url_name, |
| 32 |
'url': url, |
| 33 |
'comment': comment, |
| 34 |
} |
| 35 |
|
| 36 |
page_set_name = 'skia_%s_%s.py' % (url_name, user_agent) |
| 37 |
page_set_path = os.path.join(PAGE_SET_DIR, page_set_name) |
| 38 |
with open(page_set_path, 'w') as f: |
| 39 |
f.write(t.render(**subs)) |
| 40 |
created_page_sets.append(page_set_path) |
| 41 |
print('\nPage set has been created in %s\n\n' % page_set_path) |
| 42 |
|
| 43 |
keep_going = raw_input('Do you have more page sets to create? (y/n)') |
| 44 |
if keep_going != 'y': |
| 45 |
break |
| 46 |
|
| 47 |
print('\n\nSummarizing all created page sets:') |
| 48 |
for page_set_path in created_page_sets: |
| 49 |
print('* %s' % page_set_path) |
| 50 |
|
| 51 |
|
| 52 |
if __name__ == '__main__': |
| 53 |
main() |