summaryrefslogtreecommitdiff
path: root/Tools/scripts/byteyears.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-06-04 20:36:54 +0000
committerGuido van Rossum <guido@python.org>1991-06-04 20:36:54 +0000
commitec758ead391daa2ce0e5697aa0e67ec3ba0f37af (patch)
tree7f2d186afd41d797882d5b5be3330e921804ebe9 /Tools/scripts/byteyears.py
parent0481447f4135c11d42ae25f55696af8e8d52fe74 (diff)
downloadcpython-git-ec758ead391daa2ce0e5697aa0e67ec3ba0f37af.tar.gz
Initial revision
Diffstat (limited to 'Tools/scripts/byteyears.py')
-rwxr-xr-xTools/scripts/byteyears.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py
new file mode 100755
index 0000000000..8c5ec69898
--- /dev/null
+++ b/Tools/scripts/byteyears.py
@@ -0,0 +1,29 @@
+#! /usr/local/python
+
+# byteyears file ...
+#
+# Print a number representing the product of age and size of each file,
+# in suitable units.
+
+import sys, posix, time
+from stat import *
+
+secs_per_year = 365.0 * 24.0 * 3600.0
+now = time.time()
+status = 0
+
+for file in sys.argv[1:]:
+ try:
+ st = posix.stat(file)
+ except posix.error, msg:
+ sys.stderr.write('can\'t stat ' + `file` + ': ' + `msg` + '\n')
+ status = 1
+ st = ()
+ if st:
+ mtime = st[ST_MTIME]
+ size = st[ST_SIZE]
+ age = now - mtime
+ byteyears = float(size) * float(age) / secs_per_year
+ print file + '\t\t' + `int(byteyears)`
+
+sys.exit(status)