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

Side by Side Diff: tools/telemetry/telemetry/page_filter.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import optparse
5 import re
6
7 class PageFilter(object):
8 """Filters pages in the page set based on command line flags."""
9
10 def __init__(self, options):
11 if options.page_filter:
12 try:
13 self._page_regex = re.compile(options.page_filter)
14 except re.error:
15 raise Exception('--page-filter: invalid regex')
16 else:
17 self._page_regex = None
18
19 if options.page_filter_exclude:
20 try:
21 self._page_exclude_regex = re.compile(options.page_filter_exclude)
22 except re.error:
23 raise Exception('--page-filter-exclude: invalid regex')
24 else:
25 self._page_exclude_regex = None
26
27 def IsSelected(self, page):
28 if self._page_exclude_regex and self._page_exclude_regex.search(page.url):
29 return False
30 if self._page_regex:
31 return self._page_regex.search(page.url)
32 return True
33
34 @staticmethod
35 def AddCommandLineOptions(parser):
36 group = optparse.OptionGroup(parser, 'Page filtering options')
37 group.add_option('--page-filter', dest='page_filter',
38 help='Use only pages whose URLs match the given filter regexp.')
39 group.add_option('--page-filter-exclude', dest='page_filter_exclude',
40 help='Exclude pages whose URLs match the given filter regexp.')
41 parser.add_option_group(group)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page_benchmark_value.py ('k') | tools/telemetry/telemetry/page_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698