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

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

Issue 26538009: Docserver: make file_system a property of Create (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: niggles Created 7 years, 2 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 from HTMLParser import HTMLParser 5 from HTMLParser import HTMLParser
6 import logging 6 import logging
7 import os 7 import os
8 import re 8 import re
9 9
10 from docs_server_utils import FormatKey 10 from docs_server_utils import FormatKey
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 else: 56 else:
57 self.page_title += data 57 self.page_title += data
58 elif self._recent_tag in ['h2', 'h3']: 58 elif self._recent_tag in ['h2', 'h3']:
59 self._current_heading['title'] += data 59 self._current_heading['title'] += data
60 60
61 class IntroDataSource(object): 61 class IntroDataSource(object):
62 '''This class fetches the intros for a given API. From this intro, a table 62 '''This class fetches the intros for a given API. From this intro, a table
63 of contents dictionary is created, which contains the headings in the intro. 63 of contents dictionary is created, which contains the headings in the intro.
64 ''' 64 '''
65 class Factory(object): 65 class Factory(object):
66 def __init__(self, compiled_fs_factory, ref_resolver_factory, base_paths): 66 def __init__(self,
67 self._cache = compiled_fs_factory.Create(self._MakeIntroDict, 67 compiled_fs_factory,
68 file_system,
69 ref_resolver_factory,
70 base_paths):
71 self._cache = compiled_fs_factory.Create(file_system,
72 self._MakeIntroDict,
68 IntroDataSource) 73 IntroDataSource)
69 self._ref_resolver = ref_resolver_factory.Create() 74 self._ref_resolver = ref_resolver_factory.Create()
70 self._base_paths = base_paths 75 self._base_paths = base_paths
71 76
72 def _MakeIntroDict(self, intro_path, intro): 77 def _MakeIntroDict(self, intro_path, intro):
73 # Guess the name of the API from the path to the intro. 78 # Guess the name of the API from the path to the intro.
74 api_name = os.path.splitext(intro_path.split('/')[-1])[0] 79 api_name = os.path.splitext(intro_path.split('/')[-1])[0]
75 intro_with_links = self._ref_resolver.ResolveAllLinks(intro, 80 intro_with_links = self._ref_resolver.ResolveAllLinks(intro,
76 namespace=api_name) 81 namespace=api_name)
77 apps_parser = _IntroParser() 82 apps_parser = _IntroParser()
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return self._cache.GetFromFile('%s/%s' % (base_path, path)).Get() 114 return self._cache.GetFromFile('%s/%s' % (base_path, path)).Get()
110 for base_path in self._base_paths: 115 for base_path in self._base_paths:
111 try: 116 try:
112 return get_from_base_path(base_path) 117 return get_from_base_path(base_path)
113 except FileNotFoundError: 118 except FileNotFoundError:
114 continue 119 continue
115 # Not found. Do the first operation again so that we get a stack trace - we 120 # Not found. Do the first operation again so that we get a stack trace - we
116 # know that it'll fail. 121 # know that it'll fail.
117 get_from_base_path(self._base_paths[0]) 122 get_from_base_path(self._base_paths[0])
118 raise AssertionError() 123 raise AssertionError()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698