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