diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-06-18 14:10:49 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-06-18 13:53:24 +0000 |
commit | 813fbf95af77a531c57a8c497345ad2c61d475b3 (patch) | |
tree | 821b2c8de8365f21b6c9ba17a236fb3006a1d506 /chromium/mojo/tools/utils.py | |
parent | af6588f8d723931a298c995fa97259bb7f7deb55 (diff) | |
download | qtwebengine-chromium-813fbf95af77a531c57a8c497345ad2c61d475b3.tar.gz |
BASELINE: Update chromium to 44.0.2403.47
Change-Id: Ie056fedba95cf5e5c76b30c4b2c80fca4764aa2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/mojo/tools/utils.py')
-rwxr-xr-x | chromium/mojo/tools/utils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/chromium/mojo/tools/utils.py b/chromium/mojo/tools/utils.py new file mode 100755 index 00000000000..740b363330c --- /dev/null +++ b/chromium/mojo/tools/utils.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# 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 fnmatch +import os +import subprocess + +chromium_root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), + os.pardir, os.pardir) + +def commit(message, cwd=None): + subprocess.call(['git', 'commit', '-a', '-m', message], cwd=cwd) + +def system(command, cwd=None): + return subprocess.check_output(command, cwd=cwd) + +def find(patterns, start='.'): + for path, dirs, files in os.walk(start): + for basename in files + dirs: + if any([fnmatch.fnmatch(basename, pattern) for pattern in patterns]): + filename = os.path.join(path, basename) + yield filename + +def filter_file(path, predicate): + with open(path, 'r+') as f: + lines = f.readlines() + new_lines = [line for line in lines if predicate(line)] + f.seek(0) + f.truncate() + f.write(''.join(new_lines)) |