| # Print the product of age and size of each file, in suitable units. |
| # Usage: byteyears [ -a | -m | -c ] file ... |
| # Options -[amc] select atime, mtime (default) or ctime as age. |
| # Use lstat() to stat files if it exists, else stat() |
| elif sys.argv[1] == '-c': |
| elif sys.argv[1] == '-a': |
| secs_per_year = 365.0 * 24.0 * 3600.0 # Scale factor |
| now = time.time() # Current time, for age computations |
| status = 0 # Exit status, set to 1 on errors |
| # Compute max file name length |
| for filename in sys.argv[1:]: |
| maxlen = max(maxlen, len(filename)) |
| # Process each argument in turn |
| for filename in sys.argv[1:]: |
| sys.stderr.write("can't stat %r: %r\n" % (filename, msg)) |
| byteyears = float(size) * float(age) / secs_per_year |
| print filename.ljust(maxlen), |
| print repr(int(byteyears)).rjust(8) |
| if __name__ == '__main__': |