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

Unified Diff: scripts/slave/recipe_modules/path/api.py

Issue 302763003: First version of the PGO recipe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Address Robbie's comments. Created 6 years, 6 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
Index: scripts/slave/recipe_modules/path/api.py
diff --git a/scripts/slave/recipe_modules/path/api.py b/scripts/slave/recipe_modules/path/api.py
index 1e66fe88c06cd428cc530f7c5d6b4b740e6ac842..8480f55559e8e1e33a544fc8a0e8a993e9ead91d 100644
--- a/scripts/slave/recipe_modules/path/api.py
+++ b/scripts/slave/recipe_modules/path/api.py
@@ -182,7 +182,7 @@ class PathApi(recipe_api.RecipeApi):
json.dump(os.listdir(sys.argv[1]), f)
""",
args=[path, self.m.json.output()],
- step_test_data=(step_test_data or
+ step_test_data=(step_test_data or
self.test_api.listdir(['file 1', 'file 2'])),
)
@@ -223,7 +223,7 @@ class PathApi(recipe_api.RecipeApi):
args=[path],
)
- def rmcontents(self, name, path):
+ def rmcontents(self, name, path, file_filter=None):
"""
Similar to rmtree, but removes only contents not the directory.
@@ -231,21 +231,33 @@ class PathApi(recipe_api.RecipeApi):
Deleting current working directory makes all further getcwd calls fail
until chdir is called. chdir would be tricky in recipes, so we provide
a call that doesn't delete the directory itself.
+
+ An optional filter can be passed to the function to only remove the files
+ that match it.
iannucci 2014/06/19 21:37:17 specify that this should be a glob pattern appende
Sébastien Marchand 2014/07/03 19:13:17 I've removed this.
"""
self.assert_absolute(path)
return self.m.python.inline(
'rmcontents ' + name,
"""
- import os, sys
+ import glob, os, sys
from common import chromium_utils
- for p in [os.path.join(sys.argv[1], x) for x in os.listdir(sys.argv[1])]:
+ file_list = []
+
+ if len(sys.argv) > 2:
+ file_list = [os.path.join(sys.argv[1], x) for x in glob.glob(
+ sys.argv[1] + sys.argv[2])]
+ else:
+ file_list = [os.path.join(sys.argv[1], x) for x in os.listdir(
+ sys.argv[1])]
+
+ for p in file_list:
if os.path.isdir(p):
chromium_utils.RemoveDirectory(p)
else:
os.unlink(p)
""",
- args=[path],
+ args=[path, file_filter],
)
def rmwildcard(self, pattern, path, **kwargs):

Powered by Google App Engine
This is Rietveld 408576698