Chromium Code Reviews| 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 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 '''An async version of Stat. Returns a Future to a StatInfo rather than a | 152 '''An async version of Stat. Returns a Future to a StatInfo rather than a |
| 153 raw StatInfo. | 153 raw StatInfo. |
| 154 | 154 |
| 155 This is a bandaid for a lack of an async Stat function. Stat() should be | 155 This is a bandaid for a lack of an async Stat function. Stat() should be |
| 156 async by default but for now just let implementations override this if they | 156 async by default but for now just let implementations override this if they |
| 157 like. | 157 like. |
| 158 ''' | 158 ''' |
| 159 return Future(callback=lambda: self.Stat(path)) | 159 return Future(callback=lambda: self.Stat(path)) |
| 160 | 160 |
| 161 def GetIdentity(self): | 161 def GetIdentity(self): |
| 162 '''The identity of the file system, exposed for caching classes to | 162 '''A legacy alias for the stable identity of the file system.''' |
| 163 namespace their caches. this will usually depend on the configuration of | 163 return self.GetStableIdentity() |
|
not at google - send to devlin
2014/10/22 18:08:47
(comment written before our chat, but I'll include
| |
| 164 | |
| 165 def GetStableIdentity(self): | |
| 166 '''The stable identity of the file system, exposed for caching classes to | |
| 167 namespace their caches. This will usually depend on the configuration of | |
| 164 that file system - e.g. a LocalFileSystem with a base path of /var is | 168 that file system - e.g. a LocalFileSystem with a base path of /var is |
| 165 different to that of a SubversionFileSystem with a base path of /bar, is | 169 different to that of a SubversionFileSystem with a base path of /bar, is |
| 166 different to a LocalFileSystem with a base path of /usr. | 170 different to a LocalFileSystem with a base path of /usr. |
| 167 ''' | 171 ''' |
| 168 raise NotImplementedError(self.__class__) | 172 raise NotImplementedError(self.__class__) |
| 169 | 173 |
| 174 def GetUnstableIdentity(self): | |
|
not at google - send to devlin
2014/10/22 18:08:47
And yeah, it would be nice to think about these na
| |
| 175 '''The unstable identity of the file system, exposed for more volatile | |
| 176 caching classes to namespace their caches. This will usually depend not only | |
| 177 on the configuration of the file system, but also on its active revision | |
| 178 (e.g. a commit ID for a Git filesystem). | |
| 179 | |
| 180 The default implementation is an alias for stable identity. | |
| 181 ''' | |
| 182 return self.GetStableIdentity() | |
| 183 | |
| 170 def Walk(self, root, depth=-1, file_lister=None): | 184 def Walk(self, root, depth=-1, file_lister=None): |
| 171 '''Recursively walk the directories in a file system, starting with root. | 185 '''Recursively walk the directories in a file system, starting with root. |
| 172 | 186 |
| 173 Behaviour is very similar to os.walk from the standard os module, yielding | 187 Behaviour is very similar to os.walk from the standard os module, yielding |
| 174 (base, dirs, files) recursively, where |base| is the base path of |files|, | 188 (base, dirs, files) recursively, where |base| is the base path of |files|, |
| 175 |dirs| relative to |root|, and |files| and |dirs| the list of files/dirs in | 189 |dirs| relative to |root|, and |files| and |dirs| the list of files/dirs in |
| 176 |base| respectively. If |depth| is specified and greater than 0, Walk will | 190 |base| respectively. If |depth| is specified and greater than 0, Walk will |
| 177 only recurse |depth| times. | 191 only recurse |depth| times. |
| 178 | 192 |
| 179 |file_lister|, if specified, should be a callback of signature | 193 |file_lister|, if specified, should be a callback of signature |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 self.GetIdentity() == other.GetIdentity()) | 236 self.GetIdentity() == other.GetIdentity()) |
| 223 | 237 |
| 224 def __ne__(self, other): | 238 def __ne__(self, other): |
| 225 return not (self == other) | 239 return not (self == other) |
| 226 | 240 |
| 227 def __repr__(self): | 241 def __repr__(self): |
| 228 return '<%s>' % type(self).__name__ | 242 return '<%s>' % type(self).__name__ |
| 229 | 243 |
| 230 def __str__(self): | 244 def __str__(self): |
| 231 return repr(self) | 245 return repr(self) |
| OLD | NEW |