Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / server2 / empty_dir_file_system.py
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
3 # found in the LICENSE file.
4
5 from file_system import FileNotFoundError, FileSystem, StatInfo
6 from future import Future
7 from path_util import IsDirectory
8
9
10 class EmptyDirFileSystem(FileSystem):
11   '''A FileSystem with empty directories. Useful to inject places to disable
12   features such as samples.
13   '''
14   def Read(self, paths):
15     result = {}
16     for path in paths:
17       if not IsDirectory(path):
18         raise FileNotFoundError('EmptyDirFileSystem cannot read %s' % path)
19       result[path] = []
20     return Future(value=result)
21
22   def Refresh(self):
23     return Future(value=())
24
25   def Stat(self, path):
26     if not IsDirectory(path):
27       raise FileNotFoundError('EmptyDirFileSystem cannot stat %s' % path)
28     return StatInfo(0, child_versions=[])
29
30   def GetIdentity(self):
31     return self.__class__.__name__