Chromium Code Reviews| Index: scripts/common/filesystem.py | 
| diff --git a/scripts/common/filesystem.py b/scripts/common/filesystem.py | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..b7507bfe31d78390239cc4bd550ab4dd0cffe22b | 
| --- /dev/null | 
| +++ b/scripts/common/filesystem.py | 
| @@ -0,0 +1,41 @@ | 
| +# Copyright 2014 The Chromium Authors. All rights reserved. | 
| +# Use of this source code is governed by a BSD-style license that can be | 
| +# found in the LICENSE file. | 
| + | 
| +import os | 
| + | 
| + | 
| +class Filesystem(object): | 
| 
 
agable
2014/12/09 21:13:24
Seems like this should be in a tests/ directory so
 
Dirk Pranke
2014/12/09 21:32:00
It's used by buildbot-tool directly, not just by t
 
 | 
| + """A simple filesystem abstraction, useful for faking out for testing. | 
| + | 
| + This is a stripped-down version of the Filesystem class provided in the | 
| + TYP (Test Your Project) framework: https://github.com/dpranke/typ. | 
| + """ | 
| + | 
| + def abspath(self, path): | 
| + return os.path.abspath(path) | 
| + | 
| + def basename(self, path): | 
| + return os.path.basename(path) | 
| + | 
| + def dirname(self, path): | 
| + return os.path.dirname(path) | 
| + | 
| + def exists(self, *comps): | 
| + return os.path.exists(self.join(*comps)) | 
| + | 
| + def join(self, *comps): | 
| + return os.path.join(*comps) | 
| + | 
| + def listfiles(self, path): | 
| + return [path for path in os.listdir(path) | 
| + if not os.path.isdir(path) and | 
| + not os.path.basename(path).startswith('.')] | 
| + | 
| + def read_text_file(self, path): | 
| + with open(path) as fp: | 
| + return fp.read() | 
| + | 
| + def write_text_file(self, path, contents): | 
| + with open(path, 'w') as fp: | 
| + fp.write(contents) |