| Index: mojo/tools/roll/utils.py
|
| diff --git a/mojo/tools/roll/utils.py b/mojo/tools/roll/utils.py
|
| index dcdfc3510e700aa7eace92f09761c7633986c533..bf10cdcbce014d03303eae1c0d5392c17f164ee3 100755
|
| --- a/mojo/tools/roll/utils.py
|
| +++ b/mojo/tools/roll/utils.py
|
| @@ -3,9 +3,12 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import contextlib
|
| import fnmatch
|
| import os
|
| import subprocess
|
| +import shutil
|
| +import tempfile
|
|
|
| mojo_root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
| os.pardir, os.pardir, os.pardir)
|
| @@ -23,6 +26,16 @@ def find(patterns, start='.'):
|
| filename = os.path.join(path, basename)
|
| yield filename
|
|
|
| +# From
|
| +# http://stackoverflow.com/questions/13379742/right-way-to-clean-up-a-temporary-folder-in-python-class
|
| +@contextlib.contextmanager
|
| +def temp_dir(*args, **kwargs):
|
| + d = tempfile.mkdtemp(*args, **kwargs)
|
| + try:
|
| + yield d
|
| + finally:
|
| + shutil.rmtree(d)
|
| +
|
| def filter_file(path, predicate):
|
| with open(path, 'r+') as f:
|
| lines = f.readlines()
|
|
|