OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 from operator import itemgetter | 5 from operator import itemgetter |
6 import random | 6 import random |
7 | 7 |
8 from data_source import DataSource | 8 from data_source import DataSource |
9 from docs_server_utils import MarkLast | 9 from docs_server_utils import MarkLast |
10 from extensions_paths import BROWSER_API_PATHS, BROWSER_CHROME_EXTENSIONS | 10 from extensions_paths import BROWSER_API_PATHS, BROWSER_CHROME_EXTENSIONS |
(...skipping 27 matching lines...) Expand all Loading... |
38 # Randomize the list so owners toward the front of the list aren't | 38 # Randomize the list so owners toward the front of the list aren't |
39 # diproportionately inundated with reviews. | 39 # diproportionately inundated with reviews. |
40 if randomize: | 40 if randomize: |
41 random.shuffle(owners) | 41 random.shuffle(owners) |
42 MarkLast(owners) | 42 MarkLast(owners) |
43 return owners, '\n'.join(notes) | 43 return owners, '\n'.join(notes) |
44 | 44 |
45 | 45 |
46 class OwnersDataSource(DataSource): | 46 class OwnersDataSource(DataSource): |
47 def __init__(self, server_instance, _, randomize=True): | 47 def __init__(self, server_instance, _, randomize=True): |
48 self._host_fs = server_instance.host_file_system_provider.GetTrunk() | 48 self._host_fs = server_instance.host_file_system_provider.GetMaster() |
49 self._cache = server_instance.object_store_creator.Create(OwnersDataSource) | 49 self._cache = server_instance.object_store_creator.Create(OwnersDataSource) |
50 self._owners_fs = server_instance.compiled_fs_factory.Create( | 50 self._owners_fs = server_instance.compiled_fs_factory.Create( |
51 self._host_fs, self._CreateAPIEntry, OwnersDataSource) | 51 self._host_fs, self._CreateAPIEntry, OwnersDataSource) |
52 self._randomize = randomize | 52 self._randomize = randomize |
53 | 53 |
54 def _CreateAPIEntry(self, path, content): | 54 def _CreateAPIEntry(self, path, content): |
55 '''Creates a dict with owners information for an API, specified | 55 '''Creates a dict with owners information for an API, specified |
56 by |owners_file|. | 56 by |owners_file|. |
57 ''' | 57 ''' |
58 owners, notes = ParseOwnersFile(content, self._randomize) | 58 owners, notes = ParseOwnersFile(content, self._randomize) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return All(api_owners).Then(sort_and_cache) | 97 return All(api_owners).Then(sort_and_cache) |
98 return self._cache.Get('api_owners').Then(collect) | 98 return self._cache.Get('api_owners').Then(collect) |
99 | 99 |
100 def get(self, key): | 100 def get(self, key): |
101 return { | 101 return { |
102 'apis': self._CollectOwnersData() | 102 'apis': self._CollectOwnersData() |
103 }.get(key).Get() | 103 }.get(key).Get() |
104 | 104 |
105 def Cron(self): | 105 def Cron(self): |
106 return self._CollectOwnersData() | 106 return self._CollectOwnersData() |
OLD | NEW |