diff options
| author | Kevin Yap <me@kevinyap.ca> | 2015-02-06 15:03:45 -0800 |
|---|---|---|
| committer | Kevin Yap <me@kevinyap.ca> | 2015-02-23 21:14:51 -0800 |
| commit | f1eebb8f371cf2703ca1d4096f974d037938ece8 (patch) | |
| tree | f908fe2cab7e4a1f55adbcf60b7cecab436919e3 | |
| parent | 7884eb8e2ff8f0796a95aa0216e69241934ce14f (diff) | |
| download | rust-f1eebb8f371cf2703ca1d4096f974d037938ece8.tar.gz rust-f1eebb8f371cf2703ca1d4096f974d037938ece8.zip | |
Order list of linted files by frequency
Since it makes more sense for .rs files to appear at the top of the list of linted files and "other" files to appear at the end, this commit moves the "other" count outside of the `file_counts` dictionary and sorts the remaining "interesting" files by decreasing frequency.
| -rw-r--r-- | src/etc/tidy.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/etc/tidy.py b/src/etc/tidy.py index fd3309dce12..5caa0c90f1b 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -66,20 +66,22 @@ src_dir = sys.argv[1] try: count_lines = 0 count_non_blank_lines = 0 + count_other_linted_files = 0 interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h'] file_counts = {ext: 0 for ext in interesting_files} - file_counts['other'] = 0 def update_counts(current_name): global file_counts + global count_other_linted_files + _, ext = os.path.splitext(current_name) - if ext in file_counts: + if ext in interesting_files: file_counts[ext] += 1 else: - file_counts['other'] += 1 + count_other_linted_files += 1 all_paths = set() @@ -196,10 +198,11 @@ except UnicodeDecodeError as e: report_err("UTF-8 decoding error " + str(e)) print -for ext in file_counts: - print "* linted " + str(file_counts[ext]) + " " + ext + " files" -print "* total lines of code: " + str(count_lines) -print "* total non-blank lines of code: " + str(count_non_blank_lines) +for ext in sorted(file_counts, key=file_counts.get, reverse=True): + print "* linted {} {} files".format(file_counts[ext], ext) +print "* linted {} other files".format(count_other_linted_files) +print "* total lines of code: {}".format(count_lines) +print "* total non-blank lines of code: {}".format(count_non_blank_lines) print sys.exit(err) |
