Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(951)

Side by Side Diff: chrome/common/extensions/docs/server2/intro_data_source.py

Issue 10704252: Extensions Docs Server: Internal file system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 logging
6 import re 5 import re
7 from path_utils import FormatKey 6 from path_utils import FormatKey
8 from third_party.handlebar import Handlebar 7 from third_party.handlebar import Handlebar
9 8
10 class IntroDataSource(object): 9 class IntroDataSource(object):
11 """This class fetches the intros for a given API. From this intro, a table 10 """This class fetches the intros for a given API. From this intro, a table
12 of contents dictionary is created, which contains the headings in the intro. 11 of contents dictionary is created, which contains the headings in the intro.
13 """ 12 """
14 def __init__(self, cache_builder, base_paths): 13 def __init__(self, cache_builder, base_paths):
15 self._cache = cache_builder.build(self._MakeIntroDict) 14 self._cache = cache_builder.build(self._MakeIntroDict)
(...skipping 15 matching lines...) Expand all
31 toc[-1]['subheadings'].append({ 'link': link, 'title': title }) 30 toc[-1]['subheadings'].append({ 'link': link, 'title': title })
32 return { 'intro': Handlebar(intro), 'toc': toc , 'title': page_title } 31 return { 'intro': Handlebar(intro), 'toc': toc , 'title': page_title }
33 32
34 def __getitem__(self, key): 33 def __getitem__(self, key):
35 return self.get(key) 34 return self.get(key)
36 35
37 def get(self, key): 36 def get(self, key):
38 real_path = FormatKey(key) 37 real_path = FormatKey(key)
39 for base_path in self._base_paths: 38 for base_path in self._base_paths:
40 try: 39 try:
41 return self._cache.getFromFile(base_path + '/' + real_path) 40 return self._cache.GetFromFile(base_path + '/' + real_path)
42 except: 41 except Exception:
43 pass 42 pass
44 return None 43 return None
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/in_memory_memcache.py ('k') | chrome/common/extensions/docs/server2/local_fetcher.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698