Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: tools/telemetry/telemetry/page/page_set.py

Issue 311193003: [telemetry] Cleanups for benchmarks importing page sets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove description fo' realz. (from gpu tests) Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import csv 5 import csv
6 import inspect 6 import inspect
7 import os 7 import os
8 8
9 from telemetry.core import util 9 from telemetry.core import util
10 from telemetry.page import page as page_module 10 from telemetry.page import page as page_module
11 from telemetry.page import page_set_archive_info 11 from telemetry.page import page_set_archive_info
12 12
13 class PageSetError(Exception): 13 class PageSetError(Exception):
14 pass 14 pass
15 15
16 16
17 class PageSet(object): 17 class PageSet(object):
18 def __init__(self, file_path=None, description='', archive_data_file='', 18 def __init__(self, file_path=None, archive_data_file='',
19 credentials_path=None, user_agent_type=None, 19 credentials_path=None, user_agent_type=None,
20 make_javascript_deterministic=True, startup_url='', 20 make_javascript_deterministic=True, startup_url='',
21 serving_dirs=None): 21 serving_dirs=None):
22 # The default value of file_path is location of the file that define this 22 # The default value of file_path is location of the file that define this
23 # page set instance's class. 23 # page set instance's class.
24 if file_path is None: 24 if file_path is None:
25 file_path = inspect.getfile(self.__class__) 25 file_path = inspect.getfile(self.__class__)
26 # Turn pyc file into py files if we can 26 # Turn pyc file into py files if we can
27 if file_path.endswith('.pyc') and os.path.exists(file_path[:-1]): 27 if file_path.endswith('.pyc') and os.path.exists(file_path[:-1]):
28 file_path = file_path[:-1] 28 file_path = file_path[:-1]
29 29
30 self.file_path = file_path 30 self.file_path = file_path
31 # These attributes can be set dynamically by the page set. 31 # These attributes can be set dynamically by the page set.
32 self.description = description
33 self.archive_data_file = archive_data_file 32 self.archive_data_file = archive_data_file
34 self.credentials_path = credentials_path 33 self.credentials_path = credentials_path
35 self.user_agent_type = user_agent_type 34 self.user_agent_type = user_agent_type
36 self.make_javascript_deterministic = make_javascript_deterministic 35 self.make_javascript_deterministic = make_javascript_deterministic
37 self._wpr_archive_info = None 36 self._wpr_archive_info = None
38 self.startup_url = startup_url 37 self.startup_url = startup_url
39 self.pages = [] 38 self.pages = []
40 self.serving_dirs = set() 39 self.serving_dirs = set()
41 serving_dirs = [] if serving_dirs is None else serving_dirs 40 serving_dirs = [] if serving_dirs is None else serving_dirs
42 # Makes sure that page_set's serving_dirs are absolute paths 41 # Makes sure that page_set's serving_dirs are absolute paths
43 for sd in serving_dirs: 42 for sd in serving_dirs:
44 if os.path.isabs(sd): 43 if os.path.isabs(sd):
45 self.serving_dirs.add(os.path.realpath(sd)) 44 self.serving_dirs.add(os.path.realpath(sd))
46 else: 45 else:
47 self.serving_dirs.add(os.path.realpath(os.path.join(self.base_dir, sd))) 46 self.serving_dirs.add(os.path.realpath(os.path.join(self.base_dir, sd)))
48 47
48 @classmethod
49 def Name(cls):
50 return cls.__module__.split('.')[-1]
51
52 @classmethod
53 def Description(cls):
54 if cls.__doc__:
55 return cls.__doc__.splitlines()[0]
56 else:
57 return ''
58
49 def AddPage(self, page): 59 def AddPage(self, page):
50 assert page.page_set is self 60 assert page.page_set is self
51 self.pages.append(page) 61 self.pages.append(page)
52 62
53 def AddPageWithDefaultRunNavigate(self, page_url): 63 def AddPageWithDefaultRunNavigate(self, page_url):
54 """ Add a simple page with url equals to page_url that contains only default 64 """ Add a simple page with url equals to page_url that contains only default
55 RunNavigateSteps. 65 RunNavigateSteps.
56 """ 66 """
57 self.AddPage(page_module.Page( 67 self.AddPage(page_module.Page(
58 page_url, self, self.base_dir)) 68 page_url, self, self.base_dir))
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return self.pages.__iter__() 158 return self.pages.__iter__()
149 159
150 def __len__(self): 160 def __len__(self):
151 return len(self.pages) 161 return len(self.pages)
152 162
153 def __getitem__(self, key): 163 def __getitem__(self, key):
154 return self.pages[key] 164 return self.pages[key]
155 165
156 def __setitem__(self, key, value): 166 def __setitem__(self, key, value):
157 self.pages[key] = value 167 self.pages[key] = value
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/extensions_profile_creator.py ('k') | tools/telemetry/telemetry/page/page_set_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698