| Index: py/utils/misc.py
|
| diff --git a/py/utils/misc.py b/py/utils/misc.py
|
| index a61527e4213813074448ff741df3aec9f73c30bc..a1bec6a17f1bf8a31cc7e0e5a0f582b3f12b99a1 100644
|
| --- a/py/utils/misc.py
|
| +++ b/py/utils/misc.py
|
| @@ -67,14 +67,16 @@ def GetAbsPath(relative_path):
|
| class ChDir(object):
|
| """Enter and exit the given directory appropriately."""
|
|
|
| - def __init__(self, directory):
|
| + def __init__(self, directory, verbose=True):
|
| """Instantiate the ChDir.
|
|
|
| Args:
|
| directory: string; the directory to enter.
|
| + verbose: bool; whether or not to print the directory changes.
|
| """
|
| self._destination = directory
|
| self._origin = None
|
| + self._verbose = verbose
|
|
|
| def __enter__(self):
|
| """Change to the destination directory.
|
| @@ -82,12 +84,14 @@ class ChDir(object):
|
| Does not check whether the directory exists.
|
| """
|
| self._origin = os.getcwd()
|
| - print 'chdir %s' % self._destination
|
| + if self._verbose:
|
| + print 'chdir %s' % self._destination
|
| os.chdir(self._destination)
|
|
|
| def __exit__(self, *args):
|
| """Change back to the original directory."""
|
| - print 'chdir %s' % self._origin
|
| + if self._verbose:
|
| + print 'chdir %s' % self._origin
|
| os.chdir(self._origin)
|
|
|
|
|
|
|