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

Unified Diff: recipe_modules/file/resources/fileutil.py

Issue 2993713003: Add file.filesizes to recipe engine core modules. (Closed)
Patch Set: 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
Index: recipe_modules/file/resources/fileutil.py
diff --git a/recipe_modules/file/resources/fileutil.py b/recipe_modules/file/resources/fileutil.py
index c02db54a2026eccaf53c6ef5a7d0142d485476b5..81affcbe15a7becf6cd8df01ad09cde4b832ec3a 100755
--- a/recipe_modules/file/resources/fileutil.py
+++ b/recipe_modules/file/resources/fileutil.py
@@ -250,6 +250,14 @@ def main(args):
subparser.add_argument('dest', help='The dir to ensure.')
subparser.set_defaults(func=lambda opts: _EnsureDir(opts.mode, opts.dest))
+ # Subcommand: filesize
+ subparser = subparsers.add_parser('filesize',
+ help='Prints a list for sizes in bytes (1 per line) for each given file')
+ subparser.add_argument('file', nargs='+', help='Path to a file')
+ subparser.set_defaults(
+ func=lambda opts: print('\n'.join(str(os.stat(f).st_size)
+ for f in opts.file)))
Michael Achenbach 2017/08/07 07:37:40 nit: The for loop should be indented on the level
tandrii(chromium) 2017/08/07 10:59:49 Done.
+
# Parse arguments.
opts = parser.parse_args(args)

Powered by Google App Engine
This is Rietveld 408576698