Chromium Code Reviews| 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 | |
|
dtu
2015/02/12 23:46:12
style guide nit: 2 blank spaces between top level
erikchen
2015/02/13 03:58:58
Done.
| |
| 8 def GetShuffledSafeUrls(): | |
| 9 """Returns a deterministic shuffling of safe urls. The profile generators | |
| 10 access the urls in order, and the urls are grouped by domain. The shuffling | |
| 11 reduces the load on external servers.""" | |
| 12 random.seed(0) | |
| 13 url_list_copy = list(_GetSafeUrls()) | |
| 14 random.shuffle(url_list_copy) | |
| 15 return url_list_copy | |
| 16 | |
| 17 def _GetSafeUrls(): | |
| 18 """Returns a list of safe urls by loading them from a pre-generated file.""" | |
| 19 safe_url_dir = os.path.dirname(os.path.realpath(__file__)) | |
| 20 safe_url_path = os.path.join(safe_url_dir, "profile_safe_url_list.json") | |
| 21 json_data = open(safe_url_path).read() | |
| 22 return json.loads(json_data) | |
|
dtu
2015/02/12 23:46:12
To ensure prompt file closing (otherwise file is c
erikchen
2015/02/13 03:58:58
Ah, good point.
| |
| OLD | NEW |