Chromium Code Reviews| Index: recipe_modules/file/api.py |
| diff --git a/recipe_modules/file/api.py b/recipe_modules/file/api.py |
| index ca9ebb66bca268c6e2714b56352c00e7ab9a3f45..a79960f7cf3c043223662da84396e1f8de303f4d 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, **kwargs): |
| + """Returns list of filesizes for a given files. |
|
Michael Achenbach
2017/08/07 07:37:40
s/a/the
tandrii(chromium)
2017/08/07 10:59:49
Done.
|
| + |
| + Args: |
| + * name (str) - The name of the step. |
| + * files (Path) - One or more paths to files. |
| + |
| + Returns list[int], size of each file in bytes. |
| + """ |
| + test_data = kwargs.pop('test_data', ()) |
|
Michael Achenbach
2017/08/07 07:37:39
How about some better fake data when no test data
tandrii(chromium)
2017/08/07 10:59:49
Done.
|
| + assert not kwargs, 'only test_data kwarg allowed' |
| + 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. |