Chromium Code Reviews| Index: recipe_modules/tempfile/api.py |
| diff --git a/recipe_modules/tempfile/api.py b/recipe_modules/tempfile/api.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1bbbf407013c9e5fb6e6efdf5533277b4fcc0144 |
| --- /dev/null |
| +++ b/recipe_modules/tempfile/api.py |
| @@ -0,0 +1,19 @@ |
| +# Copyright 2016 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 contextlib |
| + |
| +from recipe_engine import recipe_api |
| + |
| + |
| +class TempfileApi(recipe_api.RecipeApi): |
| + @contextlib.contextmanager |
| + def temp_dir(self, prefix): |
|
martiniss
2016/04/07 17:35:22
This (roughly) already exists at https://github.co
Paweł Hajdan Jr.
2016/04/07 20:39:04
Yes, in fact this method calls path.mkdtemp .
martiniss
2016/04/07 21:34:02
I mis-read this function, sorry.
iannucci
2016/04/08 00:19:20
This is fine for now, but this is really the wrong
Paweł Hajdan Jr.
2016/04/08 07:46:15
The circular dependency was path -> python -> step
|
| + path = None |
| + try: |
| + path = self.m.path.mkdtemp(prefix) |
| + yield path |
| + finally: |
| + if path: |
| + self.m.shutil.rmtree(path, infra_step=True) |