OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2015 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 json | |
5 import os | |
6 import random | |
7 | |
8 | |
9 def GetShuffledSafeUrls(): | |
10 """Returns a deterministic shuffling of safe urls. The profile generators | |
11 access the urls in order, and the urls are grouped by domain. The shuffling | |
12 reduces the load on external servers.""" | |
13 random.seed(0) | |
14 url_list_copy = list(_GetSafeUrls()) | |
15 random.shuffle(url_list_copy) | |
16 return url_list_copy | |
17 | |
18 | |
19 def _GetSafeUrls(): | |
20 """Returns a list of safe urls by loading them from a pre-generated file.""" | |
21 safe_url_dir = os.path.dirname(os.path.realpath(__file__)) | |
22 safe_url_path = os.path.join(safe_url_dir, "profile_safe_url_list.json") | |
23 with open(safe_url_path, 'r') as safe_url_file: | |
24 return json.load(safe_url_file) | |
dtu
2015/02/13 23:00:00
nit: 2 space indent
erikchen
2015/02/13 23:11:24
Done.
| |
OLD | NEW |