OLD | NEW |
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 FileSystem, FileNotFoundError | 5 from file_system import FileSystem, FileNotFoundError |
6 | 6 |
7 class OfflineFileSystem(FileSystem): | 7 class OfflineFileSystem(FileSystem): |
8 '''An offline FileSystem which masquerades as another file system. It throws | 8 '''An offline FileSystem which masquerades as another file system. It throws |
9 FileNotFound error for all operations, and overrides GetName and GetVersion. | 9 FileNotFound error for all operations, and overrides GetIdentity. |
10 ''' | 10 ''' |
11 def __init__(self, cls): | 11 def __init__(self, fs): |
12 self._cls = cls | 12 self._fs = fs |
13 | 13 |
14 def Read(self, paths, binary=False): | 14 def Read(self, paths, binary=False): |
15 raise FileNotFoundError('File system is offline, cannot read %s' % paths) | 15 raise FileNotFoundError('File system is offline, cannot read %s' % paths) |
16 | 16 |
17 def Stat(self, path): | 17 def Stat(self, path): |
18 raise FileNotFoundError('File system is offline, cannot read %s' % path) | 18 raise FileNotFoundError('File system is offline, cannot read %s' % path) |
19 | 19 |
20 # HACK: despite GetName being a @classmethod, these need to be instance | 20 def GetIdentity(self): |
21 # methods so that we can grab the name from the class given on construction. | 21 return self._fs.GetIdentity() |
22 def GetName(self): | |
23 return self._cls.GetName() | |
OLD | NEW |