| 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 json | 6 import json |
| 7 | 7 import logging |
| 8 import compiled_file_system as compiled_fs | |
| 9 from third_party.json_schema_compiler.model import UnixName | |
| 10 | 8 |
| 11 class SidenavDataSource(object): | 9 class SidenavDataSource(object): |
| 12 """This class reads in and caches a JSON file representing the side navigation | 10 """This class reads in and caches a JSON file representing the side navigation |
| 13 menu. | 11 menu. |
| 14 """ | 12 """ |
| 15 class Factory(object): | 13 class Factory(object): |
| 16 def __init__(self, compiled_fs_factory, json_path): | 14 def __init__(self, compiled_fs_factory, json_path): |
| 17 self._cache = compiled_fs_factory.Create(self._CreateSidenavDict, | 15 self._cache = compiled_fs_factory.Create(self._CreateSidenavDict, |
| 18 SidenavDataSource) | 16 SidenavDataSource) |
| 19 self._json_path = json_path | 17 self._json_path = json_path |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) | 64 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) |
| 67 href = '/' + href | 65 href = '/' + href |
| 68 item['href'] = href | 66 item['href'] = href |
| 69 | 67 |
| 70 def get(self, key): | 68 def get(self, key): |
| 71 sidenav = copy.deepcopy(self._cache.GetFromFile( | 69 sidenav = copy.deepcopy(self._cache.GetFromFile( |
| 72 '%s/%s_sidenav.json' % (self._json_path, key))) | 70 '%s/%s_sidenav.json' % (self._json_path, key))) |
| 73 self._AddSelected(sidenav) | 71 self._AddSelected(sidenav) |
| 74 self._QualifyHrefs(sidenav) | 72 self._QualifyHrefs(sidenav) |
| 75 return sidenav | 73 return sidenav |
| OLD | NEW |