| 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 import sys | 6 import sys |
| 7 | 7 |
| 8 from docs_server_utils import StringIdentity | 8 from docs_server_utils import StringIdentity |
| 9 from file_system import FileSystem, FileNotFoundError, StatInfo | 9 from file_system import FileSystem, FileNotFoundError, StatInfo |
| 10 from future import Future | 10 from future import Future |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 def Read(self, paths, skip_not_found=False): | 81 def Read(self, paths, skip_not_found=False): |
| 82 def resolve(): | 82 def resolve(): |
| 83 result = {} | 83 result = {} |
| 84 for path in paths: | 84 for path in paths: |
| 85 AssertIsValid(path) | 85 AssertIsValid(path) |
| 86 full_path = os.path.join(self._base_path, | 86 full_path = os.path.join(self._base_path, |
| 87 _ConvertToFilepath(path).lstrip(os.sep)) | 87 _ConvertToFilepath(path).lstrip(os.sep)) |
| 88 if path == '' or path.endswith('/'): | 88 if path == '' or path.endswith('/'): |
| 89 result[path] = _ListDir(full_path) | 89 result[path] = _ListDir(full_path) |
| 90 else: | 90 else: |
| 91 result[path] = _ReadFile(full_path) | 91 try: |
| 92 result[path] = _ReadFile(full_path) |
| 93 except FileNotFoundError: |
| 94 if skip_not_found: |
| 95 continue |
| 96 return Future(exc_info=sys.exc_info()) |
| 92 return result | 97 return result |
| 93 return Future(callback=resolve) | 98 return Future(callback=resolve) |
| 94 | 99 |
| 95 def Refresh(self): | 100 def Refresh(self): |
| 96 return Future(value=()) | 101 return Future(value=()) |
| 97 | 102 |
| 98 def Stat(self, path): | 103 def Stat(self, path): |
| 99 AssertIsValid(path) | 104 AssertIsValid(path) |
| 100 full_path = os.path.join(self._base_path, | 105 full_path = os.path.join(self._base_path, |
| 101 _ConvertToFilepath(path).lstrip(os.sep)) | 106 _ConvertToFilepath(path).lstrip(os.sep)) |
| 102 return _CreateStatInfo(full_path) | 107 return _CreateStatInfo(full_path) |
| 103 | 108 |
| 104 def GetIdentity(self): | 109 def GetIdentity(self): |
| 105 return '@'.join((self.__class__.__name__, StringIdentity(self._base_path))) | 110 return '@'.join((self.__class__.__name__, StringIdentity(self._base_path))) |
| 106 | 111 |
| 107 def __repr__(self): | 112 def __repr__(self): |
| 108 return 'LocalFileSystem(%s)' % self._base_path | 113 return 'LocalFileSystem(%s)' % self._base_path |
| OLD | NEW |