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.
12 # Use lstat() to stat files if it exists, else stat()
15 except AttributeError:
19 if sys
.argv
[1] == '-m':
22 elif sys
.argv
[1] == '-c':
25 elif sys
.argv
[1] == '-a':
31 secs_per_year
= 365.0 * 24.0 * 3600.0 # Scale factor
32 now
= time
.time() # Current time, for age computations
33 status
= 0 # Exit status, set to 1 on errors
35 # Compute max file name length
37 for file in sys
.argv
[1:]:
38 if len(file) > maxlen
: maxlen
= len(file)
40 # Process each argument in turn
41 for file in sys
.argv
[1:]:
45 sys
.stderr
.write('can\'t stat ' + `
file`
+ ': ' + `msg`
+ '\n')
52 byteyears
= float(size
) * float(age
) / secs_per_year
53 print file.ljust(maxlen
),
54 print repr(int(byteyears
)).rjust(8)