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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/common/fake_filesystem.py ('k') | scripts/tools/buildbot-tool » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 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 import os
6
7
8 class Filesystem(object):
9 """A simple filesystem abstraction, useful for faking out for testing.
10
11 This is a stripped-down version of the Filesystem class provided in the
12 TYP (Test Your Project) framework: https://github.com/dpranke/typ.
13 """
14
15 def abspath(self, path):
16 return os.path.abspath(path)
17
18 def basename(self, path):
19 return os.path.basename(path)
20
21 def dirname(self, path):
22 return os.path.dirname(path)
23
24 def exists(self, *comps):
25 return os.path.exists(self.join(*comps))
26
27 def join(self, *comps):
28 return os.path.join(*comps)
29
30 def listfiles(self, path):
31 return [path for path in os.listdir(path)
32 if not os.path.isdir(path) and
33 not os.path.basename(path).startswith('.')]
34
35 def normpath(self, path):
36 return os.path.normpath(path)
37
38 def read_text_file(self, path):
39 with open(path) as fp:
40 return fp.read()
41
42 def relpath(self, path, start='.'):
43 return os.path.relpath(path, start)
44
45 def write_text_file(self, path, contents):
46 with open(path, 'w') as fp:
47 fp.write(contents)
OLDNEW
« 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