Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Unified Diff: recipe_modules/tempfile/api.py

Issue 1866313002: recipe engine: add tempfile and shutil modules (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: TODO Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_modules/tempfile/__init__.py ('k') | recipe_modules/tempfile/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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):
+ path = None
+ try:
+ path = self.m.path.mkdtemp(prefix)
+ yield path
+ finally:
+ if path:
+ self.m.shutil.rmtree(path, infra_step=True)
« no previous file with comments | « recipe_modules/tempfile/__init__.py ('k') | recipe_modules/tempfile/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698