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

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

Issue 151883009: Docserver: Make MockFileSystem not iterate over the entire file system as part (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yoz and then some Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 file_system import FileNotFoundError, FileSystem, StatInfo 5 from file_system import FileNotFoundError, FileSystem, StatInfo
6 from future import Future 6 from future import Future
7 from path_util import IsDirectory
8
7 9
8 class EmptyDirFileSystem(FileSystem): 10 class EmptyDirFileSystem(FileSystem):
9 '''A FileSystem with empty directories. Useful to inject places to disable 11 '''A FileSystem with empty directories. Useful to inject places to disable
10 features such as samples. 12 features such as samples.
11 ''' 13 '''
12 def Read(self, paths): 14 def Read(self, paths):
13 result = {} 15 result = {}
14 for path in paths: 16 for path in paths:
15 if not path.endswith('/'): 17 if not IsDirectory(path):
16 raise FileNotFoundError('EmptyDirFileSystem cannot read %s' % path) 18 raise FileNotFoundError('EmptyDirFileSystem cannot read %s' % path)
17 result[path] = [] 19 result[path] = []
18 return Future(value=result) 20 return Future(value=result)
19 21
20 def Refresh(self): 22 def Refresh(self):
21 return Future(value=()) 23 return Future(value=())
22 24
23 def Stat(self, path): 25 def Stat(self, path):
24 if not path.endswith('/'): 26 if not IsDirectory(path):
25 raise FileNotFoundError('EmptyDirFileSystem cannot stat %s' % path) 27 raise FileNotFoundError('EmptyDirFileSystem cannot stat %s' % path)
26 return StatInfo(0, child_versions=[]) 28 return StatInfo(0, child_versions=[])
27 29
28 def GetIdentity(self): 30 def GetIdentity(self):
29 return self.__class__.__name__ 31 return self.__class__.__name__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698