OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import contextlib | |
6 | |
7 from recipe_engine import recipe_api | |
8 | |
9 | |
10 class TempfileApi(recipe_api.RecipeApi): | |
11 @contextlib.contextmanager | |
12 def temp_dir(self, prefix): | |
13 path = None | |
14 try: | |
15 path = self.m.path.mkdtemp(prefix) | |
16 yield path | |
17 finally: | |
18 if path: | |
19 self.m.shutil.rmtree(path, infra_step=True) | |
OLD | NEW |