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 os | 5 import os |
6 | 6 |
7 import file_system | 7 import file_system |
8 from future import Future | 8 from future import Future |
9 | 9 |
10 class LocalFileSystem(file_system.FileSystem): | 10 class LocalFileSystem(file_system.FileSystem): |
(...skipping 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 def Read(self, paths, binary=False): | 39 def Read(self, paths, binary=False): |
40 result = {} | 40 result = {} |
41 for path in paths: | 41 for path in paths: |
42 if path.endswith('/'): | 42 if path.endswith('/'): |
43 result[path] = self._ListDir(self._ConvertToFilepath(path)) | 43 result[path] = self._ListDir(self._ConvertToFilepath(path)) |
44 else: | 44 else: |
45 result[path] = self._ReadFile(self._ConvertToFilepath(path), binary) | 45 result[path] = self._ReadFile(self._ConvertToFilepath(path), binary) |
46 return Future(value=result) | 46 return Future(value=result) |
47 | 47 |
48 def _CreateStatInfo(self, path): | |
49 versions = [(filename, os.stat(os.path.join(path, filename)).st_mtime) | |
50 for filename in os.listdir(path)] | |
not at google - send to devlin
2012/08/10 06:42:24
can construct the dict without an intermediate lis
cduvall
2012/08/11 00:15:23
Done.
| |
51 return self.StatInfo(os.stat(path).st_mtime, dict(versions)) | |
52 | |
48 def Stat(self, path): | 53 def Stat(self, path): |
49 return self.StatInfo(os.stat(os.path.join(self._base_path, path)).st_mtime) | 54 if '/' in path: |
55 par_dir = path.rsplit('/', 1)[0] + '/' | |
56 else: | |
57 par_dir = '.' | |
58 return self._CreateStatInfo(os.path.join(self._base_path, par_dir)) | |
OLD | NEW |