Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 30 lines (23 sloc) 0.689 kB
#!/usr/bin/env python
# By Gary Bernhardt.
# Dotfiles at: https://github.com/garybernhardt/dotfiles
import sys
import zlib
import bz2
def main():
data = file_data()
size = len(data)
print 'file size', size
gzip_size = len(zlib.compress(data))
print 'gzip size %i (%i%%)' % (gzip_size, percent(gzip_size, size))
bz2_size = len(bz2.compress(data))
print 'bz2 size %i (%i%%)' % (bz2_size, percent(bz2_size, size))
def file_data():
files = map(open, sys.argv[1:])
if not files:
files = [sys.stdin]
return ''.join(f.read() for f in files)
def percent(part, whole):
return int(100.0 * part / whole)
if __name__ == '__main__':
main()
Jump to Line
Something went wrong with that request. Please try again.