OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 copy | 5 import copy |
6 import logging | 6 import logging |
7 | 7 |
8 from compiled_file_system import SingleFile | 8 from compiled_file_system import SingleFile |
9 from data_source import DataSource | 9 from data_source import DataSource |
10 from future import Gettable, Future | 10 from future import Gettable, Future |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if not href.startswith('/'): | 73 if not href.startswith('/'): |
74 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) | 74 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) |
75 else: | 75 else: |
76 href = href.lstrip('/') | 76 href = href.lstrip('/') |
77 item['href'] = self._server_instance.base_path + href | 77 item['href'] = self._server_instance.base_path + href |
78 | 78 |
79 def Cron(self): | 79 def Cron(self): |
80 futures = [ | 80 futures = [ |
81 self._cache.GetFromFile('%s/%s_sidenav.json' % (JSON_PATH, platform)) | 81 self._cache.GetFromFile('%s/%s_sidenav.json' % (JSON_PATH, platform)) |
82 for platform in ('apps', 'extensions')] | 82 for platform in ('apps', 'extensions')] |
83 for future in futures: | 83 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) |
84 future.Get() | |
85 | 84 |
86 def get(self, key): | 85 def get(self, key): |
87 sidenav = copy.deepcopy(self._cache.GetFromFile( | 86 sidenav = copy.deepcopy(self._cache.GetFromFile( |
88 '%s/%s_sidenav.json' % (JSON_PATH, key)).Get()) | 87 '%s/%s_sidenav.json' % (JSON_PATH, key)).Get()) |
89 _AddSelected(sidenav, self._server_instance.base_path + self._request.path) | 88 _AddSelected(sidenav, self._server_instance.base_path + self._request.path) |
90 return sidenav | 89 return sidenav |
OLD | NEW |