diff options
Diffstat (limited to 'project')
| -rw-r--r-- | project/boost/directory.py | 3 | ||||
| -rw-r--r-- | project/format.py | 3 | ||||
| -rw-r--r-- | project/utils.py | 10 |
3 files changed, 4 insertions, 12 deletions
diff --git a/project/boost/directory.py b/project/boost/directory.py index cc3d129..771f6ee 100644 --- a/project/boost/directory.py +++ b/project/boost/directory.py @@ -3,6 +3,7 @@ # For details, see https://github.com/egor-tensin/cmake-common # Distributed under the MIT License. +from contextlib import chdir import logging import os.path @@ -18,7 +19,7 @@ class BoostDir: self.path = path def _go(self): - return utils.cd(self.path) + return chdir(self.path) def build(self, params): with self._go(): diff --git a/project/format.py b/project/format.py index fc5ae0e..9ea3936 100644 --- a/project/format.py +++ b/project/format.py @@ -11,6 +11,7 @@ formatting the files in-place. """ import argparse +from contextlib import chdir import difflib import os import sys @@ -130,7 +131,7 @@ def do_format( version=DEFAULT_VERSION, style=DEFAULT_STYLE, in_place=False, exclude=None ): clang_format = ClangFormat(version, style) - with utils.cd(git_root_dir()): + with chdir(git_root_dir()): cpp_files = filter_files(list_cpp_files(), exclude) if in_place: clang_format.format_in_place(cpp_files) diff --git a/project/utils.py b/project/utils.py index 87ac8d1..d3a9b10 100644 --- a/project/utils.py +++ b/project/utils.py @@ -77,16 +77,6 @@ def setup_logging(verbose=False): sys.exit(1) -@contextmanager -def cd(path): - cwd = os.getcwd() - os.chdir(path) - try: - yield - finally: - os.chdir(cwd) - - def run(cmd, **kwargs): logging.info("Running: %s", shlex.join(cmd)) return subprocess.run(cmd, check=True, **kwargs) |
