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

Unified Diff: recipe_modules/file/api.py

Issue 2993713003: Add file.filesizes to recipe engine core modules. (Closed)
Patch Set: -kwargs. Created 3 years, 4 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 | « README.recipes.md ('k') | recipe_modules/file/example.disable » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/file/api.py
diff --git a/recipe_modules/file/api.py b/recipe_modules/file/api.py
index ca9ebb66bca268c6e2714b56352c00e7ab9a3f45..93ba2acbb9596c163ad3df136c03407580dbc3ca 100644
--- a/recipe_modules/file/api.py
+++ b/recipe_modules/file/api.py
@@ -224,6 +224,28 @@ class FileApi(recipe_api.RecipeApi):
name, ['ensure-directory', '--mode', oct(mode), dest])
self.m.path.mock_add_paths(dest)
+ def filesizes(self, name, files, test_data=None):
+ """Returns list of filesizes for the given files.
+
+ Args:
+ * name (str) - The name of the step.
+ * files (list[Path]) - Paths to files.
+
+ Returns list[int], size of each file in bytes.
+ """
+ if test_data is None:
+ test_data = [111 * (i+1) + (i % 3 - 2) * i for i, _ in enumerate(files)]
+ for f in files:
+ self.m.path.assert_absolute(f)
+ result = self._run(
+ name, ['filesizes'] + list(files),
+ lambda: self.test_api.filesizes(test_data),
+ self.m.raw_io.output_text())
+ ret = map(int, result.stdout.strip().splitlines())
+ result.presentation.logs['filesizes'] = ['%s: \t%d' % fs
+ for fs in zip(files, ret)]
+ return ret
+
def rmtree(self, name, source):
"""Recursively removes a directory.
« no previous file with comments | « README.recipes.md ('k') | recipe_modules/file/example.disable » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698