diff options
author | Guido van Rossum <guido@python.org> | 2007-09-27 22:39:12 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-09-27 22:39:12 (GMT) |
commit | 7c77f753b452cfd423c2cb790977ddcfdabfa162 (patch) | |
tree | 5f8718012fa4113d456ae442c8b8b8d4d6828a0d /Tools/scripts/byext.py | |
parent | d2e44df07af46645c42a8d154ab2ad9880480389 (diff) | |
download | cpython-7c77f753b452cfd423c2cb790977ddcfdabfa162.zip cpython-7c77f753b452cfd423c2cb790977ddcfdabfa162.tar.gz cpython-7c77f753b452cfd423c2cb790977ddcfdabfa162.tar.bz2 |
Make byext.py really work.
Diffstat (limited to 'Tools/scripts/byext.py')
-rwxr-xr-x | Tools/scripts/byext.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Tools/scripts/byext.py b/Tools/scripts/byext.py index 1d58a94..e5b090c 100755 --- a/Tools/scripts/byext.py +++ b/Tools/scripts/byext.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3.0 """Show file statistics by extension.""" @@ -60,13 +60,13 @@ class Stats: data = f.read() f.close() self.addstats(ext, "bytes", len(data)) - if '\0' in data: + if b'\0' in data: self.addstats(ext, "binary", 1) return if not data: self.addstats(ext, "empty", 1) #self.addstats(ext, "chars", len(data)) - lines = data.splitlines() + lines = str(data, "latin-1").splitlines() self.addstats(ext, "lines", len(lines)) del lines words = data.split() @@ -77,14 +77,12 @@ class Stats: d[key] = d.get(key, 0) + n def report(self): - exts = self.stats.keys() - exts.sort() + exts = sorted(self.stats) # Get the column keys columns = {} for ext in exts: columns.update(self.stats[ext]) - cols = columns.keys() - cols.sort() + cols = sorted(columns) colwidth = {} colwidth["ext"] = max([len(ext) for ext in exts]) minwidth = 6 |