2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
10 chromium_root_dir
= os
.path
.join(os
.path
.dirname(os
.path
.realpath(__file__
)),
13 def commit(message
, cwd
=None):
14 subprocess
.call(['git', 'commit', '-a', '-m', message
], cwd
=cwd
)
16 def system(command
, cwd
=None):
17 return subprocess
.check_output(command
, cwd
=cwd
)
19 def find(patterns
, start
='.'):
20 for path
, dirs
, files
in os
.walk(start
):
21 for basename
in files
+ dirs
:
22 if any([fnmatch
.fnmatch(basename
, pattern
) for pattern
in patterns
]):
23 filename
= os
.path
.join(path
, basename
)
26 def filter_file(path
, predicate
):
27 with
open(path
, 'r+') as f
:
29 new_lines
= [line
for line
in lines
if predicate(line
)]
32 f
.write(''.join(new_lines
))