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

Unified Diff: tools/telemetry/telemetry/page_set.py

Issue 11881051: Telemetry: add a metadata layer between page set and .wpr. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no ordereddict Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page_set.py
diff --git a/tools/telemetry/telemetry/page_set.py b/tools/telemetry/telemetry/page_set.py
index 7c085bb81ffc38b93c65b91809f2cfb72317b616..45ab8a83e33a5d280e44009f5342dd4436ad47ef 100644
--- a/tools/telemetry/telemetry/page_set.py
+++ b/tools/telemetry/telemetry/page_set.py
@@ -7,12 +7,13 @@ import os
import urlparse
from telemetry import page as page_module
+from telemetry import page_set_archive_info
class PageSet(object):
- def __init__(self, base_dir='', attributes=None):
+ def __init__(self, file_path='', attributes=None):
self.description = ''
- self.archive_path = ''
- self.base_dir = base_dir
+ self.archive_data_file = ''
+ self.file_path = file_path
self.credentials_path = None
self.user_agent_type = None
@@ -22,20 +23,27 @@ class PageSet(object):
self.pages = []
+ if self.archive_data_file:
+ base_dir = os.path.dirname(file_path)
+ self.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
+ os.path.join(base_dir, self.archive_data_file), file_path)
+ else:
+ self.wpr_archive_info = None
+
@classmethod
def FromFile(cls, file_path):
with open(file_path, 'r') as f:
contents = f.read()
data = json.loads(contents)
- return cls.FromDict(data, os.path.dirname(file_path))
+ return cls.FromDict(data, file_path)
@classmethod
def FromDict(cls, data, file_path=''):
page_set = cls(file_path, data)
for page_attributes in data['pages']:
url = page_attributes.pop('url')
- page = page_module.Page(url, attributes=page_attributes,
- base_dir=file_path)
+ page = page_module.Page(url, page_set, attributes=page_attributes,
+ base_dir=os.path.dirname(file_path))
page_set.pages.append(page)
return page_set
@@ -70,6 +78,11 @@ class PageSet(object):
return pages
+ def WprFilePathForPage(self, page):
+ if not self.wpr_archive_info:
+ return None
+ return self.wpr_archive_info.WprFilePathForPage(page)
+
def __iter__(self):
return self.pages.__iter__()
« no previous file with comments | « tools/telemetry/telemetry/page_runner_unittest.py ('k') | tools/telemetry/telemetry/page_set_archive_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698