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

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

Issue 474293007: Docserver: Automatically implement FileSystem.Stat if FileSystem.StatAsync has (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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 posixpath 5 import posixpath
6 import traceback 6 import traceback
7 7
8 from future import Future 8 from future import Future
9 from path_util import ( 9 from path_util import (
10 AssertIsDirectory, AssertIsValid, IsDirectory, IsValid, SplitParent, 10 AssertIsDirectory, AssertIsValid, IsDirectory, IsValid, SplitParent,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 handle) 114 handle)
115 115
116 def Refresh(self): 116 def Refresh(self):
117 '''Asynchronously refreshes the content of the FileSystem, returning a 117 '''Asynchronously refreshes the content of the FileSystem, returning a
118 future to its completion. 118 future to its completion.
119 ''' 119 '''
120 raise NotImplementedError(self.__class__) 120 raise NotImplementedError(self.__class__)
121 121
122 # TODO(cduvall): Allow Stat to take a list of paths like Read. 122 # TODO(cduvall): Allow Stat to take a list of paths like Read.
123 def Stat(self, path): 123 def Stat(self, path):
124 '''Returns a |StatInfo| object containing the version of |path|. If |path| 124 '''DEPRECATED: Please try to use StatAsync instead.
125
126 Returns a |StatInfo| object containing the version of |path|. If |path|
125 is a directory, |StatInfo| will have the versions of all the children of 127 is a directory, |StatInfo| will have the versions of all the children of
126 the directory in |StatInfo.child_versions|. 128 the directory in |StatInfo.child_versions|.
127 129
128 If the path cannot be found, raises a FileNotFoundError. 130 If the path cannot be found, raises a FileNotFoundError.
129 For any other failure, raises a FileSystemError. 131 For any other failure, raises a FileSystemError.
130 ''' 132 '''
133 # Delegate to this implementation's StatAsync if it has been implemented.
134 if type(self).StatAsync != FileSystem.StatAsync:
135 return self.StatAsync(path).Get()
131 raise NotImplementedError(self.__class__) 136 raise NotImplementedError(self.__class__)
132 137
133 def StatAsync(self, path): 138 def StatAsync(self, path):
134 '''Bandaid for a lack of an async Stat function. Stat() should be async 139 '''An async version of Stat. Returns a Future to a StatInfo rather than a
135 by default but for now just let implementations override this if they like. 140 raw StatInfo.
141
142 This is a bandaid for a lack of an async Stat function. Stat() should be
143 async by default but for now just let implementations override this if they
144 like.
136 ''' 145 '''
137 return Future(callback=lambda: self.Stat(path)) 146 return Future(callback=lambda: self.Stat(path))
138 147
139 def GetIdentity(self): 148 def GetIdentity(self):
140 '''The identity of the file system, exposed for caching classes to 149 '''The identity of the file system, exposed for caching classes to
141 namespace their caches. this will usually depend on the configuration of 150 namespace their caches. this will usually depend on the configuration of
142 that file system - e.g. a LocalFileSystem with a base path of /var is 151 that file system - e.g. a LocalFileSystem with a base path of /var is
143 different to that of a SubversionFileSystem with a base path of /bar, is 152 different to that of a SubversionFileSystem with a base path of /bar, is
144 different to a LocalFileSystem with a base path of /usr. 153 different to a LocalFileSystem with a base path of /usr.
145 ''' 154 '''
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 self.GetIdentity() == other.GetIdentity()) 194 self.GetIdentity() == other.GetIdentity())
186 195
187 def __ne__(self, other): 196 def __ne__(self, other):
188 return not (self == other) 197 return not (self == other)
189 198
190 def __repr__(self): 199 def __repr__(self):
191 return '<%s>' % type(self).__name__ 200 return '<%s>' % type(self).__name__
192 201
193 def __str__(self): 202 def __str__(self):
194 return repr(self) 203 return repr(self)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698