blob: 062c859d7e06de29cc84adeee484d0e531da17a4 [file] [log] [blame]
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Directory lister is a ls-like wrapper to return listed files in yaml format.
The output of this tool will be a dictionary where key is file name and value
is the file size.
./ <directory>
import os
import sys
import yaml
if __name__ == '__main__':
if len(sys.argv[1:]) != 1:
raise ValueError('Accept only single argument as directory name')
dir_path = sys.argv[1]
files = dict()
for file_path in os.listdir(dir_path):
full_path = os.path.join(dir_path, file_path)
if not os.path.isfile(full_path):
files[file_path] = os.path.getsize(full_path)
print yaml.safe_dump(files, canonical=True)