OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 re | |
6 import urlparse | |
7 | |
5 import common_util | 8 import common_util |
6 import emulation | 9 import emulation |
7 import sandwich_runner | 10 import sandwich_runner |
8 import task_manager | 11 import task_manager |
9 | 12 |
10 | 13 |
14 class SandwichKnownError(Exception): | |
15 pass | |
16 | |
17 | |
18 def NormalizeUrl(url): | |
pasko
2016/07/04 18:05:58
better inline this function. Called once and the n
gabadie
2016/07/06 08:57:55
I don't think so because it will very probably be
pasko
2016/07/06 12:45:52
Let's not complicate reading before it is necessar
gabadie
2016/07/06 13:31:14
Done.
| |
19 """Returns normalized URL with trailing slashes.""" | |
20 parsed_url = list(urlparse.urlparse(url)) | |
21 parsed_url[2] = re.sub(r"/{2,}", r"/", parsed_url[2]) | |
pasko
2016/07/04 18:05:57
single quotes for consistency
gabadie
2016/07/06 08:57:55
Oups... done.
| |
22 return urlparse.urlunparse(parsed_url) | |
23 | |
24 | |
11 def NetworkSimulationTransformer(network_condition): | 25 def NetworkSimulationTransformer(network_condition): |
12 """Creates a function that accepts a SandwichRunner as a parameter and sets | 26 """Creates a function that accepts a SandwichRunner as a parameter and sets |
13 network emulation options on it. | 27 network emulation options on it. |
14 | 28 |
15 Args: | 29 Args: |
16 network_condition: The network condition to apply to the sandwich runner. | 30 network_condition: The network condition to apply to the sandwich runner. |
17 | 31 |
18 Returns: | 32 Returns: |
19 A callback transforming the SandwichRunner given in argument accordingly | 33 A callback transforming the SandwichRunner given in argument accordingly |
20 """ | 34 """ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 @self.RegisterTask('common/webpages.wpr') | 73 @self.RegisterTask('common/webpages.wpr') |
60 def BuildOriginalWpr(): | 74 def BuildOriginalWpr(): |
61 common_util.EnsureParentDirectoryExists(BuildOriginalWpr.path) | 75 common_util.EnsureParentDirectoryExists(BuildOriginalWpr.path) |
62 runner = self.CreateSandwichRunner() | 76 runner = self.CreateSandwichRunner() |
63 runner.wpr_archive_path = BuildOriginalWpr.path | 77 runner.wpr_archive_path = BuildOriginalWpr.path |
64 runner.wpr_record = True | 78 runner.wpr_record = True |
65 runner.output_dir = BuildOriginalWpr.path[:-4] + '-run' | 79 runner.output_dir = BuildOriginalWpr.path[:-4] + '-run' |
66 runner.Run() | 80 runner.Run() |
67 | 81 |
68 self.original_wpr_task = BuildOriginalWpr | 82 self.original_wpr_task = BuildOriginalWpr |
OLD | NEW |