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 from HTMLParser import HTMLParser | 5 from HTMLParser import HTMLParser |
6 import re | 6 import re |
7 | 7 |
8 from docs_server_utils import FormatKey | 8 from docs_server_utils import FormatKey |
9 from file_system import FileNotFoundError | |
9 from third_party.handlebar import Handlebar | 10 from third_party.handlebar import Handlebar |
10 | 11 |
11 class _IntroParser(HTMLParser): | 12 class _IntroParser(HTMLParser): |
12 """ An HTML parser which will parse table of contents and page title info out | 13 """ An HTML parser which will parse table of contents and page title info out |
13 of an intro. | 14 of an intro. |
14 """ | 15 """ |
15 def __init__(self): | 16 def __init__(self): |
16 HTMLParser.__init__(self) | 17 HTMLParser.__init__(self) |
17 self.toc = [] | 18 self.toc = [] |
18 self.page_title = None | 19 self.page_title = None |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 } | 71 } |
71 | 72 |
72 def __getitem__(self, key): | 73 def __getitem__(self, key): |
73 return self.get(key) | 74 return self.get(key) |
74 | 75 |
75 def get(self, key): | 76 def get(self, key): |
76 real_path = FormatKey(key) | 77 real_path = FormatKey(key) |
77 for base_path in self._base_paths: | 78 for base_path in self._base_paths: |
78 try: | 79 try: |
79 return self._cache.GetFromFile(base_path + '/' + real_path) | 80 return self._cache.GetFromFile(base_path + '/' + real_path) |
80 except Exception: | 81 except FileNotFoundError: |
81 pass | 82 pass |
82 return None | 83 return None |
not at google - send to devlin
2012/08/10 06:12:16
log error before returning None?
cduvall
2012/08/10 17:25:16
Done.
not at google - send to devlin
2012/08/12 22:22:58
Like ApiListDataSource, this should only be happen
cduvall
2012/08/13 18:44:05
Done.
| |
OLD | NEW |