Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Unified Diff: scripts/common/filesystem.py

Issue 761253003: Add a new buildbot-tool generator for master configs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: merge to head Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/common/fake_filesystem.py ('k') | scripts/tools/buildbot-tool » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/common/filesystem.py
diff --git a/scripts/common/filesystem.py b/scripts/common/filesystem.py
new file mode 100644
index 0000000000000000000000000000000000000000..0289ba1a7271cad0470964f163c1ace80e829d26
--- /dev/null
+++ b/scripts/common/filesystem.py
@@ -0,0 +1,47 @@
+# 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):
+ """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 normpath(self, path):
+ return os.path.normpath(path)
+
+ def read_text_file(self, path):
+ with open(path) as fp:
+ return fp.read()
+
+ def relpath(self, path, start='.'):
+ return os.path.relpath(path, start)
+
+ def write_text_file(self, path, contents):
+ with open(path, 'w') as fp:
+ fp.write(contents)
« no previous file with comments | « scripts/common/fake_filesystem.py ('k') | scripts/tools/buildbot-tool » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698