3 # Print the product of age and size of each file, in suitable units.
5 # Usage: byteyears [ -a | -m | -c ] file ...
7 # Options -[amc] select atime, mtime (default) or ctime as age.
14 # Use lstat() to stat files if it exists, else stat()
17 except AttributeError:
21 if sys
.argv
[1] == '-m':
24 elif sys
.argv
[1] == '-c':
27 elif sys
.argv
[1] == '-a':
33 secs_per_year
= 365.0 * 24.0 * 3600.0 # Scale factor
34 now
= time
.time() # Current time, for age computations
35 status
= 0 # Exit status, set to 1 on errors
37 # Compute max file name length
39 for filename
in sys
.argv
[1:]:
40 maxlen
= max(maxlen
, len(filename
))
42 # Process each argument in turn
43 for filename
in sys
.argv
[1:]:
45 st
= statfunc(filename
)
47 sys
.stderr
.write("can't stat %r: %r\n" % (filename
, msg
))
54 byteyears
= float(size
) * float(age
) / secs_per_year
55 print filename
.ljust(maxlen
),
56 print repr(int(byteyears
)).rjust(8)
60 if __name__
== '__main__':