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.
13 # Use lstat() to stat files if it exists, else stat()
16 except AttributeError:
20 if sys
.argv
[1] == '-m':
23 elif sys
.argv
[1] == '-c':
26 elif sys
.argv
[1] == '-a':
32 secs_per_year
= 365.0 * 24.0 * 3600.0 # Scale factor
33 now
= time
.time() # Current time, for age computations
34 status
= 0 # Exit status, set to 1 on errors
36 # Compute max file name length
38 for file in sys
.argv
[1:]:
39 if len(file) > maxlen
: maxlen
= len(file)
41 # Process each argument in turn
42 for file in sys
.argv
[1:]:
46 sys
.stderr
.write('can\'t stat ' + `
file`
+ ': ' + `msg`
+ '\n')
53 byteyears
= float(size
) * float(age
) / secs_per_year
54 print string
.ljust(file, maxlen
),
55 print string
.rjust(`
int(byteyears
)`
, 8)