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 # 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 Loading... |
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 Loading... |
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 }) |
OLD | NEW |