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

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

Issue 10832299: Extensions Docs Server: Fix preview.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for .svn Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # These are fake fetchers that are used for testing and the preview server. 5 # These are fake fetchers that are used for testing and the preview server.
6 # They return canned responses for URLs. appengine_wrappers.py uses the fake 6 # They return canned responses for URLs. appengine_wrappers.py uses the fake
7 # fetchers if the App Engine imports fail. 7 # fetchers if the App Engine imports fail.
8 8
9 import os 9 import os
10 import re 10 import re
(...skipping 14 matching lines...) Expand all
25 def __init__(self): 25 def __init__(self):
26 self._base_pattern = re.compile(r'.*chrome/common/extensions/(.*)') 26 self._base_pattern = re.compile(r'.*chrome/common/extensions/(.*)')
27 27
28 def fetch(self, url): 28 def fetch(self, url):
29 path = os.path.join( 29 path = os.path.join(
30 os.pardir, os.pardir, self._base_pattern.match(url).group(1)) 30 os.pardir, os.pardir, self._base_pattern.match(url).group(1))
31 if os.path.isdir(path): 31 if os.path.isdir(path):
32 html = ['<html>Revision 000000'] 32 html = ['<html>Revision 000000']
33 try: 33 try:
34 for f in os.listdir(path): 34 for f in os.listdir(path):
35 if f.startswith('.'):
36 continue
35 if os.path.isdir(os.path.join(path, f)): 37 if os.path.isdir(os.path.join(path, f)):
36 html.append('<a>' + f + '/</a>') 38 html.append('<a>' + f + '/</a>')
37 else: 39 else:
38 html.append('<a>' + f + '</a>') 40 html.append('<a>' + f + '</a>')
39 html.append('</html>') 41 html.append('</html>')
40 return '\n'.join(html) 42 return '\n'.join(html)
41 except OSError: 43 except OSError:
42 raise FileNotFoundError(path) 44 raise FileNotFoundError(path)
43 try: 45 try:
44 return _ReadFile(path) 46 return _ReadFile(path)
(...skipping 25 matching lines...) Expand all
70 def fetch(self, url): 72 def fetch(self, url):
71 return '{ "commit": { "tree": { "sha": 0} } }' 73 return '{ "commit": { "tree": { "sha": 0} } }'
72 74
73 def ConfigureFakeFetchers(): 75 def ConfigureFakeFetchers():
74 appengine_wrappers.ConfigureFakeUrlFetch({ 76 appengine_wrappers.ConfigureFakeUrlFetch({
75 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(), 77 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(),
76 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(), 78 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(),
77 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(), 79 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(),
78 '%s/.*' % url_constants.GITHUB_URL: FakeGithub() 80 '%s/.*' % url_constants.GITHUB_URL: FakeGithub()
79 }) 81 })
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698